Simon Hunt
Committed by Gerrit Code Review

GUI -- toggle state for some of the topo buttons, now persisted via cookie.

Change-Id: Ie80c840635fcc7b87705d73abf77b7bc6df03f18
......@@ -125,6 +125,7 @@
} else {
showPanel(cb);
}
return p.on;
}
function emptyPanel() {
......
......@@ -45,8 +45,8 @@
// thus, deferred to here...
actionMap = {
I: [toggleInstances, 'Toggle ONOS instances panel'],
O: [tps.toggleSummary, 'Toggle ONOS summary panel'],
D: [tps.toggleDetails, 'Disable / enable details panel'],
O: [toggleSummary, 'Toggle ONOS summary panel'],
D: [toggleDetails, 'Disable / enable details panel'],
H: [tfs.toggleHosts, 'Toggle host visibility'],
M: [tfs.toggleOffline, 'Toggle offline visibility'],
......@@ -95,28 +95,27 @@
// --- Keystroke functions -------------------------------------------
// NOTE: this really belongs in the TopoPanelService -- but how to
// cleanly link in the updateDeviceColors() call? To be fixed later.
function toggleInstances(x) {
if (x === 'keyev') {
tis.toggle();
updatePrefsState('insts', tis.isVisible());
} else if (x) {
tis.show();
} else {
tis.hide();
}
updatePrefsState('insts', tis.toggle(x));
tfs.updateDeviceColors();
}
function toggleSummary(x) {
updatePrefsState('summary', tps.toggleSummary(x));
}
function toggleDetails(x) {
updatePrefsState('detail', tps.toggleDetails(x));
}
function toggleMap(x) {
var on = (x === 'keyev') ? !sus.visible(mapG) : !!x;
var on = (x === 'keyev') ? !sus.visible(mapG) : !!x,
verb = on ? 'Show' : 'Hide';
sus.visible(mapG, on);
updatePrefsState('bg', on);
flash.flash(verb + ' background map');
}
// TODO: need wrapper functions for state changes needed in cookies
function resetZoom() {
zoomer.reset();
}
......@@ -250,20 +249,8 @@
// --- User Preferemces ----------------------------------------------
var defaultPrefsState = {
bg: 1,
insts: 1,
summary: 1,
detail: 1,
hosts: 0
};
var prefsState = {};
function topoDefPrefs() {
return angular.extend({}, defaultPrefsState);
}
function updatePrefsState(what, b) {
prefsState[what] = b ? 1 : 0;
ps.setPrefs('topo_prefs', prefsState);
......@@ -277,8 +264,8 @@
$log.debug('TOPO---- Prefs State:', prefsState);
toggleInstances(prefsState.insts);
tps.toggleSummary(prefsState.summary);
tps.toggleDetails(prefsState.detail);
toggleSummary(prefsState.summary);
toggleDetails(prefsState.detail);
}
......
......@@ -86,7 +86,6 @@
openListener = wss.addOpenListener(wsOpen);
wss.bindHandlers(handlerMap);
wss.sendEvent('topoStart');
wss.sendEvent('requestSummary');
$log.debug('topo comms started');
}
......
......@@ -23,7 +23,7 @@
'use strict';
// injected refs
var $log, ps, sus, gs, ts, fs;
var $log, ps, sus, gs, ts, fs, flash;
// api from topo
var api;
......@@ -309,20 +309,49 @@
oiShowMaster = false;
}
function showInsts() {
oiBox.show();
}
function hideInsts() {
oiBox.hide();
}
function toggleInsts(x) {
var kev = (x === 'keyev'),
on,
verb;
if (kev) {
on = oiBox.toggle();
} else {
on = !!x;
if (on) {
showInsts();
} else {
hideInsts();
}
}
verb = on ? 'Show' : 'Hide';
flash.flash(verb + ' instances panel');
return on;
}
// ==========================
angular.module('ovTopo')
.factory('TopoInstService',
['$log', 'PanelService', 'SvgUtilService', 'GlyphService',
'ThemeService', 'FnService',
'ThemeService', 'FnService', 'FlashService',
function (_$log_, _ps_, _sus_, _gs_, _ts_, _fs_) {
function (_$log_, _ps_, _sus_, _gs_, _ts_, _fs_, _flash_) {
$log = _$log_;
ps = _ps_;
sus = _sus_;
gs = _gs_;
ts = _ts_;
fs = _fs_;
flash = _flash_;
return {
initInst: initInst,
......@@ -335,9 +364,9 @@
cancelAffinity: cancelAffinity,
isVisible: function () { return oiBox.isVisible(); },
show: function () { oiBox.show(); },
hide: function () { oiBox.hide(); },
toggle: function () { oiBox.toggle(); },
show: showInsts,
hide: hideInsts,
toggle: toggleInsts,
showMaster: function () { return oiShowMaster; }
};
}]);
......
......@@ -226,7 +226,9 @@
}
function toggleSummary(x) {
var on = (x === 'keyev') ? !summaryPanel.isVisible() : !!x;
var kev = (x === 'keyev'),
on = kev ? !summaryPanel.isVisible() : !!x,
verb = on ? 'Show' : 'Hide';
if (on) {
// ask server to start sending summary data.
......@@ -235,6 +237,8 @@
} else {
hideSummaryPanel();
}
flash.flash(verb + ' summary panel');
return on;
}
// === -----------------------------------------------------
......@@ -292,16 +296,21 @@
}
function toggleDetails(x) {
useDetails = (x === 'keyev') ? !useDetails : !!x;
var kev = (x === 'keyev'),
verb;
useDetails = kev ? !useDetails : !!x;
verb = useDetails ? 'Enable' : 'Disable';
if (useDetails) {
flash.flash('Enable details panel');
if (haveDetails) {
showDetailPanel();
}
} else {
flash.flash('Disable details panel');
hideDetailPanel();
}
flash.flash(verb + ' details panel');
return useDetails;
}
// ==========================
......