blob: 98d3926d745fbb026e2797e28b49d80630ceb76a [file] [log] [blame]
Simon Hunt6cc86452017-04-27 17:46:22 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Simon Hunt6cc86452017-04-27 17:46:22 -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(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 () {
Steven Burrows1c2a9682017-07-14 16:52:46 +010033 $log.debug('Traffic-2 overlay ACTIVATED');
Simon Hunt6cc86452017-04-27 17:46:22 -070034 },
35
36 deactivate: function () {
37 t2ts.cancelTraffic(true);
Steven Burrows1c2a9682017-07-14 16:52:46 +010038 $log.debug('Traffic-2 overlay DEACTIVATED');
Simon Hunt6cc86452017-04-27 17:46:22 -070039 },
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',
Steven Burrows1c2a9682017-07-14 16:52:46 +010047 gid: 'm_xMark',
Simon Hunt6cc86452017-04-27 17:46:22 -070048 },
49
50 A: {
51 cb: function () { t2ts.showAllTraffic(); },
52 tt: 'Monitor all traffic',
Steven Burrows1c2a9682017-07-14 16:52:46 +010053 gid: 'm_allTraffic',
Simon Hunt6cc86452017-04-27 17:46:22 -070054 },
55
56 _keyOrder: [
Steven Burrows1c2a9682017-07-14 16:52:46 +010057 '0', 'A',
58 ],
Simon Hunt6cc86452017-04-27 17:46:22 -070059 },
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);
Steven Burrows1c2a9682017-07-14 16:52:46 +010066 },
Simon Hunt6cc86452017-04-27 17:46:22 -070067 // TODO : add node selection events etc.
68 // NOTE : see topoTrafficNew.js
Steven Burrows1c2a9682017-07-14 16:52:46 +010069 },
Simon Hunt6cc86452017-04-27 17:46:22 -070070 };
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
Steven Burrows1c2a9682017-07-14 16:52:46 +010083}());