Simon Hunt | 72e44bf | 2015-07-21 21:34:20 -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 | 72e44bf | 2015-07-21 21:34:20 -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 | /* |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 19 | ONOS GUI -- Topology Traffic Overlay Module. |
Simon Hunt | 72e44bf | 2015-07-21 21:34:20 -0700 | [diff] [blame] | 20 | Defines behavior for viewing different traffic modes. |
| 21 | Installed as a Topology Overlay. |
| 22 | */ |
| 23 | (function () { |
| 24 | 'use strict'; |
| 25 | |
| 26 | // injected refs |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 27 | 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 Hunt | 72e44bf | 2015-07-21 21:34:20 -0700 | [diff] [blame] | 34 | |
| 35 | // traffic overlay definition |
| 36 | var overlay = { |
| 37 | overlayId: 'traffic', |
Simon Hunt | c217cb9 | 2016-08-30 16:17:51 -0700 | [diff] [blame] | 38 | glyphId: 'm_allTraffic', |
Simon Hunt | 72e44bf | 2015-07-21 21:34:20 -0700 | [diff] [blame] | 39 | tooltip: 'Traffic Overlay', |
| 40 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 41 | // 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 Hunt | d2862c3 | 2015-08-24 17:41:51 -0700 | [diff] [blame] | 48 | tts.cancelTraffic(true); |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 49 | $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 Hunt | c217cb9 | 2016-08-30 16:17:51 -0700 | [diff] [blame] | 56 | gid: 'm_flows', |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 57 | tt: 'Show Device Flows', |
| 58 | cb: function (data) { tts.showDeviceLinkFlows(); } |
| 59 | }, |
| 60 | |
| 61 | showRelatedTraffic: { |
Simon Hunt | c217cb9 | 2016-08-30 16:17:51 -0700 | [diff] [blame] | 62 | gid: 'm_relatedIntents', |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 63 | 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 Hunt | d2862c3 | 2015-08-24 17:41:51 -0700 | [diff] [blame] | 72 | cb: function () { tts.cancelTraffic(true); }, |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 73 | tt: 'Cancel traffic monitoring', |
Simon Hunt | c217cb9 | 2016-08-30 16:17:51 -0700 | [diff] [blame] | 74 | gid: 'm_xMark' |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 75 | }, |
| 76 | |
| 77 | A: { |
| 78 | cb: function () { tts.showAllFlowTraffic(); }, |
| 79 | tt: 'Monitor all traffic using flow stats', |
Simon Hunt | c217cb9 | 2016-08-30 16:17:51 -0700 | [diff] [blame] | 80 | gid: 'm_allTraffic' |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 81 | }, |
| 82 | Q: { |
| 83 | cb: function () { tts.showAllPortTraffic(); }, |
| 84 | tt: 'Monitor all traffic using port stats', |
Simon Hunt | c217cb9 | 2016-08-30 16:17:51 -0700 | [diff] [blame] | 85 | gid: 'm_allTraffic' |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 86 | }, |
| 87 | F: { |
| 88 | cb: function () { tts.showDeviceLinkFlows(); }, |
| 89 | tt: 'Show device link flows', |
Simon Hunt | c217cb9 | 2016-08-30 16:17:51 -0700 | [diff] [blame] | 90 | gid: 'm_flows' |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 91 | }, |
| 92 | V: { |
| 93 | cb: function () { tts.showRelatedIntents(); }, |
| 94 | tt: 'Show all related intents', |
Simon Hunt | c217cb9 | 2016-08-30 16:17:51 -0700 | [diff] [blame] | 95 | gid: 'm_relatedIntents' |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 96 | }, |
| 97 | leftArrow: { |
| 98 | cb: function () { tts.showPrevIntent(); }, |
| 99 | tt: 'Show previous related intent', |
Simon Hunt | c217cb9 | 2016-08-30 16:17:51 -0700 | [diff] [blame] | 100 | gid: 'm_prev' |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 101 | }, |
| 102 | rightArrow: { |
| 103 | cb: function () { tts.showNextIntent(); }, |
| 104 | tt: 'Show next related intent', |
Simon Hunt | c217cb9 | 2016-08-30 16:17:51 -0700 | [diff] [blame] | 105 | gid: 'm_next' |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 106 | }, |
| 107 | W: { |
| 108 | cb: function () { tts.showSelectedIntentTraffic(); }, |
| 109 | tt: 'Monitor traffic of selected intent', |
Simon Hunt | c217cb9 | 2016-08-30 16:17:51 -0700 | [diff] [blame] | 110 | gid: 'm_intentTraffic' |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 111 | }, |
| 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 Hunt | 5783017 | 2015-08-26 13:25:17 -0700 | [diff] [blame] | 122 | return tts.cancelTraffic(true); |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 123 | }, |
| 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 Hunt | 584e92d | 2015-08-24 11:27:22 -0700 | [diff] [blame] | 135 | }, |
| 136 | |
| 137 | // mouse hooks |
| 138 | mouseover: function (m) { |
| 139 | // m has id, class, and type properties |
Simon Hunt | d2862c3 | 2015-08-24 17:41:51 -0700 | [diff] [blame] | 140 | tts.requestTrafficForMode(true); |
Simon Hunt | 584e92d | 2015-08-24 11:27:22 -0700 | [diff] [blame] | 141 | }, |
| 142 | mouseout: function () { |
Simon Hunt | d2862c3 | 2015-08-24 17:41:51 -0700 | [diff] [blame] | 143 | tts.requestTrafficForMode(true); |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 144 | } |
| 145 | } |
Simon Hunt | 72e44bf | 2015-07-21 21:34:20 -0700 | [diff] [blame] | 146 | }; |
| 147 | |
Simon Hunt | 72e44bf | 2015-07-21 21:34:20 -0700 | [diff] [blame] | 148 | // invoke code to register with the overlay service |
| 149 | angular.module('ovTopo') |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 150 | .run(['$log', 'TopoOverlayService', 'TopoTrafficService', |
Simon Hunt | 72e44bf | 2015-07-21 21:34:20 -0700 | [diff] [blame] | 151 | |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 152 | function (_$log_, _tov_, _tts_) { |
Simon Hunt | 72e44bf | 2015-07-21 21:34:20 -0700 | [diff] [blame] | 153 | $log = _$log_; |
Simon Hunt | 8d22c4b | 2015-08-06 16:24:43 -0700 | [diff] [blame] | 154 | tov = _tov_; |
| 155 | tts = _tts_; |
Simon Hunt | 72e44bf | 2015-07-21 21:34:20 -0700 | [diff] [blame] | 156 | tov.register(overlay); |
| 157 | }]); |
| 158 | |
| 159 | }()); |