GUI -- Table views' auto refresh can be toggled on or off.

Change-Id: I9c307d8ea43101d6f6cff28c16d2cdbe709871e1
diff --git a/web/gui/src/main/webapp/app/common.css b/web/gui/src/main/webapp/app/common.css
index 1aef4fb..d0d878e 100644
--- a/web/gui/src/main/webapp/app/common.css
+++ b/web/gui/src/main/webapp/app/common.css
@@ -24,63 +24,3 @@
     padding-top: 20px;
     padding-bottom: 20px;
 }
-
-/* Tabular view upper right control buttons */
-
-div.ctrl-btns {
-    display: inline-block;
-    float: right;
-    height: 44px;
-    margin-right: 24px;
-    margin-top: 7px;
-}
-
-
-div.ctrl-btns div {
-    display: inline-block;
-    padding: 4px;
-    cursor: pointer;
-}
-
-/* Inactive */
-.light .ctrl-btns div g.icon rect,
-.light .ctrl-btns div:hover g.icon rect {
-    fill: #eee;
-}
-.dark .ctrl-btns div g.icon rect,
-.dark .ctrl-btns div:hover g.icon rect {
-    fill: #222;
-}
-
-.light .ctrl-btns div g.icon use {
-    fill: #ddd;
-}
-.dark .ctrl-btns div g.icon use {
-    fill: #333;
-}
-
-/* Active hover */
-.light .ctrl-btns div.active:hover g.icon rect {
-    fill: #800;
-}
-
-.dark .ctrl-btns div.active:hover g.icon rect {
-    fill: #CE5650;
-}
-
-/* Active */
-.light .ctrl-btns div.active g.icon use {
-    fill: #fff;
-}
-.dark .ctrl-btns div.active g.icon use {
-    fill: #eee;
-}
-
-.light .ctrl-btns div.active g.icon rect {
-    fill: #bbb;
-}
-.dark .ctrl-btns div.active g.icon rect {
-    fill: #444;
-}
-
-
diff --git a/web/gui/src/main/webapp/app/fw/widget/table.css b/web/gui/src/main/webapp/app/fw/widget/table.css
index ff222e7..4b56f2e 100644
--- a/web/gui/src/main/webapp/app/fw/widget/table.css
+++ b/web/gui/src/main/webapp/app/fw/widget/table.css
@@ -93,3 +93,70 @@
 .dark div.summary-list td {
     color: #ccc;
 }
+
+/* Tabular view upper right control buttons */
+
+div.ctrl-btns {
+    display: inline-block;
+    float: right;
+    height: 44px;
+    margin-right: 24px;
+    margin-top: 7px;
+}
+
+
+div.ctrl-btns div {
+    display: inline-block;
+    padding: 4px;
+    cursor: pointer;
+}
+
+/* Inactive */
+.light .ctrl-btns div g.icon rect,
+.light .ctrl-btns div:hover g.icon rect {
+    fill: #eee;
+}
+.dark .ctrl-btns div g.icon rect,
+.dark .ctrl-btns div:hover g.icon rect {
+    fill: #222;
+}
+
+.light .ctrl-btns div g.icon use {
+    fill: #ddd;
+}
+.dark .ctrl-btns div g.icon use {
+    fill: #333;
+}
+
+/* Active hover */
+.light .ctrl-btns div.active:hover g.icon rect {
+    fill: #800;
+}
+
+.dark .ctrl-btns div.active:hover g.icon rect {
+    fill: #CE5650;
+}
+
+/* Active */
+.light .ctrl-btns div.active g.icon use {
+    fill: #fff;
+}
+.dark .ctrl-btns div.active g.icon use {
+    fill: #eee;
+}
+
+.light .ctrl-btns div.active g.icon rect {
+    fill: #bbb;
+}
+.dark .ctrl-btns div.active g.icon rect {
+    fill: #444;
+}
+
+/* Refresh button specific */
+.light .ctrl-btns div.refresh:hover g.icon rect {
+    fill: #800;
+}
+
+.dark .ctrl-btns div.refresh:hover g.icon rect {
+    fill: #CE5650;
+}
diff --git a/web/gui/src/main/webapp/app/fw/widget/tableBuilder.js b/web/gui/src/main/webapp/app/fw/widget/tableBuilder.js
index 84f11b7..3af8d60 100644
--- a/web/gui/src/main/webapp/app/fw/widget/tableBuilder.js
+++ b/web/gui/src/main/webapp/app/fw/widget/tableBuilder.js
@@ -48,6 +48,7 @@
 
         o.scope.tableData = [];
         o.scope.sortParams = {};
+        o.scope.autoRefresh = true;
 
         function respCb(data) {
             o.scope.tableData = data[root];
@@ -66,11 +67,25 @@
         }
         o.scope.selectCallback = selCb;
 
