Simon Hunt

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

Change-Id: I80e3cc20c426c9c9781ad73a891e0f2fe93594b9
...@@ -236,12 +236,17 @@ ...@@ -236,12 +236,17 @@
236 return s.replace(/px$/,''); 236 return s.replace(/px$/,'');
237 } 237 }
238 238
239 + function makeVisible(el, b) {
240 + el.style('visibility', (b ? 'visible' : 'hidden'));
241 + }
242 +
239 return { 243 return {
240 createDragBehavior: createDragBehavior, 244 createDragBehavior: createDragBehavior,
241 loadGlow: loadGlow, 245 loadGlow: loadGlow,
242 cat7: cat7, 246 cat7: cat7,
243 translate: translate, 247 translate: translate,
244 - stripPx: stripPx 248 + stripPx: stripPx,
249 + makeVisible: makeVisible
245 }; 250 };
246 }]); 251 }]);
247 }()); 252 }());
......
...@@ -18,25 +18,51 @@ ...@@ -18,25 +18,51 @@
18 ONOS GUI -- Topology View -- CSS file 18 ONOS GUI -- Topology View -- CSS file
19 */ 19 */
20 20
21 -/* --- Topo Map --- */ 21 +/* --- Base SVG Layer --- */
22 22
23 .light #ov-topo svg { 23 .light #ov-topo svg {
24 background-color: #fff; 24 background-color: #fff;
25 - /* For Debugging the placement of the SVG layer... */
26 - /*border: 1px solid red;*/
27 } 25 }
28 .dark #ov-topo svg { 26 .dark #ov-topo svg {
29 background-color: #2b2b2b; 27 background-color: #2b2b2b;
30 } 28 }
31 29
30 +
31 +/* --- "No Devices" Layer --- */
32 +
33 +#ov-topo svg #topo-noDevsLayer {
34 + visibility: hidden;
35 +}
36 +
37 +.light #ov-topo svg .noDevsBird {
38 + fill: #ecd;
39 +}
40 +.dark #ov-topo svg .noDevsBird {
41 + fill: #683434;
42 +}
43 +
44 +#ov-topo svg #topo-noDevsLayer text {
45 + font-size: 60pt;
46 + font-style: italic;
47 +}
48 +.light #ov-topo svg #topo-noDevsLayer text {
49 + fill: #dde;
50 +}
51 +.dark #ov-topo svg #topo-noDevsLayer text {
52 + fill: #3b3b4f;
53 +}
54 +
55 +
56 +/* --- Topo Map --- */
57 +
32 #ov-topo svg #topo-map { 58 #ov-topo svg #topo-map {
33 stroke-width: 2px; 59 stroke-width: 2px;
34 fill: transparent; 60 fill: transparent;
35 } 61 }
36 62
37 .light #ov-topo svg #topo-map { 63 .light #ov-topo svg #topo-map {
38 - /*stroke: #eee;*/ 64 + stroke: #ddd;
39 - stroke: #88b; 65 + /*stroke: #88b;*/
40 } 66 }
41 .dark #ov-topo svg #topo-map { 67 .dark #ov-topo svg #topo-map {
42 stroke: #444; 68 stroke: #444;
......
...@@ -28,10 +28,10 @@ ...@@ -28,10 +28,10 @@
28 ]; 28 ];
29 29
30 // references to injected services etc. 30 // references to injected services etc.
31 - var $log, fs, ks, zs, gs, ms, tfs; 31 + var $log, fs, ks, zs, gs, ms, sus, tfs;
32 32
33 // DOM elements 33 // DOM elements
34 - var ovtopo, svg, defs, zoomLayer, mapG, forceG; 34 + var ovtopo, svg, defs, zoomLayer, mapG, forceG, noDevsLayer;
35 35
36 // Internal state 36 // Internal state
37 var zoomer; 37 var zoomer;
...@@ -102,12 +102,37 @@ ...@@ -102,12 +102,37 @@
102 102
103 // callback invoked when the SVG view has been resized.. 103 // callback invoked when the SVG view has been resized..
104 function svgResized(dim) { 104 function svgResized(dim) {
105 - //$log.debug('TopoView just resized... ', dim);
106 tfs.resize(dim); 105 tfs.resize(dim);
107 } 106 }
108 107
109 // --- Background Map ------------------------------------------------ 108 // --- Background Map ------------------------------------------------
110 109
110 + function setUpNoDevs() {
111 + var g, box;
112 + noDevsLayer = svg.append('g').attr({
113 + id: 'topo-noDevsLayer',
114 + transform: sus.translate(500,500)
115 + });
116 + // Note, SVG viewbox is '0 0 1000 1000', defined in topo.html.
117 + // We are translating this layer to have its origin at the center
118 +
119 + g = noDevsLayer.append('g');
120 + gs.addGlyph(g, 'bird', 100).attr('class', 'noDevsBird');
121 + g.append('text').text('No devices are connected')
122 + .attr({ x: 120, y: 80});
123 +
124 + box = g.node().getBBox();
125 + box.x -= box.width/2;
126 + box.y -= box.height/2;
127 + g.attr('transform', sus.translate(box.x, box.y));
128 +
129 + showNoDevs(true);
130 + }
131 +
132 + function showNoDevs(b) {
133 + sus.makeVisible(noDevsLayer, b);
134 + }
135 +
111 function showCallibrationPoints() { 136 function showCallibrationPoints() {
112 // temp code for calibration 137 // temp code for calibration
113 var points = [ 138 var points = [
...@@ -144,12 +169,12 @@ ...@@ -144,12 +169,12 @@
144 .controller('OvTopoCtrl', [ 169 .controller('OvTopoCtrl', [
145 '$scope', '$log', '$location', '$timeout', 170 '$scope', '$log', '$location', '$timeout',
146 'FnService', 'MastService', 'KeyService', 'ZoomService', 171 'FnService', 'MastService', 'KeyService', 'ZoomService',
147 - 'GlyphService', 'MapService', 172 + 'GlyphService', 'MapService', 'SvgUtilService',
148 'TopoEventService', 'TopoForceService', 'TopoPanelService', 173 'TopoEventService', 'TopoForceService', 'TopoPanelService',
149 'TopoInstService', 174 'TopoInstService',
150 175
151 function ($scope, _$log_, $loc, $timeout, _fs_, mast, 176 function ($scope, _$log_, $loc, $timeout, _fs_, mast,
152 - _ks_, _zs_, _gs_, _ms_, tes, _tfs_, tps, tis) { 177 + _ks_, _zs_, _gs_, _ms_, _sus_, tes, _tfs_, tps, tis) {
153 var self = this; 178 var self = this;
154 $log = _$log_; 179 $log = _$log_;
155 fs = _fs_; 180 fs = _fs_;
...@@ -157,6 +182,7 @@ ...@@ -157,6 +182,7 @@
157 zs = _zs_; 182 zs = _zs_;
158 gs = _gs_; 183 gs = _gs_;
159 ms = _ms_; 184 ms = _ms_;
185 + sus = _sus_;
160 tfs = _tfs_; 186 tfs = _tfs_;
161 187
162 self.notifyResize = function () { 188 self.notifyResize = function () {
...@@ -180,6 +206,7 @@ ...@@ -180,6 +206,7 @@
180 setUpKeys(); 206 setUpKeys();
181 setUpDefs(); 207 setUpDefs();
182 setUpZoom(); 208 setUpZoom();
209 + setUpNoDevs();
183 setUpMap(); 210 setUpMap();
184 setUpForce(); 211 setUpForce();
185 212
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
18 ONOS GUI -- SVG -- SVG Util Service - Unit Tests 18 ONOS GUI -- SVG -- SVG Util Service - Unit Tests
19 */ 19 */
20 describe('factory: fw/svg/svgUtil.js', function() { 20 describe('factory: fw/svg/svgUtil.js', function() {
21 - var $log, fs, sus, d3Elem; 21 + var $log, fs, sus, svg, d3Elem;
22 22
23 beforeEach(module('onosUtil', 'onosSvg')); 23 beforeEach(module('onosUtil', 'onosSvg'));
24 24
...@@ -26,7 +26,8 @@ describe('factory: fw/svg/svgUtil.js', function() { ...@@ -26,7 +26,8 @@ describe('factory: fw/svg/svgUtil.js', function() {
26 $log = _$log_; 26 $log = _$log_;
27 fs = FnService; 27 fs = FnService;
28 sus = SvgUtilService; 28 sus = SvgUtilService;
29 - d3Elem = d3.select('body').append('svg').append('defs').attr('id', 'myDefs'); 29 + svg = d3.select('body').append('svg').attr('id', 'mySvg');
30 + d3Elem = svg.append('defs');
30 })); 31 }));
31 32
32 afterEach(function () { 33 afterEach(function () {
...@@ -39,7 +40,8 @@ describe('factory: fw/svg/svgUtil.js', function() { ...@@ -39,7 +40,8 @@ describe('factory: fw/svg/svgUtil.js', function() {
39 40
40 it('should define api functions', function () { 41 it('should define api functions', function () {
41 expect(fs.areFunctions(sus, [ 42 expect(fs.areFunctions(sus, [
42 - 'createDragBehavior', 'loadGlow', 'cat7', 'translate', 'stripPx' 43 + 'createDragBehavior', 'loadGlow', 'cat7', 'translate', 'stripPx',
44 + 'makeVisible'
43 ])).toBeTruthy(); 45 ])).toBeTruthy();
44 }); 46 });
45 47
...@@ -111,4 +113,16 @@ describe('factory: fw/svg/svgUtil.js', function() { ...@@ -111,4 +113,16 @@ describe('factory: fw/svg/svgUtil.js', function() {
111 it('should remove trailing px', function () { 113 it('should remove trailing px', function () {
112 expect(sus.stripPx('4px')).toEqual('4'); 114 expect(sus.stripPx('4px')).toEqual('4');
113 }); 115 });
116 +
117 + // === makeVisible()
118 +
119 + it('should hide and show an element', function () {
120 + var r = svg.append('rect');
121 +
122 + sus.makeVisible(r, false);
123 + expect(r.style('visibility')).toEqual('hidden');
124 +
125 + sus.makeVisible(r, true);
126 + expect(r.style('visibility')).toEqual('visible');
127 + });
114 }); 128 });
......