GUI - Fixed reverse-link-id lookup issue for 'showTraffic'.
- removed obsolete 'showPath' code. Change-Id: I5b7bdf9156b18022838b8f7ebc0e6d0846f9b20f
Showing
7 changed files
with
70 additions
and
47 deletions
1 | -{ | ||
2 | - "event": "showPath", | ||
3 | - "sid": 15, | ||
4 | - "payload": { | ||
5 | - "links": [ | ||
6 | - "62:4F:65:BF:FF:B3/-1/0-of:000000000000000b/1", | ||
7 | - "of:000000000000000b/4-of:000000000000000a/1", | ||
8 | - "of:000000000000000a/4-of:0000000000000001/3", | ||
9 | - "of:0000000000000001/1-of:0000000000000002/4", | ||
10 | - "of:0000000000000002/1-of:0000000000000003/4", | ||
11 | - "of:0000000000000003/1-CA:4B:EE:A4:B0:33/-1/0" | ||
12 | - ], | ||
13 | - "intentId": "0x52a914f9" | ||
14 | - } | ||
15 | -} |
1 | +{ | ||
2 | + "event": "showTraffic", | ||
3 | + "sid":62, | ||
4 | + "payload": { | ||
5 | + "paths": [ | ||
6 | + { | ||
7 | + "class": "primary", | ||
8 | + "traffic": false, | ||
9 | + "links": [ | ||
10 | + "0E:2A:69:30:13:8A/-1/0-of:0000ffffffff0008/1", | ||
11 | + "of:0000ffffffff0008/20-of:0000ffffffff0007/10", | ||
12 | + "of:0000ffffffff0007/1-0E:2A:69:30:13:89/-1/0" | ||
13 | + ], | ||
14 | + "labels": [ | ||
15 | + "Load{rate=98, latest=38080}", | ||
16 | + "Load{rate=98, latest=38080}", | ||
17 | + "Load{rate=98, latest=38080}" | ||
18 | + ] | ||
19 | + } | ||
20 | + ] | ||
21 | + } | ||
22 | +} |
1 | +{ | ||
2 | + "event": "showTraffic", | ||
3 | + "sid":63, | ||
4 | + "payload": { | ||
5 | + "paths": [ | ||
6 | + { | ||
7 | + "class": "primary animated", | ||
8 | + "traffic": true, | ||
9 | + "links": [ | ||
10 | + "0E:2A:69:30:13:8A/-1/0-of:0000ffffffff0008/1", | ||
11 | + "of:0000ffffffff0008/20-of:0000ffffffff0007/10", | ||
12 | + "of:0000ffffffff0007/1-0E:2A:69:30:13:89/-1/0" | ||
13 | + ], | ||
14 | + "labels": [ | ||
15 | + "Load{rate=98, latest=38080}", | ||
16 | + "Load{rate=98, latest=38080}", | ||
17 | + "Load{rate=98, latest=38080}" | ||
18 | + ] | ||
19 | + } | ||
20 | + ] | ||
21 | + } | ||
22 | +} |
... | @@ -145,7 +145,8 @@ | ... | @@ -145,7 +145,8 @@ |
145 | view: null, // view token reference | 145 | view: null, // view token reference |
146 | nodes: [], | 146 | nodes: [], |
147 | links: [], | 147 | links: [], |
148 | - lookup: {} | 148 | + lookup: {}, |
149 | + revLinkToKey: {} | ||
149 | }, | 150 | }, |
150 | scenario = { | 151 | scenario = { |
151 | evDir: 'json/ev/', | 152 | evDir: 'json/ev/', |
... | @@ -423,6 +424,12 @@ | ... | @@ -423,6 +424,12 @@ |
423 | return one + '-' + two; | 424 | return one + '-' + two; |
424 | } | 425 | } |
425 | 426 | ||
427 | + function findLinkById(id) { | ||
428 | + // check to see if this is a reverse lookup, else default to given id | ||
429 | + var key = network.revLinkToKey[id] || id; | ||
430 | + return key && network.lookup[key]; | ||
431 | + } | ||
432 | + | ||
426 | function findLink(linkData, op) { | 433 | function findLink(linkData, op) { |
427 | var key = makeLinkKey(linkData), | 434 | var key = makeLinkKey(linkData), |
428 | keyrev = makeLinkKey(linkData, 1), | 435 | keyrev = makeLinkKey(linkData, 1), |
... | @@ -476,10 +483,12 @@ | ... | @@ -476,10 +483,12 @@ |
476 | ldata.key = keyrev; | 483 | ldata.key = keyrev; |
477 | delete network.lookup[key]; | 484 | delete network.lookup[key]; |
478 | network.lookup[keyrev] = ldata; | 485 | network.lookup[keyrev] = ldata; |
486 | + delete network.revLinkToKey[keyrev]; | ||
479 | } | 487 | } |
480 | } else { | 488 | } else { |
481 | // remove fromTarget | 489 | // remove fromTarget |
482 | ldata.fromTarget = null; | 490 | ldata.fromTarget = null; |
491 | + delete network.revLinkToKey[keyrev]; | ||
483 | } | 492 | } |
484 | if (ldata.fromSource) { | 493 | if (ldata.fromSource) { |
485 | restyleLinkElement(ldata); | 494 | restyleLinkElement(ldata); |
... | @@ -496,6 +505,7 @@ | ... | @@ -496,6 +505,7 @@ |
496 | function addLinkUpdate(ldata, link) { | 505 | function addLinkUpdate(ldata, link) { |
497 | // add link event, but we already have the reverse link installed | 506 | // add link event, but we already have the reverse link installed |
498 | ldata.fromTarget = link; | 507 | ldata.fromTarget = link; |
508 | + network.revLinkToKey[link.id] = ldata.key; | ||
499 | restyleLinkElement(ldata); | 509 | restyleLinkElement(ldata); |
500 | } | 510 | } |
501 | 511 | ||
... | @@ -548,7 +558,6 @@ | ... | @@ -548,7 +558,6 @@ |
548 | removeHost: removeHost, | 558 | removeHost: removeHost, |
549 | 559 | ||
550 | showDetails: showDetails, | 560 | showDetails: showDetails, |
551 | - showPath: showPath, | ||
552 | showTraffic: showTraffic | 561 | showTraffic: showTraffic |
553 | }; | 562 | }; |
554 | 563 | ||
... | @@ -693,24 +702,6 @@ | ... | @@ -693,24 +702,6 @@ |
693 | detailPane.show(); | 702 | detailPane.show(); |
694 | } | 703 | } |
695 | 704 | ||
696 | - function showPath(data) { | ||
697 | - // TODO: review - making sure we are handling the payload correctly. | ||
698 | - evTrace(data); | ||
699 | - var links = data.payload.links, | ||
700 | - s = [ data.event + "\n" + links.length ]; | ||
701 | - links.forEach(function (d, i) { | ||
702 | - s.push(d); | ||
703 | - }); | ||
704 | - network.view.alert(s.join('\n')); | ||
705 | - | ||
706 | - links.forEach(function (d, i) { | ||
707 | - var link = network.lookup[d]; | ||
708 | - if (link) { | ||
709 | - link.el.classed('showPath', true); | ||
710 | - } | ||
711 | - }); | ||
712 | - } | ||
713 | - | ||
714 | function showTraffic(data) { | 705 | function showTraffic(data) { |
715 | evTrace(data); | 706 | evTrace(data); |
716 | var paths = data.payload.paths; | 707 | var paths = data.payload.paths; |
... | @@ -722,7 +713,7 @@ | ... | @@ -722,7 +713,7 @@ |
722 | paths.forEach(function (p) { | 713 | paths.forEach(function (p) { |
723 | var cls = p.class; | 714 | var cls = p.class; |
724 | p.links.forEach(function (id) { | 715 | p.links.forEach(function (id) { |
725 | - var lnk = network.lookup[id]; | 716 | + var lnk = findLinkById(id); |
726 | if (lnk) { | 717 | if (lnk) { |
727 | lnk.el.classed(cls, true); | 718 | lnk.el.classed(cls, true); |
728 | } | 719 | } | ... | ... |
-
Please register or login to post a comment