[ONOS-6657] Topo2: Added Host label cycling:
Hide Label
Show Friendly Label
Show Ip Address
Show MAC Address

Change-Id: I0e5b9f303960f71b6cd45b97a2e748ff64a1fae9
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2Host.js b/web/gui/src/main/webapp/app/view/topo2/topo2Host.js
index a2f2124..bd04c7b 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2Host.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2Host.js
@@ -49,7 +49,8 @@
     .factory('Topo2HostService', [
         'Topo2Collection', 'Topo2NodeModel', 'Topo2ViewService',
         'IconService', 'Topo2ZoomService', 'Topo2HostsPanelService', 'PrefsService',
-        function (_c_, NodeModel, _t2vs_, is, zs, t2hds, ps) {
+        'Topo2PrefsService',
+        function (_c_, NodeModel, _t2vs_, is, zs, t2hds, ps, t2ps) {
 
             Collection = _c_;
 
@@ -76,8 +77,18 @@
                     var type = this.get('type');
                     return remappedDeviceTypes[type] || type || 'm_endstation';
                 },
+                labelIndex: function () {
+                    return t2ps.get('hlbls');
+                },
                 label: function () {
-                    return this.get('ips')[0] || 'unknown';
+                    var props = this.get('props'),
+                        id = this.get('ips')[0] || 'unknown',
+                        friendlyName = props && props.name ? props.name : id,
+                        labels = ['', friendlyName || id, id, this.get('id')],
+                        nli = this.labelIndex(),
+                        idx = (nli < labels.length) ? nli : 0;
+
+                    return labels[idx];
                 },
                 setScale: function () {
 
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2KeyCommands.js b/web/gui/src/main/webapp/app/view/topo2/topo2KeyCommands.js
index a3b75f5..b396f30 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2KeyCommands.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2KeyCommands.js
@@ -35,6 +35,7 @@
             H: [toggleHosts, 'Toggle host visibility'],
             M: [toggleOfflineDevices, 'Toggle offline visibility'],
             dot: [toggleToolbar, 'Toggle Toolbar'],
+            'shift-L': [cycleHostLabels, 'Cycle host labels'],
 
             esc: handleEscape,
 
@@ -114,6 +115,15 @@
         }
     }
 
+    function hostLabelFlashMessage(index) {
+        switch (index) {
+            case 0: return 'Hide host labels';
+            case 1: return 'Show friendly host labels';
+            case 2: return 'Show host IP labels';
+            case 3: return 'Show host MAC Address labels';
+        }
+    }
+
     function cycleDeviceLabels() {
         var deviceLabelIndex = t2ps.get('dlbls') + 1,
             newDeviceLabelIndex = deviceLabelIndex % 3;
@@ -123,6 +133,15 @@
         flash.flash(deviceLabelFlashMessage(newDeviceLabelIndex));
     }
 
+    function cycleHostLabels() {
+        var hostLabelIndex = t2ps.get('hlbls') + 1,
+            newHostLabelIndex = hostLabelIndex % 4;
+
+        t2ps.set('hlbls', newHostLabelIndex);
+        t2fs.updateNodes();
+        flash.flash(hostLabelFlashMessage(newHostLabelIndex));
+    }
+
     function toggleBackground(x) {
         t2bgs.toggle(x);
     }