-        function refresh(params) {
-            $log.debug('Refreshing ' + root + ' page');
-            sortCb(params);
+        function startRefresh() {
+            promise = $interval(function () {
+                $log.debug('Refreshing ' + root + ' page');
+                sortCb(o.scope.sortParams);
+            }, refreshInterval);
         }
-        o.scope.refresh = refresh;
+
+        function stopRefresh() {
+            if (angular.isDefined(promise)) {
+                $interval.cancel(promise);
+                promise = undefined;
+            }
+        }
+
+        function toggleRefresh() {
+            o.scope.autoRefresh = !o.scope.autoRefresh;
+            o.scope.autoRefresh ? startRefresh() : stopRefresh();
+        }
+        o.scope.toggleRefresh = toggleRefresh;
 
         handlers[resp] = respCb;
         wss.bindHandlers(handlers);
@@ -79,17 +94,11 @@
         o.scope.$on('$destroy', function () {
             wss.unbindHandlers(handlers);
             ts.resetSort();
-            if (angular.isDefined(promise)) {
-                $interval.cancel(promise);
-                promise = undefined;
-            }
+            stopRefresh();
         });
 
         sortCb();
-
-        promise = $interval(function () {
-            refresh(o.scope.sortParams);
-        }, refreshInterval);
+        startRefresh();
     }
 
     angular.module('onosWidget')
diff --git a/web/gui/src/main/webapp/app/view/app/app.html b/web/gui/src/main/webapp/app/view/app/app.html
index 6f27443..0420cff 100644
--- a/web/gui/src/main/webapp/app/view/app/app.html
+++ b/web/gui/src/main/webapp/app/view/app/app.html
@@ -3,9 +3,9 @@
     <div class="tabular-header">
         <h2>Applications ({{tableData.length}} total)</h2>
         <div class="ctrl-btns">
-            <div class="refresh active"
+            <div class="refresh" ng-class="{active: autoRefresh}"
                  icon icon-size="36" icon-id="refresh"
-                 ng-click="refresh(sortParams)"></div>
+                 ng-click="toggleRefresh()"></div>
             <div class="separator"></div>
             <div id="app-install"    icon icon-size="36" icon-id="plus" class="active"></div>
             <div id="app-activate"   icon icon-size="36" icon-id="play"></div>
diff --git a/web/gui/src/main/webapp/app/view/cluster/cluster.html b/web/gui/src/main/webapp/app/view/cluster/cluster.html
index 29c84b0..8750cac 100644
--- a/web/gui/src/main/webapp/app/view/cluster/cluster.html
+++ b/web/gui/src/main/webapp/app/view/cluster/cluster.html
@@ -19,9 +19,9 @@
     <div class="tabular-header">
         <h2>Cluster Nodes ({{tableData.length}} total)</h2>
         <div class="ctrl-btns">
-            <div class="refresh active"
+            <div class="refresh" ng-class="{active: autoRefresh}"
                  icon icon-size="36" icon-id="refresh"
-                 ng-click="refresh(sortParams)"></div>
+                 ng-click="toggleRefresh()"></div>
         </div>
     </div>
 
diff --git a/web/gui/src/main/webapp/app/view/device/device.html b/web/gui/src/main/webapp/app/view/device/device.html
index 0ff488d..364efc2 100644
--- a/web/gui/src/main/webapp/app/view/device/device.html
+++ b/web/gui/src/main/webapp/app/view/device/device.html
@@ -3,9 +3,9 @@
     <div class="tabular-header">
         <h2>Devices ({{tableData.length}} total)</h2>
         <div class="ctrl-btns">
-            <div class="refresh active"
+            <div class="refresh" ng-class="{active: autoRefresh}"
                  icon icon-size="36" icon-id="refresh"
-                 ng-click="refresh(sortParams)"></div>
+                 ng-click="toggleRefresh()"></div>
         </div>
     </div>
 
diff --git a/web/gui/src/main/webapp/app/view/flow/flow.html b/web/gui/src/main/webapp/app/view/flow/flow.html
index 88b15127..a79e925 100644
--- a/web/gui/src/main/webapp/app/view/flow/flow.html
+++ b/web/gui/src/main/webapp/app/view/flow/flow.html
@@ -6,9 +6,9 @@
             ({{tableData.length}} total)
         </h2>
         <div class="ctrl-btns">
-            <div class="refresh active"
+            <div class="refresh" ng-class="{active: autoRefresh}"
                  icon icon-size="36" icon-id="refresh"
-                 ng-click="refresh(sortParams)"></div>
+                 ng-click="toggleRefresh()"></div>
         </div>
     </div>
 
