Skip to content
Snippets Groups Projects
Commit 271c9e55 authored by Xiao Gui's avatar Xiao Gui
Browse files

bugfix: closing widgets

bugfix: time limit on fetching plugin manifests
chore: updated checklist
parent ae9deee2
No related branches found
No related tags found
No related merge requests found
...@@ -35,40 +35,45 @@ const getKey = url => `plugin:manifest-cache:${url}` ...@@ -35,40 +35,45 @@ const getKey = url => `plugin:manifest-cache:${url}`
router.get('/manifests', async (_req, res) => { router.get('/manifests', async (_req, res) => {
const allManifests = await Promise.all( const allManifests = await Promise.all(
[...V2_7_PLUGIN_URLS, ...V2_7_STAGING_PLUGIN_URLS].map(async url => [...V2_7_PLUGIN_URLS, ...V2_7_STAGING_PLUGIN_URLS].map(async url => {
race( try {
async () => { return await race(
const key = getKey(url) 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)
let replaceObj = {} await lruStore._initPr
if (!/^https?:\/\//.test(iframeUrl)) { const { store } = lruStore
u.pathname = path.resolve(path.dirname(u.pathname), iframeUrl)
replaceObj['iframeUrl'] = u.toString() 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 }) { timeout: 1000 }
return returnObj )
} } catch (e) {
}, console.error(`fetching manifest error: ${e}`)
{ timeout: 1000 } return null
) }
) })
) )
res.status(200).json( res.status(200).json(
......
...@@ -72,3 +72,4 @@ ...@@ -72,3 +72,4 @@
- [ ] [vipUrl](https://atlases.ebrains.eu/viewer-staging/mouse) redirects allen mouse 2017 - [ ] [vipUrl](https://atlases.ebrains.eu/viewer-staging/mouse) redirects allen mouse 2017
## plugins ## plugins
- [ ] jugex plugin works - [ ] jugex plugin works
- [ ] 1um section works
...@@ -19,7 +19,6 @@ export class WidgetService { ...@@ -19,7 +19,6 @@ export class WidgetService {
} }
public addNewWidget<T>(Component: new (...arg: any) => T, injector: Injector): WidgetPortal<T> { 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({ const inj = Injector.create({
providers: [{ providers: [{
provide: RM_WIDGET, provide: RM_WIDGET,
...@@ -27,6 +26,7 @@ export class WidgetService { ...@@ -27,6 +26,7 @@ export class WidgetService {
}], }],
parent: injector parent: injector
}) })
const widgetPortal = this.vcr.createComponent(this.cf, 0, inj) as ComponentRef<WidgetPortal<T>>
const cmpPortal = new ComponentPortal<T>(Component, this.vcr, inj) const cmpPortal = new ComponentPortal<T>(Component, this.vcr, inj)
this.viewRefMap.set(widgetPortal.instance, widgetPortal) this.viewRefMap.set(widgetPortal.instance, widgetPortal)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment