GUI -- Added "No Devices Connected" layer; (themed too).

Change-Id: I80e3cc20c426c9c9781ad73a891e0f2fe93594b9
This commit is contained in:
Simon Hunt 2015-02-03 15:05:15 -08:00
parent 19ffea35f8
commit 7c8ab8ddae
4 changed files with 86 additions and 14 deletions

View File

@ -236,12 +236,17 @@
return s.replace(/px$/,''); return s.replace(/px$/,'');
} }
function makeVisible(el, b) {
el.style('visibility', (b ? 'visible' : 'hidden'));
}
return { return {
createDragBehavior: createDragBehavior, createDragBehavior: createDragBehavior,
loadGlow: loadGlow, loadGlow: loadGlow,
cat7: cat7, cat7: cat7,
translate: translate, translate: translate,
stripPx: stripPx stripPx: stripPx,
makeVisible: makeVisible
}; };
}]); }]);
}()); }());

View File

@ -18,25 +18,51 @@
ONOS GUI -- Topology View -- CSS file ONOS GUI -- Topology View -- CSS file
*/ */
/* --- Topo Map --- */ /* --- Base SVG Layer --- */
.light #ov-topo svg { .light #ov-topo svg {
background-color: #fff; background-color: #fff;
/* For Debugging the placement of the SVG layer... */
/*border: 1px solid red;*/
} }
.dark #ov-topo svg { .dark #ov-topo svg {
background-color: #2b2b2b; background-color: #2b2b2b;
} }
/* --- "No Devices" Layer --- */
#ov-topo svg #topo-noDevsLayer {
visibility: hidden;
}
.light #ov-topo svg .noDevsBird {
fill: #ecd;
}
.dark #ov-topo svg .noDevsBird {
fill: #683434;
}
#ov-topo svg #topo-noDevsLayer text {
font-size: 60pt;
font-style: italic;
}
.light #ov-topo svg #topo-noDevsLayer text {
fill: #dde;
}
.dark #ov-topo svg #topo-noDevsLayer text {
fill: #3b3b4f;
}
/* --- Topo Map --- */
#ov-topo svg #topo-map { #ov-topo svg #topo-map {
stroke-width: 2px; stroke-width: 2px;
fill: transparent; fill: transparent;
} }
.light #ov-topo svg #topo-map { .light #ov-topo svg #topo-map {
/*stroke: #eee;*/ stroke: #ddd;
stroke: #88b; /*stroke: #88b;*/
} }
.dark #ov-topo svg #topo-map { .dark #ov-topo svg #topo-map {
stroke: #444; stroke: #444;

View File

