GUI - Fixed reverse-link-id lookup issue for 'showTraffic'.
- removed obsolete 'showPath' code.

Change-Id: I5b7bdf9156b18022838b8f7ebc0e6d0846f9b20f
diff --git a/web/gui/src/main/webapp/json/ev/_capture/rx/showPath_ex1.json b/web/gui/src/main/webapp/json/ev/_capture/rx/showPath_ex1.json
deleted file mode 100644
index de1023e..0000000
--- a/web/gui/src/main/webapp/json/ev/_capture/rx/showPath_ex1.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
-  "event": "showPath",
-  "sid": 15,
-  "payload": {
-    "links": [
-      "62:4F:65:BF:FF:B3/-1/0-of:000000000000000b/1",
-      "of:000000000000000b/4-of:000000000000000a/1",
-      "of:000000000000000a/4-of:0000000000000001/3",
-      "of:0000000000000001/1-of:0000000000000002/4",
-      "of:0000000000000002/1-of:0000000000000003/4",
-      "of:0000000000000003/1-CA:4B:EE:A4:B0:33/-1/0"
-    ],
-    "intentId": "0x52a914f9"
-  }
-}
diff --git a/web/gui/src/main/webapp/json/ev/_capture/rx/showPath_ex2.json b/web/gui/src/main/webapp/json/ev/_capture/rx/showPath_ex2.json
deleted file mode 100644
index 2a05249..0000000
--- a/web/gui/src/main/webapp/json/ev/_capture/rx/showPath_ex2.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
-  "event": "showPath",
-  "sid": 3,
-  "payload": {
-    "ids": [
-      "of:0000000000000007"
-    ],
-    "traffic": true
-  }
-}
-// what is the client supposed to do with this?
diff --git a/web/gui/src/main/webapp/json/ev/_capture/rx/showTraffic_ex3_none.json b/web/gui/src/main/webapp/json/ev/_capture/rx/showTraffic_ex3_none.json
new file mode 100644
index 0000000..4acd829
--- /dev/null
+++ b/web/gui/src/main/webapp/json/ev/_capture/rx/showTraffic_ex3_none.json
@@ -0,0 +1,7 @@
+{
+  "event": "showTraffic",
+  "sid": 11,
+  "payload": {
+    "paths": []
+  }
+}
diff --git a/web/gui/src/main/webapp/json/ev/links/ev_23_onos.json b/web/gui/src/main/webapp/json/ev/links/ev_23_onos.json
new file mode 100644
index 0000000..7d14845
--- /dev/null
+++ b/web/gui/src/main/webapp/json/ev/links/ev_23_onos.json
@@ -0,0 +1,22 @@
+{
+  "event": "showTraffic",
+  "sid":62,
+  "payload": {
+    "paths": [
+      {
+        "class": "primary",
+        "traffic": false,
+        "links": [
+          "0E:2A:69:30:13:8A/-1/0-of:0000ffffffff0008/1",
+          "of:0000ffffffff0008/20-of:0000ffffffff0007/10",
+          "of:0000ffffffff0007/1-0E:2A:69:30:13:89/-1/0"
+        ],
+        "labels": [
+          "Load{rate=98, latest=38080}",
+          "Load{rate=98, latest=38080}",
+          "Load{rate=98, latest=38080}"
+        ]
+      }
+    ]
+  }
+}
diff --git a/web/gui/src/main/webapp/json/ev/links/ev_24_onos.json b/web/gui/src/main/webapp/json/ev/links/ev_24_onos.json
new file mode 100644
index 0000000..93b6aa6
--- /dev/null
+++ b/web/gui/src/main/webapp/json/ev/links/ev_24_onos.json
@@ -0,0 +1,22 @@
+{
+  "event": "showTraffic",
+  "sid":63,
+  "payload": {
+    "paths": [
+      {
+        "class": "primary animated",
+        "traffic": true,
+        "links": [
+          "0E:2A:69:30:13:8A/-1/0-of:0000ffffffff0008/1",
+          "of:0000ffffffff0008/20-of:0000ffffffff0007/10",
+          "of:0000ffffffff0007/1-0E:2A:69:30:13:89/-1/0"
+        ],
+        "labels": [
+          "Load{rate=98, latest=38080}",
+          "Load{rate=98, latest=38080}",
+          "Load{rate=98, latest=38080}"
+        ]
+      }
+    ]
+  }
+}
diff --git a/web/gui/src/main/webapp/json/ev/links/ev_25_onos.json b/web/gui/src/main/webapp/json/ev/links/ev_25_onos.json
new file mode 100644
index 0000000..59c12fa
--- /dev/null
+++ b/web/gui/src/main/webapp/json/ev/links/ev_25_onos.json
@@ -0,0 +1,7 @@
+{
+  "event": "showTraffic",
+  "sid": 64,
+  "payload": {
+    "paths": []
+  }
+}
diff --git a/web/gui/src/main/webapp/topo2.js b/web/gui/src/main/webapp/topo2.js
index 8a7efd3..0624677 100644
--- a/web/gui/src/main/webapp/topo2.js
+++ b/web/gui/src/main/webapp/topo2.js
@@ -145,7 +145,8 @@
             view: null,     // view token reference
             nodes: [],
             links: [],
-            lookup: {}
+            lookup: {},
+            revLinkToKey: {}
         },
         scenario = {
             evDir: 'json/ev/',
@@ -423,6 +424,12 @@
         return one + '-' + two;
     }
 
+    function findLinkById(id) {
+        // check to see if this is a reverse lookup, else default to given id
+        var key = network.revLinkToKey[id] || id;
+            return key && network.lookup[key];
+    }
+
     function findLink(linkData, op) {
         var key = makeLinkKey(linkData),
             keyrev = makeLinkKey(linkData, 1),
@@ -476,10 +483,12 @@
                                 ldata.key = keyrev;
                                 delete network.lookup[key];
                                 network.lookup[keyrev] = ldata;
+                                delete network.revLinkToKey[keyrev];
                             }
                         } else {
                             // remove fromTarget
                             ldata.fromTarget = null;
+                            delete network.revLinkToKey[keyrev];
                         }
                         if (ldata.fromSource) {
                             restyleLinkElement(ldata);
@@ -496,6 +505,7 @@
     function addLinkUpdate(ldata, link) {
         // add link event, but we already have the reverse link installed
         ldata.fromTarget = link;
+        network.revLinkToKey[link.id] = ldata.key;
         restyleLinkElement(ldata);
     }
 
@@ -548,7 +558,6 @@
         removeHost: removeHost,
 
         showDetails: showDetails,
-        showPath: showPath,
         showTraffic: showTraffic
     };
 
@@ -693,24 +702,6 @@
         detailPane.show();
     }
 
-    function showPath(data) {
-        // TODO: review - making sure we are handling the payload correctly.
-        evTrace(data);
-        var links = data.payload.links,
-            s = [ data.event + "\n" + links.length ];
-        links.forEach(function (d, i) {
-            s.push(d);
-        });
-        network.view.alert(s.join('\n'));
-
-        links.forEach(function (d, i) {
-            var link = network.lookup[d];
-            if (link) {
-                link.el.classed('showPath', true);
-            }
-        });
-    }
-
     function showTraffic(data) {
         evTrace(data);
         var paths = data.payload.paths;
@@ -722,7 +713,7 @@
         paths.forEach(function (p) {
             var cls = p.class;
             p.links.forEach(function (id) {
-                var lnk = network.lookup[id];
+                var lnk = findLinkById(id);
                 if (lnk) {
                     lnk.el.classed(cls, true);
                 }