parameter injection mechanism to onos gui from other gui apps

Change-Id: I50e6a06ae07c4afc45497983947c076ae7ba4333
diff --git a/web/gui/src/main/webapp/app/fw/nav/nav.js b/web/gui/src/main/webapp/app/fw/nav/nav.js
index 671fa91..d962b8e 100644
--- a/web/gui/src/main/webapp/app/fw/nav/nav.js
+++ b/web/gui/src/main/webapp/app/fw/nav/nav.js
@@ -25,6 +25,7 @@
 
     // internal state
     var navShown = false;
+    var ovParamsDataNs = {};
 
     function updatePane() {
         var vis = navShown ? 'visible' : 'hidden';
@@ -51,8 +52,19 @@
         return false;
     }
 
+    function isEmpty(obj) {
+        for (var x in obj) { return false; }
+        return true;
+    }
+
     function navTo(path, params) {
+
         var url;
+        if (params.hasOwnProperty('ovParams') && !isEmpty(params.ovParams) ) {
+            ovParamsDataNs = params.ovParams;
+            delete params.ovParams;
+        }
+
         if (!path) {
             $log.warn('Not a valid navigation path');
             return null;
@@ -68,6 +80,11 @@
         url = $location.absUrl();
         $log.log('Navigating to ', url);
         $window.location.href = url;
+
+    }
+
+    function getOvParamsData() {
+        return ovParamsDataNs;
     }
 
     angular.module('onosNav', [])
@@ -84,18 +101,20 @@
         .factory('NavService',
             ['$log', '$location', '$window', 'FnService',
 
-            function (_$log_, _$location_, _$window_, _fs_) {
+            function (_$log_, _$location_, _$window_, _fs_ ) {
                 $log = _$log_;
                 $location = _$location_;
                 $window = _$window_;
                 fs = _fs_;
 
+
                 return {
                     showNav: showNav,
                     hideNav: hideNav,
                     toggleNav: toggleNav,
                     hideIfShown: hideIfShown,
                     navTo: navTo,
+                    navPassedData: getOvParamsData,
                 };
         }]);
 
diff --git a/web/gui/src/main/webapp/app/view/topo/topo.js b/web/gui/src/main/webapp/app/view/topo/topo.js
index 04b552c..fef2da5 100644
--- a/web/gui/src/main/webapp/app/view/topo/topo.js
+++ b/web/gui/src/main/webapp/app/view/topo/topo.js
@@ -31,7 +31,7 @@
     // references to injected services
     var $scope, $log, $loc, $timeout,
         fs, ks, zs, gs, ms, sus, flash, wss, ps, th, tds, t3s, tes, tfs, tps,
-        tis, tms, tss, tls, tos, fltr, ttbs, tspr, tov;
+        tis, tms, tss, tls, tos, fltr, ttbs, tspr, tov, ns;
 
     // DOM elements
     var ovtopo, svg, defs, zoomLayer, mapG, spriteG, forceG, noDevsLayer;
@@ -596,7 +596,7 @@
             'TopoSelectService', 'TopoLinkService', 'TopoTrafficService',
             'TopoObliqueService', 'TopoFilterService', 'TopoToolbarService',
             'TopoMapService', 'TopoSpriteService', 'TooltipService',
-            'TopoOverlayService', 'LionService',
+            'TopoOverlayService', 'LionService','NavService',
 
                 function (_$scope_, _$log_, _$loc_, _$timeout_, _$cookies_,
                   _fs_, mast, _ks_, _zs_,
@@ -607,7 +607,7 @@
                   _tss_, _tls_, _tts_,
                   _tos_, _fltr_, _ttbs_,
                   _tms_, _tspr_, _ttip_,
-                  _tov_, lion) {
+                  _tov_, lion, _ns_) {
 
             var params = _$loc_.search(),
                 selOverlay = params.overlayId,
@@ -654,6 +654,7 @@
             tspr = _tspr_;
             tov = _tov_;
             tss = _tss_;
+            ns = _ns_;
 
             tms.start({
                 toggleMap: toggleMap,
@@ -661,7 +662,9 @@
                 setMap: setMap,
             });
 
-            // pull intent data from the query string...
+            $scope.ovParamsData = ns.navPassedData();
+
+                    // pull intent data from the query string...
             if (params.key && params.appId && params.appName) {
                 $scope.intentData = {
                     key: params.key,
@@ -671,6 +674,7 @@
                 };
             }
 
+
             $scope.notifyResize = function () {
                 svgResized(fs.windowSize(mast.mastHeight()));
             };
@@ -749,7 +753,7 @@
 
             restoreConfigFromPrefs();
 
-            ttbs.selectOverlay(selOverlay || prefsState.ovid);
+            ttbs.selectOverlay(selOverlay || prefsState.ovid, $scope.ovParamsData);
 
             $log.debug('registered overlays...', tov.list());
             $log.log('OvTopoCtrl has been created');
diff --git a/web/gui/src/main/webapp/app/view/topo/topoToolbar.js b/web/gui/src/main/webapp/app/view/topo/topoToolbar.js
index 8b37002..18559d3 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoToolbar.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoToolbar.js
@@ -98,6 +98,8 @@
             spr: 'S',
             // NOTE: toolbar state is handled separately
         };
+    // Params passed to overlay.
+    var ovParams = {};
 
     function init(_api_) {
         api = _api_;
@@ -304,12 +306,17 @@
         persistTopoPrefs('toolbar');
     }
 
-    function selectOverlay(ovid) {
+    function getOverlayParams(typeOfOverlay) {
+        return ovParams;
+    }
+
+    function selectOverlay(ovid, params) {
         var idx = ovIndex[defaultOverlay] || 0,
             pidx = (ovid === null) ? 0 : ovIndex[ovid] || -1;
         if (pidx >= 0 && pidx < ovRset.size()) {
             idx = pidx;
         }
+        ovParams = params;
         ovRset.selectedIndex(idx);
     }
 
@@ -341,6 +348,7 @@
                 toggleToolbar: toggleToolbar,
                 selectOverlay: selectOverlay,
                 defaultPrefs: defaultPrefsState,
+                paramsOverlay: getOverlayParams,
                 fnkey: fnkey,
                 setLionBundle: function (bundle) { topoLion = bundle; },
             };