From f6ddad9c6f5d5801da3e6cb8d2c12ae81c2b7582 Mon Sep 17 00:00:00 2001 From: ilanap Date: Tue, 17 Dec 2019 14:57:13 +0200 Subject: Fix loader for unready plugins 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 Change-Id: I9c3d637135153f0607a6588e5f588450c1708b99 --- .../src/app/ng2/components/ui/plugin/plugin-frame.component.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'catalog-ui/src/app/ng2/components/ui') 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 d94f24da28..e704e3c983 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 @@ -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); -- cgit 1.2.3-korg