[ONOS-3642] Add GUI Meter View

This implements the web GUI meter view.
Current implementation uses the group table icon for meter,
and the revised meter icon will be updated in following commit.
See ONOS-3645 for detail.

Change-Id: Iaa2e673ef83024135d757a2aaec1c31a87263217
diff --git a/web/gui/src/main/webapp/app/fw/svg/glyph.js b/web/gui/src/main/webapp/app/fw/svg/glyph.js
index b54ec78..182de49 100644
--- a/web/gui/src/main/webapp/app/fw/svg/glyph.js
+++ b/web/gui/src/main/webapp/app/fw/svg/glyph.js
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Open Networking Laboratory
+ * Copyright 2015,2016 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.
@@ -230,6 +230,28 @@
             '-6.3,0.9-8.9,2.5c3.7,3.8,6.1,8.9,6.2,14.6c6.1,3.1,10.6,8.9,11.7,' +
             '15.8C81.5,65.6,85,60,85,53.5C85,43.8,77.1,35.8,67.3,35.8z',
 
+            meterTable: 'M16,19.1H8v-13h8V19.1z M90.6,6.1H75.7v13h14.9V6.1z ' +
+            'M71.9,6.1H57v13h14.9V6.1z M53.3,6.1H38.4v13h14.9V6.1z M34.6,6.1' +
+            'H19.7v13h14.9V6.1z M102.3,6.1h-8v13h8V6.1z M45.7,52.7c0.2-5.6,' +
+            '2.6-10.7,6.2-14.4c-2.6-1.5-5.7-2.5-8.9-2.5c-9.8,0-17.7,7.9-17.7,' +
+            '17.7c0,6.3,3.3,11.9,8.3,15C34.8,61.5,39.4,55.6,45.7,52.7z M51.9,' +
+            '68.8c-3.1-3.1-5.2-7.2-6-11.7c-4.7,2.8-7.9,7.6-8.6,13.2c1.8,0.6,' +
+            '3.6,0.9,5.6,0.9C46.2,71.2,49.3,70.3,51.9,68.8z M55.2,71.5c-3.5,' +
+            '2.4-7.7,3.7-12.2,3.7c-1.9,0-3.8-0.3-5.6-0.7C38.5,83.2,45.9,90,' +
+            '54.9,90c9,0,16.4-6.7,17.5-15.4c-1.6,0.4-3.4,0.6-5.1,0.6C62.8,' +
+            '75.2,58.6,73.8,55.2,71.5z M54.9,50.6c1.9,0,3.8,0.3,5.6,0.7c-0.5' +
+            '-4.1-2.5-7.9-5.4-10.6c-2.9,2.7-4.8,6.4-5.3,10.5C51.5,50.8,53.2,' +
+            '50.6,54.9,50.6z M49.7,55.4c0.5,4.3,2.4,8.1,5.4,10.9c2.9-2.8,4.9' +
+            '-6.6,5.4-10.8c-1.8-0.6-3.6-0.9-5.6-0.9C53.1,54.6,51.4,54.9,49.7,' +
+            '55.4z M102.3,23.6v78.5H8V23.6H102.3z M89,53.5c0-12-9.7-21.7-' +
+            '21.7-21.7c-4.5,0-8.7,1.4-12.2,3.7c-3.5-2.4-7.7-3.7-12.2-3.7c-12,' +
+            '0-21.7,9.7-21.7,21.7c0,8.5,4.9,15.9,12,19.4C33.6,84.6,43.2,94,' +
+            '54.9,94c11.7,0,21.2-9.3,21.7-20.9C84,69.7,89,62.2,89,53.5z M' +
+            '64.3,57.3c-0.8,4.4-2.9,8.4-5.9,11.5c2.6,1.5,5.7,2.5,8.9,2.5c1.8,' +
+            '0,3.6-0.3,5.2-0.8C72,64.9,68.8,60.1,64.3,57.3z M67.3,35.8c-3.3,0' +
+            '-6.3,0.9-8.9,2.5c3.7,3.8,6.1,8.9,6.2,14.6c6.1,3.1,10.6,8.9,11.7,' +
+            '15.8C81.5,65.6,85,60,85,53.5C85,43.8,77.1,35.8,67.3,35.8z',
+
             // --- Topology toolbar specific glyphs ----------------------
 
             summary: "M95.8,9.2H14.2c-2.8,0-5,2.2-5,5v81.5c0,2.8,2.2,5,5," +
