Added keyboard shortcut to show/hide instance panel

Change-Id: I88bed44fe84a91ca870d67d0428b95c4a30dab85
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2Instance.js b/web/gui/src/main/webapp/app/view/topo2/topo2Instance.js
index 1172662..64cefdd 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2Instance.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2Instance.js
@@ -2,7 +2,7 @@
     'use strict';
 
     // injected refs
-    var $log, ps, sus, gs, ts;
+    var $log, ps, sus, gs, flash, ts;
 
     // api from topo
     var api;
@@ -238,6 +238,26 @@
         });
     }
 
+    function toggle(x) {
+        var kev = (x === 'keyev'),
+            on,
+            verb;
+
+        if (kev) {
+            on = oiBox.toggle();
+        } else {
+            on = Boolean(x);
+            if (on) {
+                oiBox.show();
+            } else {
+                oiBox.hide();
+            }
+        }
+        verb = on ? 'Show' : 'Hide';
+        flash.flash(verb + ' instances panel');
+        return on;
+    }
+
     function destroy() {
         ts.removeListener(updateInstances);
 
@@ -250,20 +270,22 @@
 
     angular.module('ovTopo2')
         .factory('Topo2InstanceService',
-        ['$log', 'PanelService', 'SvgUtilService', 'GlyphService',
+        ['$log', 'PanelService', 'SvgUtilService', 'GlyphService', 'FlashService',
         'ThemeService',
 
-        function (_$log_, _ps_, _sus_, _gs_, _ts_) {
+        function (_$log_, _ps_, _sus_, _gs_, _flash_, _ts_) {
             $log = _$log_;
             ps = _ps_;
             sus = _sus_;
             gs = _gs_;
+            flash = _flash_;
             ts = _ts_;
 
             return {
                 initInst: initInst,
                 allInstances: allInstances,
-                destroy: destroy
+                destroy: destroy,
+                toggle: toggle
             };
         }]);
 
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 ea6436d..1b0b10f 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2KeyCommands.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2KeyCommands.js
@@ -17,7 +17,7 @@
 (function () {
 
     // Injected Services
-    var ks, t2ps, t2ms;
+    var ks, t2ps, t2ms, ps, t2is;
     var topo2ForceService;
 
     // Commmands
@@ -25,6 +25,7 @@
         L: [cycleDeviceLabels, 'Cycle device labels'],
         G: [openMapSelection, 'Select background geo map'],
         B: [toggleMap, 'Toggle background geo map'],
+        I: [toggleInstancePanel, 'Toggle ONOS Instance Panel']
     };
 
     function init(t2fs) {
@@ -45,6 +46,13 @@
         ]);
     }
 
+    var prefsState = {};
+
+    function updatePrefsState(what, b) {
+        prefsState[what] = b ? 1 : 0;
+        ps.setPrefs('topo_prefs', prefsState);
+    }
+
     function cycleDeviceLabels() {
         var deviceLabelIndex = t2ps.get('dlbls') + 1;
         t2ps.set('dlbls', deviceLabelIndex % 3);
@@ -59,14 +67,20 @@
         t2ms.toggle(x);
     }
 
+    function toggleInstancePanel(x) {
+        updatePrefsState('insts', t2is.toggle(x));
+    }
+
     angular.module('ovTopo2')
     .factory('Topo2KeyCommandService',
-    ['KeyService', 'Topo2PrefsService', 'Topo2MapService',
-
-        function (_ks_, _t2ps_, _t2ms_) {
+    ['KeyService', 'Topo2PrefsService', 'Topo2MapService', 'PrefsService',
+    'Topo2InstanceService',
+        function (_ks_, _t2ps_, _t2ms_, _ps_, _t2is_) {
 
             t2ps = _t2ps_;
             t2ms = _t2ms_;
+            t2is = _t2is_;
+            ps = _ps_;
             ks = _ks_;
 
             return {