diff --git a/web/gui/src/main/webapp/app/view/group/group.html b/web/gui/src/main/webapp/app/view/group/group.html
index e19d6e1..22cd5ee 100644
--- a/web/gui/src/main/webapp/app/view/group/group.html
+++ b/web/gui/src/main/webapp/app/view/group/group.html
@@ -22,9 +22,9 @@
             ({{tableData.length}} total)
         </h2>
         <div class="ctrl-btns">
-            <div class="refresh active"
+            <div class="refresh" ng-class="{active: autoRefresh}"
                  icon icon-size="36" icon-id="refresh"
-                 ng-click="refresh(sortParams)"></div>
+                 ng-click="toggleRefresh()"></div>
         </div>
     </div>
 
diff --git a/web/gui/src/main/webapp/app/view/host/host.html b/web/gui/src/main/webapp/app/view/host/host.html
index 8f83132..ad0e77e 100644
--- a/web/gui/src/main/webapp/app/view/host/host.html
+++ b/web/gui/src/main/webapp/app/view/host/host.html
@@ -3,9 +3,9 @@
     <div class="tabular-header">
         <h2>Hosts ({{tableData.length}} total)</h2>
         <div class="ctrl-btns">
-            <div class="refresh active"
+            <div class="refresh" ng-class="{active: autoRefresh}"
                  icon icon-size="36" icon-id="refresh"
-                 ng-click="refresh(sortParams)"></div>
+                 ng-click="toggleRefresh()"></div>
         </div>
     </div>
 
diff --git a/web/gui/src/main/webapp/app/view/intent/intent.html b/web/gui/src/main/webapp/app/view/intent/intent.html
index 8096cea..e60e788 100644
--- a/web/gui/src/main/webapp/app/view/intent/intent.html
+++ b/web/gui/src/main/webapp/app/view/intent/intent.html
@@ -19,9 +19,9 @@
     <div class="tabular-header">
         <h2>Intents ({{tableData.length}} total)</h2>
         <div class="ctrl-btns">
-            <div class="refresh active"
+            <div class="refresh" ng-class="{active: autoRefresh}"
                  icon icon-size="36" icon-id="refresh"
-                 ng-click="refresh(sortParams)"></div>
+                 ng-click="toggleRefresh()"></div>
         </div>
     </div>
 
diff --git a/web/gui/src/main/webapp/app/view/link/link.html b/web/gui/src/main/webapp/app/view/link/link.html
index f984c61..dd1f534 100644
--- a/web/gui/src/main/webapp/app/view/link/link.html
+++ b/web/gui/src/main/webapp/app/view/link/link.html
@@ -19,9 +19,9 @@
     <div class="tabular-header">
         <h2>Links ({{tableData.length}} total)</h2>
         <div class="ctrl-btns">
-            <div class="refresh active"
+            <div class="refresh" ng-class="{active: autoRefresh}"
                  icon icon-size="36" icon-id="refresh"
-                 ng-click="refresh(sortParams)"></div>
+                 ng-click="toggleRefresh()"></div>
         </div>
     </div>
 
diff --git a/web/gui/src/main/webapp/app/view/port/port.html b/web/gui/src/main/webapp/app/view/port/port.html
index 54611f3..5683ca2 100644
--- a/web/gui/src/main/webapp/app/view/port/port.html
+++ b/web/gui/src/main/webapp/app/view/port/port.html
@@ -22,9 +22,9 @@
             ({{tableData.length}} total)
         </h2>
         <div class="ctrl-btns">
-            <div class="refresh active"
+            <div class="refresh" ng-class="{active: autoRefresh}"
                  icon icon-size="36" icon-id="refresh"
-                 ng-click="refresh(sortParams)"></div>
+                 ng-click="toggleRefresh()"></div>
         </div>
     </div>
 
diff --git a/web/gui/src/main/webapp/app/view/settings/settings.html b/web/gui/src/main/webapp/app/view/settings/settings.html
index 6e7dba5..2c89984 100644
--- a/web/gui/src/main/webapp/app/view/settings/settings.html
+++ b/web/gui/src/main/webapp/app/view/settings/settings.html
@@ -3,9 +3,9 @@
     <div class="tabular-header">
         <h2>Component Settings ({{tableData.length}} total)</h2>
         <div class="ctrl-btns">
-            <div class="refresh active"
+            <div class="refresh" ng-class="{active: autoRefresh}"
                  icon icon-size="36" icon-id="refresh"
-                 ng-click="refresh(sortParams)"></div>
+                 ng-click="toggleRefresh()"></div>
         </div>
     </div>
 
@@ -17,7 +17,7 @@
              sort-callback="sortCallback(sortParams)">
             <table>
                 <tr>
-                    <td colId="component" sortable col-width="400px">Component </td>
+                    <td colId="component" sortable col-width="350px">Component </td>
                     <td colId="id" sortable>Property </td>
                     <td colId="type" sortable col-width="70px">Type </td>
                     <td colId="value" sortable>Value </td>