blob: a8da7af971d447b2c0e0535396928639083488cf [file] [log] [blame]
Thomas Vachuskaee79ad32019-03-05 17:26:55 -08001// path painter topology overlay - client side
2//
3// This is the glue that binds our business logic (in ppTopov.js)
4// to the overlay framework.
5
6(function () {
7 'use strict';
8
9 // injected refs
Thomas Vachuskac6e98c82019-03-28 21:11:56 -070010 var $log, tov, ns, tts, lts, sel;
11
12 // function to be replaced by the localization bundle function
13 var topoLion = function (x) {
14 return '#ttrafov#' + x + '#';
15 };
Thomas Vachuskaee79ad32019-03-05 17:26:55 -080016
17 // our overlay definition
18 var overlay = {
19 overlayId: 'od-overlay',
20 glyphId: 'm_disjointPaths',
21 tooltip: 'ONLP Data Overlay',
22
23 activate: function () {
24 $log.debug("ONLP data topology overlay ACTIVATED");
25 },
26 deactivate: function () {
27 lts.clear();
28 $log.debug("ONLP data topology overlay DEACTIVATED");
29 },
30
31 // detail panel button definitions
32 buttons: {
33 showOnlpView: {
34 gid: 'chain',
35 tt: 'ONLP data',
36 cb: function (data) {
37 $log.debug('ONLP action invoked on selection:', sel);
38 ns.navTo('onlp', { devId: sel.id });
39 }
Thomas Vachuskac6e98c82019-03-28 21:11:56 -070040 },
41 showDeviceFlows: {
42 gid: 'm_flows',
43 tt: function () { return topoLion('tr_btn_show_device_flows'); },
44 cb: function (data) { tts.showDeviceLinkFlows(); },
45 },
46 },
47
48 // key bindings for traffic overlay toolbar buttons
49 // NOTE: fully qual. button ID is derived from overlay-id and key-name
50 keyBindings: {
51 0: {
52 cb: function () { tts.cancelTraffic(true); },
53 tt: function () { return topoLion('tr_btn_cancel_monitoring'); },
54 gid: 'm_xMark',
55 },
56
57 A: {
58 cb: function () { tts.showAllTraffic(); },
59 tt: function () { return topoLion('tr_btn_monitor_all'); },
60 gid: 'm_allTraffic',
61 },
62 F: {
63 cb: function () { tts.showDeviceLinkFlows(); },
64 tt: function () { return topoLion('tr_btn_show_dev_link_flows'); },
65 gid: 'm_flows',
66 },
67
68 _keyOrder: [
69 '0', 'A', 'F',
70 ],
Thomas Vachuskaee79ad32019-03-05 17:26:55 -080071 },
72
73 hooks: {
Thomas Vachuskac6e98c82019-03-28 21:11:56 -070074 // hook for handling escape key
75 escape: function () {
76 // Must return true to consume ESC, false otherwise.
77 return tts.cancelTraffic(true);
78 },
79
80 // hooks for when the selection changes...
81 empty: function () {
82 tts.cancelTraffic();
83 },
Thomas Vachuskaee79ad32019-03-05 17:26:55 -080084 // hooks for when the selection changes...
85 single: function (data) {
86 $log.debug('selection data:', data);
87 sel = data;
88 tov.addDetailButton('showOnlpView');
Thomas Vachuskac6e98c82019-03-28 21:11:56 -070089 tov.addDetailButton('showDeviceFlows');
90 tts.requestTrafficForMode();
91 },
92 multi: function (selectOrder) {
93 tts.requestTrafficForMode();
94 tov.addDetailButton('showRelatedTraffic');
95 },
96
97 // mouse hooks
98 mouseover: function (m) {
99 // m has id, class, and type properties
100 tts.requestTrafficForMode(true);
101 },
102 mouseout: function () {
103 tts.requestTrafficForMode(true);
104 },
105
106 // localization bundle injection hook
107 injectLion: function (bundle) {
108 topoLion = bundle;
109 tts.setLionBundle(bundle);
110 },
111 },
Thomas Vachuskaee79ad32019-03-05 17:26:55 -0800112 };
113
114 // invoke code to register with the overlay service
115 angular.module('ovOdTopov')
Thomas Vachuskac6e98c82019-03-28 21:11:56 -0700116 .run(['$log', 'TopoOverlayService', 'NavService', 'TopoTrafficService',
117 'OnlpDemoTopovService',
Thomas Vachuskaee79ad32019-03-05 17:26:55 -0800118
Thomas Vachuskac6e98c82019-03-28 21:11:56 -0700119 function (_$log_, _tov_, _ns_, _tts_, _lts_) {
Thomas Vachuskaee79ad32019-03-05 17:26:55 -0800120 $log = _$log_;
121 tov = _tov_;
122 ns = _ns_;
Thomas Vachuskac6e98c82019-03-28 21:11:56 -0700123 tts = _tts_;
Thomas Vachuskaee79ad32019-03-05 17:26:55 -0800124 lts = _lts_;
125 tov.register(overlay);
126 }]);
127}());