Fix loader for unready plugins 15/99715/3
authorilanap <ilanap@amdocs.com>
Tue, 17 Dec 2019 12:57:13 +0000 (14:57 +0200)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Wed, 5 Feb 2020 07:46:21 +0000 (07:46 +0000)
Checks whether plugin was ready and will reset loader and ready event when moving between windows if not.

Issue-ID: SDC-2715
Signed-off-by: ilanap <ilanap@amdocs.com>
Change-Id: I9c3d637135153f0607a6588e5f588450c1708b99

catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts

index d94f24d..e704e3c 100644 (file)
@@ -18,6 +18,7 @@ export class PluginFrameComponent implements OnInit {
     pluginUrl: string;
     private urlSearchParams: URLSearchParams;
     private isClosed: boolean;
+    private isReady: boolean;
     private isPluginCheckDone: boolean;
 
     constructor(private eventBusService: EventBusService,
@@ -44,6 +45,7 @@ export class PluginFrameComponent implements OnInit {
     private initPlugin() {
         this.pluginUrl = this.plugin.pluginSourceUrl;
         this.isClosed = false;
+        this.isReady = false;
 
         if (this.queryParams && !_.isEmpty(this.queryParams)) {
             _.forOwn(this.queryParams, (value, key) => {
@@ -57,6 +59,7 @@ export class PluginFrameComponent implements OnInit {
         let readyEvent = (eventData) => {
             if (eventData.originId === this.plugin.pluginId) {
                 if (eventData.type == "READY") {
+                    this.isReady = true;
                     this.onLoadingDone.emit();
                     this.eventBusService.off(readyEvent)
                 }
@@ -69,10 +72,13 @@ 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.isReady) {
+                    this.onLoadingDone.emit();
+                    this.eventBusService.off(readyEvent)
+                }
                 if (this.eventBusService.NoWindowOutEvents.indexOf(this.eventBusService.lastEventNotified) == -1) {
                     if (!this.isClosed) {
                         event.preventDefault();
-
                         this.eventBusService.notify("WINDOW_OUT").subscribe(() => {
                             this.isClosed = true;
                             this.eventBusService.unregister(this.plugin.pluginId);