diff --git a/web/gui/src/main/webapp/app/fw/svg/icon.js b/web/gui/src/main/webapp/app/fw/svg/icon.js
index e5b8bb4..e797f8a 100644
--- a/web/gui/src/main/webapp/app/fw/svg/icon.js
+++ b/web/gui/src/main/webapp/app/fw/svg/icon.js
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Open Networking Laboratory
+ * Copyright 2015,2016 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.
@@ -53,6 +53,7 @@
         flowTable: 'flowTable',
         portTable: 'portTable',
         groupTable: 'groupTable',
+        meterTable: 'meterTable',
 
         hostIcon_endstation: 'endstation',
         hostIcon_router: 'router',
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 31e2eb2..f2b6f8d 100644
--- a/web/gui/src/main/webapp/app/view/device/device.html
+++ b/web/gui/src/main/webapp/app/view/device/device.html
@@ -26,6 +26,11 @@
                  icon icon-id="groupTable" icon-size="36"
                  tooltip tt-msg="groupTip"
                  ng-click="nav('group')"></div>
+
+            <div ng-class="{active: !!selId}"
+                 icon icon-id="meterTable" icon-size="36"
+                 tooltip tt-msg="meterTip"
+                 ng-click="nav('meter')"></div>
         </div>
     </div>
 
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 5b7120f..b2faee1 100644
--- a/web/gui/src/main/webapp/app/view/device/device.js
+++ b/web/gui/src/main/webapp/app/view/device/device.js
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Open Networking Laboratory
+ * Copyright 2015,2016 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.
@@ -294,6 +294,7 @@
             $scope.flowTip = 'Show flow view for selected device';
             $scope.portTip = 'Show port view for selected device';
             $scope.groupTip = 'Show group view for selected device';
+            $scope.meterTip = 'Show meter view for selected device';
 
             // details panel handlers
             handlers[detailsResp] = respDetailsCb;
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 f7142d3..374da0b 100644
--- a/web/gui/src/main/webapp/app/view/flow/flow.html
+++ b/web/gui/src/main/webapp/app/view/flow/flow.html
@@ -30,6 +30,11 @@
                  icon icon-id="groupTable" icon-size="36"
                  tooltip tt-msg="groupTip"
                  ng-click="nav('group')"></div>
+
+            <div class="active"
+                 icon icon-id="meterTable" icon-size="36"
+                 tooltip tt-msg="meterTip"
+                 ng-click="nav('meter')"></div>
         </div>
     </div>
 
diff --git a/web/gui/src/main/webapp/app/view/flow/flow.js b/web/gui/src/main/webapp/app/view/flow/flow.js
index 7bb988a..da6ac8b 100644
--- a/web/gui/src/main/webapp/app/view/flow/flow.js
+++ b/web/gui/src/main/webapp/app/view/flow/flow.js
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Open Networking Laboratory
+ * Copyright 2015,2016 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.
@@ -40,6 +40,7 @@
             $scope.deviceTip = 'Show device table';
             $scope.portTip = 'Show port view for this device';
             $scope.groupTip = 'Show group view for this device';
