Simon Hunt

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
......@@ -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);
......
......@@ -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');
......
......@@ -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
......
......@@ -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 &#x21e7;';
selOver = 'Select overlay here &#x21e7;',
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
......