Committed by
Gerrit Code Review
Added keyboard shortcut to show/hide instance panel
Change-Id: I88bed44fe84a91ca870d67d0428b95c4a30dab85
Showing
2 changed files
with
44 additions
and
8 deletions
| ... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
| 2 | 'use strict'; | 2 | 'use strict'; |
| 3 | 3 | ||
| 4 | // injected refs | 4 | // injected refs |
| 5 | - var $log, ps, sus, gs, ts; | 5 | + var $log, ps, sus, gs, flash, ts; |
| 6 | 6 | ||
| 7 | // api from topo | 7 | // api from topo |
| 8 | var api; | 8 | var api; |
| ... | @@ -238,6 +238,26 @@ | ... | @@ -238,6 +238,26 @@ |
| 238 | }); | 238 | }); |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | + function toggle(x) { | ||
| 242 | + var kev = (x === 'keyev'), | ||
| 243 | + on, | ||
| 244 | + verb; | ||
| 245 | + | ||
| 246 | + if (kev) { | ||
| 247 | + on = oiBox.toggle(); | ||
| 248 | + } else { | ||
| 249 | + on = Boolean(x); | ||
| 250 | + if (on) { | ||
| 251 | + oiBox.show(); | ||
| 252 | + } else { | ||
| 253 | + oiBox.hide(); | ||
| 254 | + } | ||
| 255 | + } | ||
| 256 | + verb = on ? 'Show' : 'Hide'; | ||
| 257 | + flash.flash(verb + ' instances panel'); | ||
| 258 | + return on; | ||
| 259 | + } | ||
| 260 | + | ||
| 241 | function destroy() { | 261 | function destroy() { |
| 242 | ts.removeListener(updateInstances); | 262 | ts.removeListener(updateInstances); |
| 243 | 263 | ||
| ... | @@ -250,20 +270,22 @@ | ... | @@ -250,20 +270,22 @@ |
| 250 | 270 | ||
| 251 | angular.module('ovTopo2') | 271 | angular.module('ovTopo2') |
| 252 | .factory('Topo2InstanceService', | 272 | .factory('Topo2InstanceService', |
| 253 | - ['$log', 'PanelService', 'SvgUtilService', 'GlyphService', | 273 | + ['$log', 'PanelService', 'SvgUtilService', 'GlyphService', 'FlashService', |
| 254 | 'ThemeService', | 274 | 'ThemeService', |
| 255 | 275 | ||
| 256 | - function (_$log_, _ps_, _sus_, _gs_, _ts_) { | 276 | + function (_$log_, _ps_, _sus_, _gs_, _flash_, _ts_) { |
| 257 | $log = _$log_; | 277 | $log = _$log_; |
| 258 | ps = _ps_; | 278 | ps = _ps_; |
| 259 | sus = _sus_; | 279 | sus = _sus_; |
| 260 | gs = _gs_; | 280 | gs = _gs_; |
| 281 | + flash = _flash_; | ||
| 261 | ts = _ts_; | 282 | ts = _ts_; |
| 262 | 283 | ||
| 263 | return { | 284 | return { |
| 264 | initInst: initInst, | 285 | initInst: initInst, |
| 265 | allInstances: allInstances, | 286 | allInstances: allInstances, |
| 266 | - destroy: destroy | 287 | + destroy: destroy, |
| 288 | + toggle: toggle | ||
| 267 | }; | 289 | }; |
| 268 | }]); | 290 | }]); |
| 269 | 291 | ... | ... |
| ... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
| 17 | (function () { | 17 | (function () { |
| 18 | 18 | ||
| 19 | // Injected Services | 19 | // Injected Services |
| 20 | - var ks, t2ps, t2ms; | 20 | + var ks, t2ps, t2ms, ps, t2is; |
| 21 | var topo2ForceService; | 21 | var topo2ForceService; |
| 22 | 22 | ||
| 23 | // Commmands | 23 | // Commmands |
| ... | @@ -25,6 +25,7 @@ | ... | @@ -25,6 +25,7 @@ |
| 25 | L: [cycleDeviceLabels, 'Cycle device labels'], | 25 | L: [cycleDeviceLabels, 'Cycle device labels'], |
| 26 | G: [openMapSelection, 'Select background geo map'], | 26 | G: [openMapSelection, 'Select background geo map'], |
| 27 | B: [toggleMap, 'Toggle background geo map'], | 27 | B: [toggleMap, 'Toggle background geo map'], |
| 28 | + I: [toggleInstancePanel, 'Toggle ONOS Instance Panel'] | ||
| 28 | }; | 29 | }; |
| 29 | 30 | ||
| 30 | function init(t2fs) { | 31 | function init(t2fs) { |
| ... | @@ -45,6 +46,13 @@ | ... | @@ -45,6 +46,13 @@ |
| 45 | ]); | 46 | ]); |
| 46 | } | 47 | } |
| 47 | 48 | ||
| 49 | + var prefsState = {}; | ||
| 50 | + | ||
| 51 | + function updatePrefsState(what, b) { | ||
| 52 | + prefsState[what] = b ? 1 : 0; | ||
| 53 | + ps.setPrefs('topo_prefs', prefsState); | ||
| 54 | + } | ||
| 55 | + | ||
| 48 | function cycleDeviceLabels() { | 56 | function cycleDeviceLabels() { |
| 49 | var deviceLabelIndex = t2ps.get('dlbls') + 1; | 57 | var deviceLabelIndex = t2ps.get('dlbls') + 1; |
| 50 | t2ps.set('dlbls', deviceLabelIndex % 3); | 58 | t2ps.set('dlbls', deviceLabelIndex % 3); |
| ... | @@ -59,14 +67,20 @@ | ... | @@ -59,14 +67,20 @@ |
| 59 | t2ms.toggle(x); | 67 | t2ms.toggle(x); |
| 60 | } | 68 | } |
| 61 | 69 | ||
| 70 | + function toggleInstancePanel(x) { | ||
| 71 | + updatePrefsState('insts', t2is.toggle(x)); | ||
| 72 | + } | ||
| 73 | + | ||
| 62 | angular.module('ovTopo2') | 74 | angular.module('ovTopo2') |
| 63 | .factory('Topo2KeyCommandService', | 75 | .factory('Topo2KeyCommandService', |
| 64 | - ['KeyService', 'Topo2PrefsService', 'Topo2MapService', | 76 | + ['KeyService', 'Topo2PrefsService', 'Topo2MapService', 'PrefsService', |
| 65 | - | 77 | + 'Topo2InstanceService', |
| 66 | - function (_ks_, _t2ps_, _t2ms_) { | 78 | + function (_ks_, _t2ps_, _t2ms_, _ps_, _t2is_) { |
| 67 | 79 | ||
| 68 | t2ps = _t2ps_; | 80 | t2ps = _t2ps_; |
| 69 | t2ms = _t2ms_; | 81 | t2ms = _t2ms_; |
| 82 | + t2is = _t2is_; | ||
| 83 | + ps = _ps_; | ||
| 70 | ks = _ks_; | 84 | ks = _ks_; |
| 71 | 85 | ||
| 72 | return { | 86 | return { | ... | ... |
-
Please register or login to post a comment