ONOS-6255 : Integrate Topology 2 into Nav Menu.
- Topo2: layouts with neither geo nor grid, use default pan/zoom.
- Topo2: Add 'dot' keyboard command to toggle toolbar.
- Topo2: Toolbar starts hidden.

Change-Id: I328da4be5c75032d437c84be07d166607efe06ad
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java b/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
index 14b3db9..02d0808 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
@@ -132,11 +132,7 @@
                 new UiView(PLATFORM, "processor", "Packet Processors", "nav_processors"),
                 new UiView(PLATFORM, "partition", "Partitions", "nav_partitions"),
                 new UiView(NETWORK, "topo", "Topology", "nav_topo"),
-
-                // FIXME: leave commented out for now, while still under development
-                // (remember to also comment out inclusions in index.html)
-//                new UiView(NETWORK, "topo2", "New-Topo"),
-
+                new UiView(NETWORK, "topo2", "Topology 2", "nav_topo2"),
                 new UiView(NETWORK, "device", "Devices", "nav_devs"),
                 new UiViewHidden("flow"),
                 new UiViewHidden("port"),
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/UiWebSocket.java b/web/gui/src/main/java/org/onosproject/ui/impl/UiWebSocket.java
index be0ab24..00295c4 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/UiWebSocket.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/UiWebSocket.java
@@ -99,10 +99,6 @@
         sharedModel.injectJsonifier(t2json);
 
         topoSession = new UiTopoSession(this, t2json, sharedModel, layoutService);
-
-        // FIXME: this is temporary to prevent unhandled events being set to GUI...
-        //         while Topo2 is still under development
-        topoSession.enableEvent(false);
     }
 
     @Override
diff --git a/web/gui/src/main/webapp/app/fw/svg/icon.js b/web/gui/src/main/webapp/app/fw/svg/icon.js
index 8e0252f..659a5be 100644
--- a/web/gui/src/main/webapp/app/fw/svg/icon.js
+++ b/web/gui/src/main/webapp/app/fw/svg/icon.js
@@ -71,6 +71,7 @@
         nav_processors: 'allTraffic',
 
         nav_topo: 'topo',
+        nav_topo2: 'm_cloud',
         nav_devs: 'switch',
         nav_links: 'ports',
         nav_hosts: 'endstation',
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2Background.js b/web/gui/src/main/webapp/app/view/topo2/topo2Background.js
index f0312f5..902ebdc 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2Background.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2Background.js
@@ -63,11 +63,8 @@
                         t2ms.init();
                         this.zoomer = t2zs.getZoomer();
                     },
+
                     addLayout: function (data) {
-
-                        var oldBgType = this.bgType,
-                            oldBgId = this.bgId;
-
                         this.background = data;
                         this.bgType = data.bgType;
                         this.bgId = data.bgId;
@@ -105,14 +102,17 @@
                             t2ms.hide();
                             t2sls.hide();
 
-                            // TODO: don't just use previous layout's pan/zoom settings!
-                            // _this.region.loaded('bgRendered', true);
-                            // t2zs.panAndZoom(pan, _this.background.bgZoomScale, 1000);
+                            _this.region.loaded('bgRendered', true);
+
+                            // Use default zoom and pan
+                            t2zs.panAndZoom([0, 0], 1);
                         }
                     },
+
                     getBackgroundType: function () {
                         return this.bgType;
                     },
