Simon Hunt | 6cc8645 | 2017-04-27 17:46:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Laboratory |
| 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 | (function () { |
| 19 | 'use strict'; |
| 20 | |
| 21 | // injected refs |
| 22 | var $log, t2ov, t2ts; |
| 23 | |
| 24 | // NOTE: no internal state here -- see Topo2TrafficService for that |
| 25 | |
| 26 | // traffic 2 overlay definition |
| 27 | var overlay = { |
| 28 | overlayId: 'traffic-2-overlay', |
| 29 | glyphId: 'm_allTraffic', |
| 30 | tooltip: 'Traffic Overlay', |
| 31 | |
| 32 | activate: function () { |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 33 | $log.debug("Traffic-2 overlay ACTIVATED"); |
Simon Hunt | 6cc8645 | 2017-04-27 17:46:22 -0700 | [diff] [blame] | 34 | }, |
| 35 | |
| 36 | deactivate: function () { |
| 37 | t2ts.cancelTraffic(true); |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 38 | $log.debug("Traffic-2 overlay DEACTIVATED"); |
Simon Hunt | 6cc8645 | 2017-04-27 17:46:22 -0700 | [diff] [blame] | 39 | }, |
| 40 | |
| 41 | // key bindings for toolbar buttons |
| 42 | // NOTE: fully qual. button ID is derived from overlay-id and key-name |
| 43 | keyBindings: { |
| 44 | 0: { |
| 45 | cb: function () { t2ts.cancelTraffic(true); }, |
| 46 | tt: 'Cancel traffic monitoring', |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 47 | gid: 'm_xMark' |
Simon Hunt | 6cc8645 | 2017-04-27 17:46:22 -0700 | [diff] [blame] | 48 | }, |
| 49 | |
| 50 | A: { |
| 51 | cb: function () { t2ts.showAllTraffic(); }, |
| 52 | tt: 'Monitor all traffic', |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 53 | gid: 'm_allTraffic' |
Simon Hunt | 6cc8645 | 2017-04-27 17:46:22 -0700 | [diff] [blame] | 54 | }, |
| 55 | |
| 56 | _keyOrder: [ |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 57 | '0', 'A' |
| 58 | ] |
Simon Hunt | 6cc8645 | 2017-04-27 17:46:22 -0700 | [diff] [blame] | 59 | }, |
| 60 | |
| 61 | hooks: { |
| 62 | // hook for handling escape key |
| 63 | escape: function () { |
| 64 | // Must return true to consume ESC, false otherwise. |
| 65 | return t2ts.cancelTraffic(true); |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 66 | } |
Simon Hunt | 6cc8645 | 2017-04-27 17:46:22 -0700 | [diff] [blame] | 67 | // TODO : add node selection events etc. |
| 68 | // NOTE : see topoTrafficNew.js |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 69 | } |
Simon Hunt | 6cc8645 | 2017-04-27 17:46:22 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | // invoke code to register with the overlay service |
| 73 | angular.module('ovTopo2') |
| 74 | .run(['$log', 'Topo2OverlayService', 'Topo2TrafficService', |
| 75 | |
| 76 | function (_$log_, _t2ov_, _t2ts_) { |
| 77 | $log = _$log_; |
| 78 | t2ov = _t2ov_; |
| 79 | t2ts = _t2ts_; |
| 80 | t2ov.register(overlay); |
| 81 | }]); |
| 82 | |
Simon Hunt | 5c3ed73 | 2017-07-20 19:03:28 +0000 | [diff] [blame] | 83 | }()); |