Simon Hunt | 1002cd8 | 2015-04-23 14:44:03 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Simon Hunt | 1002cd8 | 2015-04-23 14:44:03 -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 -- Flow View Module |
| 19 | */ |
| 20 | |
| 21 | (function () { |
| 22 | 'use strict'; |
| 23 | |
Bri Prebilic Cole | cdc188d | 2015-04-24 16:40:11 -0700 | [diff] [blame] | 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 | cdc188d | 2015-04-24 16:40:11 -0700 | [diff] [blame] | 26 | |
Simon Hunt | 1002cd8 | 2015-04-23 14:44:03 -0700 | [diff] [blame] | 27 | angular.module('ovFlow', []) |
| 28 | .controller('OvFlowCtrl', |
Bri Prebilic Cole | 3d4d01c | 2015-04-30 13:48:36 -0700 | [diff] [blame] | 29 | ['$log', '$scope', '$location', |
Bri Prebilic Cole | 9b1fb9a | 2015-07-01 13:57:11 -0700 | [diff] [blame] | 30 | 'FnService', 'TableBuilderService', 'NavService', |
Simon Hunt | 1002cd8 | 2015-04-23 14:44:03 -0700 | [diff] [blame] | 31 | |
Bri Prebilic Cole | 9b1fb9a | 2015-07-01 13:57:11 -0700 | [diff] [blame] | 32 | function (_$log_, _$scope_, _$location_, _fs_, _tbs_, _ns_) { |
Bri Prebilic Cole | e568ead | 2015-05-01 09:51:28 -0700 | [diff] [blame] | 33 | var params; |
Bri Prebilic Cole | cdc188d | 2015-04-24 16:40:11 -0700 | [diff] [blame] | 34 | $log = _$log_; |
| 35 | $scope = _$scope_; |
| 36 | $location = _$location_; |
| 37 | fs = _fs_; |
| 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.portTip = 'Show port view for this device'; |
| 42 | $scope.groupTip = 'Show group 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'; |
Kavitha Alagesan | eaf614c | 2016-08-22 23:46:05 -0700 | [diff] [blame] | 44 | $scope.briefTip = 'Switch to brief view'; |
| 45 | $scope.detailTip = 'Switch to detailed view'; |
| 46 | $scope.brief = true; |
Bri Prebilic Cole | cdc188d | 2015-04-24 16:40:11 -0700 | [diff] [blame] | 47 | params = $location.search(); |
| 48 | if (params.hasOwnProperty('devId')) { |
Bri Prebilic Cole | e568ead | 2015-05-01 09:51:28 -0700 | [diff] [blame] | 49 | $scope.devId = params['devId']; |
Bri Prebilic Cole | cdc188d | 2015-04-24 16:40:11 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | tbs.buildTable({ |
Bri Prebilic Cole | cdc188d | 2015-04-24 16:40:11 -0700 | [diff] [blame] | 53 | scope: $scope, |
| 54 | tag: 'flow', |
| 55 | query: params |
| 56 | }); |
Bri Prebilic Cole | 3d4d01c | 2015-04-30 13:48:36 -0700 | [diff] [blame] | 57 | |
Bri Prebilic Cole | 9b1fb9a | 2015-07-01 13:57:11 -0700 | [diff] [blame] | 58 | $scope.nav = function (path) { |
| 59 | if ($scope.devId) { |
| 60 | ns.navTo(path, { devId: $scope.devId }); |
| 61 | } |
| 62 | }; |
| 63 | |
Kavitha Alagesan | eaf614c | 2016-08-22 23:46:05 -0700 | [diff] [blame] | 64 | $scope.briefToggle = function () { |
| 65 | $scope.brief = !$scope.brief; |
| 66 | }; |
| 67 | |
sisubram | 9ada8d7 | 2016-09-02 13:54:40 +0530 | [diff] [blame] | 68 | Object.defineProperty($scope, "queryFilter", { |
| 69 | get: function() { |
| 70 | var out = {}; |
| 71 | out[$scope.queryBy || "$"] = $scope.query; |
| 72 | return out; |
| 73 | } |
| 74 | }); |
| 75 | |
| 76 | |
Simon Hunt | 1002cd8 | 2015-04-23 14:44:03 -0700 | [diff] [blame] | 77 | $log.log('OvFlowCtrl has been created'); |
| 78 | }]); |
| 79 | }()); |