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 @@ ...@@ -224,7 +224,9 @@
224 } else { 224 } else {
225 if (x >= 0 && x < rads.length) { 225 if (x >= 0 && x < rads.length) {
226 if (currIdx !== x) { 226 if (currIdx !== x) {
227 + rads[currIdx].el.classed('selected', false);
227 currIdx = x; 228 currIdx = x;
229 + rads[currIdx].el.classed('selected', true);
228 invokeCurrent(); 230 invokeCurrent();
229 } else { 231 } else {
230 $log.warn('current index already selected:', x); 232 $log.warn('current index already selected:', x);
......
...@@ -525,6 +525,7 @@ ...@@ -525,6 +525,7 @@
525 525
526 // temporary solution for persisting user settings 526 // temporary solution for persisting user settings
527 restoreConfigFromPrefs(); 527 restoreConfigFromPrefs();
528 + ttbs.setDefaultOverlay();
528 529
529 $log.debug('registered overlays...', tov.list()); 530 $log.debug('registered overlays...', tov.list());
530 $log.log('OvTopoCtrl has been created'); 531 $log.log('OvTopoCtrl has been created');
......
...@@ -113,7 +113,11 @@ ...@@ -113,7 +113,11 @@
113 } 113 }
114 114
115 // add a radio button for each registered overlay 115 // add a radio button for each registered overlay
116 + // return an overlay id to index map
116 function augmentRbset(rset, switchFn) { 117 function augmentRbset(rset, switchFn) {
118 + var map = {},
119 + idx = 1;
120 +
117 angular.forEach(overlays, function (ov) { 121 angular.forEach(overlays, function (ov) {
118 rset.push({ 122 rset.push({
119 gid: ov._glyphId, 123 gid: ov._glyphId,
...@@ -122,7 +126,9 @@ ...@@ -122,7 +126,9 @@
122 tbSelection(ov.overlayId, switchFn); 126 tbSelection(ov.overlayId, switchFn);
123 } 127 }
124 }); 128 });
129 + map[ov.overlayId] = idx++;
125 }); 130 });
131 + return map;
126 } 132 }
127 133
128 // an overlay was selected via toolbar radio button press from user 134 // an overlay was selected via toolbar radio button press from user
......
...@@ -30,13 +30,14 @@ ...@@ -30,13 +30,14 @@
30 // setUpKeys 30 // setUpKeys
31 31
32 // internal state 32 // internal state
33 - var toolbar, keyData, cachedState, thirdRow; 33 + var toolbar, keyData, cachedState, thirdRow, ovRset, ovIndex;
34 34
35 // constants 35 // constants
36 var name = 'topo-tbar', 36 var name = 'topo-tbar',
37 cooktag = 'topo_prefs', 37 cooktag = 'topo_prefs',
38 soa = 'switchOverlayActions: ', 38 soa = 'switchOverlayActions: ',
39 - selOver = 'Select overlay here &#x21e7;'; 39 + selOver = 'Select overlay here &#x21e7;',
40 + defaultOverlay = 'traffic';
40 41
41 42
42 // key to button mapping data 43 // key to button mapping data
...@@ -172,8 +173,8 @@ ...@@ -172,8 +173,8 @@
172 tov.tbSelection(null, switchOverlayActions); 173 tov.tbSelection(null, switchOverlayActions);
173 } 174 }
174 }]; 175 }];
175 - tov.augmentRbset(rset, switchOverlayActions); 176 + ovIndex = tov.augmentRbset(rset, switchOverlayActions);
176 - toolbar.addRadioSet('topo-overlays', rset); 177 + ovRset = toolbar.addRadioSet('topo-overlays', rset);
177 } 178 }
178 179
179 // invoked by overlay service to switch out old buttons and switch in new 180 // invoked by overlay service to switch out old buttons and switch in new
...@@ -261,6 +262,11 @@ ...@@ -261,6 +262,11 @@
261 toolbar.toggle(); 262 toolbar.toggle();
262 } 263 }
263 264
265 + function setDefaultOverlay() {
266 + var idx = ovIndex[defaultOverlay] || 0;
267 + ovRset.selectedIndex(idx);
268 + }
269 +
264 angular.module('ovTopo') 270 angular.module('ovTopo')
265 .factory('TopoToolbarService', 271 .factory('TopoToolbarService',
266 ['$log', 'FnService', 'ToolbarService', 'PrefsService', 272 ['$log', 'FnService', 'ToolbarService', 'PrefsService',
...@@ -278,7 +284,8 @@ ...@@ -278,7 +284,8 @@
278 createToolbar: createToolbar, 284 createToolbar: createToolbar,
279 destroyToolbar: destroyToolbar, 285 destroyToolbar: destroyToolbar,
280 keyListener: keyListener, 286 keyListener: keyListener,
281 - toggleToolbar: toggleToolbar 287 + toggleToolbar: toggleToolbar,
288 + setDefaultOverlay: setDefaultOverlay
282 }; 289 };
283 }]); 290 }]);
284 }()); 291 }());
...\ No newline at end of file ...\ No newline at end of file
......