blob: 304b4e6fc5dc6f5e8b84ff9d6386e65197d9160e [file] [log] [blame]
Simon Hunt72e44bf2015-07-21 21:34:20 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
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 () {
44 $log.debug("Traffic overlay ACTIVATED");
45 },
46
47 deactivate: function () {
Simon Huntd2862c32015-08-24 17:41:51 -070048 tts.cancelTraffic(true);
Simon Hunt8d22c4b2015-08-06 16:24:43 -070049 $log.debug("Traffic overlay DEACTIVATED");
50 },
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',
58 cb: function (data) { tts.showDeviceLinkFlows(); }
59 },
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',
64 cb: function (data) { tts.showRelatedIntents(); }
65 }
66 },
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',
Simon Huntc217cb92016-08-30 16:17:51 -070074 gid: 'm_xMark'
Simon Hunt8d22c4b2015-08-06 16:24:43 -070075 },
76
77 A: {
78 cb: function () { tts.showAllFlowTraffic(); },
79 tt: 'Monitor all traffic using flow stats',
Simon Huntc217cb92016-08-30 16:17:51 -070080 gid: 'm_allTraffic'
Simon Hunt8d22c4b2015-08-06 16:24:43 -070081 },
82 Q: {
83 cb: function () { tts.showAllPortTraffic(); },
84 tt: 'Monitor all traffic using port stats',
Simon Huntc217cb92016-08-30 16:17:51 -070085 gid: 'm_allTraffic'
Simon Hunt8d22c4b2015-08-06 16:24:43 -070086 },
87 F: {
88 cb: function () { tts.showDeviceLinkFlows(); },
89 tt: 'Show device link flows',
Simon Huntc217cb92016-08-30 16:17:51 -070090 gid: 'm_flows'
Simon Hunt8d22c4b2015-08-06 16:24:43 -070091 },
92 V: {
93 cb: function () { tts.showRelatedIntents(); },
94 tt: 'Show all related intents',
Simon Huntc217cb92016-08-30 16:17:51 -070095 gid: 'm_relatedIntents'
Simon Hunt8d22c4b2015-08-06 16:24:43 -070096 },
97 leftArrow: {
98 cb: function () { tts.showPrevIntent(); },
99 tt: 'Show previous related intent',
Simon Huntc217cb92016-08-30 16:17:51 -0700100 gid: 'm_prev'
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700101 },
102 rightArrow: {
103 cb: function () { tts.showNextIntent(); },
104 tt: 'Show next related intent',
Simon Huntc217cb92016-08-30 16:17:51 -0700105 gid: 'm_next'
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700106 },
107 W: {
108 cb: function () { tts.showSelectedIntentTraffic(); },
109 tt: 'Monitor traffic of selected intent',
Simon Huntc217cb92016-08-30 16:17:51 -0700110 gid: 'm_intentTraffic'
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700111 },
112
113 _keyOrder: [
114 '0', 'A', 'Q', 'F', 'V', 'leftArrow', 'rightArrow', 'W'
115 ]
116 },
117
118 hooks: {
119 // hook for handling escape key
120 escape: function () {
121 // Must return true to consume ESC, false otherwise.
Simon Hunt57830172015-08-26 13:25:17 -0700122 return tts.cancelTraffic(true);
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700123 },
124
125 // hooks for when the selection changes...
126 empty: function () {
127 tts.cancelTraffic();
128 },
129 single: function (data) {
130 tts.requestTrafficForMode();
131 },
132 multi: function (selectOrder) {
133 tts.requestTrafficForMode();
134 tov.addDetailButton('showRelatedTraffic');
Simon Hunt584e92d2015-08-24 11:27:22 -0700135 },
136
137 // mouse hooks
138 mouseover: function (m) {
139 // m has id, class, and type properties
Simon Huntd2862c32015-08-24 17:41:51 -0700140 tts.requestTrafficForMode(true);
Simon Hunt584e92d2015-08-24 11:27:22 -0700141 },
142 mouseout: function () {
Simon Huntd2862c32015-08-24 17:41:51 -0700143 tts.requestTrafficForMode(true);
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700144 }
145 }
Simon Hunt72e44bf2015-07-21 21:34:20 -0700146 };
147
Simon Hunt72e44bf2015-07-21 21:34:20 -0700148 // invoke code to register with the overlay service
149 angular.module('ovTopo')
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700150 .run(['$log', 'TopoOverlayService', 'TopoTrafficService',
Simon Hunt72e44bf2015-07-21 21:34:20 -0700151
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700152 function (_$log_, _tov_, _tts_) {
Simon Hunt72e44bf2015-07-21 21:34:20 -0700153 $log = _$log_;
Simon Hunt8d22c4b2015-08-06 16:24:43 -0700154 tov = _tov_;
155 tts = _tts_;
Simon Hunt72e44bf2015-07-21 21:34:20 -0700156 tov.register(overlay);
157 }]);
158
159}());