@@ -3,6 +3,7 @@ var iaLabels;
3
3
var iaLocations = [ ] ;
4
4
var iaGeoLoc ;
5
5
var g = { } ;
6
+ var jPathColors = [ ] ;
6
7
7
8
function setupDebug ( src , dst ) {
8
9
var src = $ ( '#ia_cli' ) . val ( ) ;
@@ -15,6 +16,24 @@ function setupDebug(src, dst) {
15
16
}
16
17
}
17
18
19
+ var cMissingPath = '#cccccc' ;
20
+ var cPaths = [ "#3366cc" , "#dc3912" , "#ff9900" , "#109618" , "#990099" ,
21
+ "#0099c6" , "#dd4477" , "#66aa00" , "#b82e2e" , "#316395" , "#994499" ,
22
+ "#22aa99" , "#aaaa11" , "#6633cc" , "#e67300" , "#8b0707" , "#651067" ,
23
+ "#329262" , "#5574a6" , "#3b3eac" ] ;
24
+ function path_colors ( n ) {
25
+ return cPaths [ n % cPaths . length ] ;
26
+ }
27
+
28
+ function getPathColor ( hops ) {
29
+ var idx = jPathColors . indexOf ( hops + '' ) ;
30
+ if ( idx < 0 ) {
31
+ return cMissingPath ;
32
+ } else {
33
+ return path_colors ( idx ) ;
34
+ }
35
+ }
36
+
18
37
function isConfigComplete ( data , textStatus , jqXHR ) {
19
38
console . log ( JSON . stringify ( data ) ) ;
20
39
g [ 'nodes_xml_url' ] = data . nodes_xml_url ;
@@ -326,13 +345,42 @@ function drawTopo(src, dst, paths, segs) {
326
345
} , width , height ) ;
327
346
}
328
347
348
+ function formatPathJson ( paths , idx ) {
349
+ if ( typeof idx === 'undefined' ) {
350
+ return '' ;
351
+ }
352
+ var ent = paths [ idx ] . Entry ;
353
+ var hops = ent . Path . Interfaces ;
354
+ var path = "[" ;
355
+ for ( var i = 0 ; i < hops . length ; i += 2 ) {
356
+ var prev = hops [ i ] ;
357
+ var next = hops [ i + 1 ] ;
358
+ if ( i > 0 ) {
359
+ path += ' ' ;
360
+ }
361
+ path += iaRaw2Read ( prev . RawIsdas ) + ' ' + prev . IfID + '>' + next . IfID ;
362
+ if ( i == ( hops . length - 2 ) ) {
363
+ path += ' ' + iaRaw2Read ( next . RawIsdas ) ;
364
+ }
365
+ }
366
+ path += "]" ;
367
+ return path ;
368
+ }
369
+
329
370
function get_path_html ( paths , csegs , usegs , dsegs , show_segs ) {
330
371
var html = "<ul class='tree'>" ;
331
372
for ( p in paths ) {
332
- html += "<li seg-type='PATH' seg-num=" + p + "><a href='#'>PATH "
333
- + ( parseInt ( p ) + 1 ) + "</a>" ;
373
+
334
374
var ent = paths [ p ] . Entry ;
335
375
var exp = new Date ( 0 ) ;
376
+ if_ = ent . Path . Interfaces ;
377
+ var hops = if_ . length / 2 ;
378
+
379
+ var style = "style='background-color: "
380
+ + getPathColor ( formatPathJson ( paths , parseInt ( p ) ) ) + "; '" ;
381
+ html += "<li seg-type='PATH' seg-num=" + p + "><a " + style
382
+ + " href='#'>PATH " + ( parseInt ( p ) + 1 )
383
+ + "</a> <span class='badge'>" + hops + "</span>" ;
336
384
exp . setUTCSeconds ( ent . Path . ExpTime ) ;
337
385
html += "<ul>" ;
338
386
html += "<li><a href='#'>Mtu: " + ent . Path . Mtu + "</a>" ;
@@ -347,9 +395,6 @@ function get_path_html(paths, csegs, usegs, dsegs, show_segs) {
347
395
html += "<li><a href='#'>Port: " + ent . HostInfo . Port + "</a>" ;
348
396
html += "<li><a href='#'>Expiration: " + exp . toLocaleDateString ( ) + " "
349
397
+ exp . toLocaleTimeString ( ) + "</a>" ;
350
- if_ = ent . Path . Interfaces ;
351
- var hops = if_ . length / 2 ;
352
- html += "<li><a href='#'>Hops: " + hops + "</a>" ;
353
398
for ( i in if_ ) {
354
399
html += "<li><a href='#'>" + iaRaw2Read ( if_ [ i ] . RawIsdas ) + " ("
355
400
+ if_ [ i ] . IfID + ")</a>" ;
@@ -365,19 +410,33 @@ function get_path_html(paths, csegs, usegs, dsegs, show_segs) {
365
410
return html ;
366
411
}
367
412
413
+ // add style to list of paths and segments
414
+ function getSegColor ( type ) {
415
+ if ( type == "CORE" ) {
416
+ return colorSegCore ;
417
+ } else if ( type == "DOWN" ) {
418
+ return colorSegDown ;
419
+ } else if ( type == "UP" ) {
420
+ return colorSegUp ;
421
+ } else {
422
+ return colorPaths ;
423
+ }
424
+ }
425
+
368
426
function get_segment_info ( segs , type ) {
369
427
var html = "" ;
370
428
for ( s in segs . if_lists ) {
371
- html += "<li seg-type='" + type + "' seg-num=" + s + "><a href='#'>"
372
- + type + " SEGMENT " + ( parseInt ( s ) + 1 ) + "</a>" ;
373
429
var exp = new Date ( 0 ) ;
374
430
exp . setUTCSeconds ( segs . if_lists [ s ] . expTime ) ;
431
+ if_ = segs . if_lists [ s ] . interfaces ;
432
+ var hops = if_ . length / 2 ;
433
+ var style = "style='color: " + getSegColor ( type ) + ";'" ;
434
+ html += "<li seg-type='" + type + "' seg-num=" + s + "><a " + style
435
+ + " href='#'>" + type + " SEGMENT " + ( parseInt ( s ) + 1 )
436
+ + "</a> <span class='badge'>" + hops + "</span>" ;
375
437
html += "<ul>" ;
376
438
html += "<li><a href='#'>Expiration: " + exp . toLocaleDateString ( ) + " "
377
439
+ exp . toLocaleTimeString ( ) + "</a>" ;
378
- if_ = segs . if_lists [ s ] . interfaces ;
379
- var hops = if_ . length / 2 ;
380
- html += "<li><a href='#'>Hops: " + hops + "</a>" ;
381
440
for ( i in if_ ) {
382
441
html += "<li><a href='#'>" + if_ [ i ] . ISD + "-" + if_ [ i ] . AS + " ("
383
442
+ if_ [ i ] . IFID + ")</a>" ;
@@ -625,6 +684,14 @@ function requestPaths() {
625
684
resUp = resSegs . up_segments ;
626
685
resDown = resSegs . down_segments ;
627
686
687
+ // store incoming paths
688
+ for ( var idx = 0 ; idx < resPath . if_lists . length ; idx ++ ) {
689
+ var hops = formatPathString ( resPath , idx , 'PATH' ) ;
690
+ if ( ! jPathColors . includes ( hops ) ) {
691
+ jPathColors . push ( hops ) ;
692
+ }
693
+ }
694
+
628
695
jTopo = get_json_path_links ( resPath , resCore , resUp , resDown ) ;
629
696
$ ( '#path-info' ) . html (
630
697
get_path_html ( data . paths , resCore , resUp , resDown , true ) ) ;
0 commit comments