Topo2: Key Command 'M' to show and hide offline devices

JIRA Tasks; ONOS-5381

Change-Id: Iab3a837a9bb05a334460e6b9222473bc8bc6b5c5
This commit is contained in:
Steven Burrows 2017-04-13 13:59:43 -07:00
parent 2e89adabe6
commit 02e67f469f
4 changed files with 42 additions and 9 deletions

View File

@ -46,9 +46,10 @@
} }
angular.module('ovTopo2') angular.module('ovTopo2')
.factory('Topo2DeviceService', .factory('Topo2DeviceService', [
['Topo2Collection', 'Topo2NodeModel', 'Topo2DeviceDetailsPanel', 'Topo2SelectService', 'Topo2Collection', 'Topo2NodeModel', 'Topo2DeviceDetailsPanel',
function (_c_, _nm_, detailsPanel, t2ss) { 'PrefsService',
function (_c_, _nm_, detailsPanel, ps) {
Collection = _c_; Collection = _c_;
@ -69,6 +70,8 @@
this.el.attr('class', this.svgClassName()); this.el.attr('class', this.svgClassName());
var rect = this.el.select('.icon-rect'); var rect = this.el.select('.icon-rect');
rect.style('fill', this.devGlyphColor()); rect.style('fill', this.devGlyphColor());
this.setOfflineVisibility();
} }
}, },
icon: function () { icon: function () {
@ -85,7 +88,12 @@
var id = this.mastershipService.mastership(), var id = this.mastershipService.mastership(),
suppress = id ? this.get('master') !== id : false; suppress = id ? this.get('master') !== id : false;
this.set({ mastership: suppress }); this.set({mastership: suppress});
},
setOfflineVisibility: function () {
var showOffline = ps.getPrefs('topo2_prefs')['offline_devices'],
display = this.get('online') || showOffline;
this.el.style('visibility', display ? 'visible' : 'hidden');
}, },
onExit: function () { onExit: function () {
var node = this.el; var node = this.el;

View File

@ -33,6 +33,7 @@
X: [resetNodeLocation, 'Reset Node Location'], X: [resetNodeLocation, 'Reset Node Location'],
U: [unpinNode, 'Unpin node (mouse over)'], U: [unpinNode, 'Unpin node (mouse over)'],
H: [toggleHosts, 'Toggle host visibility'], H: [toggleHosts, 'Toggle host visibility'],
M: [toggleOfflineDevices, 'Toggle offline visibility'],
dot: [toggleToolbar, 'Toggle Toolbar'], dot: [toggleToolbar, 'Toggle Toolbar'],
esc: handleEscape, esc: handleEscape,
@ -146,8 +147,18 @@
t2tbs.toggle(); t2tbs.toggle();
} }
function actionedFlashed(action, message) {
flash.flash(action + ' ' + message);
}
function toggleHosts() { function toggleHosts() {
t2rs.toggleHosts(); var on = t2rs.toggleHosts();
actionedFlashed(on ? 'Show': 'Hide', 'Hosts')
}
function toggleOfflineDevices() {
var on = t2rs.toggleOfflineDevices();
actionedFlashed(on ? 'Show': 'Hide', 'offline devices')
} }
function notValid(what) { function notValid(what) {

View File

@ -22,7 +22,7 @@
(function () { (function () {
'use strict'; 'use strict';
var ps, sus, is, ts, t2mcs, t2nps, fn; var t2ps, sus, is, ts, t2mcs, t2nps, fn;
var devIconDim = 36, var devIconDim = 36,
devIconDimMin = 20, devIconDimMin = 20,
@ -60,7 +60,7 @@
ts = _ts_; ts = _ts_;
fn = _fn_; fn = _fn_;
ps = _ps_; t2ps = _t2ps_;
sus = _sus_; sus = _sus_;
is = _is_; is = _is_;
t2mcs = _t2mcs_; t2mcs = _t2mcs_;
@ -124,7 +124,7 @@
return 'unknown'; return 'unknown';
}, },
labelIndex: function () { labelIndex: function () {
return ps.get('dlbls'); return t2ps.get('dlbls');
}, },
label: function () { label: function () {
var props = this.get('props'), var props = this.get('props'),
@ -278,7 +278,10 @@
} }
this.setScale(); this.setScale();
} },
// Override Methods
setOfflineVisibility: function () {},
}); });
}] }]
); );

View File

@ -215,6 +215,17 @@
_.each(this.model.get('links').models, function (link) { _.each(this.model.get('links').models, function (link) {
link.setVisibility(); link.setVisibility();
}); });
return !state;
},
toggleOfflineDevices: function () {
var state = this.lookupPrefState('offline_devices');
this.updatePrefState('offline_devices', !state);
_.each(this.regionNodes(), function (node) {
node.setOfflineVisibility();
});
return !state;
}, },
update: function (event) { update: function (event) {