summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2
diff options
context:
space:
mode:
authorIdan Amit <idan.amit@intl.att.com>2019-01-08 16:41:23 +0200
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-01-16 09:13:38 +0000
commitfe65ddd4b7e68a683d4e027f136ac85c8d0b29f4 (patch)
tree2cce37a407c0d5b48b375a5a60ef15ab24b199fb /catalog-ui/src/app/ng2
parent82be4fb725eef356ccf45a191990973753176ec7 (diff)
minor fixes to sdc-pubsub
Aligned sdc code to the fixes that were made in the sdc-pubsub library Change-Id: I54e48e55915dadd3fdb53c0290e013708161aa46 Issue-ID: SDC-2032 Signed-off-by: Idan Amit <idan.amit@intl.att.com>
Diffstat (limited to 'catalog-ui/src/app/ng2')
-rw-r--r--catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts9
-rw-r--r--catalog-ui/src/app/ng2/services/event-bus.service.ts72
2 files changed, 40 insertions, 41 deletions
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 067bb96d8e..d70c448984 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} from "@angular/core";
+import {Component, EventEmitter, Inject, Input, OnInit, Output} from "@angular/core";
import {URLSearchParams} from '@angular/http';
import {Plugin} from "app/models";
import {EventBusService} from "../../../services/event-bus.service";
@@ -35,6 +35,8 @@ export class PluginFrameComponent implements OnInit {
if (this.plugin.isOnline) {
this.initPlugin();
+ } else {
+ this.onLoadingDone.emit();
}
})
@@ -68,7 +70,7 @@ export class PluginFrameComponent implements OnInit {
// before moving to a new state
this.$scope.$on('$stateChangeStart', (event, toState, toParams, fromState, fromParams) => {
if ((fromState.name !== toState.name) || (fromState.name === toState.name) && (toParams.path !== fromParams.path)) {
- if(this.eventBusService.NoWindowOutEvents.indexOf(this.eventBusService.lastEventNotified) == -1) {
+ if (this.eventBusService.NoWindowOutEvents.indexOf(this.eventBusService.lastEventNotified) == -1) {
if (!this.isClosed) {
event.preventDefault();
@@ -79,8 +81,7 @@ export class PluginFrameComponent implements OnInit {
this.$state.go(toState.name, toParams);
});
}
- }
- else {
+ } else {
this.eventBusService.unregister(this.plugin.pluginId);
}
}
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);
+ }
+ }
}