diff --git a/deploy/plugins/index.js b/deploy/plugins/index.js index 6089e2fe9eb3c54dcb8f4c081f947d4cb719377c..028a0158d9a94b4a353242099c9cfed7eb8f867f 100644 --- a/deploy/plugins/index.js +++ b/deploy/plugins/index.js @@ -35,40 +35,45 @@ const getKey = url => `plugin:manifest-cache:${url}` router.get('/manifests', async (_req, res) => { const allManifests = await Promise.all( - [...V2_7_PLUGIN_URLS, ...V2_7_STAGING_PLUGIN_URLS].map(async url => - race( - async () => { - const key = getKey(url) - - await lruStore._initPr - const { store } = lruStore - - try { - const storedManifest = await store.get(key) - if (storedManifest) return JSON.parse(storedManifest) - else throw `not found` - } catch (e) { - const resp = await got(url) - const json = JSON.parse(resp.body) - - const { iframeUrl, 'siibra-explorer': flag } = json - if (!flag) return null - if (!iframeUrl) return null - const u = new URL(url) + [...V2_7_PLUGIN_URLS, ...V2_7_STAGING_PLUGIN_URLS].map(async url => { + try { + return await race( + async () => { + const key = getKey(url) - let replaceObj = {} - if (!/^https?:\/\//.test(iframeUrl)) { - u.pathname = path.resolve(path.dirname(u.pathname), iframeUrl) - replaceObj['iframeUrl'] = u.toString() + await lruStore._initPr + const { store } = lruStore + + try { + const storedManifest = await store.get(key) + if (storedManifest) return JSON.parse(storedManifest) + else throw `not found` + } catch (e) { + const resp = await got(url) + const json = JSON.parse(resp.body) + + const { iframeUrl, 'siibra-explorer': flag } = json + if (!flag) return null + if (!iframeUrl) return null + const u = new URL(url) + + let replaceObj = {} + if (!/^https?:\/\//.test(iframeUrl)) { + u.pathname = path.resolve(path.dirname(u.pathname), iframeUrl) + replaceObj['iframeUrl'] = u.toString() + } + const returnObj = {...json, ...replaceObj} + await store.set(key, JSON.stringify(returnObj), { maxAge: 1000 * 60 * 60 }) + return returnObj } - const returnObj = {...json, ...replaceObj} - await store.set(key, JSON.stringify(returnObj), { maxAge: 1000 * 60 * 60 }) - return returnObj - } - }, - { timeout: 1000 } - ) - ) + }, + { timeout: 1000 } + ) + } catch (e) { + console.error(`fetching manifest error: ${e}`) + return null + } + }) ) res.status(200).json( diff --git a/e2e/checklist.md b/e2e/checklist.md index b51cd1cdc38ce354cf1bc0ca97a6d06e9b3896b4..b1a0c2ce262eb278c84724a0c680404b6c512fc6 100644 --- a/e2e/checklist.md +++ b/e2e/checklist.md @@ -72,3 +72,4 @@ - [ ] [vipUrl](https://atlases.ebrains.eu/viewer-staging/mouse) redirects allen mouse 2017 ## plugins - [ ] jugex plugin works +- [ ] 1um section works diff --git a/src/widget/service.ts b/src/widget/service.ts index b20ee1f278be7991b2f0728af198e0624546eb29..9430269418731ceb3b57810b54b26ef155ef7ef0 100644 --- a/src/widget/service.ts +++ b/src/widget/service.ts @@ -19,7 +19,6 @@ export class WidgetService { } public addNewWidget<T>(Component: new (...arg: any) => T, injector: Injector): WidgetPortal<T> { - const widgetPortal = this.vcr.createComponent(this.cf, 0, injector) as ComponentRef<WidgetPortal<T>> const inj = Injector.create({ providers: [{ provide: RM_WIDGET, @@ -27,6 +26,7 @@ export class WidgetService { }], parent: injector }) + const widgetPortal = this.vcr.createComponent(this.cf, 0, inj) as ComponentRef<WidgetPortal<T>> const cmpPortal = new ComponentPortal<T>(Component, this.vcr, inj) this.viewRefMap.set(widgetPortal.instance, widgetPortal)