blob: 687fdabcd29ce3c2e9581c2d051ef9a2cbf1c874 [file] [log] [blame]
Simon Hunt72e44bf2015-07-21 21:34:20 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Simon Hunt72e44bf2015-07-21 21:34:20 -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/*
Simon Hunt8d22c4b2015-08-06 16:24:43 -070019 ONOS GUI -- Topology Traffic Overlay Module.
Simon Hunt72e44bf2015-07-21 21:34:20 -070020 Defines behavior for viewing different traffic modes.
21 Installed as a Topology Overlay.
22 */
23(function () {
24 'use strict';
25
26 // injected refs
Simon Hunt8d22c4b2015-08-06 16:24:43 -070027 var $log, tov, tts;
28
29 // NOTE: no internal state here -- see TopoTrafficService for that
30
31 // NOTE: providing button disabling requires too big a refactoring of
32 // the button factory etc. Will have to be done another time.
33
Simon Hunt72e44bf2015-07-21 21:34:20 -070034
35 // traffic overlay definition
36 var overlay = {
37 overlayId: 'traffic',
Simon Huntc217cb92016-08-30 16:17:51 -070038 glyphId: 'm_allTraffic',
Simon Hunt72e44bf2015-07-21 21:34:20 -070039 tooltip: 'Traffic Overlay',
40
Simon Hunt8d22c4b2015-08-06 16:24:43 -070041 // NOTE: Traffic glyphs already installed as part of the base ONOS set.
42
43 activate: function () {
Steven Burrows1c2a9682017-07-14 16:52:46 +010044 $log.debug('Traffic overlay ACTIVATED');
Simon Hunt8d22c4b2015-08-06 16:24:43 -070045 },
46
47 deactivate: function () {
Simon Huntd2862c32015-08-24 17:41:51 -070048 tts.cancelTraffic(true);
Steven Burrows1c2a9682017-07-14 16:52:46 +010049 $log.debug('Traffic overlay DEACTIVATED');
Simon Hunt8d22c4b2015-08-06 16:24:43 -070050 },
51
52 // detail panel button definitions
53 // (keys match button identifiers, also defined in TrafficOverlay.java)
54 buttons: {
55 showDeviceFlows: {
Simon Huntc217cb92016-08-30 16:17:51 -070056 gid: 'm_flows',
Simon Hunt8d22c4b2015-08-06 16:24:43 -070057 tt: 'Show Device Flows',
Steven Burrows1c2a9682017-07-14 16:52:46 +010058 cb: function (data) { tts.showDeviceLinkFlows(); },
Simon Hunt8d22c4b2015-08-06 16:24:43 -070059 },
60
61 showRelatedTraffic: {
Simon Huntc217cb92016-08-30 16:17:51 -070062 gid: 'm_relatedIntents',
Simon Hunt8d22c4b2015-08-06 16:24:43 -070063 tt: 'Show Related Traffic',
Steven Burrows1c2a9682017-07-14 16:52:46 +010064 cb: function (data) { tts.showRelatedIntents(); },
65 },
Simon Hunt8d22c4b2015-08-06 16:24:43 -070066 },
67
68 // key bindings for traffic overlay toolbar buttons
69 // NOTE: fully qual. button ID is derived from overlay-id and key-name
70 keyBindings: {
71 0: {
Simon Huntd2862c32015-08-24 17:41:51 -070072 cb: function () { tts.cancelTraffic(true); },
Simon Hunt8d22c4b2015-08-06 16:24:43 -070073 tt: 'Cancel traffic monitoring',
Steven Burrows1c2a9682017-07-14 16:52:46 +010074 gid: 'm_xMark',
Simon Hunt8d22c4b2015-08-06 16:24:43 -070075 },
76
77 A: {
Simon Hunt21281fd2017-03-30 22:28:28 -070078 cb: function () { tts.showAllTraffic(); },
79 tt: 'Monitor all traffic',
Steven Burrows1c2a9682017-07-14 16:52:46 +010080 gid: 'm_allTraffic',
Simon Hunt8d22c4b2015-08-06 16:24:43 -070081 },
82 F: {
83 cb: function () { tts.showDeviceLinkFlows(); },
84 tt: 'Show device link flows',
Steven Burrows1c2a9682017-07-14 16:52:46 +010085 gid: 'm_flows',
Simon Hunt8d22c4b2015-08-06 16:24:43 -070086 },
87 V: {
88 cb: function () { tts.showRelatedIntents(); },
89 tt: 'Show all related intents',
Steven Burrows1c2a9682017-07-14 16:52:46 +010090 gid: 'm_relatedIntents',
Simon Hunt8d22c4b2015-08-06 16:24:43 -070091 },
92 leftArrow: {
93 cb: function () { tts.showPrevIntent(); },
94 tt: 'Show previous related intent',
Steven Burrows1c2a9682017-07-14 16:52:46 +010095 gid: 'm_prev',
Simon Hunt8d22c4b2015-08-06 16:24:43 -070096 },
97 rightArrow: {
98 cb: function () { tts.showNextIntent(); },
99 tt: 'Show next related intent',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100100 gid: 'm_next',
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700101 },
102 W: {
103 cb: function () { tts.showSelectedIntentTraffic(); },
104 tt: 'Monitor traffic of selected intent',
Steven Burrows1c2a9682017-07-14 16:52:46 +0100105 gid: 'm_intentTraffic',
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700106 },
107
108 _keyOrder: [
Steven Burrows1c2a9682017-07-14 16:52:46 +0100109 '0', 'A', 'F', 'V', 'leftArrow', 'rightArrow', 'W',
110 ],
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700111 },
112
113 hooks: {
114 // hook for handling escape key
115 escape: function () {
116 // Must return true to consume ESC, false otherwise.
Simon Hunt57830172015-08-26 13:25:17 -0700117 return tts.cancelTraffic(true);
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700118 },
119
120 // hooks for when the selection changes...
121 empty: function () {
122 tts.cancelTraffic();
123 },
124 single: function (data) {
125 tts.requestTrafficForMode();
126 },
127 multi: function (selectOrder) {
128 tts.requestTrafficForMode();
129 tov.addDetailButton('showRelatedTraffic');
Simon Hunt584e92d2015-08-24 11:27:22 -0700130 },
131
132 // mouse hooks
133 mouseover: function (m) {
134 // m has id, class, and type properties
Simon Huntd2862c32015-08-24 17:41:51 -0700135 tts.requestTrafficForMode(true);
Simon Hunt584e92d2015-08-24 11:27:22 -0700136 },
137 mouseout: function () {
Simon Huntd2862c32015-08-24 17:41:51 -0700138 tts.requestTrafficForMode(true);
Simon Hunt8419efd2017-01-12 12:36:28 -0800139 },
140
Simon Hunt441c9ae2017-02-03 18:22:31 -0800141 // intent visualization hooks
142 acceptIntent: function (type) {
143 // accept any intent type except "Protected" intents
144 return (!type.startsWith('Protected'));
145 },
146 showIntent: function (info) {
Simon Huntfc5c5842017-02-01 23:32:18 -0800147 $log.debug('^^ trafficOverlay.showintent() ^^', info);
148 tts.selectIntent(info);
Steven Burrows1c2a9682017-07-14 16:52:46 +0100149 },
150 },
Simon Hunt72e44bf2015-07-21 21:34:20 -0700151 };
152
Simon Hunt72e44bf2015-07-21 21:34:20 -0700153 // invoke code to register with the overlay service
154 angular.module('ovTopo')
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700155 .run(['$log', 'TopoOverlayService', 'TopoTrafficService',
Simon Hunt72e44bf2015-07-21 21:34:20 -0700156
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700157 function (_$log_, _tov_, _tts_) {
Simon Hunt72e44bf2015-07-21 21:34:20 -0700158 $log = _$log_;
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700159 tov = _tov_;
160 tts = _tts_;
Simon Hunt72e44bf2015-07-21 21:34:20 -0700161 tov.register(overlay);
162 }]);
163
164}());