ONOS-3128 : Web UI - Traffic overlay as default overlay.
- fixed bug in radiobuttonset which failed to update button selection state via programmatic selectedIndex() call.
- default overlay configured at beginning of topoToolbar.js
Change-Id: I54c82e402b3c3955c3d83a264c6d8ac14127ce70
diff --git a/web/gui/src/main/webapp/app/fw/widget/button.js b/web/gui/src/main/webapp/app/fw/widget/button.js
index 09cdd43..2ef5b4b 100644
--- a/web/gui/src/main/webapp/app/fw/widget/button.js
+++ b/web/gui/src/main/webapp/app/fw/widget/button.js
@@ -224,7 +224,9 @@
} else {
if (x >= 0 && x < rads.length) {
if (currIdx !== x) {
+ rads[currIdx].el.classed('selected', false);
currIdx = x;
+ rads[currIdx].el.classed('selected', true);
invokeCurrent();
} else {
$log.warn('current index already selected:', x);
diff --git a/web/gui/src/main/webapp/app/view/topo/topo.js b/web/gui/src/main/webapp/app/view/topo/topo.js
index 42b6f4b..0dfd628 100644
--- a/web/gui/src/main/webapp/app/view/topo/topo.js
+++ b/web/gui/src/main/webapp/app/view/topo/topo.js
@@ -525,6 +525,7 @@
// temporary solution for persisting user settings
restoreConfigFromPrefs();
+ ttbs.setDefaultOverlay();
$log.debug('registered overlays...', tov.list());
$log.log('OvTopoCtrl has been created');
diff --git a/web/gui/src/main/webapp/app/view/topo/topoOverlay.js b/web/gui/src/main/webapp/app/view/topo/topoOverlay.js
index 0b3b88d..74fa2f2 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoOverlay.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoOverlay.js
@@ -113,7 +113,11 @@
}
// add a radio button for each registered overlay
+ // return an overlay id to index map
function augmentRbset(rset, switchFn) {
+ var map = {},
+ idx = 1;
+
angular.forEach(overlays, function (ov) {
rset.push({
gid: ov._glyphId,
@@ -122,7 +126,9 @@
tbSelection(ov.overlayId, switchFn);
}
});
+ map[ov.overlayId] = idx++;
});
+ return map;
}
// an overlay was selected via toolbar radio button press from user
diff --git a/web/gui/src/main/webapp/app/view/topo/topoToolbar.js b/web/gui/src/main/webapp/app/view/topo/topoToolbar.js
index 84de261..3928cd2 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoToolbar.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoToolbar.js
@@ -30,13 +30,14 @@
// setUpKeys
// internal state
- var toolbar, keyData, cachedState, thirdRow;
+ var toolbar, keyData, cachedState, thirdRow, ovRset, ovIndex;
// constants
var name = 'topo-tbar',
cooktag = 'topo_prefs',
soa = 'switchOverlayActions: ',
- selOver = 'Select overlay here ⇧';
+ selOver = 'Select overlay here ⇧',
+ defaultOverlay = 'traffic';
// key to button mapping data
@@ -172,8 +173,8 @@
tov.tbSelection(null, switchOverlayActions);
}
}];
- tov.augmentRbset(rset, switchOverlayActions);
- toolbar.addRadioSet('topo-overlays', rset);
+ ovIndex = tov.augmentRbset(rset, switchOverlayActions);
+ ovRset = toolbar.addRadioSet('topo-overlays', rset);
}
// invoked by overlay service to switch out old buttons and switch in new
@@ -261,6 +262,11 @@
toolbar.toggle();
}
+ function setDefaultOverlay() {
+ var idx = ovIndex[defaultOverlay] || 0;
+ ovRset.selectedIndex(idx);
+ }
+
angular.module('ovTopo')
.factory('TopoToolbarService',
['$log', 'FnService', 'ToolbarService', 'PrefsService',
@@ -278,7 +284,8 @@
createToolbar: createToolbar,
destroyToolbar: destroyToolbar,
keyListener: keyListener,
- toggleToolbar: toggleToolbar
+ toggleToolbar: toggleToolbar,
+ setDefaultOverlay: setDefaultOverlay
};
}]);
}());
\ No newline at end of file