blob: 6d6645ae26becde708821842c7076b0b7345c21e [file] [log] [blame]
Bri Prebilic Coleac829e42015-05-05 13:42:06 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Bri Prebilic Coleac829e42015-05-05 13:42:06 -07003 *
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 Hunt5c3ed732017-07-20 19:03:28 +000025 var $log, $scope, $location, fs, tbs, ns;
Bri Prebilic Coleac829e42015-05-05 13:42:06 -070026
Simon Hunt105bc4e2017-07-21 11:07:01 -070027 // 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 Coleac829e42015-05-05 13:42:06 -070035 angular.module('ovPort', [])
36 .controller('OvPortCtrl',
Simon Hunt5c3ed732017-07-20 19:03:28 +000037 ['$log', '$scope', '$location',
38 'FnService', 'TableBuilderService', 'NavService',
Bri Prebilic Coleac829e42015-05-05 13:42:06 -070039
Simon Hunt5c3ed732017-07-20 19:03:28 +000040 function (_$log_, _$scope_, _$location_, _fs_, _tbs_, _ns_) {
Bri Prebilic Coleac829e42015-05-05 13:42:06 -070041 var params;
42 $log = _$log_;
43 $scope = _$scope_;
44 $location = _$location_;
Simon Hunt5c3ed732017-07-20 19:03:28 +000045 fs = _fs_;
Bri Prebilic Coleac829e42015-05-05 13:42:06 -070046 tbs = _tbs_;
Bri Prebilic Cole9b1fb9a2015-07-01 13:57:11 -070047 ns = _ns_;
Simon Hunt20856ec2015-11-16 15:58:14 -080048 $scope.deviceTip = 'Show device table';
Bri Prebilic Coleeef67ae2015-07-01 16:26:59 -070049 $scope.flowTip = 'Show flow view for this device';
50 $scope.groupTip = 'Show group view for this device';
Jian Li1f544732015-12-30 23:36:37 -080051 $scope.meterTip = 'Show meter view for selected device';
Bri Prebilic Coleac829e42015-05-05 13:42:06 -070052
53 params = $location.search();
54 if (params.hasOwnProperty('devId')) {
55 $scope.devId = params['devId'];
56 }
57
Simon Hunt105bc4e2017-07-21 11:07:01 -070058 $scope.payloadParams = {
59 nzFilter: nzFilter,
60 showDelta: showDelta
61 };
62
Bri Prebilic Coleac829e42015-05-05 13:42:06 -070063 tbs.buildTable({
64 scope: $scope,
65 tag: 'port',
Simon Hunt5c3ed732017-07-20 19:03:28 +000066 query: params
Bri Prebilic Coleac829e42015-05-05 13:42:06 -070067 });
68
Bri Prebilic Cole9b1fb9a2015-07-01 13:57:11 -070069 $scope.nav = function (path) {
70 if ($scope.devId) {
71 ns.navTo(path, { devId: $scope.devId });
72 }
73 };
74
Simon Hunt5c3ed732017-07-20 19:03:28 +000075 Object.defineProperty($scope, "queryFilter", {
76 get: function() {
kalagesa1101dbb2016-12-20 23:34:28 +053077 var out = {};
Simon Hunt5c3ed732017-07-20 19:03:28 +000078 out[$scope.queryBy || "$"] = $scope.query;
kalagesa1101dbb2016-12-20 23:34:28 +053079 return out;
Simon Hunt5c3ed732017-07-20 19:03:28 +000080 }
kalagesa1101dbb2016-12-20 23:34:28 +053081 });
82
Bri Prebilic Coleac829e42015-05-05 13:42:06 -070083 $log.log('OvPortCtrl has been created');
84 }]);
85}());