From 2f65168dc133118866911f644b189d79f3a10bfc Mon Sep 17 00:00:00 2001 From: Xiao Gui <xgui3783@gmail.com> Date: Tue, 23 Apr 2019 17:16:02 +0200 Subject: [PATCH] chore: standardise launch widget with pluginState --- .../atlasViewer.pluginService.service.ts | 16 +++++++++------- .../atlasViewer.urlService.service.ts | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/atlasViewer/atlasViewer.pluginService.service.ts b/src/atlasViewer/atlasViewer.pluginService.service.ts index 0ad03718b..07be6886b 100644 --- a/src/atlasViewer/atlasViewer.pluginService.service.ts +++ b/src/atlasViewer/atlasViewer.pluginService.service.ts @@ -32,13 +32,7 @@ export class PluginServices{ ){ this.pluginUnitFactory = this.cfr.resolveComponentFactory( PluginUnit ) - this.apiService.interactiveViewer.uiHandle.launchNewWidget = (manifest) => this.launchPlugin(manifest) - .then(handler => { - this.orphanPlugins.add(manifest) - handler.onShutdown(() => { - this.orphanPlugins.delete(manifest) - }) - }) + this.apiService.interactiveViewer.uiHandle.launchNewWidget = this.launchNewWidget.bind(this) this.atlasDataService.promiseFetchedPluginManifests @@ -47,6 +41,14 @@ export class PluginServices{ .catch(console.error) } + launchNewWidget = (manifest) => this.launchPlugin(manifest) + .then(handler => { + this.orphanPlugins.add(manifest) + handler.onShutdown(() => { + this.orphanPlugins.delete(manifest) + }) + }) + readyPlugin(plugin:PluginManifest):Promise<any>{ return Promise.all([ isDefined(plugin.template) ? diff --git a/src/atlasViewer/atlasViewer.urlService.service.ts b/src/atlasViewer/atlasViewer.urlService.service.ts index 7d95d349e..c707eb3c7 100644 --- a/src/atlasViewer/atlasViewer.urlService.service.ts +++ b/src/atlasViewer/atlasViewer.urlService.service.ts @@ -182,7 +182,7 @@ export class AtlasViewerURLService{ const pluginStates = searchparams.get('pluginStates') if(pluginStates){ const arrPluginStates = pluginStates.split('__') - arrPluginStates.forEach(url => fetch(url).then(res => res.json()).then(json => this.pluginService.launchPlugin(json)).catch(console.error)) + arrPluginStates.forEach(url => fetch(url).then(res => res.json()).then(json => this.pluginService.launchNewWidget(json)).catch(console.error)) } }) -- GitLab