GUI -- Link selection showing link details implemented.
- note: basic link data shown for now. will need enhancing. Change-Id: I067edec6f336b5ea5c83c610622346d5fcedce38
Showing
6 changed files
with
196 additions
and
66 deletions
... | @@ -432,9 +432,15 @@ | ... | @@ -432,9 +432,15 @@ |
432 | opacity: .9; | 432 | opacity: .9; |
433 | } | 433 | } |
434 | 434 | ||
435 | +#ov-topo svg .link.selected, | ||
436 | +#ov-topo svg .link.enhanced { | ||
437 | + stroke-width: 4.5px; | ||
438 | +} | ||
439 | +.light #ov-topo svg .link.selected, | ||
435 | .light #ov-topo svg .link.enhanced { | 440 | .light #ov-topo svg .link.enhanced { |
436 | filter: url(#blue-glow); | 441 | filter: url(#blue-glow); |
437 | } | 442 | } |
443 | +.dark #ov-topo svg .link.selected, | ||
438 | .dark #ov-topo svg .link.enhanced { | 444 | .dark #ov-topo svg .link.enhanced { |
439 | filter: url(#yellow-glow); | 445 | filter: url(#yellow-glow); |
440 | } | 446 | } | ... | ... |
... | @@ -29,7 +29,7 @@ | ... | @@ -29,7 +29,7 @@ |
29 | 29 | ||
30 | // references to injected services etc. | 30 | // references to injected services etc. |
31 | var $log, fs, ks, zs, gs, ms, sus, flash, wss, | 31 | var $log, fs, ks, zs, gs, ms, sus, flash, wss, |
32 | - tes, tfs, tps, tis, tss, tts, tos, ttbs; | 32 | + tes, tfs, tps, tis, tss, tls, tts, tos, ttbs; |
33 | 33 | ||
34 | // DOM elements | 34 | // DOM elements |
35 | var ovtopo, svg, defs, zoomLayer, mapG, forceG, noDevsLayer; | 35 | var ovtopo, svg, defs, zoomLayer, mapG, forceG, noDevsLayer; |
... | @@ -45,7 +45,7 @@ | ... | @@ -45,7 +45,7 @@ |
45 | actionMap = { | 45 | actionMap = { |
46 | I: [toggleInstances, 'Toggle ONOS instances pane'], | 46 | I: [toggleInstances, 'Toggle ONOS instances pane'], |
47 | O: [tps.toggleSummary, 'Toggle ONOS summary pane'], | 47 | O: [tps.toggleSummary, 'Toggle ONOS summary pane'], |
48 | - D: [tss.toggleDetails, 'Disable / enable details pane'], | 48 | + D: [tps.toggleDetails, 'Disable / enable details pane'], |
49 | 49 | ||
50 | H: [tfs.toggleHosts, 'Toggle host visibility'], | 50 | H: [tfs.toggleHosts, 'Toggle host visibility'], |
51 | M: [tfs.toggleOffline, 'Toggle offline visibility'], | 51 | M: [tfs.toggleOffline, 'Toggle offline visibility'], |
... | @@ -117,9 +117,13 @@ | ... | @@ -117,9 +117,13 @@ |
117 | // if an instance is selected, cancel the affinity mapping | 117 | // if an instance is selected, cancel the affinity mapping |
118 | tis.cancelAffinity() | 118 | tis.cancelAffinity() |
119 | 119 | ||
120 | - } else if (tss.haveDetails()) { | 120 | + } else if (tss.deselectAll()) { |
121 | // else if we have node selections, deselect them all | 121 | // else if we have node selections, deselect them all |
122 | - tss.deselectAll(); | 122 | + // (work already done) |
123 | + | ||
124 | + } else if (tls.deselectLink()) { | ||
125 | + // else if we have a link selected, deselect it | ||
126 | + // (work already done) | ||
123 | 127 | ||
124 | } else if (tis.isVisible()) { | 128 | } else if (tis.isVisible()) { |
125 | // else if the Instance Panel is visible, hide it | 129 | // else if the Instance Panel is visible, hide it |
... | @@ -238,12 +242,12 @@ | ... | @@ -238,12 +242,12 @@ |
238 | 'GlyphService', 'MapService', 'SvgUtilService', 'FlashService', | 242 | 'GlyphService', 'MapService', 'SvgUtilService', 'FlashService', |
239 | 'WebSocketService', | 243 | 'WebSocketService', |
240 | 'TopoEventService', 'TopoForceService', 'TopoPanelService', | 244 | 'TopoEventService', 'TopoForceService', 'TopoPanelService', |
241 | - 'TopoInstService', 'TopoSelectService', 'TopoTrafficService', | 245 | + 'TopoInstService', 'TopoSelectService', 'TopoLinkService', |
242 | - 'TopoObliqueService', 'TopoToolbarService', | 246 | + 'TopoTrafficService', 'TopoObliqueService', 'TopoToolbarService', |
243 | 247 | ||
244 | - function ($scope, _$log_, $loc, $timeout, _fs_, mast, | 248 | + function ($scope, _$log_, $loc, $timeout, _fs_, mast, _ks_, _zs_, |
245 | - _ks_, _zs_, _gs_, _ms_, _sus_, _flash_, _wss_, | 249 | + _gs_, _ms_, _sus_, _flash_, _wss_, _tes_, _tfs_, _tps_, |
246 | - _tes_, _tfs_, _tps_, _tis_, _tss_, _tts_, _tos_, _ttbs_) { | 250 | + _tis_, _tss_, _tls_, _tts_, _tos_, _ttbs_) { |
247 | var self = this, | 251 | var self = this, |
248 | projection, | 252 | projection, |
249 | dim, | 253 | dim, |
... | @@ -273,6 +277,7 @@ | ... | @@ -273,6 +277,7 @@ |
273 | tps = _tps_; | 277 | tps = _tps_; |
274 | tis = _tis_; | 278 | tis = _tis_; |
275 | tss = _tss_; | 279 | tss = _tss_; |
280 | + tls = _tls_; | ||
276 | tts = _tts_; | 281 | tts = _tts_; |
277 | tos = _tos_; | 282 | tos = _tos_; |
278 | ttbs = _ttbs_; | 283 | ttbs = _ttbs_; | ... | ... |
... | @@ -615,6 +615,7 @@ | ... | @@ -615,6 +615,7 @@ |
615 | d.fixed = true; | 615 | d.fixed = true; |
616 | d3.select(this).classed('fixed', true); | 616 | d3.select(this).classed('fixed', true); |
617 | sendUpdateMeta(d); | 617 | sendUpdateMeta(d); |
618 | + tss.clickConsumed(true); | ||
618 | } | 619 | } |
619 | 620 | ||
620 | // predicate that indicates when dragging is active | 621 | // predicate that indicates when dragging is active |
... | @@ -692,7 +693,8 @@ | ... | @@ -692,7 +693,8 @@ |
692 | return { | 693 | return { |
693 | node: function () { return node; }, | 694 | node: function () { return node; }, |
694 | zoomingOrPanning: zoomingOrPanning, | 695 | zoomingOrPanning: zoomingOrPanning, |
695 | - updateDeviceColors: td3.updateDeviceColors | 696 | + updateDeviceColors: td3.updateDeviceColors, |
697 | + deselectLink: tls.deselectLink | ||
696 | }; | 698 | }; |
697 | } | 699 | } |
698 | 700 | ... | ... |
... | @@ -23,34 +23,35 @@ | ... | @@ -23,34 +23,35 @@ |
23 | 'use strict'; | 23 | 'use strict'; |
24 | 24 | ||
25 | // injected refs | 25 | // injected refs |
26 | - var $log, fs, sus, ts, flash; | 26 | + var $log, fs, sus, ts, flash, tss, tps; |
27 | 27 | ||
28 | + // internal state | ||
28 | var api, | 29 | var api, |
29 | td3, | 30 | td3, |
30 | network, | 31 | network, |
31 | - enhancedLink = null; // the link which the mouse is hovering over | 32 | + showPorts = true, // enable port highlighting by default |
33 | + enhancedLink = null, // the link over which the mouse is hovering | ||
34 | + selectedLink = null; // the link which is currently selected | ||
32 | 35 | ||
33 | // SVG elements; | 36 | // SVG elements; |
34 | var svg; | 37 | var svg; |
35 | 38 | ||
36 | - // internal state | ||
37 | - var showPorts = true; // enable port highlighting by default | ||
38 | - | ||
39 | 39 | ||
40 | // ======== ALGORITHM TO FIND LINK CLOSEST TO MOUSE ======== | 40 | // ======== ALGORITHM TO FIND LINK CLOSEST TO MOUSE ======== |
41 | 41 | ||
42 | - function mouseMoveHandler() { | 42 | + function getLogicalMousePosition(container) { |
43 | - var m = d3.mouse(this), | 43 | + var m = d3.mouse(container), |
44 | sc = api.zoomer.scale(), | 44 | sc = api.zoomer.scale(), |
45 | tr = api.zoomer.translate(), | 45 | tr = api.zoomer.translate(), |
46 | mx = (m[0] - tr[0]) / sc, | 46 | mx = (m[0] - tr[0]) / sc, |
47 | my = (m[1] - tr[1]) / sc; | 47 | my = (m[1] - tr[1]) / sc; |
48 | - computeNearestLink({x: mx, y: my}); | 48 | + return {x: mx, y: my}; |
49 | } | 49 | } |
50 | 50 | ||
51 | function computeNearestLink(mouse) { | 51 | function computeNearestLink(mouse) { |
52 | var proximity = 30 / api.zoomer.scale(), | 52 | var proximity = 30 / api.zoomer.scale(), |
53 | - nearest, minDist; | 53 | + nearest = null, |
54 | + minDist; | ||
54 | 55 | ||
55 | function sq(x) { return x * x; } | 56 | function sq(x) { return x * x; } |
56 | 57 | ||
... | @@ -91,7 +92,6 @@ | ... | @@ -91,7 +92,6 @@ |
91 | } | 92 | } |
92 | 93 | ||
93 | if (network.links.length) { | 94 | if (network.links.length) { |
94 | - nearest = null; | ||
95 | minDist = proximity * 2; | 95 | minDist = proximity * 2; |
96 | 96 | ||
97 | network.links.forEach(function (d) { | 97 | network.links.forEach(function (d) { |
... | @@ -112,13 +112,11 @@ | ... | @@ -112,13 +112,11 @@ |
112 | } | 112 | } |
113 | } | 113 | } |
114 | }); | 114 | }); |
115 | - | ||
116 | - enhanceNearestLink(nearest); | ||
117 | } | 115 | } |
116 | + return nearest; | ||
118 | } | 117 | } |
119 | 118 | ||
120 | - | 119 | + function enhanceLink(ldata) { |
121 | - function enhanceNearestLink(ldata) { | ||
122 | // if the new link is same as old link, do nothing | 120 | // if the new link is same as old link, do nothing |
123 | if (enhancedLink && ldata && enhancedLink.key === ldata.key) return; | 121 | if (enhancedLink && ldata && enhancedLink.key === ldata.key) return; |
124 | 122 | ||
... | @@ -148,7 +146,6 @@ | ... | @@ -148,7 +146,6 @@ |
148 | if (!d.el) return; | 146 | if (!d.el) return; |
149 | 147 | ||
150 | d.el.classed('enhanced', true); | 148 | d.el.classed('enhanced', true); |
151 | - $log.debug('[' + (d.srcPort || 'H') + '] ---> [' + d.tgtPort + ']', d.key); | ||
152 | 149 | ||
153 | // Define port label data objects. | 150 | // Define port label data objects. |
154 | // NOTE: src port is absent in the case of host-links. | 151 | // NOTE: src port is absent in the case of host-links. |
... | @@ -188,6 +185,62 @@ | ... | @@ -188,6 +185,62 @@ |
188 | return {x: k * dx + ln.x, y: k * dy + ln.y}; | 185 | return {x: k * dx + ln.x, y: k * dy + ln.y}; |
189 | } | 186 | } |
190 | 187 | ||
188 | + | ||
189 | + function selectLink(ldata) { | ||
190 | + // if the new link is same as old link, do nothing | ||
191 | + if (selectedLink && ldata && selectedLink.key === ldata.key) return; | ||
192 | + | ||
193 | + // make sure no nodes are selected | ||
194 | + tss.deselectAll(); | ||
195 | + | ||
196 | + // first, unenhance the currently enhanced link | ||
197 | + if (selectedLink) { | ||
198 | + unselLink(selectedLink); | ||
199 | + } | ||
200 | + selectedLink = ldata; | ||
201 | + if (selectedLink) { | ||
202 | + selLink(selectedLink); | ||
203 | + } | ||
204 | + } | ||
205 | + | ||
206 | + function unselLink(d) { | ||
207 | + // guard against link element not set | ||
208 | + if (d.el) { | ||
209 | + d.el.classed('selected', false); | ||
210 | + } | ||
211 | + } | ||
212 | + | ||
213 | + function selLink(d) { | ||
214 | + // guard against link element not set | ||
215 | + if (!d.el) return; | ||
216 | + | ||
217 | + d.el.classed('selected', true); | ||
218 | + | ||
219 | + tps.displayLink(d); | ||
220 | + tps.displaySomething(); | ||
221 | + } | ||
222 | + | ||
223 | + // ====== MOUSE EVENT HANDLERS ====== | ||
224 | + | ||
225 | + function mouseMoveHandler() { | ||
226 | + var mp = getLogicalMousePosition(this), | ||
227 | + link = computeNearestLink(mp); | ||
228 | + enhanceLink(link); | ||
229 | + } | ||
230 | + | ||
231 | + function mouseClickHandler() { | ||
232 | + var mp, link; | ||
233 | + | ||
234 | + if (!tss.clickConsumed()) { | ||
235 | + mp = getLogicalMousePosition(this); | ||
236 | + link = computeNearestLink(mp); | ||
237 | + selectLink(link); | ||
238 | + } | ||
239 | + } | ||
240 | + | ||
241 | + | ||
242 | + // ====================== | ||
243 | + | ||
191 | function togglePorts() { | 244 | function togglePorts() { |
192 | showPorts = !showPorts; | 245 | showPorts = !showPorts; |
193 | 246 | ||
... | @@ -195,25 +248,37 @@ | ... | @@ -195,25 +248,37 @@ |
195 | handler = showPorts ? mouseMoveHandler : null; | 248 | handler = showPorts ? mouseMoveHandler : null; |
196 | 249 | ||
197 | if (!showPorts) { | 250 | if (!showPorts) { |
198 | - enhanceNearestLink(null); | 251 | + enhanceLink(null); |
199 | } | 252 | } |
200 | svg.on('mousemove', handler); | 253 | svg.on('mousemove', handler); |
201 | flash.flash(what + ' port highlighting'); | 254 | flash.flash(what + ' port highlighting'); |
202 | } | 255 | } |
203 | 256 | ||
257 | + function deselectLink() { | ||
258 | + if (selectedLink) { | ||
259 | + unselLink(selectedLink); | ||
260 | + selectedLink = null; | ||
261 | + return true; | ||
262 | + } | ||
263 | + return false; | ||
264 | + } | ||
265 | + | ||
204 | // ========================== | 266 | // ========================== |
205 | // Module definition | 267 | // Module definition |
206 | 268 | ||
207 | angular.module('ovTopo') | 269 | angular.module('ovTopo') |
208 | .factory('TopoLinkService', | 270 | .factory('TopoLinkService', |
209 | ['$log', 'FnService', 'SvgUtilService', 'ThemeService', 'FlashService', | 271 | ['$log', 'FnService', 'SvgUtilService', 'ThemeService', 'FlashService', |
272 | + 'TopoSelectService', 'TopoPanelService', | ||
210 | 273 | ||
211 | - function (_$log_, _fs_, _sus_, _ts_, _flash_) { | 274 | + function (_$log_, _fs_, _sus_, _ts_, _flash_, _tss_, _tps_) { |
212 | $log = _$log_; | 275 | $log = _$log_; |
213 | fs = _fs_; | 276 | fs = _fs_; |
214 | sus = _sus_; | 277 | sus = _sus_; |
215 | ts = _ts_; | 278 | ts = _ts_; |
216 | flash = _flash_; | 279 | flash = _flash_; |
280 | + tss = _tss_; | ||
281 | + tps = _tps_; | ||
217 | 282 | ||
218 | function initLink(_api_, _td3_) { | 283 | function initLink(_api_, _td3_) { |
219 | api = _api_; | 284 | api = _api_; |
... | @@ -223,17 +288,20 @@ | ... | @@ -223,17 +288,20 @@ |
223 | if (showPorts) { | 288 | if (showPorts) { |
224 | svg.on('mousemove', mouseMoveHandler); | 289 | svg.on('mousemove', mouseMoveHandler); |
225 | } | 290 | } |
291 | + svg.on('click', mouseClickHandler); | ||
226 | } | 292 | } |
227 | 293 | ||
228 | function destroyLink() { | 294 | function destroyLink() { |
229 | - // unconditionally remove any mousemove event handler | 295 | + // unconditionally remove any event handlers |
230 | svg.on('mousemove', null); | 296 | svg.on('mousemove', null); |
297 | + svg.on('click', null); | ||
231 | } | 298 | } |
232 | 299 | ||
233 | return { | 300 | return { |
234 | initLink: initLink, | 301 | initLink: initLink, |
235 | destroyLink: destroyLink, | 302 | destroyLink: destroyLink, |
236 | - togglePorts: togglePorts | 303 | + togglePorts: togglePorts, |
304 | + deselectLink: deselectLink | ||
237 | }; | 305 | }; |
238 | }]); | 306 | }]); |
239 | }()); | 307 | }()); | ... | ... |
... | @@ -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, ps, gs, wss; | 26 | + var $log, fs, ps, gs, flash, wss; |
27 | 27 | ||
28 | // constants | 28 | // constants |
29 | var pCls = 'topo-p', | 29 | var pCls = 'topo-p', |
... | @@ -37,6 +37,9 @@ | ... | @@ -37,6 +37,9 @@ |
37 | var summaryPanel, | 37 | var summaryPanel, |
38 | detailPanel; | 38 | detailPanel; |
39 | 39 | ||
40 | + // internal state | ||
41 | + var useDetails = true, // should we show details if we have 'em? | ||
42 | + haveDetails = false; // do we have details that we could show? | ||
40 | 43 | ||
41 | // === ----------------------------------------------------- | 44 | // === ----------------------------------------------------- |
42 | // Utility functions | 45 | // Utility functions |
... | @@ -129,6 +132,42 @@ | ... | @@ -129,6 +132,42 @@ |
129 | .on('click', cb); | 132 | .on('click', cb); |
130 | } | 133 | } |
131 | 134 | ||
135 | + function displayLink(data) { | ||
136 | + detailPanel.empty(); | ||
137 | + | ||
138 | + var svg = dpa('svg'), | ||
139 | + title = dpa('h2'), | ||
140 | + table = dpa('table'), | ||
141 | + tbody = table.append('tbody'); | ||
142 | + | ||
143 | + gs.addGlyph(svg, 'ports', 40); | ||
144 | + title.text('Link'); | ||
145 | + listProps(tbody, { | ||
146 | + propOrder: [ | ||
147 | + 'type', '-', 'src', 'srcPort', '-', 'tgt', 'tgtPort' | ||
148 | + ], | ||
149 | + props: { | ||
150 | + type: data.type(), | ||
151 | + src: data.source.id, | ||
152 | + srcPort: data.srcPort, | ||
153 | + tgt: data.target.id, | ||
154 | + tgtPort: data.tgtPort | ||
155 | + } | ||
156 | + }); | ||
157 | + } | ||
158 | + | ||
159 | + function displayNothing() { | ||
160 | + haveDetails = false; | ||
161 | + hideDetailPanel(); | ||
162 | + } | ||
163 | + | ||
164 | + function displaySomething() { | ||
165 | + haveDetails = true; | ||
166 | + if (useDetails) { | ||
167 | + showDetailPanel(); | ||
168 | + } | ||
169 | + } | ||
170 | + | ||
132 | // === ----------------------------------------------------- | 171 | // === ----------------------------------------------------- |
133 | // Event Handlers | 172 | // Event Handlers |
134 | 173 | ||
... | @@ -201,6 +240,19 @@ | ... | @@ -201,6 +240,19 @@ |
201 | dp.up = function (cb) { dp._move(dp.ypos.up, cb); }; | 240 | dp.up = function (cb) { dp._move(dp.ypos.up, cb); }; |
202 | } | 241 | } |
203 | 242 | ||
243 | + function toggleDetails() { | ||
244 | + useDetails = !useDetails; | ||
245 | + if (useDetails) { | ||
246 | + flash.flash('Enable details panel'); | ||
247 | + if (haveDetails) { | ||
248 | + showDetailPanel(); | ||
249 | + } | ||
250 | + } else { | ||
251 | + flash.flash('Disable details panel'); | ||
252 | + hideDetailPanel(); | ||
253 | + } | ||
254 | + } | ||
255 | + | ||
204 | // ========================== | 256 | // ========================== |
205 | 257 | ||
206 | function initPanels() { | 258 | function initPanels() { |
... | @@ -223,13 +275,15 @@ | ... | @@ -223,13 +275,15 @@ |
223 | 275 | ||
224 | angular.module('ovTopo') | 276 | angular.module('ovTopo') |
225 | .factory('TopoPanelService', | 277 | .factory('TopoPanelService', |
226 | - ['$log', 'FnService', 'PanelService', 'GlyphService', 'WebSocketService', | 278 | + ['$log', 'FnService', 'PanelService', 'GlyphService', |
279 | + 'FlashService', 'WebSocketService', | ||
227 | 280 | ||
228 | - function (_$log_, _fs_, _ps_, _gs_, _wss_) { | 281 | + function (_$log_, _fs_, _ps_, _gs_, _flash_, _wss_) { |
229 | $log = _$log_; | 282 | $log = _$log_; |
230 | fs = _fs_; | 283 | fs = _fs_; |
231 | ps = _ps_; | 284 | ps = _ps_; |
232 | gs = _gs_; | 285 | gs = _gs_; |
286 | + flash = _flash_; | ||
233 | wss = _wss_; | 287 | wss = _wss_; |
234 | 288 | ||
235 | return { | 289 | return { |
... | @@ -239,13 +293,15 @@ | ... | @@ -239,13 +293,15 @@ |
239 | showSummary: showSummary, | 293 | showSummary: showSummary, |
240 | toggleSummary: toggleSummary, | 294 | toggleSummary: toggleSummary, |
241 | 295 | ||
296 | + toggleDetails: toggleDetails, | ||
242 | displaySingle: displaySingle, | 297 | displaySingle: displaySingle, |
243 | displayMulti: displayMulti, | 298 | displayMulti: displayMulti, |
244 | addAction: addAction, | 299 | addAction: addAction, |
300 | + displayLink: displayLink, | ||
301 | + displayNothing: displayNothing, | ||
302 | + displaySomething: displaySomething, | ||
245 | 303 | ||
246 | hideSummaryPanel: hideSummaryPanel, | 304 | hideSummaryPanel: hideSummaryPanel, |
247 | - showDetailPanel: showDetailPanel, | ||
248 | - hideDetailPanel: hideDetailPanel, | ||
249 | 305 | ||
250 | detailVisible: function () { return detailPanel.isVisible(); }, | 306 | detailVisible: function () { return detailPanel.isVisible(); }, |
251 | summaryVisible: function () { return summaryPanel.isVisible(); } | 307 | summaryVisible: function () { return summaryPanel.isVisible(); } | ... | ... |
... | @@ -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, wss, tps, tts; | 26 | + var $log, fs, wss, tps, tts; |
27 | 27 | ||
28 | // api to topoForce | 28 | // api to topoForce |
29 | var api; | 29 | var api; |
... | @@ -31,14 +31,14 @@ | ... | @@ -31,14 +31,14 @@ |
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 | + deselectLink() | ||
34 | */ | 35 | */ |
35 | 36 | ||
36 | // internal state | 37 | // internal state |
37 | var hovered, // the node over which the mouse is hovering | 38 | var hovered, // the node over which the mouse is hovering |
38 | selections = {}, // currently selected nodes (by id) | 39 | selections = {}, // currently selected nodes (by id) |
39 | selectOrder = [], // the order in which we made selections | 40 | selectOrder = [], // the order in which we made selections |
40 | - haveDetails = false, // do we have details of one or more nodes? | 41 | + consumeClick = false; // used to coordinate with SVG click handler |
41 | - useDetails = true; // should we show details if we have 'em? | ||
42 | 42 | ||
43 | // ========================== | 43 | // ========================== |
44 | 44 | ||
... | @@ -101,6 +101,9 @@ | ... | @@ -101,6 +101,9 @@ |
101 | } | 101 | } |
102 | if (!n) return; | 102 | if (!n) return; |
103 | 103 | ||
104 | + consumeClick = true; | ||
105 | + api.deselectLink(); | ||
106 | + | ||
104 | if (ev.shiftKey && n.classed('selected')) { | 107 | if (ev.shiftKey && n.classed('selected')) { |
105 | deselectObject(obj.id); | 108 | deselectObject(obj.id); |
106 | updateDetail(); | 109 | updateDetail(); |
... | @@ -130,12 +133,17 @@ | ... | @@ -130,12 +133,17 @@ |
130 | } | 133 | } |
131 | 134 | ||
132 | function deselectAll() { | 135 | function deselectAll() { |
136 | + var something = (selectOrder.length > 0); | ||
137 | + | ||
133 | // deselect all nodes in the network... | 138 | // deselect all nodes in the network... |
134 | api.node().classed('selected', false); | 139 | api.node().classed('selected', false); |
135 | selections = {}; | 140 | selections = {}; |
136 | selectOrder = []; | 141 | selectOrder = []; |
137 | api.updateDeviceColors(); | 142 | api.updateDeviceColors(); |
138 | updateDetail(); | 143 | updateDetail(); |
144 | + | ||
145 | + // return true if something was selected | ||
146 | + return something; | ||
139 | } | 147 | } |
140 | 148 | ||
141 | // === ----------------------------------------------------- | 149 | // === ----------------------------------------------------- |
... | @@ -162,9 +170,8 @@ | ... | @@ -162,9 +170,8 @@ |
162 | } | 170 | } |
163 | 171 | ||
164 | function emptySelect() { | 172 | function emptySelect() { |
165 | - haveDetails = false; | ||
166 | - tps.hideDetailPanel(); | ||
167 | tts.cancelTraffic(); | 173 | tts.cancelTraffic(); |
174 | + tps.displayNothing(); | ||
168 | } | 175 | } |
169 | 176 | ||
170 | function singleSelect() { | 177 | function singleSelect() { |
... | @@ -175,8 +182,6 @@ | ... | @@ -175,8 +182,6 @@ |
175 | } | 182 | } |
176 | 183 | ||
177 | function multiSelect() { | 184 | function multiSelect() { |
178 | - haveDetails = true; | ||
179 | - | ||
180 | // display the selected nodes in the detail panel | 185 | // display the selected nodes in the detail panel |
181 | tps.displayMulti(selectOrder); | 186 | tps.displayMulti(selectOrder); |
182 | 187 | ||
... | @@ -192,6 +197,7 @@ | ... | @@ -192,6 +197,7 @@ |
192 | 197 | ||
193 | tts.cancelTraffic(); | 198 | tts.cancelTraffic(); |
194 | tts.requestTrafficForMode(); | 199 | tts.requestTrafficForMode(); |
200 | + tps.displaySomething(); | ||
195 | } | 201 | } |
196 | 202 | ||
197 | 203 | ||
... | @@ -199,8 +205,6 @@ | ... | @@ -199,8 +205,6 @@ |
199 | // Event Handlers | 205 | // Event Handlers |
200 | 206 | ||
201 | function showDetails(data) { | 207 | function showDetails(data) { |
202 | - haveDetails = true; | ||
203 | - | ||
204 | // display the data for the single selected node | 208 | // display the data for the single selected node |
205 | tps.displaySingle(data); | 209 | tps.displaySingle(data); |
206 | 210 | ||
... | @@ -212,23 +216,7 @@ | ... | @@ -212,23 +216,7 @@ |
212 | tps.addAction('Show Device Flows', tts.showDeviceLinkFlowsAction); | 216 | tps.addAction('Show Device Flows', tts.showDeviceLinkFlowsAction); |
213 | } | 217 | } |
214 | 218 | ||
215 | - // only show the details panel if the user hasn't "hidden" it | 219 | + tps.displaySomething(); |
216 | - if (useDetails) { | ||
217 | - tps.showDetailPanel(); | ||
218 | - } | ||
219 | - } | ||
220 | - | ||
221 | - function toggleDetails() { | ||
222 | - useDetails = !useDetails; | ||
223 | - if (useDetails) { | ||
224 | - flash.flash('Enable details panel'); | ||
225 | - if (haveDetails) { | ||
226 | - tps.showDetailPanel(); | ||
227 | - } | ||
228 | - } else { | ||
229 | - flash.flash('Disable details panel'); | ||
230 | - tps.hideDetailPanel(); | ||
231 | - } | ||
232 | } | 220 | } |
233 | 221 | ||
234 | function validateSelectionContext() { | 222 | function validateSelectionContext() { |
... | @@ -239,18 +227,23 @@ | ... | @@ -239,18 +227,23 @@ |
239 | return true; | 227 | return true; |
240 | } | 228 | } |
241 | 229 | ||
230 | + function clickConsumed(x) { | ||
231 | + var cc = consumeClick; | ||
232 | + consumeClick = !!x; | ||
233 | + return cc; | ||
234 | + } | ||
235 | + | ||
242 | // === ----------------------------------------------------- | 236 | // === ----------------------------------------------------- |
243 | // === MODULE DEFINITION === | 237 | // === MODULE DEFINITION === |
244 | 238 | ||
245 | angular.module('ovTopo') | 239 | angular.module('ovTopo') |
246 | .factory('TopoSelectService', | 240 | .factory('TopoSelectService', |
247 | - ['$log', 'FnService', 'FlashService', 'WebSocketService', | 241 | + ['$log', 'FnService', 'WebSocketService', |
248 | 'TopoPanelService', 'TopoTrafficService', | 242 | 'TopoPanelService', 'TopoTrafficService', |
249 | 243 | ||
250 | - function (_$log_, _fs_, _flash_, _wss_, _tps_, _tts_) { | 244 | + function (_$log_, _fs_, _wss_, _tps_, _tts_) { |
251 | $log = _$log_; | 245 | $log = _$log_; |
252 | fs = _fs_; | 246 | fs = _fs_; |
253 | - flash = _flash_; | ||
254 | wss = _wss_; | 247 | wss = _wss_; |
255 | tps = _tps_; | 248 | tps = _tps_; |
256 | tts = _tts_; | 249 | tts = _tts_; |
... | @@ -266,7 +259,6 @@ | ... | @@ -266,7 +259,6 @@ |
266 | destroySelect: destroySelect, | 259 | destroySelect: destroySelect, |
267 | 260 | ||
268 | showDetails: showDetails, | 261 | showDetails: showDetails, |
269 | - toggleDetails: toggleDetails, | ||
270 | 262 | ||
271 | nodeMouseOver: nodeMouseOver, | 263 | nodeMouseOver: nodeMouseOver, |
272 | nodeMouseOut: nodeMouseOut, | 264 | nodeMouseOut: nodeMouseOut, |
... | @@ -275,9 +267,10 @@ | ... | @@ -275,9 +267,10 @@ |
275 | deselectAll: deselectAll, | 267 | deselectAll: deselectAll, |
276 | 268 | ||
277 | hovered: function () { return hovered; }, | 269 | hovered: function () { return hovered; }, |
278 | - haveDetails: function () { return haveDetails; }, | ||
279 | selectOrder: function () { return selectOrder; }, | 270 | selectOrder: function () { return selectOrder; }, |
280 | - validateSelectionContext: validateSelectionContext | 271 | + validateSelectionContext: validateSelectionContext, |
272 | + | ||
273 | + clickConsumed: clickConsumed | ||
281 | }; | 274 | }; |
282 | }]); | 275 | }]); |
283 | }()); | 276 | }()); | ... | ... |
-
Please register or login to post a comment