diff options
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.ts | 72 |
1 files changed, 35 insertions, 37 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 664ce35080..cc53d7978b 100644 --- a/catalog-ui/src/app/ng2/services/event-bus.service.ts +++ b/catalog-ui/src/app/ng2/services/event-bus.service.ts @@ -1,5 +1,5 @@ -import { Injectable } from '@angular/core'; -import {BasePubSub, IPubSubEvent} from "../../models/base-pubsub"; +import {Injectable} from '@angular/core'; +import {BasePubSub, IPubSubEvent} from 'sdc-pubsub'; @Injectable() export class EventBusService extends BasePubSub { @@ -11,26 +11,6 @@ export class EventBusService extends BasePubSub { this.NoWindowOutEvents = ["CHECK_IN", "SUBMIT_FOR_TESTING", "UNDO_CHECK_OUT"]; } - protected handlePluginRegistration(eventData: IPubSubEvent, event: any) { - if (eventData.type === 'PLUGIN_REGISTER') { - this.register(eventData.data.pluginId, event.source, event.origin); - - let newEventsList = []; - - if (this.eventsToWait.has(eventData.data.pluginId)) { - newEventsList = _.union(this.eventsToWait.get(eventData.data.pluginId), eventData.data.eventsToWait); - } - else { - newEventsList = eventData.data.eventsToWait; - } - - this.eventsToWait.set(eventData.data.pluginId, newEventsList); - - } else if (eventData.type === 'PLUGIN_UNREGISTER') { - this.unregister(eventData.data.pluginId); - } - } - public unregister(pluginId: string) { const unregisterData = { pluginId: pluginId @@ -41,18 +21,6 @@ export class EventBusService extends BasePubSub { }); } - protected onMessage(event: any) { - if (event.data.type === 'PLUGIN_REGISTER') { - this.handlePluginRegistration(event.data, event); - } - - super.onMessage(event); - - if (event.data.type === 'PLUGIN_UNREGISTER') { - this.handlePluginRegistration(event.data, event); - } - } - public disableNavigation(isDisable: boolean) { let iframes = document.getElementsByClassName("plugin-iframe"); @@ -70,8 +38,7 @@ export class EventBusService extends BasePubSub { "left: 0;"; disableDiv.setAttribute("class", "disable-navigation-div"); document.body.appendChild(disableDiv); - } - else { + } else { document.getElementsByClassName("disable-navigation-div")[0].remove(); _.forEach(iframes, (iframeElement: HTMLElement) => { @@ -80,7 +47,7 @@ export class EventBusService extends BasePubSub { } } - public notify(eventType:string, eventData?:any, disableOnWaiting:boolean=true) { + public notify(eventType: string, eventData?: any, disableOnWaiting: boolean = true) { let doDisable = false; if (disableOnWaiting) { @@ -105,4 +72,35 @@ export class EventBusService extends BasePubSub { }.bind(this) }; } + + protected handlePluginRegistration(eventData: IPubSubEvent, event: any) { + if (eventData.type === 'PLUGIN_REGISTER') { + this.register(eventData.data.pluginId, event.source, event.origin); + + let newEventsList = []; + + if (this.eventsToWait.has(eventData.data.pluginId)) { + newEventsList = _.union(this.eventsToWait.get(eventData.data.pluginId), eventData.data.eventsToWait); + } else { + newEventsList = eventData.data.eventsToWait; + } + + this.eventsToWait.set(eventData.data.pluginId, newEventsList); + + } else if (eventData.type === 'PLUGIN_UNREGISTER') { + this.unregister(eventData.data.pluginId); + } + } + + protected onMessage(event: any) { + if (event.data.type === 'PLUGIN_REGISTER') { + this.handlePluginRegistration(event.data, event); + } + + super.onMessage(event); + + if (event.data.type === 'PLUGIN_UNREGISTER') { + this.handlePluginRegistration(event.data, event); + } + } } |