ONOS-2582 : fix for reselecting previously selected nodes in the topology view.
Note that this also fixes the race condition with showing selected intent. Change-Id: Icf3cd168bca985136d3ca6c63d98aa193a476d00
Showing
3 changed files
with
27 additions
and
8 deletions
... | @@ -29,9 +29,9 @@ | ... | @@ -29,9 +29,9 @@ |
29 | ]; | 29 | ]; |
30 | 30 | ||
31 | // references to injected services | 31 | // references to injected services |
32 | - var $scope, $log, $cookies, $loc, fs, ks, zs, gs, ms, sus, flash, wss, ps, th, | 32 | + var $scope, $log, $loc, $timeout, $cookies, |
33 | - tds, t3s, tes, tfs, tps, tis, tms, tss, tls, tts, tos, fltr, ttbs, tspr, | 33 | + fs, ks, zs, gs, ms, sus, flash, wss, ps, th, tds, t3s, tes, tfs, tps, |
34 | - ttip, tov; | 34 | + tis, tms, tss, tls, tts, tos, fltr, ttbs, tspr, ttip, tov; |
35 | 35 | ||
36 | // DOM elements | 36 | // DOM elements |
37 | var ovtopo, svg, defs, zoomLayer, mapG, spriteG, forceG, noDevsLayer; | 37 | var ovtopo, svg, defs, zoomLayer, mapG, spriteG, forceG, noDevsLayer; |
... | @@ -508,9 +508,14 @@ | ... | @@ -508,9 +508,14 @@ |
508 | 508 | ||
509 | function topoStartDone() { | 509 | function topoStartDone() { |
510 | var d = $scope.intentData; | 510 | var d = $scope.intentData; |
511 | + // give a small delay before attempting to reselect node(s) and stuff | ||
512 | + // since they have to be re-added to the DOM first... | ||
513 | + $timeout(function () { | ||
514 | + tss.reselect(); | ||
511 | if (d) { | 515 | if (d) { |
512 | tts.selectIntent(d); | 516 | tts.selectIntent(d); |
513 | } | 517 | } |
518 | + }, 200); | ||
514 | } | 519 | } |
515 | 520 | ||
516 | // --- Controller Definition ----------------------------------------- | 521 | // --- Controller Definition ----------------------------------------- |
... | @@ -527,7 +532,7 @@ | ... | @@ -527,7 +532,7 @@ |
527 | 'TopoToolbarService', 'TopoMapService', 'TopoSpriteService', | 532 | 'TopoToolbarService', 'TopoMapService', 'TopoSpriteService', |
528 | 'TooltipService', 'TopoOverlayService', | 533 | 'TooltipService', 'TopoOverlayService', |
529 | 534 | ||
530 | - function (_$scope_, _$log_, _$loc_, $timeout, _$cookies_, _fs_, mast, _ks_, | 535 | + function (_$scope_, _$log_, _$loc_, _$timeout_, _$cookies_, _fs_, mast, _ks_, |
531 | _zs_, _gs_, _ms_, _sus_, _flash_, _wss_, _ps_, _th_, | 536 | _zs_, _gs_, _ms_, _sus_, _flash_, _wss_, _ps_, _th_, |
532 | _tds_, _t3s_, _tes_, | 537 | _tds_, _t3s_, _tes_, |
533 | _tfs_, _tps_, _tis_, _tss_, _tls_, _tts_, _tos_, _fltr_, | 538 | _tfs_, _tps_, _tis_, _tss_, _tls_, _tts_, _tos_, _fltr_, |
... | @@ -548,6 +553,7 @@ | ... | @@ -548,6 +553,7 @@ |
548 | $scope = _$scope_; | 553 | $scope = _$scope_; |
549 | $log = _$log_; | 554 | $log = _$log_; |
550 | $loc = _$loc_; | 555 | $loc = _$loc_; |
556 | + $timeout = _$timeout_; | ||
551 | $cookies = _$cookies_; | 557 | $cookies = _$cookies_; |
552 | fs = _fs_; | 558 | fs = _fs_; |
553 | ks = _ks_; | 559 | ks = _ks_; | ... | ... |
... | @@ -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, wss, tov, tps, tts, ns; | 26 | + var $log, fs, wss, tov, tps, tts, ns, sus; |
27 | 27 | ||
28 | // api to topoForce | 28 | // api to topoForce |
29 | var api; | 29 | var api; |
... | @@ -133,6 +133,14 @@ | ... | @@ -133,6 +133,14 @@ |
133 | updateDetail(); | 133 | updateDetail(); |
134 | } | 134 | } |
135 | 135 | ||
136 | + function reselect() { | ||
137 | + selectOrder.forEach(function (id) { | ||
138 | + var sel = d3.select('g#' + sus.safeId(id)); | ||
139 | + sel.classed('selected', true); | ||
140 | + }); | ||
141 | + updateDetail(); | ||
142 | + } | ||
143 | + | ||
136 | function deselectObject(id) { | 144 | function deselectObject(id) { |
137 | var obj = selections[id]; | 145 | var obj = selections[id]; |
138 | if (obj) { | 146 | if (obj) { |
... | @@ -280,8 +288,9 @@ | ... | @@ -280,8 +288,9 @@ |
280 | .factory('TopoSelectService', | 288 | .factory('TopoSelectService', |
281 | ['$log', 'FnService', 'WebSocketService', 'TopoOverlayService', | 289 | ['$log', 'FnService', 'WebSocketService', 'TopoOverlayService', |
282 | 'TopoPanelService', 'TopoTrafficService', 'NavService', | 290 | 'TopoPanelService', 'TopoTrafficService', 'NavService', |
291 | + 'SvgUtilService', | ||
283 | 292 | ||
284 | - function (_$log_, _fs_, _wss_, _tov_, _tps_, _tts_, _ns_) { | 293 | + function (_$log_, _fs_, _wss_, _tov_, _tps_, _tts_, _ns_, _sus_) { |
285 | $log = _$log_; | 294 | $log = _$log_; |
286 | fs = _fs_; | 295 | fs = _fs_; |
287 | wss = _wss_; | 296 | wss = _wss_; |
... | @@ -289,11 +298,14 @@ | ... | @@ -289,11 +298,14 @@ |
289 | tps = _tps_; | 298 | tps = _tps_; |
290 | tts = _tts_; | 299 | tts = _tts_; |
291 | ns = _ns_; | 300 | ns = _ns_; |
301 | + sus = _sus_; | ||
292 | 302 | ||
293 | function initSelect(_api_) { | 303 | function initSelect(_api_) { |
294 | api = _api_; | 304 | api = _api_; |
305 | + if (!selections) { | ||
295 | setInitialState(); | 306 | setInitialState(); |
296 | } | 307 | } |
308 | + } | ||
297 | 309 | ||
298 | function destroySelect() { } | 310 | function destroySelect() { } |
299 | 311 | ||
... | @@ -315,7 +327,8 @@ | ... | @@ -315,7 +327,8 @@ |
315 | somethingSelected: somethingSelected, | 327 | somethingSelected: somethingSelected, |
316 | 328 | ||
317 | clickConsumed: clickConsumed, | 329 | clickConsumed: clickConsumed, |
318 | - selectionContext: selectionContext | 330 | + selectionContext: selectionContext, |
331 | + reselect: reselect | ||
319 | }; | 332 | }; |
320 | }]); | 333 | }]); |
321 | }()); | 334 | }()); | ... | ... |
... | @@ -43,7 +43,7 @@ describe('factory: view/topo/topoSelect.js', function() { | ... | @@ -43,7 +43,7 @@ describe('factory: view/topo/topoSelect.js', function() { |
43 | 'deselectAll', 'updateDetail', | 43 | 'deselectAll', 'updateDetail', |
44 | 'hovered', 'selectOrder', | 44 | 'hovered', 'selectOrder', |
45 | 'somethingSelected', | 45 | 'somethingSelected', |
46 | - 'clickConsumed', 'selectionContext' | 46 | + 'clickConsumed', 'selectionContext', 'reselect' |
47 | ])).toBeTruthy(); | 47 | ])).toBeTruthy(); |
48 | }); | 48 | }); |
49 | 49 | ... | ... |
-
Please register or login to post a comment