+
                     resetZoom: function () {
                         var pan = zoomPan(this.zoomData, true);
                         t2zs.panAndZoom(pan, zoomScale(this.zoomData, true), 1000);
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 fda74c7..d1fa72d 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,8 @@
 (function () {
 
     // Injected Services
-    var $log, fs, ks, flash, wss, t2ps, t2bgs, ps, t2is, t2sp, t2vs, t2rs, t2fs, t2sls, t2tbs;
+    var $log, fs, ks, flash, wss, t2ps, t2bgs, ps, t2is, t2sp, t2vs, t2rs,
+        t2fs, t2sls, t2tbs;
 
     // Commmands
     function actionMap() {
@@ -31,6 +32,7 @@
             E: [equalizeMasters, 'Equalize mastership roles'],
             X: [resetNodeLocation, 'Reset Node Location'],
             U: [unpinNode, 'Unpin node (mouse over)'],
+            dot: [toggleToolbar, 'Toggle Toolbar'],
 
             esc: handleEscape,
 
@@ -139,6 +141,10 @@
         flash.flash('Unpin node');
     }
 
+    function toggleToolbar() {
+        t2tbs.toggle();
+    }
+
     function notValid(what) {
         $log.warn('topo.js getActionEntry(): Not a valid ' + what);
     }
@@ -162,12 +168,13 @@
 
     angular.module('ovTopo2')
     .factory('Topo2KeyCommandService', [
-        '$log', 'FnService', 'KeyService', 'FlashService', 'WebSocketService', 'Topo2PrefsService',
-        'Topo2BackgroundService', 'PrefsService', 'Topo2InstanceService',
-        'Topo2SummaryPanelService', 'Topo2ViewService', 'Topo2RegionService',
-        'Topo2SpriteLayerService',
-        function (_$log_, _fs_, _ks_, _flash_, _wss_, _t2ps_, _t2bgs_, _ps_, _t2is_, _t2sp_,
-                  _t2vs_, _t2rs_, _t2sls_) {
+        '$log', 'FnService', 'KeyService', 'FlashService', 'WebSocketService',
+        'Topo2PrefsService', 'Topo2BackgroundService', 'PrefsService',
+        'Topo2InstanceService', 'Topo2SummaryPanelService', 'Topo2ViewService',
+        'Topo2RegionService', 'Topo2SpriteLayerService',
+
+        function (_$log_, _fs_, _ks_, _flash_, _wss_, _t2ps_, _t2bgs_, _ps_,
+                  _t2is_, _t2sp_, _t2vs_, _t2rs_, _t2sls_) {
 
             $log = _$log_;
             fs = _fs_;
diff --git a/web/gui/src/main/webapp/app/view/topo2/topo2Toolbar.js b/web/gui/src/main/webapp/app/view/topo2/topo2Toolbar.js
index a0b1b94..264ce54 100644
--- a/web/gui/src/main/webapp/app/view/topo2/topo2Toolbar.js
+++ b/web/gui/src/main/webapp/app/view/topo2/topo2Toolbar.js
@@ -43,7 +43,7 @@
                         this.el.addRow();
                         this.addSecondRow();
 
-                        this.el.show();
+                        this.el.hide();
                     },
                     initKeyData: function () {
                         _.each(k2b, function(value, key) {
@@ -74,6 +74,10 @@
                         v.tog = this.el.addToggle(v.id, v.gid, v.isel, v.cb, v.tt);
                     },
 
+                    toggle: function () {
+                        this.el.toggle();
+                    },
+
                     addFirstRow: function () {
                         this.addToggle('I');
                         this.addToggle('O');
diff --git a/web/gui/src/main/webapp/index.html b/web/gui/src/main/webapp/index.html
index b73dcb2..031dedb 100644
--- a/web/gui/src/main/webapp/index.html
+++ b/web/gui/src/main/webapp/index.html
@@ -131,7 +131,6 @@
     <link rel="stylesheet" href="app/fw/widget/table-theme.css">
 
     <!-- Under development for Region support. -->
-    <!--
     <script src="app/view/topo2/topo2.js"></script>
     <script src="app/view/topo2/topo2Breadcrumb.js"></script>
     <script src="app/view/topo2/topo2Background.js"></script>
@@ -174,7 +173,6 @@
     <script src="app/view/topo2/uiView.js"></script>
     <link rel="stylesheet" href="app/view/topo2/topo2.css">
     <link rel="stylesheet" href="app/view/topo2/topo2-theme.css">
-    -->
 
     <!-- Builtin views javascript. -->
     <script src="app/view/topo/topo.js"></script>