GUI -- [ONOS-324] - making hosts invisible by default.
 - press the 'H' key to toggle host visibility.
 - minor update to 'simple' scenario events.
 - cleanup of alert usage.

Change-Id: I531417720e6b98e795c53729b0c30775b88f8fc1
diff --git a/web/gui/src/main/webapp/json/ev/simple/ev_1_onos.json b/web/gui/src/main/webapp/json/ev/simple/ev_1_onos.json
index c478378..b86a73c 100644
--- a/web/gui/src/main/webapp/json/ev/simple/ev_1_onos.json
+++ b/web/gui/src/main/webapp/json/ev/simple/ev_1_onos.json
@@ -10,10 +10,13 @@
       "lng": -122.4167
     },
     "labels": [
-      "0000ffffffff0008",
-      "FF:FF:FF:FF:00:08",
+      "",
       "sw-8",
-      ""
-    ]
+      "0000ffffffff0008"
+    ],
+    "metaUi": {
+      "x": 520,
+      "y": 350
+    }
   }
 }
diff --git a/web/gui/src/main/webapp/json/ev/simple/ev_2_onos.json b/web/gui/src/main/webapp/json/ev/simple/ev_2_onos.json
index d12e194..2df409a 100644
--- a/web/gui/src/main/webapp/json/ev/simple/ev_2_onos.json
+++ b/web/gui/src/main/webapp/json/ev/simple/ev_2_onos.json
@@ -4,16 +4,19 @@
     "id": "of:0000ffffffff0003",
     "type": "switch",
     "online": false,
-    "labels": [
-      "0000ffffffff0003",
-      "FF:FF:FF:FF:00:03",
-      "sw-3",
-      ""
-    ],
     "location": {
       "type": "latlng",
       "lat": 40.7127,
       "lng": -74.0059
+    },
+    "labels": [
+      "",
+      "sw-3",
+      "0000ffffffff0003"
+    ],
+    "metaUi": {
+      "x": 800,
+      "y": 280
     }
   }
 }
diff --git a/web/gui/src/main/webapp/json/ev/simple/ev_3_onos.json b/web/gui/src/main/webapp/json/ev/simple/ev_3_onos.json
index 56651c0..0083530 100644
--- a/web/gui/src/main/webapp/json/ev/simple/ev_3_onos.json
+++ b/web/gui/src/main/webapp/json/ev/simple/ev_3_onos.json
@@ -5,10 +5,9 @@
     "type": "switch",
     "online": true,
     "labels": [
-      "0000ffffffff0008",
-      "FF:FF:FF:FF:00:08",
-      "sw-8-yo",
-      ""
+      "",
+      "switch-8",
+      "0000ffffffff0008"
     ],
     "metaUi": {
       "x": 520,
diff --git a/web/gui/src/main/webapp/json/ev/simple/ev_4_onos.json b/web/gui/src/main/webapp/json/ev/simple/ev_4_onos.json
index 958af28..57e3347 100644
--- a/web/gui/src/main/webapp/json/ev/simple/ev_4_onos.json
+++ b/web/gui/src/main/webapp/json/ev/simple/ev_4_onos.json
@@ -5,10 +5,9 @@
     "type": "switch",
     "online": true,
     "labels": [
-      "0000ffffffff0003",
-      "FF:FF:FF:FF:00:03",
-      "sw-3-yo",
-      ""
+      "",
+      "switch-3",
+      "0000ffffffff0003"
     ],
     "metaUi": {
       "x": 800,
diff --git a/web/gui/src/main/webapp/topo2.js b/web/gui/src/main/webapp/topo2.js
index 3c2f512..ba21295 100644
--- a/web/gui/src/main/webapp/topo2.js
+++ b/web/gui/src/main/webapp/topo2.js
@@ -143,6 +143,7 @@
         O: [toggleSummary, 'Toggle ONOS summary pane'],
         I: [toggleInstances, 'Toggle ONOS instances pane'],
         B: [toggleBg, 'Toggle background image'],
+        H: [toggleHosts, 'Toggle host visibility'],
         L: [cycleLabels, 'Cycle Device labels'],
         P: togglePorts,
         U: [unpin, 'Unpin node'],
@@ -170,8 +171,7 @@
             ctx: null,
             params: {},
             evNumber: 0,
-            view: null,
-            debug: false
+            view: null
         },
         webSock,
         sid = 0,
@@ -191,8 +191,10 @@
         oiShowMaster = false,
         portLabelsOn = false,
         cat7 = d3u.cat7(),
-        colorAffinity = false;
+        colorAffinity = false,
+        showHosts = false;
 
+    // constants
     var hoverModeAll = 1,
         hoverModeFlows = 2,
         hoverModeIntents = 3,
@@ -247,22 +249,9 @@
         cat7.testCard(svg);
     }
 
