ONOS-2186 - GUI Topo Overlay - (WIP)
- added isActive() predicate to UiTopoOverlay.
- auto-select single intent in an intent selection group.
- clean up mouse over/out handling.

Change-Id: I0f951bd26fcfc791d73bb8121ebbe002086294ea
diff --git a/web/gui/src/main/webapp/app/view/topo/topoSelect.js b/web/gui/src/main/webapp/app/view/topo/topoSelect.js
index 779e408..483c4ba 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoSelect.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoSelect.js
@@ -229,9 +229,9 @@
         tps.displaySomething();
     }
 
-    // returns true if we are hovering over a node, or any nodes are selected
+    // returns true if one or more nodes are selected.
     function somethingSelected() {
-        return hovered || nSel();
+        return nSel();
     }
 
     function clickConsumed(x) {
diff --git a/web/gui/src/main/webapp/app/view/topo/topoTraffic.js b/web/gui/src/main/webapp/app/view/topo/topoTraffic.js
index 9308542..a2cd818 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoTraffic.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoTraffic.js
@@ -41,13 +41,15 @@
     //  Helper functions
 
     // invoked in response to change in selection and/or mouseover/out:
-    function requestTrafficForMode() {
+    function requestTrafficForMode(mouse) {
         if (trafficMode === 'flows') {
             requestDeviceLinkFlows();
         } else if (trafficMode === 'intents') {
-            requestRelatedIntents();
+            if (!mouse || hoverMode === 'intents') {
+                requestRelatedIntents();
+            }
         } else {
-            cancelTraffic();
+            // do nothing
         }
     }
 
@@ -89,8 +91,8 @@
     // === -------------------------------------------------------------
     //  Traffic requests invoked from keystrokes or toolbar buttons...
 
-    function cancelTraffic() {
-        if (!trafficMode) {
+    function cancelTraffic(forced) {
+        if (!trafficMode || (!forced && trafficMode === 'allFlowPort')) {
             return false;
         }
 
@@ -101,15 +103,15 @@
     }
 
     function showAllFlowTraffic() {
-        trafficMode = 'allFlow';
-        hoverMode = 'all';
+        trafficMode = 'allFlowPort';
+        hoverMode = null;
         wss.sendEvent('requestAllFlowTraffic');
         flash.flash('All Flow Traffic');
     }
 
     function showAllPortTraffic() {
-        trafficMode = 'allPort';
-        hoverMode = 'all';
+        trafficMode = 'allFlowPort';
+        hoverMode = null;
         wss.sendEvent('requestAllPortTraffic');
         flash.flash('All Port Traffic');
     }
@@ -161,6 +163,8 @@
             two: so[1],
             ids: so
         });
+        trafficMode = 'intents';
+        hoverMode = null;
         flash.flash('Host-to-Host flow added');
     }
 
@@ -171,6 +175,8 @@
             dst: so[so.length - 1],
             ids: so
         });
+        trafficMode = 'intents';
+        hoverMode = null;
         flash.flash('Multi-Source flow added');
     }
 
diff --git a/web/gui/src/main/webapp/app/view/topo/topoTrafficNew.js b/web/gui/src/main/webapp/app/view/topo/topoTrafficNew.js
index a0e046c..ea5e24a 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoTrafficNew.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoTrafficNew.js
@@ -45,7 +45,7 @@
         },
 
         deactivate: function () {
-            tts.cancelTraffic();
+            tts.cancelTraffic(true);
             $log.debug("Traffic overlay DEACTIVATED");
         },
 
@@ -69,7 +69,7 @@
         // NOTE: fully qual. button ID is derived from overlay-id and key-name
         keyBindings: {
             0: {
-                cb: function () { tts.cancelTraffic(); },
+                cb: function () { tts.cancelTraffic(true); },
                 tt: 'Cancel traffic monitoring',
                 gid: 'xMark'
             },
@@ -137,10 +137,10 @@
             // mouse hooks
             mouseover: function (m) {
                 // m has id, class, and type properties
-                tts.requestTrafficForMode();
+                tts.requestTrafficForMode(true);
             },
             mouseout: function () {
-                tts.requestTrafficForMode();
+                tts.requestTrafficForMode(true);
             }
         }
     };