GUI -- Preliminary work for converting tabular views to use the shared web-socket rather than via REST. WIP.

Change-Id: I68de98e8df0a2bbcebe15ad9015ce6b4df43d81c
diff --git a/web/gui/src/main/webapp/WEB-INF/web.xml b/web/gui/src/main/webapp/WEB-INF/web.xml
index 7e88d95..e6807fa 100644
--- a/web/gui/src/main/webapp/WEB-INF/web.xml
+++ b/web/gui/src/main/webapp/WEB-INF/web.xml
@@ -139,7 +139,6 @@
             <param-name>com.sun.jersey.config.property.classnames</param-name>
             <param-value>
                 org.onosproject.ui.impl.TopologyResource,
-                org.onosproject.ui.impl.DeviceGuiResource
             </param-value>
         </init-param>
         <load-on-startup>1</load-on-startup>
diff --git a/web/gui/src/main/webapp/app/view/device/device.js b/web/gui/src/main/webapp/app/view/device/device.js
index 8a1eca1..13601de 100644
--- a/web/gui/src/main/webapp/app/view/device/device.js
+++ b/web/gui/src/main/webapp/app/view/device/device.js
@@ -23,30 +23,39 @@
 
     angular.module('ovDevice', [])
     .controller('OvDeviceCtrl',
-        ['$log', '$scope', '$location', 'RestService', 'VeilService',
+        ['$log', '$scope', '$location', 'WebSocketService',
 
-        function ($log, $scope, $location, rs, vs) {
+        function ($log, $scope, $location, wss) {
             var self = this;
             self.deviceData = [];
 
+            $scope.responseCallback = function(data) {
+                self.deviceData = data.devices;
+                $scope.$apply();
+            };
+
             $scope.sortCallback = function (urlSuffix) {
+                // FIXME: fix hardcoded sort params
                 if (!urlSuffix) {
                     urlSuffix = '';
                 }
-                var url = 'device' + urlSuffix;
-                rs.get(url, function (data) {
-                    self.deviceData = data.devices;
-                }, function (errMsg) {
-                    vs.lostServer('OvDeviceCtrl', errMsg);
-                });
+                var payload = { sortCol: 'id', sortDir: 'asc' };
+                wss.sendEvent('deviceDataRequest', payload);
             };
-            $scope.sortCallback();
+
+            var handlers = {
+                deviceDataResponse: $scope.responseCallback
+            };
+            wss.bindHandlers(handlers);
 
             // Cleanup on destroyed scope
             $scope.$on('$destroy', function () {
-
+                wss.unbindHandlers(handlers);
             });
 
             $log.log('OvDeviceCtrl has been created');
+
+            $scope.sortCallback();
+
         }]);
 }());
