Thomas Vachuska | ee79ad3 | 2019-03-05 17:26:55 -0800 | [diff] [blame] | 1 | // 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 Vachuska | c6e98c8 | 2019-03-28 21:11:56 -0700 | [diff] [blame] | 10 | 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 Vachuska | ee79ad3 | 2019-03-05 17:26:55 -0800 | [diff] [blame] | 16 | |
| 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 Vachuska | c6e98c8 | 2019-03-28 21:11:56 -0700 | [diff] [blame] | 40 | }, |
| 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 Vachuska | ee79ad3 | 2019-03-05 17:26:55 -0800 | [diff] [blame] | 71 | }, |
| 72 | |
| 73 | hooks: { |
Thomas Vachuska | c6e98c8 | 2019-03-28 21:11:56 -0700 | [diff] [blame] | 74 | // 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 Vachuska | ee79ad3 | 2019-03-05 17:26:55 -0800 | [diff] [blame] | 84 | // hooks for when the selection changes... |
| 85 | single: function (data) { |
| 86 | $log.debug('selection data:', data); |
| 87 | sel = data; |
| 88 | tov.addDetailButton('showOnlpView'); |
Thomas Vachuska | c6e98c8 | 2019-03-28 21:11:56 -0700 | [diff] [blame] | 89 | 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 Vachuska | ee79ad3 | 2019-03-05 17:26:55 -0800 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | // invoke code to register with the overlay service |
| 115 | angular.module('ovOdTopov') |
Thomas Vachuska | c6e98c8 | 2019-03-28 21:11:56 -0700 | [diff] [blame] | 116 | .run(['$log', 'TopoOverlayService', 'NavService', 'TopoTrafficService', |
| 117 | 'OnlpDemoTopovService', |
Thomas Vachuska | ee79ad3 | 2019-03-05 17:26:55 -0800 | [diff] [blame] | 118 | |
Thomas Vachuska | c6e98c8 | 2019-03-28 21:11:56 -0700 | [diff] [blame] | 119 | function (_$log_, _tov_, _ns_, _tts_, _lts_) { |
Thomas Vachuska | ee79ad3 | 2019-03-05 17:26:55 -0800 | [diff] [blame] | 120 | $log = _$log_; |
| 121 | tov = _tov_; |
| 122 | ns = _ns_; |
Thomas Vachuska | c6e98c8 | 2019-03-28 21:11:56 -0700 | [diff] [blame] | 123 | tts = _tts_; |
Thomas Vachuska | ee79ad3 | 2019-03-05 17:26:55 -0800 | [diff] [blame] | 124 | lts = _lts_; |
| 125 | tov.register(overlay); |
| 126 | }]); |
| 127 | }()); |