summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/services/event-bus.service.ts
diff options
context:
space:
mode:
authorIdan Amit <ia096e@intl.att.com>2018-05-07 15:55:00 +0300
committerMichael Lando <ml636r@att.com>2018-05-08 13:33:05 +0000
commitecd3d712aad4ac37f399c90f4bf9258bfe483b9a (patch)
tree39e51c55bd99177fa59bb782ccded341420ed67f /catalog-ui/src/app/ng2/services/event-bus.service.ts
parent787ee0846bacaffedb40d481347762001c3146bd (diff)
Developed disable navigation mechanism
Added a mechanism to disable and enable the navigation when waiting for a response from a plugin Change-Id: I11cba9a7fc2a32e3d3d32fb9cf9f0590900fe73b Issue-ID: SDC-1277 Signed-off-by: Idan Amit <ia096e@intl.att.com>
Diffstat (limited to 'catalog-ui/src/app/ng2/services/event-bus.service.ts')
-rw-r--r--catalog-ui/src/app/ng2/services/event-bus.service.ts44
1 files changed, 44 insertions, 0 deletions
diff --git a/catalog-ui/src/app/ng2/services/event-bus.service.ts b/catalog-ui/src/app/ng2/services/event-bus.service.ts
index 438437d193..cff18e1db3 100644
--- a/catalog-ui/src/app/ng2/services/event-bus.service.ts
+++ b/catalog-ui/src/app/ng2/services/event-bus.service.ts
@@ -49,4 +49,48 @@ export class EventBusService extends BasePubSub {
this.handlePluginRegistration(event.data, event);
}
}
+
+ public disableNavigation(isDisable: boolean) {
+ if (isDisable) {
+ let disableDiv = document.createElement('div');
+ disableDiv.style.cssText = "position: fixed;\n" +
+ "z-index: 1029;\n" +
+ "background: rgba(0,0,0,0.5);\n" +
+ "width: 100%;\n" +
+ "height: 100%;\n" +
+ "top: 0;\n" +
+ "left: 0;";
+ disableDiv.setAttribute("class", "disable-navigation-div");
+ document.body.appendChild(disableDiv);
+ }
+ else {
+ document.getElementsByClassName("disable-navigation-div")[0].remove();
+ }
+ }
+
+ public notify(eventType:string, eventData?:any, disableOnWaiting:boolean=true) {
+ let doDisable = false;
+
+ if (disableOnWaiting) {
+ doDisable = this.isWaitingForEvent(eventType);
+
+ if (doDisable) {
+ this.disableNavigation(true);
+ }
+ }
+
+ const origSubscribe = super.notify(eventType, eventData).subscribe;
+
+ return {
+ subscribe: function (callbackFn) {
+ origSubscribe(() => {
+ if (doDisable) {
+ this.disableNavigation(false);
+ }
+
+ callbackFn();
+ });
+ }.bind(this)
+ };
+ }
}