Bri Prebilic Cole | ff3dc67 | 2015-05-06 12:59:38 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Bri Prebilic Cole | ff3dc67 | 2015-05-06 12:59:38 -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 -- Group View Module |
| 19 | */ |
| 20 | |
| 21 | (function () { |
| 22 | 'use strict'; |
| 23 | |
| 24 | // injected references |
Bri Prebilic Cole | 9b1fb9a | 2015-07-01 13:57:11 -0700 | [diff] [blame] | 25 | var $log, $scope, $location, fs, tbs, ns; |
Bri Prebilic Cole | ff3dc67 | 2015-05-06 12:59:38 -0700 | [diff] [blame] | 26 | |
| 27 | angular.module('ovGroup', []) |
| 28 | .controller('OvGroupCtrl', |
Bri Prebilic Cole | 9814226 | 2015-05-28 17:14:47 -0700 | [diff] [blame] | 29 | ['$log', '$scope', '$location', '$sce', |
Bri Prebilic Cole | 9b1fb9a | 2015-07-01 13:57:11 -0700 | [diff] [blame] | 30 | 'FnService', 'TableBuilderService', 'NavService', |
Bri Prebilic Cole | ff3dc67 | 2015-05-06 12:59:38 -0700 | [diff] [blame] | 31 | |
Bri Prebilic Cole | 9b1fb9a | 2015-07-01 13:57:11 -0700 | [diff] [blame] | 32 | function (_$log_, _$scope_, _$location_, $sce, _fs_, _tbs_, _ns_) { |
Bri Prebilic Cole | ff3dc67 | 2015-05-06 12:59:38 -0700 | [diff] [blame] | 33 | var params; |
| 34 | $log = _$log_; |
| 35 | $scope = _$scope_; |
| 36 | $location = _$location_; |
| 37 | fs = _fs_; |
Bri Prebilic Cole | ff3dc67 | 2015-05-06 12:59:38 -0700 | [diff] [blame] | 38 | tbs = _tbs_; |
Bri Prebilic Cole | 9b1fb9a | 2015-07-01 13:57:11 -0700 | [diff] [blame] | 39 | ns = _ns_; |
Simon Hunt | 20856ec | 2015-11-16 15:58:14 -0800 | [diff] [blame] | 40 | $scope.deviceTip = 'Show device table'; |
Bri Prebilic Cole | eef67ae | 2015-07-01 16:26:59 -0700 | [diff] [blame] | 41 | $scope.flowTip = 'Show flow view for this device'; |
| 42 | $scope.portTip = 'Show port view for this device'; |
Jian Li | 1f54473 | 2015-12-30 23:36:37 -0800 | [diff] [blame] | 43 | $scope.meterTip = 'Show meter view for selected device'; |
Yi Tseng | a87b40c | 2017-09-10 00:59:03 -0700 | [diff] [blame] | 44 | $scope.pipeconfTip = 'Show pipeconf view for selected device'; |
Kavitha Alagesan | c087453 | 2016-08-23 16:22:13 -0700 | [diff] [blame] | 45 | $scope.briefTip = 'Switch to brief view'; |
| 46 | $scope.detailTip = 'Switch to detailed view'; |
| 47 | $scope.brief = true; |
Bri Prebilic Cole | ff3dc67 | 2015-05-06 12:59:38 -0700 | [diff] [blame] | 48 | params = $location.search(); |
| 49 | if (params.hasOwnProperty('devId')) { |
| 50 | $scope.devId = params['devId']; |
| 51 | } |
| 52 | |
| 53 | tbs.buildTable({ |
| 54 | scope: $scope, |
| 55 | tag: 'group', |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 56 | query: params, |
Bri Prebilic Cole | ff3dc67 | 2015-05-06 12:59:38 -0700 | [diff] [blame] | 57 | }); |
| 58 | |
Bri Prebilic Cole | 76f632c | 2015-05-28 17:06:02 -0700 | [diff] [blame] | 59 | $scope.$watch('tableData', function () { |
| 60 | if (!fs.isEmptyObject($scope.tableData)) { |
| 61 | $scope.tableData.forEach(function (group) { |
| 62 | group.buckets = $sce.trustAsHtml(group.buckets); |
| 63 | }); |
| 64 | } |
| 65 | }); |
| 66 | |
Bri Prebilic Cole | 9b1fb9a | 2015-07-01 13:57:11 -0700 | [diff] [blame] | 67 | $scope.nav = function (path) { |
| 68 | if ($scope.devId) { |
| 69 | ns.navTo(path, { devId: $scope.devId }); |
| 70 | } |
| 71 | }; |
Kavitha Alagesan | c087453 | 2016-08-23 16:22:13 -0700 | [diff] [blame] | 72 | $scope.briefToggle = function () { |
| 73 | $scope.brief = !$scope.brief; |
| 74 | }; |
Bri Prebilic Cole | 9b1fb9a | 2015-07-01 13:57:11 -0700 | [diff] [blame] | 75 | |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 76 | Object.defineProperty($scope, 'queryFilter', { |
| 77 | get: function () { |
kalagesa | 1101dbb | 2016-12-20 23:34:28 +0530 | [diff] [blame] | 78 | var out = {}; |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 79 | out[$scope.queryBy || '$'] = $scope.query; |
kalagesa | 1101dbb | 2016-12-20 23:34:28 +0530 | [diff] [blame] | 80 | return out; |
Steven Burrows | 1c2a968 | 2017-07-14 16:52:46 +0100 | [diff] [blame] | 81 | }, |
kalagesa | 1101dbb | 2016-12-20 23:34:28 +0530 | [diff] [blame] | 82 | }); |
| 83 | |
| 84 | |
Bri Prebilic Cole | ff3dc67 | 2015-05-06 12:59:38 -0700 | [diff] [blame] | 85 | $log.log('OvGroupCtrl has been created'); |
| 86 | }]); |
| 87 | }()); |