Bri Prebilic Cole | ac829e4 | 2015-05-05 13:42:06 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Bri Prebilic Cole | ac829e4 | 2015-05-05 13:42:06 -0700 | [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 -- Port View Module |
| 19 | */ |
| 20 | |
| 21 | (function () { |
| 22 | 'use strict'; |
| 23 | |
| 24 | // injected references |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 25 | var $log, $scope, $location, fs, tbs, ns; |
Bri Prebilic Cole | ac829e4 | 2015-05-05 13:42:06 -0700 | [diff] [blame] | 26 | |
Simon Hunt | 105bc4e | 2017-07-21 11:07:01 -0700 | [diff] [blame] | 27 | // internal state |
| 28 | var nzFilter = true, |
| 29 | showDelta = false; |
| 30 | |
| 31 | // TODO: (1) init nzFilter and showDelta from user preferences service |
| 32 | // TODO: (2) track nzFilter and showDelta state from toggle buttons |
| 33 | // (also setting new state in user preference service) |
| 34 | |
Bri Prebilic Cole | ac829e4 | 2015-05-05 13:42:06 -0700 | [diff] [blame] | 35 | angular.module('ovPort', []) |
| 36 | .controller('OvPortCtrl', |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 37 | ['$log', '$scope', '$location', |
| 38 | 'FnService', 'TableBuilderService', 'NavService', |
Bri Prebilic Cole | ac829e4 | 2015-05-05 13:42:06 -0700 | [diff] [blame] | 39 | |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 40 | function (_$log_, _$scope_, _$location_, _fs_, _tbs_, _ns_) { |
Bri Prebilic Cole | ac829e4 | 2015-05-05 13:42:06 -0700 | [diff] [blame] | 41 | var params; |
| 42 | $log = _$log_; |
| 43 | $scope = _$scope_; |
| 44 | $location = _$location_; |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 45 | fs = _fs_; |
Bri Prebilic Cole | ac829e4 | 2015-05-05 13:42:06 -0700 | [diff] [blame] | 46 | tbs = _tbs_; |
Bri Prebilic Cole | 9b1fb9a | 2015-07-01 13:57:11 -0700 | [diff] [blame] | 47 | ns = _ns_; |
Simon Hunt | 20856ec | 2015-11-16 15:58:14 -0800 | [diff] [blame] | 48 | $scope.deviceTip = 'Show device table'; |
Bri Prebilic Cole | eef67ae | 2015-07-01 16:26:59 -0700 | [diff] [blame] | 49 | $scope.flowTip = 'Show flow view for this device'; |
| 50 | $scope.groupTip = 'Show group view for this device'; |
Jian Li | 1f54473 | 2015-12-30 23:36:37 -0800 | [diff] [blame] | 51 | $scope.meterTip = 'Show meter view for selected device'; |
Bri Prebilic Cole | ac829e4 | 2015-05-05 13:42:06 -0700 | [diff] [blame] | 52 | |
| 53 | params = $location.search(); |
| 54 | if (params.hasOwnProperty('devId')) { |
| 55 | $scope.devId = params['devId']; |
| 56 | } |
| 57 | |
Simon Hunt | 105bc4e | 2017-07-21 11:07:01 -0700 | [diff] [blame] | 58 | $scope.payloadParams = { |
| 59 | nzFilter: nzFilter, |
| 60 | showDelta: showDelta |
| 61 | }; |
| 62 | |
Bri Prebilic Cole | ac829e4 | 2015-05-05 13:42:06 -0700 | [diff] [blame] | 63 | tbs.buildTable({ |
| 64 | scope: $scope, |
| 65 | tag: 'port', |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 66 | query: params |
Bri Prebilic Cole | ac829e4 | 2015-05-05 13:42:06 -0700 | [diff] [blame] | 67 | }); |
| 68 | |
Bri Prebilic Cole | 9b1fb9a | 2015-07-01 13:57:11 -0700 | [diff] [blame] | 69 | $scope.nav = function (path) { |
| 70 | if ($scope.devId) { |
| 71 | ns.navTo(path, { devId: $scope.devId }); |
| 72 | } |
| 73 | }; |
| 74 | |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 75 | Object.defineProperty($scope, "queryFilter", { |
| 76 | get: function() { |
kalagesa | 1101dbb | 2016-12-20 23:34:28 +0530 | [diff] [blame] | 77 | var out = {}; |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 78 | out[$scope.queryBy || "$"] = $scope.query; |
kalagesa | 1101dbb | 2016-12-20 23:34:28 +0530 | [diff] [blame] | 79 | return out; |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 80 | } |
kalagesa | 1101dbb | 2016-12-20 23:34:28 +0530 | [diff] [blame] | 81 | }); |
| 82 | |
Bri Prebilic Cole | ac829e4 | 2015-05-05 13:42:06 -0700 | [diff] [blame] | 83 | $log.log('OvPortCtrl has been created'); |
| 84 | }]); |
| 85 | }()); |