Simon Hunt

ONOS-4805: Choice of selected overlay persisted server side -- restored across login sessions.

Change-Id: I17e0e06a2fcc33958ffd42cd51acb42a302de57e
...@@ -652,9 +652,8 @@ ...@@ -652,9 +652,8 @@
652 tis.initInst({ showMastership: tfs.showMastership }); 652 tis.initInst({ showMastership: tfs.showMastership });
653 tps.initPanels(); 653 tps.initPanels();
654 654
655 - // temporary solution for persisting user settings
656 restoreConfigFromPrefs(); 655 restoreConfigFromPrefs();
657 - ttbs.setDefaultOverlay(); 656 + ttbs.setDefaultOverlay(prefsState.ovidx);
658 657
659 $log.debug('registered overlays...', tov.list()); 658 $log.debug('registered overlays...', tov.list());
660 $log.log('OvTopoCtrl has been created'); 659 $log.log('OvTopoCtrl has been created');
......
...@@ -80,6 +80,7 @@ ...@@ -80,6 +80,7 @@
80 porthl: 1, 80 porthl: 1,
81 bg: 0, 81 bg: 0,
82 spr: 0, 82 spr: 0,
83 + ovidx: 1, // default to traffic overlay
83 toolbar: 0 84 toolbar: 0
84 }, 85 },
85 prefsMap = { 86 prefsMap = {
...@@ -199,6 +200,9 @@ ...@@ -199,6 +200,9 @@
199 tds.closeDialog(); 200 tds.closeDialog();
200 thirdRow.clear(); 201 thirdRow.clear();
201 202
203 + // persist our choice of overlay...
204 + persistTopoPrefs('ovidx', ovIndex[oid] || 0);
205 +
202 if (!order.length) { 206 if (!order.length) {
203 thirdRow.setText(selOver); 207 thirdRow.setText(selOver);
204 thirdRow.classed('right', true); 208 thirdRow.classed('right', true);
...@@ -264,15 +268,22 @@ ...@@ -264,15 +268,22 @@
264 } 268 }
265 } 269 }
266 270
267 - function toggleToolbar() { 271 + function persistTopoPrefs(key, val) {
268 - toolbar.toggle();
269 var prefs = ps.getPrefs(cooktag, defaultPrefsState); 272 var prefs = ps.getPrefs(cooktag, defaultPrefsState);
270 - prefs.toolbar = !prefs.toolbar; 273 + prefs[key] = val === undefined ? !prefs[key] : val;
271 ps.setPrefs('topo_prefs', prefs); 274 ps.setPrefs('topo_prefs', prefs);
272 } 275 }
273 276
274 - function setDefaultOverlay() { 277 + function toggleToolbar() {
278 + toolbar.toggle();
279 + persistTopoPrefs('toolbar');
280 + }
281 +
282 + function setDefaultOverlay(prefsIdx) {
275 var idx = ovIndex[defaultOverlay] || 0; 283 var idx = ovIndex[defaultOverlay] || 0;
284 + if (prefsIdx >= 0 && prefsIdx < ovRset.size()) {
285 + idx = prefsIdx;
286 + }
276 ovRset.selectedIndex(idx); 287 ovRset.selectedIndex(idx);
277 } 288 }
278 289
......