ONOS-2109: Fix for (0,0) coords bug - delay opening web socket until we have loaded the map projection.

Change-Id: Ibe38154c987baf77768e2d6a0bcaf8f35550efcb
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 b686aae..29fcc83 100644
--- a/web/gui/src/main/webapp/app/view/topo/topo.js
+++ b/web/gui/src/main/webapp/app/view/topo/topo.js
@@ -361,7 +361,7 @@
         // NOTE: toolbar will have set this for us..
         prefsState = ps.asNumbers(ps.getPrefs('topo_prefs'));
 
-        $log.debug('TOPO---- Prefs State:', prefsState);
+        $log.debug('TOPO- Prefs State:', prefsState);
 
         flash.enable(false);
         toggleInstances(prefsState.insts);
@@ -372,6 +372,19 @@
     }
 
 
+    // somewhat hackish, because summary update cannot happen until we
+    //  have opened the websocket to the server; hence this extra function
+    // invoked after tes.start()
+    function restoreSummaryFromPrefs() {
+        prefsState = ps.asNumbers(ps.getPrefs('topo_prefs'));
+        $log.debug('TOPO- Prefs SUMMARY State:', prefsState.summary);
+
+        flash.enable(false);
+        toggleSummary(prefsState.summary);
+        flash.enable(true);
+    }
+
+
     // --- Controller Definition -----------------------------------------
 
     angular.module('ovTopo', moduleDependencies)
@@ -463,7 +476,13 @@
                     flash.enable(false);
                     toggleMap(prefsState.bg);
                     flash.enable(true);
-                    // TODO: move tes.start() to here ????
+
+                    // now we have the map projection, we are ready for
+                    //  the server to send us device/host data...
+                    tes.start();
+                    // need to do the following so we immediately get
+                    //  the summary panel data back from the server
+                    restoreSummaryFromPrefs();
                 }
             );
             setUpSprites($loc, tspr);
@@ -472,7 +491,6 @@
             tfs.initForce(svg, forceG, uplink, dim);
             tis.initInst({ showMastership: tfs.showMastership });
             tps.initPanels();
-            tes.start();
 
             // temporary solution for persisting user settings
             restoreConfigFromPrefs();