forked from russellkelly/SR_Demo_Repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·496 lines (430 loc) · 13.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SR Topology in Force Direct Diagram</title>
<script>
function resizeIframe(obj) {
obj.style.height = 0;
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
}
</script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<style>
.w3-btn {width:400px;border:0.5px;}
.w3-btn2 {width:200px;border:0.5px;}
.hidden{
display: none;
}
#title{
align-items: center;
font-size: 10px;
background:#cccccc;
float:middle;
}
path.link {
fill: none;
stroke: #666;
stroke-width: 5px;
}
.link {
stroke: #ccc;
}
.node text {
pointer-events: none;
font: 20px sans-serif;
text-shadow: 0 1px 0 #fff, 1px 0 0 #fff, 0 -1px 0 #fff, -1px 0 0 #fff
}
#pathList {
padding: 10px;
position: fixed;
background-color: white;
font-weight: bold;
bottom: 0px;
left: 0px;
right: 0px;
}
body {
margin-bottom: 200px; /* Make sure there's space to scroll in case of #pathList overlap */
}
</style>
<meta charset="utf-8">
</head>
<body>
<div id='title'>
<h1 align="center">Logical Topological View of ISIS SR Enabled Nodes and Adjacencies</h1>
</div>
<div>
<span style="float:left;"> </span>
<fieldset>
<button onClick="history.go(0)" class="w3-btn w3-hover-red">Refresh Topology - or shift+refresh broswer</button>
<div>
<br><label>Dest FEC</label>
<input id="dstFec" type="text" placeholder="Destination FEC" />
<label> Dest FEC NH</label>
<input id="dstFecNH" type="text" placeholder="Destination FEC NH" />
</div>
<div>
<label>Dest Prefix</label>
<input id="dstPrefix" type="text" placeholder="Prefix x.x.x.x/yy" onsubmit="" />
<label> Dest Next hop</label>
<input id="dstNH" type="text" placeholder="Destination Next Hop" onsubmit="" />
</div>
<div>
<input id="Primary" type="checkbox" name="Primary"/> Primary Path
<input id="Secondary" type="checkbox" name="Secondary" />Secondary Path (Make sure one or the other is checked. Primary actually pushes to the Router. Secondary stores on Controller) <br><br>
</div>
<div id="curPath"></div>
<div>
<button onClick="window.tepath=[]; updatePathDisplay();" class="w3-btn w3-hover-red">Clear Path (Display Only)</button>
<input id="ManualFECDest" type="text" placeholder="FEC Dest x.x.x.x" onsubmit="" />
<input id="ManualFECNH" type="text" placeholder=" Next Hop x.x.x.x" onsubmit="" />
<input id="ManualFECPath" type="text" placeholder="Label Path xxxxx xxxxx" onsubmit="" /><br>
<button onClick="addPath();" class="w3-btn w3-hover-red">Submit Path Selected on Graph</button>
<button onClick="addManualPath();" class="w3-btn w3-hover-red">Manual Label Path Add</button>
</div>
</fieldset>
</div>
<div>
<span style="float:left;"> </span>
<fieldset>
<label>FEC to Remove</label>
<input id="RemoveFEC" type="text" placeholder="FEC to Remove" onsubmit="" />
<button onClick="removeFEC();" class="w3-btn2 w3-hover-green">Remove FEC </button>
<label>Dest Route to Remove</label>
<input id="RemoveRoute" type="text" placeholder="Prefix x.x.x.x/yy" onsubmit="" />
<button onClick="removeRoute();" class="w3-btn2 w3-hover-green">Remove Route</button>
</fieldset>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//d3js.org/d3.v3.min.js"></script>
<div>
<script>
var width = 1000,
height = 625;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
svg.append("svg:defs").selectAll("marker")
.data(["end"]) // Different link/path types can be defined here
.enter().append("svg:marker") // This section adds in the arrows
.attr("id", String)
.attr("viewBox", "0 -5 10 10")
.attr("refX", 15)
.attr("refY", -0.5)
.attr("markerWidth", 4)
.attr("markerHeight", 4)
.attr("orient", "auto")
.append("svg:path")
.attr("d", "M0,-5L10,0L0,5");
var force = d3.layout.force()
.gravity(6)
.distance(200)
.charge(-180000)
.linkStrength(6)
force.alpha(0)
.size([width, height]);
var drag = force.drag()
.on('dragstart', function(d) {
d3.select(this).classed('fixed', d.fixed = true);
force.stop();
})
.on('dragend', function() {
force.stop();
});
window.tepath = [];
function updatePathDisplay() {
document.getElementById("curPath").textContent = tepath.join(" -> ");
// get jquery as a <script>
// $.post('/backend', {path: path})
}
function addPath() {
var dstFec = document.getElementById("dstFec").value;
var dstPrefix = document.getElementById("dstPrefix").value;
var dstNH = document.getElementById("dstNH").value;
var dstFecNH = document.getElementById("dstFecNH").value;
var PrimaryBoolean = document.getElementById('Primary').checked;
var SecondaryBoolean = document.getElementById("Secondary").checked;
var ManualFECPath = "";
var RemoveFEC = "";
var RemoveRoute = "";
d3.xhr("/")
.header("Content-Type", "application/json")
.post(JSON.stringify({
dstPrefix: dstPrefix,
dstNH: dstNH,
fec: dstFec,
dstFecNH: dstFecNH,
path: tepath,
Primary: PrimaryBoolean,
ManualFECPath: ManualFECPath,
RemoveFEC: RemoveFEC,
RemoveRoute: RemoveRoute,
Secondary: SecondaryBoolean
}), function(){ alert('Path Programmed!'); });
}
function addManualPath() {
var dstPrefix = "";
var dstNH = "";
var PrimaryBoolean = document.getElementById('Primary').checked;
var SecondaryBoolean = document.getElementById("Secondary").checked;
var RemoveFEC = "";
var RemoveRoute = "";
var ManualFECPath = document.getElementById("ManualFECPath").value;
var ManualFECNH = document.getElementById("ManualFECNH").value;
var ManualFECDest = document.getElementById("ManualFECDest").value;
d3.xhr("/")
.header("Content-Type", "application/json")
.post(JSON.stringify({
dstPrefix: dstPrefix,
dstNH: dstNH,
fec: ManualFECDest,
dstFecNH: ManualFECNH,
ManualFECPath: ManualFECPath,
Primary: PrimaryBoolean,
RemoveFEC: RemoveFEC,
RemoveRoute: RemoveRoute,
Secondary: SecondaryBoolean
}), function(){ alert('Manual Path Programmed!'); });
}
function removeFEC() {
var dstFec = "";
var dstPrefix = "";
var dstNH = "";
var dstFecNH = "";
var PrimaryBoolean = "False";
var SecondaryBoolean = "False";
var ManualFECPath = "";
var RemoveFEC = document.getElementById("RemoveFEC").value;
var RemoveRoute = "";
d3.xhr("/")
.header("Content-Type", "application/json")
.post(JSON.stringify({
dstPrefix: dstPrefix,
dstNH: dstNH,
fec: dstFec,
dstFecNH: dstFecNH,
path: tepath,
ManualFECPath: ManualFECPath,
Primary: PrimaryBoolean,
RemoveFEC: RemoveFEC,
RemoveRoute: RemoveRoute,
Secondary: SecondaryBoolean
}), function(){ alert('Path Programmed!'); });
}
function removeRoute() {
var dstFec = "";
var dstPrefix = "";
var dstNH = "";
var dstFecNH = "";
var PrimaryBoolean = "False";
var SecondaryBoolean = "False";
var ManualFECPath = "";
var RemoveFEC = "";
var RemoveRoute = document.getElementById("RemoveRoute").value;
d3.xhr("/")
.header("Content-Type", "application/json")
.post(JSON.stringify({
dstPrefix: dstPrefix,
dstNH: dstNH,
fec: dstFec,
dstFecNH: dstFecNH,
path: tepath,
path: tepath,
ManualFECPath: ManualFECPath,
Primary: PrimaryBoolean,
RemoveFEC: RemoveFEC,
RemoveRoute: RemoveRoute,
Secondary: SecondaryBoolean
}), function(){ alert('Path Programmed!'); });
}
d3.json("sr_topology.json", function(error, json) {
if (error) throw error;
force
.nodes(json.nodes)
.links(json.links)
.start();
var link = svg.selectAll(".link")
.data(json.links)
.enter().append("path")
.attr("class", "link")
.attr("marker-end", "url(#end)")
.attr("width", 3)
.on("click",function(n){
console.log("User clicked on Link", n.id);
tepath.push(n.id);
updatePathDisplay();
console.log("path is now", tepath)
});
var node = svg.selectAll(".node")
.data(json.nodes)
.enter().append("g")
.attr("class", "node")
.call(force.drag());
node.append("image")
.attr("xlink:href", "images/router.png")
.attr("x", -20)
.attr("y", -20)
.attr("width", 40)
.attr("height", 40)
.on("click", function(n){
console.log("User clicked on node", n.name);
tepath.push(n.name);
updatePathDisplay();
console.log("path is now", tepath)
});
node.append("text")
.attr("dx", 0)
.attr("dy", 0)
.text(function(d) { return d.name })
.call(force.drag());
force.on("tick", function() {
link.attr("d", function(d) {
var dx = d.target.x - d.source.x,
dy = d.target.y - d.source.y,
dr = 800/d.value;
return "M" +
d.source.x + "," +
d.source.y + "A" +
dr + "," + dr + " 0 0,1 " +
d.target.x + "," +
d.target.y;
});
node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")";});
});
});
function createPathListText(list) {
var ret = ""
$.each(list, function(index, value) {
if (index > 0) ret += ", ";
ret += value;
});
return ret;
}
function updatePathTextList() {
$.ajax({
url: 'controller_output.json',
dataType: 'json',
cache: false,
success: function(data) {
var innerHtml = "";
innerHtml += "<h3>Paths</h3>";
innerHtml += "<div>";
innerHtml += "<span>Active Service Prefixes: </span>";
innerHtml += createPathListText(data.prefixes);
innerHtml += "</div><div>";
innerHtml += "<span>Primary FEC Paths: </span>";
innerHtml += createPathListText(data.primary);
innerHtml += "</div><div>";
innerHtml += "<span>Secondary FEC Paths: </span>";
innerHtml += createPathListText(data.secondary);
innerHtml += "</div>";
$("#pathList").html(innerHtml);
}
});
}
setInterval(updatePathTextList, 1000); // Update the list of paths once a second
</script>
<img id="myDIV" src="images/SR_Demo.png" style="float:right; display:none" width="800" height="600" />
<img id="myDIV1" src="images/SR_ECMP.png" style="float:right; display:none;" width="800" height="600" />
<img id="myDIV2" src="images/SR_Anycast.png" style="float:right; display:none;" width="800" height="600" />
<img id="myDIV3" src="images/LDP_interop.png" style="float:right; display:none;" width="800" height="600" />
<img id="myDIV4" src="images/SR_CBF.png" style="float:right; display:none;" width="800" height="600" />
<img id="myDIV5" src="images/SR_MacroTE.png" style="float:right; display:none;" width="800" height="600" />
<img id="myDIV6" src="images/SR_MicroTE.png" style="float:right; display:none;" width="800" height="600" />
</div>
<div>
<button onclick="myFunction6()" aria-pressed="false" style="float:right;">SR Micro TE</button>
<button onclick="myFunction5()" aria-pressed="false" style="float:right;">SR Macro TE</button>
<button onclick="myFunction4()" aria-pressed="false" style="float:right;">SR CBF</button>
<button onclick="myFunction3()" aria-pressed="false" style="float:right;">LDP Inter-Op</button>
<button onclick="myFunction2()" aria-pressed="false" style="float:right;">SR Anycast</button>
<button onclick="myFunction1()" aria-pressed="false" style="float:right;">SR ECMP</button>
<button onclick="myFunction()" aria-pressed="true" style="float:right;">Base Demo</button>
</div>
<style>
button,
[role="button"] {
padding: 3px;
border: 1px solid #CCC;
}
button[aria-pressed="true"],
[role="button"][aria-pressed="true"] {
border: 2px solid #000;
}
</style>
<script>
function toggleButton(element) {
// Check to see if the button is pressed
var pressed = (element.getAttribute("aria-pressed") === "true");
// Change aria-pressed to the opposite state
element.setAttribute("aria-pressed", !pressed);
}
function myFunction() {
var x = document.getElementById('myDIV');
toggleButton(event.target);
if (x.style.display === 'block') {
x.style.display = 'none';
} else {
x.style.display = 'block';
}
}
function myFunction1() {
toggleButton(event.target);
var x = document.getElementById('myDIV1');
if (x.style.display === 'block') {
x.style.display = 'none';
} else {
x.style.display = 'block';
}
}
function myFunction2() {
toggleButton(event.target);
var x = document.getElementById('myDIV2');
if (x.style.display === 'block') {
x.style.display = 'none';
} else {
x.style.display = 'block';
}
}
function myFunction3() {
toggleButton(event.target);
var x = document.getElementById('myDIV3');
if (x.style.display === 'block') {
x.style.display = 'none';
} else {
x.style.display = 'block';
}
}
function myFunction4() {
toggleButton(event.target);
var x = document.getElementById('myDIV4');
if (x.style.display === 'block') {
x.style.display = 'none';
} else {
x.style.display = 'block';
}
}
function myFunction5() {
toggleButton(event.target);
var x = document.getElementById('myDIV5');
if (x.style.display === 'block') {
x.style.display = 'none';
} else {
x.style.display = 'block';
}
}
function myFunction6() {
toggleButton(event.target);
var x = document.getElementById('myDIV6');
if (x.style.display === 'block') {
x.style.display = 'none';
} else {
x.style.display = 'block';
}
}
</script>
<div id="pathList">
</div>
</body>
</html>