blob: 19d0844c05924f72071ac92bbe6658e986a482e3 [file] [log] [blame]
Simon Hunt6cc86452017-04-27 17:46:22 -07001/*
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 () {
33 $log.debug("Traffic-2 overlay ACTIVATED");
34 },
35
36 deactivate: function () {
37 t2ts.cancelTraffic(true);
38 $log.debug("Traffic-2 overlay DEACTIVATED");
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',
47 gid: 'm_xMark'
48 },
49
50 A: {
51 cb: function () { t2ts.showAllTraffic(); },
52 tt: 'Monitor all traffic',
53 gid: 'm_allTraffic'
54 },
55
56 _keyOrder: [
57 '0', 'A'
58 ]
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);
66 }
67 // TODO : add node selection events etc.
68 // NOTE : see topoTrafficNew.js
69 }
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
83}());