Adding server-side default topo layout and fixing GUI to allow remote zoom/pan.

Change-Id: I7fe4d3256afe1bdeac5caabda0283f88e8360c23
diff --git a/apps/layout/src/main/java/org/onosproject/layout/AutoLayoutCommand.java b/apps/layout/src/main/java/org/onosproject/layout/AutoLayoutCommand.java
index 33705db..0f53371 100644
--- a/apps/layout/src/main/java/org/onosproject/layout/AutoLayoutCommand.java
+++ b/apps/layout/src/main/java/org/onosproject/layout/AutoLayoutCommand.java
@@ -20,28 +20,25 @@
 import org.onosproject.cli.AbstractShellCommand;
 
 /**
- * Lists all the default lease parameters offered by the DHCP Server.
+ * Lays out the elements in the topology using the specified algorithm.
  */
 @Command(scope = "onos", name = "topo-layout",
         description = "Lays out the elements in the topology using the specified algorithm")
 public class AutoLayoutCommand extends AbstractShellCommand {
 
     @Argument(index = 0, name = "algorithm",
-            description = "Layout algorithm to use for the layout")
+            description = "Layout algorithm to use for the layout; defaults to 'access'")
     String algorithm = "access";
 
     @Override
     protected void execute() {
         RoleBasedLayoutManager mgr = get(RoleBasedLayoutManager.class);
         switch (algorithm) {
-            case "spine-leaf":
-                mgr.layout(new AccessNetworkLayout());
-                break;
             case "access":
                 mgr.layout(new AccessNetworkLayout());
                 break;
-            case "hag-access":
-                mgr.layout(new AccessNetworkLayout());
+            case "default":
+                mgr.layout(new DefaultForceLayout());
                 break;
             default:
                 print("Unsupported layout algorithm %s", algorithm);
diff --git a/apps/layout/src/main/java/org/onosproject/layout/DefaultForceLayout.java b/apps/layout/src/main/java/org/onosproject/layout/DefaultForceLayout.java
new file mode 100644
index 0000000..6d2d43a
--- /dev/null
+++ b/apps/layout/src/main/java/org/onosproject/layout/DefaultForceLayout.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.layout;
+
+import org.onosproject.net.config.basics.BasicDeviceConfig;
+import org.onosproject.net.config.basics.BasicHostConfig;
+
+/**
+ * Default force layout leaving the client to automatically position nodes.
+ */
+public class DefaultForceLayout extends LayoutAlgorithm {
+
+    @Override
+    public void apply() {
+        hostService.getHosts()
+                .forEach(h -> netConfigService.addConfig(h.id(), BasicHostConfig.class)
+                        .gridX(null).gridY(null).locType(null).apply());
+        deviceService.getDevices()
+                .forEach(d -> netConfigService.addConfig(d.id(), BasicDeviceConfig.class)
+                        .gridX(null).gridY(null).locType(null).apply());
+    }
+}
diff --git a/tools/test/topos/wipe-ui-annotations b/tools/test/topos/wipe-ui-annotations
deleted file mode 100755
index 99eedc6..0000000
--- a/tools/test/topos/wipe-ui-annotations
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-# -----------------------------------------------------------------------------
-# Wipes out UI annotations from all devices and hosts.
-# -----------------------------------------------------------------------------
-
-aux=/tmp/wua.$$.json
-
-host=${1:-$OCI}
-
-onos $host netcfg devices | sed -E 's/("locType")( : )(".*")/\1\2"none"/;s/("grid[XY]")( : )([-0-9.]*)/\1\20.0/' > $aux
-onos-netcfg $host $aux devices
-
-onos $host netcfg hosts | sed -E 's/("locType")( : )(".*")/\1\2"none"/;s/("grid[XY]")( : )([-0-9.]*)/\1\20.0/' > $aux
-onos-netcfg $host $aux hosts
-
-rm -f $aux
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 44ed953..2afd519 100644
--- a/web/gui/src/main/webapp/app/view/topo/topo.js
+++ b/web/gui/src/main/webapp/app/view/topo/topo.js
@@ -528,9 +528,14 @@
     }
 
     function applyPreferences(evt) {
+        var zoomPrefs = ps.getPrefs('topo_zoom', null);
         if (ps.getPrefs('topo_prefs', null)) {
             restoreConfigFromPrefs();
         }
+        if (zoomPrefs) {
+            $log.debug('TOPO- Zoom State:', zoomPrefs);
+            zoomer.panZoom([zoomPrefs.tx, zoomPrefs.ty], zoomPrefs.sc, 100);
+        }
     }
 
     function restoreConfigFromPrefs() {