Bri Prebilic Cole

ONOS-1865 - GUI -- Keys from Topo View are deregistered once view is navigated a…

…way from. Device and App View 'esc' key registration added.

Change-Id: I88896266936a4f148007170d67058036fb365fe5
...@@ -167,6 +167,12 @@ ...@@ -167,6 +167,12 @@
167 }; 167 };
168 } 168 }
169 169
170 + function unbindKeys() {
171 + keyHandler.viewKeys = {};
172 + keyHandler.viewFn = null;
173 + keyHandler.viewGestures = [];
174 + }
175 +
170 angular.module('onosUtil') 176 angular.module('onosUtil')
171 .factory('KeyService', 177 .factory('KeyService',
172 ['$log', 'FnService', 'ThemeService', 'NavService', 178 ['$log', 'FnService', 'ThemeService', 'NavService',
...@@ -192,6 +198,7 @@ ...@@ -192,6 +198,7 @@
192 setKeyBindings(x); 198 setKeyBindings(x);
193 } 199 }
194 }, 200 },
201 + unbindKeys: unbindKeys,
195 gestureNotes: function (g) { 202 gestureNotes: function (g) {
196 if (g === undefined) { 203 if (g === undefined) {
197 return keyHandler.viewGestures; 204 return keyHandler.viewGestures;
......
...@@ -31,8 +31,9 @@ ...@@ -31,8 +31,9 @@
31 .controller('OvAppCtrl', 31 .controller('OvAppCtrl',
32 ['$log', '$scope', '$http', 32 ['$log', '$scope', '$http',
33 'FnService', 'TableBuilderService', 'WebSocketService', 'UrlFnService', 33 'FnService', 'TableBuilderService', 'WebSocketService', 'UrlFnService',
34 + 'KeyService',
34 35
35 - function ($log, $scope, $http, fs, tbs, wss, ufs) { 36 + function ($log, $scope, $http, fs, tbs, wss, ufs, ks) {
36 $scope.ctrlBtnState = {}; 37 $scope.ctrlBtnState = {};
37 $scope.uploadTip = 'Upload an application'; 38 $scope.uploadTip = 'Upload an application';
38 $scope.activateTip = 'Activate selected application'; 39 $scope.activateTip = 'Activate selected application';
...@@ -42,8 +43,6 @@ ...@@ -42,8 +43,6 @@
42 function selCb($event, row) { 43 function selCb($event, row) {
43 // selId comes from tableBuilder 44 // selId comes from tableBuilder
44 $scope.ctrlBtnState.selection = !!$scope.selId; 45 $scope.ctrlBtnState.selection = !!$scope.selId;
45 - $log.debug('Got a click on:', row);
46 -
47 refreshCtrls(); 46 refreshCtrls();
48 } 47 }
49 48
...@@ -68,6 +67,16 @@ ...@@ -68,6 +67,16 @@
68 respCb: refreshCtrls 67 respCb: refreshCtrls
69 }); 68 });
70 69
70 + // TODO: reexamine where keybindings should be - directive or controller?
71 + ks.keyBindings({
72 + esc: [$scope.selectCallback, 'Deselect app'],
73 + _helpFormat: ['esc']
74 + });
75 + ks.gestureNotes([
76 + ['click row', 'Select / deselect app'],
77 + ['scroll down', 'See more apps']
78 + ]);
79 +
71 $scope.appAction = function (action) { 80 $scope.appAction = function (action) {
72 if ($scope.ctrlBtnState.selection) { 81 if ($scope.ctrlBtnState.selection) {
73 $log.debug('Initiating ' + action + ' of ' + $scope.selId); 82 $log.debug('Initiating ' + action + ' of ' + $scope.selId);
...@@ -95,6 +104,10 @@ ...@@ -95,6 +104,10 @@
95 } 104 }
96 }); 105 });
97 106
107 + $scope.$on('$destroy', function () {
108 + ks.unbindKeys();
109 + });
110 +
98 $log.log('OvAppCtrl has been created'); 111 $log.log('OvAppCtrl has been created');
99 }]) 112 }])
100 113
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
31 #device-details-panel.floatpanel { 31 #device-details-panel.floatpanel {
32 -moz-border-radius: 0; 32 -moz-border-radius: 0;
33 border-radius: 0; 33 border-radius: 0;
34 + z-index: 0;
34 } 35 }
35 36
36 .light #device-details-panel.floatpanel { 37 .light #device-details-panel.floatpanel {
......
...@@ -55,14 +55,17 @@ ...@@ -55,14 +55,17 @@
55 'Enabled', 'ID', 'Speed', 'Type', 'Egress Links', 'Name' 55 'Enabled', 'ID', 'Speed', 'Type', 'Egress Links', 'Name'
56 ]; 56 ];
57 57
58 + function closePanel() {
59 + if (detailsPanel.isVisible()) {
60 + $scope.selId = null;
61 + detailsPanel.hide();
62 + }
63 + }
64 +
58 function addCloseBtn(div) { 65 function addCloseBtn(div) {
59 is.loadEmbeddedIcon(div, 'plus', 30); 66 is.loadEmbeddedIcon(div, 'plus', 30);
60 div.select('g').attr('transform', 'translate(25, 0) rotate(45)'); 67 div.select('g').attr('transform', 'translate(25, 0) rotate(45)');
61 - 68 + div.on('click', closePanel);
62 - div.on('click', function () {
63 - $scope.selId = null;
64 - detailsPanel.hide();
65 - });
66 } 69 }
67 70
68 function setUpPanel() { 71 function setUpPanel() {
...@@ -247,8 +250,8 @@ ...@@ -247,8 +250,8 @@
247 $log.log('OvDeviceCtrl has been created'); 250 $log.log('OvDeviceCtrl has been created');
248 }]) 251 }])
249 252
250 - .directive('deviceDetailsPanel', ['$rootScope', '$window', 253 + .directive('deviceDetailsPanel', ['$rootScope', '$window', 'KeyService',
251 - function ($rootScope, $window) { 254 + function ($rootScope, $window, ks) {
252 return function (scope) { 255 return function (scope) {
253 var unbindWatch; 256 var unbindWatch;
254 257
...@@ -262,6 +265,16 @@ ...@@ -262,6 +265,16 @@
262 265
263 createDetailsPane(); 266 createDetailsPane();
264 267
268 + // create key bindings to handle panel
269 + ks.keyBindings({
270 + esc: [closePanel, 'Close the details panel'],
271 + _helpFormat: ['esc']
272 + });
273 + ks.gestureNotes([
274 + ['click', 'Select a row to show device details'],
275 + ['scroll down', 'See more devices']
276 + ]);
277 +
265 scope.$watch('panelData', function () { 278 scope.$watch('panelData', function () {
266 if (!fs.isEmptyObject(scope.panelData)) { 279 if (!fs.isEmptyObject(scope.panelData)) {
267 populateDetails(scope.panelData); 280 populateDetails(scope.panelData);
...@@ -285,6 +298,7 @@ ...@@ -285,6 +298,7 @@
285 298
286 scope.$on('$destroy', function () { 299 scope.$on('$destroy', function () {
287 unbindWatch(); 300 unbindWatch();
301 + ks.unbindKeys();
288 ps.destroyPanel(pName); 302 ps.destroyPanel(pName);
289 }); 303 });
290 }; 304 };
......
...@@ -447,6 +447,7 @@ ...@@ -447,6 +447,7 @@
447 $scope.$on('$destroy', function () { 447 $scope.$on('$destroy', function () {
448 $log.log('OvTopoCtrl is saying Buh-Bye!'); 448 $log.log('OvTopoCtrl is saying Buh-Bye!');
449 tes.stop(); 449 tes.stop();
450 + ks.unbindKeys();
450 tps.destroyPanels(); 451 tps.destroyPanels();
451 tis.destroyInst(); 452 tis.destroyInst();
452 tfs.destroyForce(); 453 tfs.destroyForce();
......