Simon Hunt

GUI -- TopoView - Fixed dynamic repositioning of Details Panel.

- also implemented toggleDetails keystroke 'D'.

Change-Id: I99a9ee1235c8cc1174d8c2d542e6e40b7fb6b8dc
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
28 ]; 28 ];
29 29
30 // references to injected services etc. 30 // references to injected services etc.
31 - var $log, fs, ks, zs, gs, ms, sus, tes, tfs, tps, tis; 31 + var $log, fs, ks, zs, gs, ms, sus, tes, tfs, tps, tis, tss;
32 32
33 // DOM elements 33 // DOM elements
34 var ovtopo, svg, defs, zoomLayer, mapG, forceG, noDevsLayer; 34 var ovtopo, svg, defs, zoomLayer, mapG, forceG, noDevsLayer;
...@@ -42,9 +42,9 @@ ...@@ -42,9 +42,9 @@
42 // key bindings need to be made after the services have been injected 42 // key bindings need to be made after the services have been injected
43 // thus, deferred to here... 43 // thus, deferred to here...
44 ks.keyBindings({ 44 ks.keyBindings({
45 - O: [toggleSummary, 'Toggle ONOS summary pane'], 45 + O: [tps.toggleSummary, 'Toggle ONOS summary pane'],
46 I: [toggleInstances, 'Toggle ONOS instances pane'], 46 I: [toggleInstances, 'Toggle ONOS instances pane'],
47 - //D: [toggleDetails, 'Disable / enable details pane'], 47 + D: [tss.toggleDetails, 'Disable / enable details pane'],
48 48
49 H: [tfs.toggleHosts, 'Toggle host visibility'], 49 H: [tfs.toggleHosts, 'Toggle host visibility'],
50 M: [tfs.toggleOffline, 'Toggle offline visibility'], 50 M: [tfs.toggleOffline, 'Toggle offline visibility'],
...@@ -87,15 +87,8 @@ ...@@ -87,15 +87,8 @@
87 87
88 // --- Keystroke functions ------------------------------------------- 88 // --- Keystroke functions -------------------------------------------
89 89
90 - function toggleSummary() { 90 + // NOTE: this really belongs in the TopoPanelService -- but how to
91 - if (tps.summaryVisible()) { 91 + // cleanly link in the updateDeviceColors() call? To be fixed later.
92 - tes.sendEvent("cancelSummary");
93 - tps.hideSummaryPanel();
94 - } else {
95 - tes.sendEvent('requestSummary');
96 - }
97 - }
98 -
99 function toggleInstances() { 92 function toggleInstances() {
100 tis.toggle(); 93 tis.toggle();
101 tfs.updateDeviceColors(); 94 tfs.updateDeviceColors();
...@@ -219,10 +212,11 @@ ...@@ -219,10 +212,11 @@
219 'FnService', 'MastService', 'KeyService', 'ZoomService', 212 'FnService', 'MastService', 'KeyService', 'ZoomService',
220 'GlyphService', 'MapService', 'SvgUtilService', 213 'GlyphService', 'MapService', 'SvgUtilService',
221 'TopoEventService', 'TopoForceService', 'TopoPanelService', 214 'TopoEventService', 'TopoForceService', 'TopoPanelService',
222 - 'TopoInstService', 215 + 'TopoInstService', 'TopoSelectService',
223 216
224 function ($scope, _$log_, $loc, $timeout, _fs_, mast, 217 function ($scope, _$log_, $loc, $timeout, _fs_, mast,
225 - _ks_, _zs_, _gs_, _ms_, _sus_, _tes_, _tfs_, _tps_, _tis_) { 218 + _ks_, _zs_, _gs_, _ms_, _sus_,
219 + _tes_, _tfs_, _tps_, _tis_, _tss_) {
226 var self = this, 220 var self = this,
227 projection, 221 projection,
228 dim, 222 dim,
...@@ -244,6 +238,7 @@ ...@@ -244,6 +238,7 @@
244 tfs = _tfs_; 238 tfs = _tfs_;
245 tps = _tps_; 239 tps = _tps_;
246 tis = _tis_; 240 tis = _tis_;
241 + tss = _tss_;
247 242
248 self.notifyResize = function () { 243 self.notifyResize = function () {
249 svgResized(fs.windowSize(mast.mastHeight())); 244 svgResized(fs.windowSize(mast.mastHeight()));
...@@ -279,7 +274,7 @@ ...@@ -279,7 +274,7 @@
279 forceG = zoomLayer.append('g').attr('id', 'topo-force'); 274 forceG = zoomLayer.append('g').attr('id', 'topo-force');
280 tfs.initForce(forceG, uplink, dim); 275 tfs.initForce(forceG, uplink, dim);
281 tis.initInst(); 276 tis.initInst();
282 - tps.initPanels(); 277 + tps.initPanels({ sendEvent: tes.sendEvent });
283 tes.openSock(); 278 tes.openSock();
284 279
285 $log.log('OvTopoCtrl has been created'); 280 $log.log('OvTopoCtrl has been created');
......
...@@ -23,7 +23,12 @@ ...@@ -23,7 +23,12 @@
23 'use strict'; 23 'use strict';
24 24
25 // injected refs 25 // injected refs
26 - var $log, ps, gs; 26 + var $log, fs, ps, gs;
27 +
28 + var api;
29 + /*
30 + sendEvent( event, {payload} )
31 + */
27 32
28 // constants 33 // constants
29 var pCls = 'topo-p', 34 var pCls = 'topo-p',
...@@ -137,39 +142,83 @@ ...@@ -137,39 +142,83 @@
137 showSummaryPanel(); 142 showSummaryPanel();
138 } 143 }
139 144
145 + function toggleSummary() {
146 + if (summaryPanel.isVisible()) {
147 + api.sendEvent("cancelSummary");
148 + hideSummaryPanel();
149 + } else {
150 + api.sendEvent('requestSummary');
151 + }
152 + }
140 153
141 // === ----------------------------------------------------- 154 // === -----------------------------------------------------
142 // === LOGIC For showing/hiding summary and detail panels... 155 // === LOGIC For showing/hiding summary and detail panels...
143 156
144 function showSummaryPanel() { 157 function showSummaryPanel() {
145 - summaryPanel.show(); 158 + if (detailPanel.isVisible()) {
146 - // TODO: augment, for details panel move 159 + detailPanel.down(summaryPanel.show);
160 + } else {
161 + summaryPanel.show();
162 + }
147 } 163 }
148 164
149 function hideSummaryPanel() { 165 function hideSummaryPanel() {
150 - summaryPanel.hide(); 166 + summaryPanel.hide(function () {
151 - // TODO: augment, for details panel move 167 + if (detailPanel.isVisible()) {
168 + detailPanel.up();
169 + }
170 + });
152 } 171 }
153 172
154 function showDetailPanel() { 173 function showDetailPanel() {
155 - // TODO: augment with summary-accomodation-logic 174 + if (summaryPanel.isVisible()) {
156 - detailPanel.show(); 175 + detailPanel.down(detailPanel.show);
176 + } else {
177 + detailPanel.up(detailPanel.show);
178 + }
157 } 179 }
158 180
159 function hideDetailPanel() { 181 function hideDetailPanel() {
160 detailPanel.hide(); 182 detailPanel.hide();
161 } 183 }
162 184
185 + // ==========================
186 +
187 + function noop () {}
163 188
189 + function augmentDetailPanel() {
190 + var dp = detailPanel;
191 + dp.ypos = { up: 64, down: 320, current: 320};
192 +
193 + dp._move = function (y, cb) {
194 + var endCb = fs.isF(cb) || noop,
195 + yp = dp.ypos;
196 + if (yp.current !== y) {
197 + yp.current = y;
198 + dp.el().transition().duration(300)
199 + .each('end', endCb)
200 + .style('top', yp.current + 'px');
201 + } else {
202 + endCb();
203 + }
204 + };
205 +
206 + dp.down = function (cb) { dp._move(dp.ypos.down, cb); };
207 + dp.up = function (cb) { dp._move(dp.ypos.up, cb); };
208 + }
164 209
165 // ========================== 210 // ==========================
166 211
167 - function initPanels() { 212 + function initPanels(_api_) {
213 + api = _api_;
214 +
168 summaryPanel = ps.createPanel(idSum, panelOpts); 215 summaryPanel = ps.createPanel(idSum, panelOpts);
169 detailPanel = ps.createPanel(idDet, panelOpts); 216 detailPanel = ps.createPanel(idDet, panelOpts);
170 217
171 summaryPanel.classed(pCls, true); 218 summaryPanel.classed(pCls, true);
172 detailPanel.classed(pCls, true); 219 detailPanel.classed(pCls, true);
220 +
221 + augmentDetailPanel();
173 } 222 }
174 223
175 function destroyPanels() { 224 function destroyPanels() {
...@@ -182,10 +231,11 @@ ...@@ -182,10 +231,11 @@
182 231
183 angular.module('ovTopo') 232 angular.module('ovTopo')
184 .factory('TopoPanelService', 233 .factory('TopoPanelService',
185 - ['$log', 'PanelService', 'GlyphService', 234 + ['$log', 'FnService', 'PanelService', 'GlyphService',
186 235
187 - function (_$log_, _ps_, _gs_) { 236 + function (_$log_, _fs_, _ps_, _gs_) {
188 $log = _$log_; 237 $log = _$log_;
238 + fs = _fs_;
189 ps = _ps_; 239 ps = _ps_;
190 gs = _gs_; 240 gs = _gs_;
191 241
...@@ -194,6 +244,7 @@ ...@@ -194,6 +244,7 @@
194 destroyPanels: destroyPanels, 244 destroyPanels: destroyPanels,
195 245
196 showSummary: showSummary, 246 showSummary: showSummary,
247 + toggleSummary: toggleSummary,
197 248
198 displaySingle: displaySingle, 249 displaySingle: displaySingle,
199 displayMulti: displayMulti, 250 displayMulti: displayMulti,
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
23 'use strict'; 23 'use strict';
24 24
25 // injected refs 25 // injected refs
26 - var $log, fs, tps; 26 + var $log, fs, flash, tps;
27 27
28 // api to topoForce 28 // api to topoForce
29 var api; 29 var api;
...@@ -229,6 +229,19 @@ ...@@ -229,6 +229,19 @@
229 } 229 }
230 } 230 }
231 231
232 + function toggleDetails() {
233 + useDetails = !useDetails;
234 + if (useDetails) {
235 + flash.flash('Enable details panel');
236 + if (haveDetails) {
237 + tps.showDetailPanel();
238 + }
239 + } else {
240 + flash.flash('Disable details panel');
241 + tps.hideDetailPanel();
242 + }
243 + }
244 +
232 // === ----------------------------------------------------- 245 // === -----------------------------------------------------
233 // TODO: migrate these to topoTraffic.js 246 // TODO: migrate these to topoTraffic.js
234 247
...@@ -263,31 +276,33 @@ ...@@ -263,31 +276,33 @@
263 276
264 angular.module('ovTopo') 277 angular.module('ovTopo')
265 .factory('TopoSelectService', 278 .factory('TopoSelectService',
266 - ['$log', 'FnService', 'TopoPanelService', 279 + ['$log', 'FnService', 'FlashService', 'TopoPanelService',
267 280
268 - function (_$log_, _fs_, _tps_) { 281 + function (_$log_, _fs_, _flash_, _tps_) {
269 - $log = _$log_; 282 + $log = _$log_;
270 - fs = _fs_; 283 + fs = _fs_;
271 - tps = _tps_; 284 + flash = _flash_;
285 + tps = _tps_;
272 286
273 - function initSelect(_api_) { 287 + function initSelect(_api_) {
274 - api = _api_; 288 + api = _api_;
275 - } 289 + }
276 290
277 - function destroySelect() { } 291 + function destroySelect() { }
278 292
279 - return { 293 + return {
280 - initSelect: initSelect, 294 + initSelect: initSelect,
281 - destroySelect: destroySelect, 295 + destroySelect: destroySelect,
282 296
283 - showDetails: showDetails, 297 + showDetails: showDetails,
298 + toggleDetails: toggleDetails,
284 299
285 - nodeMouseOver: nodeMouseOver, 300 + nodeMouseOver: nodeMouseOver,
286 - nodeMouseOut: nodeMouseOut, 301 + nodeMouseOut: nodeMouseOut,
287 - selectObject: selectObject, 302 + selectObject: selectObject,
288 - deselectObject: deselectObject, 303 + deselectObject: deselectObject,
289 - deselectAll: deselectAll, 304 + deselectAll: deselectAll,
290 - hovered: function () { return hovered; } 305 + hovered: function () { return hovered; }
291 - }; 306 + };
292 - }]); 307 + }]);
293 }()); 308 }());
......
...@@ -37,6 +37,7 @@ describe('factory: view/topo/topoPanel.js', function() { ...@@ -37,6 +37,7 @@ describe('factory: view/topo/topoPanel.js', function() {
37 'initPanels', 37 'initPanels',
38 'destroyPanels', 38 'destroyPanels',
39 'showSummary', 39 'showSummary',
40 + 'toggleSummary',
40 'displaySingle', 41 'displaySingle',
41 'displayMulti', 42 'displayMulti',
42 'addAction', 43 'addAction',
......
...@@ -34,7 +34,7 @@ describe('factory: view/topo/topoSelect.js', function() { ...@@ -34,7 +34,7 @@ describe('factory: view/topo/topoSelect.js', function() {
34 34
35 it('should define api functions', function () { 35 it('should define api functions', function () {
36 expect(fs.areFunctions(tss, [ 36 expect(fs.areFunctions(tss, [
37 - 'initSelect', 'destroySelect', 'showDetails', 37 + 'initSelect', 'destroySelect', 'showDetails', 'toggleDetails',
38 'nodeMouseOver', 'nodeMouseOut', 'selectObject', 'deselectObject', 38 'nodeMouseOver', 'nodeMouseOut', 'selectObject', 'deselectObject',
39 'deselectAll', 'hovered' 39 'deselectAll', 'hovered'
40 ])).toBeTruthy(); 40 ])).toBeTruthy();
......