-    function abortIfLive() {
-        if (config.useLiveData) {
-            network.view.alert("Sorry, currently using live data..");
-            return true;
-        }
-        return false;
-    }
-
-    function testDebug(msg) {
-        if (scenario.debug) {
-            scenario.view.alert(msg);
-        }
-    }
-
     function injectTestEvent(view) {
-        if (abortIfLive()) { return; }
+        if (config.useLiveData) { return; }
+
         var sc = scenario,
             evn = ++sc.evNumber,
             pfx = sc.evDir + sc.ctx + sc.evPrefix + evn,
@@ -293,7 +282,6 @@
                     v.alert('non-404 error:\n\n' + frame.url + '\n\n' + err);
                 }
             } else {
-                testDebug('loaded: ' + frame.url);
                 wsTrace('test', JSON.stringify(data));
                 frame.cb(data);
             }
@@ -308,7 +296,7 @@
 
     function injectStartupEvents(view) {
         var last = scenario.params.lastAuto || 0;
-        if (abortIfLive()) { return; }
+        if (config.useLiveData) { return; }
 
         while (scenario.evNumber < last) {
             injectTestEvent(view);
@@ -317,7 +305,13 @@
 
     function toggleBg() {
         var vis = bgImg.style('visibility');
-        bgImg.style('visibility', (vis === 'hidden') ? 'visible' : 'hidden');
+        bgImg.style('visibility', visVal(vis === 'hidden'));
+    }
+
+    function toggleHosts() {
+        showHosts = !showHosts;
+        updateHostVisibility();
+        network.view.flash('Hosts ' + visVal(showHosts));
     }
 
     function cycleLabels() {
@@ -332,7 +326,7 @@
     }
 
     function togglePorts(view) {
-        view.alert('togglePorts() callback')
+        //view.alert('togglePorts() callback')
     }
 
     function unpin() {
@@ -568,7 +562,6 @@
 
     function logicError(msg) {
         // TODO, report logic error to server, via websock, so it can be logged
-        //network.view.alert('Logic Error:\n\n' + msg);
         console.warn(msg);
     }
 
@@ -822,7 +815,7 @@
     }
 
     function unknownEvent(data) {
-        network.view.alert('Unknown event type: "' + data.event + '"');
+        console.warn('Unknown event type: "' + data.event + '"', data);
     }
 
     function handleServerEvent(data) {
@@ -833,12 +826,6 @@
     // ==============================
     // Out-going messages...
 
-    function userFeedback(msg) {
-        // for now, use the alert pane as is. Maybe different alert style in
-        // the future (centered on view; dismiss button?)
-        network.view.alert(msg);
-    }
-
     function nSel() {
         return selectOrder.length;
     }
@@ -1221,6 +1208,10 @@
         appendBadge(svg, 12, instCfg.uiDy, 30, '#uiAttached', 'uiBadge');
     }
 
+    function visVal(b) {
+        return b ? 'visible' : 'hidden';
+    }
+
     // ==============================
     // force layout modification functions
 
@@ -1319,6 +1310,10 @@
         });
     }
 
+    function showHostVis(el) {
+        el.style('visibility', visVal(showHosts));
+    }
+
     var widthRatio = 1.4,
         linkScale = d3.scale.linear()
             .domain([1, 12])
@@ -1350,6 +1345,9 @@
             // provide ref to element selection from backing data....
             d.el = link;
             restyleLinkElement(d);
+            if (d.type() === 'hostLink') {
+                showHostVis(link);
+            }
         });
 
         // operate on both existing and new links, if necessary
@@ -1663,6 +1661,12 @@
         updateHostLabel(hostData);
     }
 
+    function updateHostVisibility() {
+        var v = visVal(showHosts);
+        nodeG.selectAll('.host').style('visibility', v);
+        linkG.selectAll('.hostLink').style('visibility', v);
+    }
+
     function nodeMouseOver(d) {
         hovered = d;
         requestTrafficForMode();
@@ -1692,7 +1696,6 @@
 
         // operate on existing nodes...
         node.filter('.device').each(function (d) {
-            //var node = d3.select(this);
             var node = d.el;
             node.classed('online', d.online);
             updateDeviceLabel(d);
@@ -1747,13 +1750,12 @@
 
             // provide ref to element from backing data....
             d.el = node;
+            showHostVis(node);
 
             node.append('circle').attr('r', r);
-
             if (iid) {
                 addHostIcon(node, r, iid);
             }
-
             node.append('text')
                 .text(hostLabel)
                 .attr('dy', textDy)
@@ -2014,9 +2016,9 @@
             if (webSock.ws) {
                 webSock.ws.send(message);
             } else if (config.useLiveData) {
-                network.view.alert('no web socket open\n\n' + message);
+                console.warn('no web socket open', message);
             } else {
-                console.log('WS Send: ' + JSON.stringify(message));
+                console.log('WS Send: ', message);
             }
         }
 
@@ -2607,7 +2609,7 @@
     }
 
     function showBg() {
-        return config.options.showBackground ? 'visible' : 'hidden';
+        return visVal(config.options.showBackground);
     }
 
     function loadStaticMap() {