blob: 35a2e141cfb638ebfeec91072951f6a81c545c9f [file] [log] [blame]
Jian Li1f544732015-12-30 23:36:37 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
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';
43
44 params = $location.search();
45 if (params.hasOwnProperty('devId')) {
46 $scope.devId = params['devId'];
47 }
48
49 tbs.buildTable({
50 scope: $scope,
51 tag: 'meter',
52 query: params
53 });
54
55 $scope.$watch('tableData', function () {
56 if (!fs.isEmptyObject($scope.tableData)) {
57 $scope.tableData.forEach(function (meter) {
58 meter.bands = $sce.trustAsHtml(meter.bands);
59 });
60 }
61 });
62
63 $scope.nav = function (path) {
64 if ($scope.devId) {
65 ns.navTo(path, { devId: $scope.devId });
66 }
67 };
68
69 $log.log('OvMeterCtrl has been created');
70 }]);
71}());