diff --git a/web/gui/src/main/webapp/app/view/host/host.css b/web/gui/src/main/webapp/app/view/host/host.css
new file mode 100644
index 0000000..2b97bfb
--- /dev/null
+++ b/web/gui/src/main/webapp/app/view/host/host.css
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.
+ */
+
+/*
+ ONOS GUI -- Device View -- CSS file
+ */
+
+#ov-device th {
+    cursor: pointer;
+}
\ No newline at end of file
diff --git a/web/gui/src/main/webapp/app/view/host/host.html b/web/gui/src/main/webapp/app/view/host/host.html
new file mode 100644
index 0000000..7ab65e2
--- /dev/null
+++ b/web/gui/src/main/webapp/app/view/host/host.html
@@ -0,0 +1,42 @@
+<!-- Host partial HTML -->
+<div id="ov-host">
+    <h2>Hosts ({{ctrl.hostData.length}} total)</h2>
+    <table class="summary-list"
+           onos-fixed-header
+           onos-sortable-header
+           sort-callback="sortCallback(urlSuffix)">
+        <thead>
+            <tr>
+                <th colId="available"></th>
+                <th colId="type"></th>
+                <th colId="id" sortable>Host ID </th>
+                <th colId="mfr" sortable>Vendor </th>
+                <th colId="hw" sortable>H/W Version </th>
+                <th colId="sw" sortable>S/W Version </th>
+                <th colId="chassisid" sortable>Chassis ID </th>
+                <th colId="serial" sortable>Serial # </th>
+                <th colId="protocol" sortable>Protocol </th>
+            </tr>
+        </thead>
+
+        <tbody>
+        <tr ng-repeat="host in ctrl.hostData"
+            ng-repeat-done>
+            <td class="table-icon">
+                <div icon icon-id="{{host._iconid_available}}"></div>
+            </td>
+            <td class="table-icon">
+                <div icon icon-id="{{host._iconid_type}}"></div>
+            </td>
+            <td>{{host.id}}</td>
+            <td>{{host.mfr}}</td>
+            <td>{{host.hw}}</td>
+            <td>{{host.sw}}</td>
+            <td>{{host.chassisid}}</td>
+            <td>{{host.serial}}</td>
+            <td>{{host.protocol}}</td>
+        </tr>
+        </tbody>
+    </table>
+
+</div>
diff --git a/web/gui/src/main/webapp/app/view/host/host.js b/web/gui/src/main/webapp/app/view/host/host.js
new file mode 100644
index 0000000..0849cdb
--- /dev/null
+++ b/web/gui/src/main/webapp/app/view/host/host.js
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.
+ */
+
+/*
+ ONOS GUI -- Host View Module
+ */
+
+(function () {
+    'use strict';
+
+    angular.module('ovHost', [])
+    .controller('OvHostCtrl',
+        ['$log', '$scope', '$location', 'WebSocketService',
+
+        function ($log, $scope, $location, wss) {
+            var self = this;
+            self.hostData = [];
+
+            $scope.responseCallback = function(data) {
+                self.hostData = data.devices;
+                $scope.$apply();
+            };
+
+            $scope.sortCallback = function (urlSuffix) {
+                // FIXME: fix hardcoded sort params
+                if (!urlSuffix) {
+                    urlSuffix = '';
+                }
+                var payload = { sortCol: 'id', sortDir: 'asc' };
+                wss.sendEvent('hostDataRequest', payload);
+            };
+
+            var handlers = {
+                hostDataResponse: $scope.responseCallback
+            };
+            wss.bindHandlers(handlers);
+
+            // Cleanup on destroyed scope
+            $scope.$on('$destroy', function () {
+                wss.unbindHandlers(handlers);
+            });
+
+            $log.log('OvHostCtrl has been created');
+
+            $scope.sortCallback();
+        }]);
+}());
diff --git a/web/gui/src/main/webapp/index.html b/web/gui/src/main/webapp/index.html
index 7b23671..89c5aff 100644
--- a/web/gui/src/main/webapp/index.html
+++ b/web/gui/src/main/webapp/index.html
@@ -100,6 +100,7 @@
     <script src="app/view/topo/topoTraffic.js"></script>
     <script src="app/view/topo/topoToolbar.js"></script>
     <script src="app/view/device/device.js"></script>
+    <script src="app/view/host/host.js"></script>
     <script src="app/view/sample/sample.js"></script>
     <!-- {INJECTED-JAVASCRIPT-END} -->
 
@@ -108,6 +109,7 @@
     <!-- {INJECTED-STYLESHEETS-START} -->
     <link rel="stylesheet" href="app/view/topo/topo.css">
     <link rel="stylesheet" href="app/view/device/device.css">
+    <link rel="stylesheet" href="app/view/host/host.css">
     <link rel="stylesheet" href="app/view/sample/sample.css">
     <!-- {INJECTED-STYLESHEETS-END} -->
 
diff --git a/web/gui/src/main/webapp/onos.js b/web/gui/src/main/webapp/onos.js
index 60ed3fb..d63d6d9 100644
--- a/web/gui/src/main/webapp/onos.js
+++ b/web/gui/src/main/webapp/onos.js
@@ -38,6 +38,7 @@
         // {INJECTED-VIEW-IDS-START}
         'topo',
         'device',
+        'host',
         'sample',
         // {INJECTED-VIEW-IDS-END}