Jian Li | 1f54473 | 2015-12-30 23:36:37 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Jian Li | 1f54473 | 2015-12-30 23:36:37 -0800 | [diff] [blame] | 3 | * |
| 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 | |
kalagesa | 1101dbb | 2016-12-20 23:34:28 +0530 | [diff] [blame] | 69 | Object.defineProperty($scope, "queryFilter", { |
| 70 | get: function() { |
| 71 | var out = {}; |
| 72 | out[$scope.queryBy || "$"] = $scope.query; |
| 73 | return out; |
| 74 | } |
| 75 | }); |
| 76 | |
| 77 | |
Jian Li | 1f54473 | 2015-12-30 23:36:37 -0800 | [diff] [blame] | 78 | $log.log('OvMeterCtrl has been created'); |
| 79 | }]); |
kalagesa | 1101dbb | 2016-12-20 23:34:28 +0530 | [diff] [blame] | 80 | }()); |