@ -28,10 +28,10 @@
]; ];
// references to injected services etc. // references to injected services etc.
var $log, fs, ks, zs, gs, ms, tfs; var $log, fs, ks, zs, gs, ms, sus, tfs;
// DOM elements // DOM elements
var ovtopo, svg, defs, zoomLayer, mapG, forceG; var ovtopo, svg, defs, zoomLayer, mapG, forceG, noDevsLayer;
// Internal state // Internal state
var zoomer; var zoomer;
@ -102,12 +102,37 @@
// callback invoked when the SVG view has been resized.. // callback invoked when the SVG view has been resized..
function svgResized(dim) { function svgResized(dim) {
//$log.debug('TopoView just resized... ', dim);
tfs.resize(dim); tfs.resize(dim);
} }
// --- Background Map ------------------------------------------------ // --- Background Map ------------------------------------------------
function setUpNoDevs() {
var g, box;
noDevsLayer = svg.append('g').attr({
id: 'topo-noDevsLayer',
transform: sus.translate(500,500)
});
// Note, SVG viewbox is '0 0 1000 1000', defined in topo.html.
// We are translating this layer to have its origin at the center
g = noDevsLayer.append('g');
gs.addGlyph(g, 'bird', 100).attr('class', 'noDevsBird');
g.append('text').text('No devices are connected')
.attr({ x: 120, y: 80});
box = g.node().getBBox();
box.x -= box.width/2;
box.y -= box.height/2;
g.attr('transform', sus.translate(box.x, box.y));
showNoDevs(true);
}
function showNoDevs(b) {
sus.makeVisible(noDevsLayer, b);
}
function showCallibrationPoints() { function showCallibrationPoints() {
// temp code for calibration // temp code for calibration
var points = [ var points = [
@ -144,12 +169,12 @@
.controller('OvTopoCtrl', [ .controller('OvTopoCtrl', [
'$scope', '$log', '$location', '$timeout', '$scope', '$log', '$location', '$timeout',
'FnService', 'MastService', 'KeyService', 'ZoomService', 'FnService', 'MastService', 'KeyService', 'ZoomService',
'GlyphService', 'MapService', 'GlyphService', 'MapService', 'SvgUtilService',
'TopoEventService', 'TopoForceService', 'TopoPanelService', 'TopoEventService', 'TopoForceService', 'TopoPanelService',
'TopoInstService', 'TopoInstService',
function ($scope, _$log_, $loc, $timeout, _fs_, mast, function ($scope, _$log_, $loc, $timeout, _fs_, mast,
_ks_, _zs_, _gs_, _ms_, tes, _tfs_, tps, tis) { _ks_, _zs_, _gs_, _ms_, _sus_, tes, _tfs_, tps, tis) {
var self = this; var self = this;
$log = _$log_; $log = _$log_;
fs = _fs_; fs = _fs_;
@ -157,6 +182,7 @@
zs = _zs_; zs = _zs_;
gs = _gs_; gs = _gs_;
ms = _ms_; ms = _ms_;
sus = _sus_;
tfs = _tfs_; tfs = _tfs_;
self.notifyResize = function () { self.notifyResize = function () {
@ -180,6 +206,7 @@
setUpKeys(); setUpKeys();
setUpDefs(); setUpDefs();
setUpZoom(); setUpZoom();
setUpNoDevs();
setUpMap(); setUpMap();
setUpForce(); setUpForce();

View File

@ -18,7 +18,7 @@
ONOS GUI -- SVG -- SVG Util Service - Unit Tests ONOS GUI -- SVG -- SVG Util Service - Unit Tests
*/ */
describe('factory: fw/svg/svgUtil.js', function() { describe('factory: fw/svg/svgUtil.js', function() {
var $log, fs, sus, d3Elem; var $log, fs, sus, svg, d3Elem;
beforeEach(module('onosUtil', 'onosSvg')); beforeEach(module('onosUtil', 'onosSvg'));
@ -26,7 +26,8 @@ describe('factory: fw/svg/svgUtil.js', function() {
$log = _$log_; $log = _$log_;
fs = FnService; fs = FnService;
sus = SvgUtilService; sus = SvgUtilService;
d3Elem = d3.select('body').append('svg').append('defs').attr('id', 'myDefs'); svg = d3.select('body').append('svg').attr('id', 'mySvg');
d3Elem = svg.append('defs');
})); }));
afterEach(function () { afterEach(function () {
@ -39,7 +40,8 @@ describe('factory: fw/svg/svgUtil.js', function() {
it('should define api functions', function () { it('should define api functions', function () {
expect(fs.areFunctions(sus, [ expect(fs.areFunctions(sus, [
'createDragBehavior', 'loadGlow', 'cat7', 'translate', 'stripPx' 'createDragBehavior', 'loadGlow', 'cat7', 'translate', 'stripPx',
'makeVisible'
])).toBeTruthy(); ])).toBeTruthy();
}); });
@ -111,4 +113,16 @@ describe('factory: fw/svg/svgUtil.js', function() {
it('should remove trailing px', function () { it('should remove trailing px', function () {
expect(sus.stripPx('4px')).toEqual('4'); expect(sus.stripPx('4px')).toEqual('4');
}); });
// === makeVisible()
it('should hide and show an element', function () {
var r = svg.append('rect');
sus.makeVisible(r, false);
expect(r.style('visibility')).toEqual('hidden');
sus.makeVisible(r, true);
expect(r.style('visibility')).toEqual('visible');
});
}); });