+            $scope.meterTip = 'Show meter view for selected device';
 
             params = $location.search();
             if (params.hasOwnProperty('devId')) {
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 538b979..9f4a70e 100644
--- a/web/gui/src/main/webapp/app/view/group/group.html
+++ b/web/gui/src/main/webapp/app/view/group/group.html
@@ -1,19 +1,3 @@
-<!--
-  ~ 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.
-  -->
-
 <!-- Group partial HTML -->
 <div id="ov-group">
     <div class="tabular-header">
@@ -46,6 +30,11 @@
 
             <div class="current-view"
                  icon icon-id="groupTable" icon-size="36"></div>
+
+            <div class="active"
+                 icon icon-id="meterTable" icon-size="36"
+                 tooltip tt-msg="meterTip"
+                 ng-click="nav('meter')"></div>
         </div>
     </div>
 
diff --git a/web/gui/src/main/webapp/app/view/group/group.js b/web/gui/src/main/webapp/app/view/group/group.js
index 2cb1f0c..ce8404d 100644
--- a/web/gui/src/main/webapp/app/view/group/group.js
+++ b/web/gui/src/main/webapp/app/view/group/group.js
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Open Networking Laboratory
+ * Copyright 2015,2016 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.
@@ -40,6 +40,7 @@
             $scope.deviceTip = 'Show device table';
             $scope.flowTip = 'Show flow view for this device';
             $scope.portTip = 'Show port view for this device';
+            $scope.meterTip = 'Show meter view for selected device';
 
             params = $location.search();
             if (params.hasOwnProperty('devId')) {
diff --git a/web/gui/src/main/webapp/app/view/meter/meter.css b/web/gui/src/main/webapp/app/view/meter/meter.css
new file mode 100644
index 0000000..b9e72cd
--- /dev/null
+++ b/web/gui/src/main/webapp/app/view/meter/meter.css
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2016 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 -- Meter View -- CSS file
+ */
+
+#ov-meter h2 {
+    display: inline-block;
+}
+
+#ov-meter div.ctrl-btns {
+}
+
+.light #ov-meter .current-view use {
+    fill: white;
+}
+.dark #ov-meter .current-view use {
+    fill: #304860;
+}
+
+.light #ov-meter .current-view rect {
+    fill: deepskyblue;
+}
+.dark #ov-meter .current-view rect {
+    fill: #eee;
+}
+
+.light #ov-meter tr:nth-child(4n + 1),
+.light #ov-meter tr:nth-child(4n + 2) {
+    background-color: #eee;
+}
+.light #ov-meter tr:nth-child(4n + 3),
+.light #ov-meter tr:nth-child(4n) {
+    background-color: #ddd;
+}
+.dark #ov-meter tr:nth-child(4n + 1),
+.dark #ov-meter tr:nth-child(4n + 2) {
+    background-color: #444;
+}
+.dark #ov-meter tr:nth-child(4n + 3),
+.dark #ov-meter tr:nth-child(4n) {
+    background-color: #333;
+}
+
+/* highlighted color */
+.light #ov-meter tr:nth-child(4n + 1).data-change,
+.light #ov-meter tr:nth-child(4n + 2).data-change,
+.light #ov-meter tr:nth-child(4n + 3).data-change,
+.light #ov-meter tr:nth-child(4n).data-change {
+    background-color: #FDFFDC;
+}
+.dark #ov-meter tr:nth-child(4n + 1).data-change,
+.dark #ov-meter tr:nth-child(4n + 2).data-change,
+.dark #ov-meter tr:nth-child(4n + 3).data-change,
+.dark #ov-meter tr:nth-child(4n).data-change {
+    background-color: #5A5600;
+}
+
+#ov-meter td.bands {
+    padding-left: 36px;
+    opacity: 0.65;
+}
\ No newline at end of file
diff --git a/web/gui/src/main/webapp/app/view/meter/meter.html b/web/gui/src/main/webapp/app/view/meter/meter.html
new file mode 100644
index 0000000..bfa48ca
--- /dev/null
+++ b/web/gui/src/main/webapp/app/view/meter/meter.html
@@ -0,0 +1,79 @@
+<!-- Meter partial HTML -->
+<div id="ov-meter">
+    <div class="tabular-header">
+        <h2>
+            Meters for Device {{devId || "(No device selected)"}}
+            ({{tableData.length}} total)
+        </h2>
+        <div class="ctrl-btns">
+            <div class="refresh" ng-class="{active: autoRefresh}"
+                 icon icon-size="36" icon-id="refresh"
+                 tooltip tt-msg="autoRefreshTip"
+                 ng-click="toggleRefresh()"></div>
+
+            <div class="separator"></div>
+
+            <div class="active"
+                 icon icon-id="deviceTable" icon-size="36"
+                 tooltip tt-msg="deviceTip"
+                 ng-click="nav('device')"></div>
+
+            <div class="active"
+                 icon icon-id="flowTable" icon-size="36"
+                 tooltip tt-msg="flowTip"
+                 ng-click="nav('flow')"></div>
+
+            <div class="active"
+                 icon icon-id="portTable" icon-size="36"
+                 tooltip tt-msg="portTip"
+                 ng-click="nav('port')"></div>
+
+            <div class="active"
+                 icon icon-id="groupTable" icon-size="36"
+                 tooltip tt-msg="groupTip"
+                 ng-click="nav('group')"></div>
+
+            <div class="current-view"
+                 icon icon-id="meterTable" icon-size="36"></div>
+        </div>
+    </div>
+
+    <div class="summary-list" onos-table-resize>
+        <div class="table-header" onos-sortable-header>
+            <table>
+                <tr>
+                    <td colId="id" sortable>Meter ID </td>
+                    <td colId="app_id" sortable>App ID </td>
+                    <td colId="state" sortable>State </td>
+                    <td colId="packets" sortable>Packets </td>
+                    <td colId="bytes" sortable>Bytes </td>
+                </tr>
+            </table>
+        </div>
+
+        <div class="table-body">
+            <table onos-flash-changes id-prop="id">
+                <tr ng-if="!tableData.length" class="no-data">
+                    <td colspan="5">
+                        No Meters found
+                    </td>
+                </tr>
+
+                <tr ng-repeat-start="meter in tableData track by $index"
+                    ng-repeat-complete row-id="{{meter.id}}">
+                    <td>{{meter.id}}</td>
+                    <td>{{meter.app_id}}</td>
+                    <td>{{meter.state}}</td>
+                    <td>{{meter.packets}}</td>
+                    <td>{{meter.bytes}}</td>
+                </tr>
+                <tr row-id="{{meter.id}}" ng-repeat-end>
+                    <td class="bands" colspan="5"
+                        ng-bind-html="meter.bands"></td>
+                </tr>
+            </table>
+        </div>
+
+    </div>
+
+</div>
\ No newline at end of file
diff --git a/web/gui/src/main/webapp/app/view/meter/meter.js b/web/gui/src/main/webapp/app/view/meter/meter.js
new file mode 100644
index 0000000..b2e2607
--- /dev/null
+++ b/web/gui/src/main/webapp/app/view/meter/meter.js
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2016 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 -- Meter View Module
+ */
+(function () {
+    'use strict';
+
+    // injected references
+    var $log, $scope, $location, fs, tbs, ns;
+
+    angular.module('ovMeter', [])
+    .controller('OvMeterCtrl',
+        ['$log', '$scope', '$location', '$sce',
+            'FnService', 'TableBuilderService', 'NavService',
+
+        function (_$log_, _$scope_, _$location_, $sce, _fs_, _tbs_, _ns_) {
+            var params;
+            $log = _$log_;
+            $scope = _$scope_;
+            $location = _$location_;
+            fs = _fs_;
+            tbs = _tbs_;
+            ns = _ns_;
+            $scope.deviceTip = 'Show device table';
+            $scope.flowTip = 'Show flow view for this device';
+            $scope.portTip = 'Show port view for this device';
+            $scope.groupTip = 'Show group view for this device';
+
+            params = $location.search();
+            if (params.hasOwnProperty('devId')) {
+                $scope.devId = params['devId'];
+            }
+
+            tbs.buildTable({
+                scope: $scope,
+                tag: 'meter',
+                query: params
+            });
+
+            $scope.$watch('tableData', function () {
+                if (!fs.isEmptyObject($scope.tableData)) {
+                    $scope.tableData.forEach(function (meter) {
+                        meter.bands = $sce.trustAsHtml(meter.bands);
+                    });
+                }
+            });
+
+            $scope.nav = function (path) {
+                if ($scope.devId) {
+                    ns.navTo(path, { devId: $scope.devId });
+                }
+            };
+
+            $log.log('OvMeterCtrl has been created');
+        }]);
+}());
\ No newline at end of file
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 ef4f37e..33ac24e 100644
--- a/web/gui/src/main/webapp/app/view/port/port.html
+++ b/web/gui/src/main/webapp/app/view/port/port.html
@@ -1,19 +1,3 @@
-<!--
-  ~ 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.
-  -->
-
 <!-- Port partial HTML -->
 <div id="ov-port">
     <div class="tabular-header">
