Committed by
Gerrit Code Review
GUI -- Topo - rewired modules to call wss.sendEvent(...) directly.
Change-Id: I9077694895b814c6dc342a518948e05e0cc2df01
Showing
6 changed files
with
45 additions
and
50 deletions
... | @@ -28,7 +28,8 @@ | ... | @@ -28,7 +28,8 @@ |
28 | ]; | 28 | ]; |
29 | 29 | ||
30 | // references to injected services etc. | 30 | // references to injected services etc. |
31 | - var $log, fs, ks, zs, gs, ms, sus, flash, tes, tfs, tps, tis, tss, tts, tos; | 31 | + var $log, fs, ks, zs, gs, ms, sus, flash, wss, |
32 | + tes, tfs, tps, tis, tss, tts, tos; | ||
32 | 33 | ||
33 | // DOM elements | 34 | // DOM elements |
34 | var ovtopo, svg, defs, zoomLayer, mapG, forceG, noDevsLayer; | 35 | var ovtopo, svg, defs, zoomLayer, mapG, forceG, noDevsLayer; |
... | @@ -102,7 +103,7 @@ | ... | @@ -102,7 +103,7 @@ |
102 | } | 103 | } |
103 | 104 | ||
104 | function equalizeMasters() { | 105 | function equalizeMasters() { |
105 | - tes.sendEvent('equalizeMasters'); | 106 | + wss.sendEvent('equalizeMasters'); |
106 | flash.flash('Equalizing master roles'); | 107 | flash.flash('Equalizing master roles'); |
107 | } | 108 | } |
108 | 109 | ||
... | @@ -213,16 +214,16 @@ | ... | @@ -213,16 +214,16 @@ |
213 | // --- Controller Definition ----------------------------------------- | 214 | // --- Controller Definition ----------------------------------------- |
214 | 215 | ||
215 | angular.module('ovTopo', moduleDependencies) | 216 | angular.module('ovTopo', moduleDependencies) |
216 | - .controller('OvTopoCtrl', [ | 217 | + .controller('OvTopoCtrl', ['$scope', '$log', '$location', '$timeout', |
217 | - '$scope', '$log', '$location', '$timeout', | ||
218 | 'FnService', 'MastService', 'KeyService', 'ZoomService', | 218 | 'FnService', 'MastService', 'KeyService', 'ZoomService', |
219 | 'GlyphService', 'MapService', 'SvgUtilService', 'FlashService', | 219 | 'GlyphService', 'MapService', 'SvgUtilService', 'FlashService', |
220 | + 'WebSocketService', | ||
220 | 'TopoEventService', 'TopoForceService', 'TopoPanelService', | 221 | 'TopoEventService', 'TopoForceService', 'TopoPanelService', |
221 | 'TopoInstService', 'TopoSelectService', 'TopoTrafficService', | 222 | 'TopoInstService', 'TopoSelectService', 'TopoTrafficService', |
222 | 'TopoObliqueService', | 223 | 'TopoObliqueService', |
223 | 224 | ||
224 | function ($scope, _$log_, $loc, $timeout, _fs_, mast, | 225 | function ($scope, _$log_, $loc, $timeout, _fs_, mast, |
225 | - _ks_, _zs_, _gs_, _ms_, _sus_, _flash_, | 226 | + _ks_, _zs_, _gs_, _ms_, _sus_, _flash_, _wss_, |
226 | _tes_, _tfs_, _tps_, _tis_, _tss_, _tts_, _tos_) { | 227 | _tes_, _tfs_, _tps_, _tis_, _tss_, _tts_, _tos_) { |
227 | var self = this, | 228 | var self = this, |
228 | projection, | 229 | projection, |
... | @@ -233,8 +234,7 @@ | ... | @@ -233,8 +234,7 @@ |
233 | projection: function () { return projection; }, | 234 | projection: function () { return projection; }, |
234 | zoomLayer: function () { return zoomLayer; }, | 235 | zoomLayer: function () { return zoomLayer; }, |
235 | zoomer: function () { return zoomer; }, | 236 | zoomer: function () { return zoomer; }, |
236 | - opacifyMap: opacifyMap, | 237 | + opacifyMap: opacifyMap |
237 | - sendEvent: _tes_.sendEvent | ||
238 | }; | 238 | }; |
239 | 239 | ||
240 | $log = _$log_; | 240 | $log = _$log_; |
... | @@ -245,6 +245,7 @@ | ... | @@ -245,6 +245,7 @@ |
245 | ms = _ms_; | 245 | ms = _ms_; |
246 | sus = _sus_; | 246 | sus = _sus_; |
247 | flash = _flash_; | 247 | flash = _flash_; |
248 | + wss = _wss_; | ||
248 | tes = _tes_; | 249 | tes = _tes_; |
249 | tfs = _tfs_; | 250 | tfs = _tfs_; |
250 | // TODO: consider funnelling actions through TopoForceService... | 251 | // TODO: consider funnelling actions through TopoForceService... |
... | @@ -290,7 +291,7 @@ | ... | @@ -290,7 +291,7 @@ |
290 | forceG = zoomLayer.append('g').attr('id', 'topo-force'); | 291 | forceG = zoomLayer.append('g').attr('id', 'topo-force'); |
291 | tfs.initForce(svg, forceG, uplink, dim); | 292 | tfs.initForce(svg, forceG, uplink, dim); |
292 | tis.initInst({ showMastership: tfs.showMastership }); | 293 | tis.initInst({ showMastership: tfs.showMastership }); |
293 | - tps.initPanels({ sendEvent: tes.sendEvent }); | 294 | + tps.initPanels(); |
294 | tes.start(); | 295 | tes.start(); |
295 | 296 | ||
296 | $log.log('OvTopoCtrl has been created'); | 297 | $log.log('OvTopoCtrl has been created'); | ... | ... |
... | @@ -23,7 +23,8 @@ | ... | @@ -23,7 +23,8 @@ |
23 | 'use strict'; | 23 | 'use strict'; |
24 | 24 | ||
25 | // injected refs | 25 | // injected refs |
26 | - var $log, fs, sus, is, ts, flash, tis, tms, td3, tss, tts, tos, fltr, tls, | 26 | + var $log, fs, sus, is, ts, flash, wss, |
27 | + tis, tms, td3, tss, tts, tos, fltr, tls, | ||
27 | icfg, uplink, svg; | 28 | icfg, uplink, svg; |
28 | 29 | ||
29 | // configuration | 30 | // configuration |
... | @@ -374,7 +375,7 @@ | ... | @@ -374,7 +375,7 @@ |
374 | metaUi = {x: d.x, y: d.y, lng: ll[0], lat: ll[1]}; | 375 | metaUi = {x: d.x, y: d.y, lng: ll[0], lat: ll[1]}; |
375 | } | 376 | } |
376 | d.metaUi = metaUi; | 377 | d.metaUi = metaUi; |
377 | - uplink.sendEvent('updateMeta', { | 378 | + wss.sendEvent('updateMeta', { |
378 | id: d.id, | 379 | id: d.id, |
379 | 'class': d.class, | 380 | 'class': d.class, |
380 | memento: metaUi | 381 | memento: metaUi |
... | @@ -691,8 +692,7 @@ | ... | @@ -691,8 +692,7 @@ |
691 | return { | 692 | return { |
692 | node: function () { return node; }, | 693 | node: function () { return node; }, |
693 | zoomingOrPanning: zoomingOrPanning, | 694 | zoomingOrPanning: zoomingOrPanning, |
694 | - updateDeviceColors: td3.updateDeviceColors, | 695 | + updateDeviceColors: td3.updateDeviceColors |
695 | - sendEvent: uplink.sendEvent | ||
696 | }; | 696 | }; |
697 | } | 697 | } |
698 | 698 | ||
... | @@ -704,8 +704,7 @@ | ... | @@ -704,8 +704,7 @@ |
704 | findLinkById: tms.findLinkById, | 704 | findLinkById: tms.findLinkById, |
705 | hovered: tss.hovered, | 705 | hovered: tss.hovered, |
706 | validateSelectionContext: tss.validateSelectionContext, | 706 | validateSelectionContext: tss.validateSelectionContext, |
707 | - selectOrder: tss.selectOrder, | 707 | + selectOrder: tss.selectOrder |
708 | - sendEvent: uplink.sendEvent | ||
709 | } | 708 | } |
710 | } | 709 | } |
711 | 710 | ||
... | @@ -749,11 +748,12 @@ | ... | @@ -749,11 +748,12 @@ |
749 | angular.module('ovTopo') | 748 | angular.module('ovTopo') |
750 | .factory('TopoForceService', | 749 | .factory('TopoForceService', |
751 | ['$log', 'FnService', 'SvgUtilService', 'IconService', 'ThemeService', | 750 | ['$log', 'FnService', 'SvgUtilService', 'IconService', 'ThemeService', |
752 | - 'FlashService', 'TopoInstService', 'TopoModelService', | 751 | + 'FlashService', 'WebSocketService', |
752 | + 'TopoInstService', 'TopoModelService', | ||
753 | 'TopoD3Service', 'TopoSelectService', 'TopoTrafficService', | 753 | 'TopoD3Service', 'TopoSelectService', 'TopoTrafficService', |
754 | 'TopoObliqueService', 'TopoFilterService', 'TopoLinkService', | 754 | 'TopoObliqueService', 'TopoFilterService', 'TopoLinkService', |
755 | 755 | ||
756 | - function (_$log_, _fs_, _sus_, _is_, _ts_, _flash_, | 756 | + function (_$log_, _fs_, _sus_, _is_, _ts_, _flash_, _wss_, |
757 | _tis_, _tms_, _td3_, _tss_, _tts_, _tos_, _fltr_, _tls_) { | 757 | _tis_, _tms_, _td3_, _tss_, _tts_, _tos_, _fltr_, _tls_) { |
758 | $log = _$log_; | 758 | $log = _$log_; |
759 | fs = _fs_; | 759 | fs = _fs_; |
... | @@ -761,6 +761,7 @@ | ... | @@ -761,6 +761,7 @@ |
761 | is = _is_; | 761 | is = _is_; |
762 | ts = _ts_; | 762 | ts = _ts_; |
763 | flash = _flash_; | 763 | flash = _flash_; |
764 | + wss = _wss_; | ||
764 | tis = _tis_; | 765 | tis = _tis_; |
765 | tms = _tms_; | 766 | tms = _tms_; |
766 | td3 = _td3_; | 767 | td3 = _td3_; | ... | ... |
... | @@ -23,12 +23,7 @@ | ... | @@ -23,12 +23,7 @@ |
23 | 'use strict'; | 23 | 'use strict'; |
24 | 24 | ||
25 | // injected refs | 25 | // injected refs |
26 | - var $log, fs, ps, gs; | 26 | + var $log, fs, ps, gs, wss; |
27 | - | ||
28 | - var api; | ||
29 | - /* | ||
30 | - sendEvent( event, {payload} ) | ||
31 | - */ | ||
32 | 27 | ||
33 | // constants | 28 | // constants |
34 | var pCls = 'topo-p', | 29 | var pCls = 'topo-p', |
... | @@ -147,7 +142,7 @@ | ... | @@ -147,7 +142,7 @@ |
147 | hideSummaryPanel(); | 142 | hideSummaryPanel(); |
148 | } else { | 143 | } else { |
149 | // ask server to start sending summary data. | 144 | // ask server to start sending summary data. |
150 | - api.sendEvent('requestSummary'); | 145 | + wss.sendEvent('requestSummary'); |
151 | // note: the summary panel will appear, once data arrives | 146 | // note: the summary panel will appear, once data arrives |
152 | } | 147 | } |
153 | } | 148 | } |
... | @@ -165,7 +160,7 @@ | ... | @@ -165,7 +160,7 @@ |
165 | 160 | ||
166 | function hideSummaryPanel() { | 161 | function hideSummaryPanel() { |
167 | // instruct server to stop sending summary data | 162 | // instruct server to stop sending summary data |
168 | - api.sendEvent("cancelSummary"); | 163 | + wss.sendEvent("cancelSummary"); |
169 | summaryPanel.hide(detailPanel.up); | 164 | summaryPanel.hide(detailPanel.up); |
170 | } | 165 | } |
171 | 166 | ||
... | @@ -208,9 +203,7 @@ | ... | @@ -208,9 +203,7 @@ |
208 | 203 | ||
209 | // ========================== | 204 | // ========================== |
210 | 205 | ||
211 | - function initPanels(_api_) { | 206 | + function initPanels() { |
212 | - api = _api_; | ||
213 | - | ||
214 | summaryPanel = ps.createPanel(idSum, panelOpts); | 207 | summaryPanel = ps.createPanel(idSum, panelOpts); |
215 | detailPanel = ps.createPanel(idDet, panelOpts); | 208 | detailPanel = ps.createPanel(idDet, panelOpts); |
216 | 209 | ||
... | @@ -230,13 +223,14 @@ | ... | @@ -230,13 +223,14 @@ |
230 | 223 | ||
231 | angular.module('ovTopo') | 224 | angular.module('ovTopo') |
232 | .factory('TopoPanelService', | 225 | .factory('TopoPanelService', |
233 | - ['$log', 'FnService', 'PanelService', 'GlyphService', | 226 | + ['$log', 'FnService', 'PanelService', 'GlyphService', 'WebSocketService', |
234 | 227 | ||
235 | - function (_$log_, _fs_, _ps_, _gs_) { | 228 | + function (_$log_, _fs_, _ps_, _gs_, _wss_) { |
236 | $log = _$log_; | 229 | $log = _$log_; |
237 | fs = _fs_; | 230 | fs = _fs_; |
238 | ps = _ps_; | 231 | ps = _ps_; |
239 | gs = _gs_; | 232 | gs = _gs_; |
233 | + wss = _wss_; | ||
240 | 234 | ||
241 | return { | 235 | return { |
242 | initPanels: initPanels, | 236 | initPanels: initPanels, | ... | ... |
... | @@ -23,7 +23,7 @@ | ... | @@ -23,7 +23,7 @@ |
23 | 'use strict'; | 23 | 'use strict'; |
24 | 24 | ||
25 | // injected refs | 25 | // injected refs |
26 | - var $log, fs, flash, tps, tts; | 26 | + var $log, fs, flash, wss, tps, tts; |
27 | 27 | ||
28 | // api to topoForce | 28 | // api to topoForce |
29 | var api; | 29 | var api; |
... | @@ -31,7 +31,6 @@ | ... | @@ -31,7 +31,6 @@ |
31 | node() // get ref to D3 selection of nodes | 31 | node() // get ref to D3 selection of nodes |
32 | zoomingOrPanning( ev ) | 32 | zoomingOrPanning( ev ) |
33 | updateDeviceColors( [dev] ) | 33 | updateDeviceColors( [dev] ) |
34 | - sendEvent( type, {payload} ) | ||
35 | */ | 34 | */ |
36 | 35 | ||
37 | // internal state | 36 | // internal state |
... | @@ -143,7 +142,7 @@ | ... | @@ -143,7 +142,7 @@ |
143 | 142 | ||
144 | function requestDetails() { | 143 | function requestDetails() { |
145 | var data = getSel(0).obj; | 144 | var data = getSel(0).obj; |
146 | - api.sendEvent('requestDetails', { | 145 | + wss.sendEvent('requestDetails', { |
147 | id: data.id, | 146 | id: data.id, |
148 | class: data.class | 147 | class: data.class |
149 | }); | 148 | }); |
... | @@ -245,13 +244,14 @@ | ... | @@ -245,13 +244,14 @@ |
245 | 244 | ||
246 | angular.module('ovTopo') | 245 | angular.module('ovTopo') |
247 | .factory('TopoSelectService', | 246 | .factory('TopoSelectService', |
248 | - ['$log', 'FnService', 'FlashService', 'TopoPanelService', | 247 | + ['$log', 'FnService', 'FlashService', 'WebSocketService', |
249 | - 'TopoTrafficService', | 248 | + 'TopoPanelService', 'TopoTrafficService', |
250 | 249 | ||
251 | - function (_$log_, _fs_, _flash_, _tps_, _tts_) { | 250 | + function (_$log_, _fs_, _flash_, _wss_, _tps_, _tts_) { |
252 | $log = _$log_; | 251 | $log = _$log_; |
253 | fs = _fs_; | 252 | fs = _fs_; |
254 | flash = _flash_; | 253 | flash = _flash_; |
254 | + wss = _wss_; | ||
255 | tps = _tps_; | 255 | tps = _tps_; |
256 | tts = _tts_; | 256 | tts = _tts_; |
257 | 257 | ... | ... |
... | @@ -23,7 +23,7 @@ | ... | @@ -23,7 +23,7 @@ |
23 | 'use strict'; | 23 | 'use strict'; |
24 | 24 | ||
25 | // injected refs | 25 | // injected refs |
26 | - var $log, fs, flash; | 26 | + var $log, fs, flash, wss; |
27 | 27 | ||
28 | // api to topoForce | 28 | // api to topoForce |
29 | var api; | 29 | var api; |
... | @@ -34,7 +34,6 @@ | ... | @@ -34,7 +34,6 @@ |
34 | findLinkById( id ) | 34 | findLinkById( id ) |
35 | hovered() | 35 | hovered() |
36 | validateSelectionContext() | 36 | validateSelectionContext() |
37 | - sendEvent( type, {payload} ) | ||
38 | */ | 37 | */ |
39 | 38 | ||
40 | // constants | 39 | // constants |
... | @@ -86,7 +85,7 @@ | ... | @@ -86,7 +85,7 @@ |
86 | } | 85 | } |
87 | 86 | ||
88 | if (api.validateSelectionContext()) { | 87 | if (api.validateSelectionContext()) { |
89 | - api.sendEvent('requestDeviceLinkFlows', { | 88 | + wss.sendEvent('requestDeviceLinkFlows', { |
90 | ids: api.selectOrder(), | 89 | ids: api.selectOrder(), |
91 | hover: hoverValid() ? hov.id : '' | 90 | hover: hoverValid() ? hov.id : '' |
92 | }); | 91 | }); |
... | @@ -102,7 +101,7 @@ | ... | @@ -102,7 +101,7 @@ |
102 | } | 101 | } |
103 | 102 | ||
104 | if (api.validateSelectionContext()) { | 103 | if (api.validateSelectionContext()) { |
105 | - api.sendEvent('requestRelatedIntents', { | 104 | + wss.sendEvent('requestRelatedIntents', { |
106 | ids: api.selectOrder(), | 105 | ids: api.selectOrder(), |
107 | hover: hoverValid() ? hov.id : '' | 106 | hover: hoverValid() ? hov.id : '' |
108 | }); | 107 | }); |
... | @@ -114,7 +113,7 @@ | ... | @@ -114,7 +113,7 @@ |
114 | // Traffic requests | 113 | // Traffic requests |
115 | 114 | ||
116 | function cancelTraffic() { | 115 | function cancelTraffic() { |
117 | - api.sendEvent('cancelTraffic'); | 116 | + wss.sendEvent('cancelTraffic'); |
118 | } | 117 | } |
119 | 118 | ||
120 | // invoked in response to change in selection and/or mouseover/out: | 119 | // invoked in response to change in selection and/or mouseover/out: |
... | @@ -132,28 +131,28 @@ | ... | @@ -132,28 +131,28 @@ |
132 | // keystroke-right-arrow (see topo.js) | 131 | // keystroke-right-arrow (see topo.js) |
133 | function showNextIntentAction() { | 132 | function showNextIntentAction() { |
134 | hoverMode = hoverModeNone; | 133 | hoverMode = hoverModeNone; |
135 | - api.sendEvent('requestNextRelatedIntent'); | 134 | + wss.sendEvent('requestNextRelatedIntent'); |
136 | flash.flash('>'); | 135 | flash.flash('>'); |
137 | } | 136 | } |
138 | 137 | ||
139 | // keystroke-left-arrow (see topo.js) | 138 | // keystroke-left-arrow (see topo.js) |
140 | function showPrevIntentAction() { | 139 | function showPrevIntentAction() { |
141 | hoverMode = hoverModeNone; | 140 | hoverMode = hoverModeNone; |
142 | - api.sendEvent('requestPrevRelatedIntent'); | 141 | + wss.sendEvent('requestPrevRelatedIntent'); |
143 | flash.flash('<'); | 142 | flash.flash('<'); |
144 | } | 143 | } |
145 | 144 | ||
146 | // keystroke-W (see topo.js) | 145 | // keystroke-W (see topo.js) |
147 | function showSelectedIntentTrafficAction() { | 146 | function showSelectedIntentTrafficAction() { |
148 | hoverMode = hoverModeNone; | 147 | hoverMode = hoverModeNone; |
149 | - api.sendEvent('requestSelectedIntentTraffic'); | 148 | + wss.sendEvent('requestSelectedIntentTraffic'); |
150 | flash.flash('Traffic on Selected Path'); | 149 | flash.flash('Traffic on Selected Path'); |
151 | } | 150 | } |
152 | 151 | ||
153 | // keystroke-A (see topo.js) | 152 | // keystroke-A (see topo.js) |
154 | function showAllTrafficAction() { | 153 | function showAllTrafficAction() { |
155 | hoverMode = hoverModeAll; | 154 | hoverMode = hoverModeAll; |
156 | - api.sendEvent('requestAllTraffic'); | 155 | + wss.sendEvent('requestAllTraffic'); |
157 | flash.flash('All Traffic'); | 156 | flash.flash('All Traffic'); |
158 | } | 157 | } |
159 | 158 | ||
... | @@ -169,7 +168,7 @@ | ... | @@ -169,7 +168,7 @@ |
169 | 168 | ||
170 | function addHostIntentAction () { | 169 | function addHostIntentAction () { |
171 | var so = api.selectOrder(); | 170 | var so = api.selectOrder(); |
172 | - api.sendEvent('addHostIntent', { | 171 | + wss.sendEvent('addHostIntent', { |
173 | one: so[0], | 172 | one: so[0], |
174 | two: so[1], | 173 | two: so[1], |
175 | ids: so | 174 | ids: so |
... | @@ -179,7 +178,7 @@ | ... | @@ -179,7 +178,7 @@ |
179 | 178 | ||
180 | function addMultiSourceIntentAction () { | 179 | function addMultiSourceIntentAction () { |
181 | var so = api.selectOrder(); | 180 | var so = api.selectOrder(); |
182 | - api.sendEvent('addMultiSourceIntent', { | 181 | + wss.sendEvent('addMultiSourceIntent', { |
183 | src: so.slice(0, so.length - 1), | 182 | src: so.slice(0, so.length - 1), |
184 | dst: so[so.length - 1], | 183 | dst: so[so.length - 1], |
185 | ids: so | 184 | ids: so |
... | @@ -200,12 +199,13 @@ | ... | @@ -200,12 +199,13 @@ |
200 | 199 | ||
201 | angular.module('ovTopo') | 200 | angular.module('ovTopo') |
202 | .factory('TopoTrafficService', | 201 | .factory('TopoTrafficService', |
203 | - ['$log', 'FnService', 'FlashService', | 202 | + ['$log', 'FnService', 'FlashService', 'WebSocketService', |
204 | 203 | ||
205 | - function (_$log_, _fs_, _flash_) { | 204 | + function (_$log_, _fs_, _flash_, _wss_) { |
206 | $log = _$log_; | 205 | $log = _$log_; |
207 | fs = _fs_; | 206 | fs = _fs_; |
208 | flash = _flash_; | 207 | flash = _flash_; |
208 | + wss = _wss_; | ||
209 | 209 | ||
210 | function initTraffic(_api_) { | 210 | function initTraffic(_api_) { |
211 | api = _api_; | 211 | api = _api_; | ... | ... |
-
Please register or login to post a comment