blob: 32058b662734c9b539a3ed5e1a918267dbcf2723 [file] [log] [blame]
Jian Li1f544732015-12-30 23:36:37 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Jian Li1f544732015-12-30 23:36:37 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 ONOS GUI -- Meter View Module
19 */
20(function () {
21 'use strict';
22
23 // injected references
24 var $log, $scope, $location, fs, tbs, ns;
25
26 angular.module('ovMeter', [])
27 .controller('OvMeterCtrl',
28 ['$log', '$scope', '$location', '$sce',
29 'FnService', 'TableBuilderService', 'NavService',
30
31 function (_$log_, _$scope_, _$location_, $sce, _fs_, _tbs_, _ns_) {
32 var params;
33 $log = _$log_;
34 $scope = _$scope_;
35 $location = _$location_;
36 fs = _fs_;
37 tbs = _tbs_;
38 ns = _ns_;
39 $scope.deviceTip = 'Show device table';
40 $scope.flowTip = 'Show flow view for this device';
41 $scope.portTip = 'Show port view for this device';
42 $scope.groupTip = 'Show group view for this device';
Yi Tsenga87b40c2017-09-10 00:59:03 -070043 $scope.pipeconfTip = 'Show pipeconf view for selected device';
Jian Li1f544732015-12-30 23:36:37 -080044
45 params = $location.search();
46 if (params.hasOwnProperty('devId')) {
47 $scope.devId = params['devId'];
48 }
49
50 tbs.buildTable({
51 scope: $scope,
52 tag: 'meter',
Steven Burrows1c2a9682017-07-14 16:52:46 +010053 query: params,
Jian Li1f544732015-12-30 23:36:37 -080054 });
55
56 $scope.$watch('tableData', function () {
57 if (!fs.isEmptyObject($scope.tableData)) {
58 $scope.tableData.forEach(function (meter) {
59 meter.bands = $sce.trustAsHtml(meter.bands);
60 });
61 }
62 });
63
64 $scope.nav = function (path) {
65 if ($scope.devId) {
66 ns.navTo(path, { devId: $scope.devId });
67 }
68 };
69
Steven Burrows1c2a9682017-07-14 16:52:46 +010070 Object.defineProperty($scope, 'queryFilter', {
71 get: function () {
kalagesa1101dbb2016-12-20 23:34:28 +053072 var out = {};
Steven Burrows1c2a9682017-07-14 16:52:46 +010073 out[$scope.queryBy || '$'] = $scope.query;
kalagesa1101dbb2016-12-20 23:34:28 +053074 return out;
Steven Burrows1c2a9682017-07-14 16:52:46 +010075 },
kalagesa1101dbb2016-12-20 23:34:28 +053076 });
77
78
Jian Li1f544732015-12-30 23:36:37 -080079 $log.log('OvMeterCtrl has been created');
80 }]);
kalagesa1101dbb2016-12-20 23:34:28 +053081}());