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
This commit is contained in:
Simon Hunt 2016-08-18 16:16:19 -07:00
parent 7c298f3e9e
commit 7faabd5102
3 changed files with 31 additions and 12 deletions

View File

@ -29,9 +29,9 @@
]; ];
// references to injected services // references to injected services
var $scope, $log, $cookies, $loc, fs, ks, zs, gs, ms, sus, flash, wss, ps, th, var $scope, $log, $loc, $timeout, $cookies,
tds, t3s, tes, tfs, tps, tis, tms, tss, tls, tts, tos, fltr, ttbs, tspr, fs, ks, zs, gs, ms, sus, flash, wss, ps, th, tds, t3s, tes, tfs, tps,
ttip, tov; tis, tms, tss, tls, tts, tos, fltr, ttbs, tspr, ttip, tov;
// DOM elements // DOM elements
var ovtopo, svg, defs, zoomLayer, mapG, spriteG, forceG, noDevsLayer; var ovtopo, svg, defs, zoomLayer, mapG, spriteG, forceG, noDevsLayer;
@ -508,9 +508,14 @@
function topoStartDone() { function topoStartDone() {
var d = $scope.intentData; var d = $scope.intentData;
// give a small delay before attempting to reselect node(s) and stuff
// since they have to be re-added to the DOM first...
$timeout(function () {
tss.reselect();
if (d) { if (d) {
tts.selectIntent(d); tts.selectIntent(d);
} }
}, 200);
} }
// --- Controller Definition ----------------------------------------- // --- Controller Definition -----------------------------------------
@ -527,7 +532,7 @@
'TopoToolbarService', 'TopoMapService', 'TopoSpriteService', 'TopoToolbarService', 'TopoMapService', 'TopoSpriteService',
'TooltipService', 'TopoOverlayService', 'TooltipService', 'TopoOverlayService',
function (_$scope_, _$log_, _$loc_, $timeout, _$cookies_, _fs_, mast, _ks_, function (_$scope_, _$log_, _$loc_, _$timeout_, _$cookies_, _fs_, mast, _ks_,
_zs_, _gs_, _ms_, _sus_, _flash_, _wss_, _ps_, _th_, _zs_, _gs_, _ms_, _sus_, _flash_, _wss_, _ps_, _th_,
_tds_, _t3s_, _tes_, _tds_, _t3s_, _tes_,
_tfs_, _tps_, _tis_, _tss_, _tls_, _tts_, _tos_, _fltr_, _tfs_, _tps_, _tis_, _tss_, _tls_, _tts_, _tos_, _fltr_,
@ -548,6 +553,7 @@
$scope = _$scope_; $scope = _$scope_;
$log = _$log_; $log = _$log_;
$loc = _$loc_; $loc = _$loc_;
$timeout = _$timeout_;
$cookies = _$cookies_; $cookies = _$cookies_;
fs = _fs_; fs = _fs_;
ks = _ks_; ks = _ks_;

View File

@ -23,7 +23,7 @@
'use strict'; 'use strict';
// injected refs // injected refs
var $log, fs, wss, tov, tps, tts, ns; var $log, fs, wss, tov, tps, tts, ns, sus;
// api to topoForce // api to topoForce
var api; var api;
@ -133,6 +133,14 @@
updateDetail(); updateDetail();
} }
function reselect() {
selectOrder.forEach(function (id) {
var sel = d3.select('g#' + sus.safeId(id));
sel.classed('selected', true);
});
updateDetail();
}
function deselectObject(id) { function deselectObject(id) {
var obj = selections[id]; var obj = selections[id];
if (obj) { if (obj) {
@ -280,8 +288,9 @@
.factory('TopoSelectService', .factory('TopoSelectService',
['$log', 'FnService', 'WebSocketService', 'TopoOverlayService', ['$log', 'FnService', 'WebSocketService', 'TopoOverlayService',
'TopoPanelService', 'TopoTrafficService', 'NavService', 'TopoPanelService', 'TopoTrafficService', 'NavService',
'SvgUtilService',
function (_$log_, _fs_, _wss_, _tov_, _tps_, _tts_, _ns_) { function (_$log_, _fs_, _wss_, _tov_, _tps_, _tts_, _ns_, _sus_) {
$log = _$log_; $log = _$log_;
fs = _fs_; fs = _fs_;
wss = _wss_; wss = _wss_;
@ -289,11 +298,14 @@
tps = _tps_; tps = _tps_;
tts = _tts_; tts = _tts_;
ns = _ns_; ns = _ns_;
sus = _sus_;
function initSelect(_api_) { function initSelect(_api_) {
api = _api_; api = _api_;
if (!selections) {
setInitialState(); setInitialState();
} }
}
function destroySelect() { } function destroySelect() { }
@ -315,7 +327,8 @@
somethingSelected: somethingSelected, somethingSelected: somethingSelected,
clickConsumed: clickConsumed, clickConsumed: clickConsumed,
selectionContext: selectionContext selectionContext: selectionContext,
reselect: reselect
}; };
}]); }]);
}()); }());

View File

@ -43,7 +43,7 @@ describe('factory: view/topo/topoSelect.js', function() {
'deselectAll', 'updateDetail', 'deselectAll', 'updateDetail',
'hovered', 'selectOrder', 'hovered', 'selectOrder',
'somethingSelected', 'somethingSelected',
'clickConsumed', 'selectionContext' 'clickConsumed', 'selectionContext', 'reselect'
])).toBeTruthy(); ])).toBeTruthy();
}); });