GUI -- Added enable() function to flash service, to allow topo view to disable f…
…lash messages while restoring state.. Change-Id: I1c904d0b69bf707ffa08b423ac5d4ecf7b0a7ff2
Showing
3 changed files
with
17 additions
and
4 deletions
| ... | @@ -41,7 +41,8 @@ | ... | @@ -41,7 +41,8 @@ |
| 41 | // internal state | 41 | // internal state |
| 42 | var settings, | 42 | var settings, |
| 43 | timer = null, | 43 | timer = null, |
| 44 | - data = []; | 44 | + data = [], |
| 45 | + enabled; | ||
| 45 | 46 | ||
| 46 | // DOM elements | 47 | // DOM elements |
| 47 | var flashDiv, svg; | 48 | var flashDiv, svg; |
| ... | @@ -123,6 +124,8 @@ | ... | @@ -123,6 +124,8 @@ |
| 123 | } | 124 | } |
| 124 | 125 | ||
| 125 | function flash(msg) { | 126 | function flash(msg) { |
| 127 | + if (!enabled) return; | ||
| 128 | + | ||
| 126 | if (timer) { | 129 | if (timer) { |
| 127 | $timeout.cancel(timer); | 130 | $timeout.cancel(timer); |
| 128 | } | 131 | } |
| ... | @@ -136,6 +139,10 @@ | ... | @@ -136,6 +139,10 @@ |
| 136 | updateFlash(); | 139 | updateFlash(); |
| 137 | } | 140 | } |
| 138 | 141 | ||
| 142 | + function enable(b) { | ||
| 143 | + enabled = !!b; | ||
| 144 | + } | ||
| 145 | + | ||
| 139 | angular.module('onosLayer') | 146 | angular.module('onosLayer') |
| 140 | .factory('FlashService', ['$log', '$timeout', | 147 | .factory('FlashService', ['$log', '$timeout', |
| 141 | function (_$log_, _$timeout_) { | 148 | function (_$log_, _$timeout_) { |
| ... | @@ -145,11 +152,13 @@ | ... | @@ -145,11 +152,13 @@ |
| 145 | function initFlash(opts) { | 152 | function initFlash(opts) { |
| 146 | settings = angular.extend({}, defaultSettings, opts); | 153 | settings = angular.extend({}, defaultSettings, opts); |
| 147 | flashDiv = d3.select('#flash'); | 154 | flashDiv = d3.select('#flash'); |
| 155 | + enabled = true; | ||
| 148 | } | 156 | } |
| 149 | 157 | ||
| 150 | return { | 158 | return { |
| 151 | initFlash: initFlash, | 159 | initFlash: initFlash, |
| 152 | - flash: flash | 160 | + flash: flash, |
| 161 | + enable: enable | ||
| 153 | }; | 162 | }; |
| 154 | }]); | 163 | }]); |
| 155 | 164 | ... | ... |
| ... | @@ -273,10 +273,12 @@ | ... | @@ -273,10 +273,12 @@ |
| 273 | 273 | ||
| 274 | $log.debug('TOPO---- Prefs State:', prefsState); | 274 | $log.debug('TOPO---- Prefs State:', prefsState); |
| 275 | 275 | ||
| 276 | + flash.enable(false); | ||
| 276 | toggleInstances(prefsState.insts); | 277 | toggleInstances(prefsState.insts); |
| 277 | toggleSummary(prefsState.summary); | 278 | toggleSummary(prefsState.summary); |
| 278 | toggleDetails(prefsState.detail); | 279 | toggleDetails(prefsState.detail); |
| 279 | toggleSprites(prefsState.sprites); | 280 | toggleSprites(prefsState.sprites); |
| 281 | + flash.enable(true); | ||
| 280 | } | 282 | } |
| 281 | 283 | ||
| 282 | 284 | ||
| ... | @@ -362,7 +364,9 @@ | ... | @@ -362,7 +364,9 @@ |
| 362 | function (proj) { | 364 | function (proj) { |
| 363 | projection = proj; | 365 | projection = proj; |
| 364 | $log.debug('** We installed the projection: ', proj); | 366 | $log.debug('** We installed the projection: ', proj); |
| 367 | + flash.enable(false); | ||
| 365 | toggleMap(prefsState.bg); | 368 | toggleMap(prefsState.bg); |
| 369 | + flash.enable(true); | ||
| 366 | } | 370 | } |
| 367 | ); | 371 | ); |
| 368 | spriteG = zoomLayer.append ('g').attr('id', 'topo-sprites'); | 372 | spriteG = zoomLayer.append ('g').attr('id', 'topo-sprites'); | ... | ... |
| ... | @@ -47,8 +47,8 @@ describe('factory: fw/layer/flash.js', function () { | ... | @@ -47,8 +47,8 @@ describe('factory: fw/layer/flash.js', function () { |
| 47 | 47 | ||
| 48 | it('should define api functions', function () { | 48 | it('should define api functions', function () { |
| 49 | expect(fs.areFunctions(flash, [ | 49 | expect(fs.areFunctions(flash, [ |
| 50 | - 'initFlash', 'flash' | 50 | + 'initFlash', 'flash', 'enable' |
| 51 | - ])).toBeTruthy(); | 51 | + ])).toBe(true); |
| 52 | }); | 52 | }); |
| 53 | 53 | ||
| 54 | it('should have no items to start', function () { | 54 | it('should have no items to start', function () { | ... | ... |
-
Please register or login to post a comment