blob: 7cb966f7c43a2f2811a6baf057c4867cb95af814 [file] [log] [blame]
Adnaan Sachidanandana915da12017-08-09 15:12:45 -07001// Link props topology overlay - client side
2//
3// This is the glue that binds our business logic (in lpTopov.js)
4// to the overlay framework.
5
6(function () {
7 'use strict';
8
9 // injected refs
10 var $log, tov, stds;
11
12 // internal state should be kept in the service module (not here)
13
14 // our overlay definition
15 var overlay = {
16 // NOTE: this must match the ID defined in AppUiTopovOverlay
17 overlayId: 'linkprops-overlay',
18 glyphId: 'topo',
19 tooltip: 'Link Properties',
20
21 activate: function () {
22 $log.debug("Link Props topology overlay ACTIVATED");
23 },
24 deactivate: function () {
25 stds.stopDisplay();
26 $log.debug("Link Props topology overlay DEACTIVATED");
27 },
28
29 // Key bindings for traffic overlay buttons
30 // NOTE: fully qual. button ID is derived from overlay-id and key-name
31 keyBindings: {
32 0: {
33 cb: function () { stds.stopDisplay(); },
34 tt: 'Cancel Display Mode',
35 gid: 'xMark'
36 },
37 V: {
38 cb: function () { stds.startDisplay('rate'); },
39 tt: 'Start Rate Mode',
40 gid: 'ports'
41 },
42 F: {
43 cb: function () { stds.startDisplay('byte'); },
44 tt: 'Start Total Byte Mode',
45 gid: 'allTraffic'
46 },
47 C: {
48 cb: function () { stds.startDisplay('band'); },
49 tt: 'Start Available Bandwidth Mode',
50 gid: 'triangleUp'
51 },
52 G: {
53 cb: buttonCallback,
54 tt: 'Uses the G key',
55 gid: 'crown'
56 },
57
58 _keyOrder: [
59 '0', 'V', 'F', 'C', 'G'
60 ]
61 },
62
63 hooks: {
64 // hook for handling escape key
65 // Must return true to consume ESC, false otherwise.
66 escape: function () {
67 // Must return true to consume ESC, false otherwise.
68 return stds.stopDisplay();
69 },
70
71 // hooks for when the selection changes...
72 empty: function () {
73 selectionCallback('empty');
74 },
75 single: function (data) {
76 selectionCallback('single', data);
77 },
78 mouseover: function (m) {
79 // m has id, class, and type properties
80 $log.debug('mouseover:', m);
81 stds.updateDisplay(m);
82 },
83 mouseout: function () {
84 $log.debug('mouseout');
85 stds.updateDisplay();
86 }
87 }
88 };
89
90
91 function buttonCallback(x) {
92 $log.debug('Toolbar-button callback', x);
93 }
94
95 function selectionCallback(x, d) {
96 $log.debug('Selection callback', x, d);
97 }
98
99 // invoke code to register with the overlay service
100 angular.module('ovLpTopov')
101 .run(['$log', 'TopoOverlayService', 'LinkPropsTopovService',
102
103 function (_$log_, _tov_, _stds_) {
104 $log = _$log_;
105 tov = _tov_;
106 stds = _stds_;
107 tov.register(overlay);
108 }]);
109
110}());