@@ -46,6 +30,11 @@
                  icon icon-id="groupTable" icon-size="36"
                  tooltip tt-msg="groupTip"
                  ng-click="nav('group')"></div>
+
+            <div class="active"
+                 icon icon-id="meterTable" icon-size="36"
+                 tooltip tt-msg="meterTip"
+                 ng-click="nav('meter')"></div>
         </div>
     </div>
 
diff --git a/web/gui/src/main/webapp/app/view/port/port.js b/web/gui/src/main/webapp/app/view/port/port.js
index 1e8585d..18fedc7 100644
--- a/web/gui/src/main/webapp/app/view/port/port.js
+++ b/web/gui/src/main/webapp/app/view/port/port.js
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Open Networking Laboratory
+ * Copyright 2015,2016 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.
@@ -40,6 +40,7 @@
             $scope.deviceTip = 'Show device table';
             $scope.flowTip = 'Show flow view for this device';
             $scope.groupTip = 'Show group view for this device';
+            $scope.meterTip = 'Show meter view for selected device';
 
             params = $location.search();
             if (params.hasOwnProperty('devId')) {
diff --git a/web/gui/src/main/webapp/index.html b/web/gui/src/main/webapp/index.html
index de70334..8cf75e0 100644
--- a/web/gui/src/main/webapp/index.html
+++ b/web/gui/src/main/webapp/index.html
@@ -1,6 +1,6 @@
 <!DOCTYPE html>
 <!--
-~ Copyright 2014,2015 Open Networking Laboratory
+~ Copyright 2014-2016 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.
@@ -118,6 +118,7 @@
     <script src="app/view/flow/flow.js"></script>
     <script src="app/view/port/port.js"></script>
     <script src="app/view/group/group.js"></script>
+    <script src="app/view/meter/meter.js"></script>
     <script src="app/view/link/link.js"></script>
     <script src="app/view/host/host.js"></script>
     <script src="app/view/intent/intent.js"></script>
@@ -137,6 +138,7 @@
     <link rel="stylesheet" href="app/view/flow/flow.css">
     <link rel="stylesheet" href="app/view/port/port.css">
     <link rel="stylesheet" href="app/view/group/group.css">
+    <link rel="stylesheet" href="app/view/meter/meter.css">
     <link rel="stylesheet" href="app/view/link/link.css">
     <link rel="stylesheet" href="app/view/host/host.css">
     <link rel="stylesheet" href="app/view/intent/intent.css">
diff --git a/web/gui/src/main/webapp/onos.js b/web/gui/src/main/webapp/onos.js
index a0de495..fcb9310 100644
--- a/web/gui/src/main/webapp/onos.js
+++ b/web/gui/src/main/webapp/onos.js
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014,2015 Open Networking Laboratory
+ * Copyright 2014-2016 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.
@@ -41,6 +41,7 @@
         'flow',
         'port',
         'group',
+        'meter',
         'host',
         'app',
         'intent',