GUI -- Added enable() function to flash service, to allow topo view to disable flash messages while restoring state..
Change-Id: I1c904d0b69bf707ffa08b423ac5d4ecf7b0a7ff2
diff --git a/web/gui/src/main/webapp/app/fw/layer/flash.js b/web/gui/src/main/webapp/app/fw/layer/flash.js
index 5ae0ca9..0d95b77 100644
--- a/web/gui/src/main/webapp/app/fw/layer/flash.js
+++ b/web/gui/src/main/webapp/app/fw/layer/flash.js
@@ -41,7 +41,8 @@
// internal state
var settings,
timer = null,
- data = [];
+ data = [],
+ enabled;
// DOM elements
var flashDiv, svg;
@@ -123,6 +124,8 @@
}
function flash(msg) {
+ if (!enabled) return;
+
if (timer) {
$timeout.cancel(timer);
}
@@ -136,6 +139,10 @@
updateFlash();
}
+ function enable(b) {
+ enabled = !!b;
+ }
+
angular.module('onosLayer')
.factory('FlashService', ['$log', '$timeout',
function (_$log_, _$timeout_) {
@@ -145,11 +152,13 @@
function initFlash(opts) {
settings = angular.extend({}, defaultSettings, opts);
flashDiv = d3.select('#flash');
+ enabled = true;
}
return {
initFlash: initFlash,
- flash: flash
+ flash: flash,
+ enable: enable
};
}]);
diff --git a/web/gui/src/main/webapp/app/view/topo/topo.js b/web/gui/src/main/webapp/app/view/topo/topo.js
index 2233bb2..24b40bd 100644
--- a/web/gui/src/main/webapp/app/view/topo/topo.js
+++ b/web/gui/src/main/webapp/app/view/topo/topo.js
@@ -273,10 +273,12 @@
$log.debug('TOPO---- Prefs State:', prefsState);
+ flash.enable(false);
toggleInstances(prefsState.insts);
toggleSummary(prefsState.summary);
toggleDetails(prefsState.detail);
toggleSprites(prefsState.sprites);
+ flash.enable(true);
}
@@ -362,7 +364,9 @@
function (proj) {
projection = proj;
$log.debug('** We installed the projection: ', proj);
+ flash.enable(false);
toggleMap(prefsState.bg);
+ flash.enable(true);
}
);
spriteG = zoomLayer.append ('g').attr('id', 'topo-sprites');
diff --git a/web/gui/src/main/webapp/tests/app/fw/layer/flash-spec.js b/web/gui/src/main/webapp/tests/app/fw/layer/flash-spec.js
index 0581b89..a17f9e7 100644
--- a/web/gui/src/main/webapp/tests/app/fw/layer/flash-spec.js
+++ b/web/gui/src/main/webapp/tests/app/fw/layer/flash-spec.js
@@ -47,8 +47,8 @@
it('should define api functions', function () {
expect(fs.areFunctions(flash, [
- 'initFlash', 'flash'
- ])).toBeTruthy();
+ 'initFlash', 'flash', 'enable'
+ ])).toBe(true);
});
it('should have no items to start', function () {