From ecd3d712aad4ac37f399c90f4bf9258bfe483b9a Mon Sep 17 00:00:00 2001 From: Idan Amit Date: Mon, 7 May 2018 15:55:00 +0300 Subject: 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 --- .../ui/plugin/plugin-frame.component.less | 4 ++ .../components/ui/plugin/plugin-frame.component.ts | 3 +- .../src/app/ng2/services/event-bus.service.ts | 44 ++++++++++++++++++++++ catalog-ui/src/app/ng2/services/plugins.service.ts | 2 +- 4 files changed, 50 insertions(+), 3 deletions(-) (limited to 'catalog-ui/src/app/ng2') diff --git a/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.less b/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.less index 4234987072..d2d4c98cb4 100644 --- a/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.less +++ b/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.less @@ -4,5 +4,9 @@ width: 100%; height: 100%; border: none; + top: 3px; + left: 2px; + position: relative; + z-index: 1030 } } diff --git a/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts b/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts index 4759721034..83d302b2a8 100644 --- a/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts +++ b/catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts @@ -1,4 +1,4 @@ -import {Component, Inject, Input, Output, OnInit, EventEmitter, ViewChild, ElementRef} from "@angular/core"; +import {Component, Inject, Input, Output, OnInit, EventEmitter} from "@angular/core"; import {URLSearchParams} from '@angular/http'; import {Plugin} from "app/models"; import {EventBusService} from "../../../services/event-bus.service"; @@ -63,7 +63,6 @@ export class PluginFrameComponent implements OnInit { this.eventBusService.notify("WINDOW_OUT").subscribe(() => { this.isClosed = true; - this.eventBusService.unregister(this.plugin.pluginId); this.$state.go(toState.name, toParams); 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) + }; + } } diff --git a/catalog-ui/src/app/ng2/services/plugins.service.ts b/catalog-ui/src/app/ng2/services/plugins.service.ts index 4ec90d1ac4..7a85b6e1b6 100644 --- a/catalog-ui/src/app/ng2/services/plugins.service.ts +++ b/catalog-ui/src/app/ng2/services/plugins.service.ts @@ -19,5 +19,5 @@ export class PluginsService { return plugin.pluginDisplayOptions["context"] && plugin.pluginDisplayOptions["context"].displayRoles.includes(userRole) && plugin.pluginDisplayOptions["context"].displayContext.indexOf(contextType) !== -1 - } + }; } -- cgit 1.2.3-korg