From 8cce8332d21e8f17020b14d1ba10b55bba0faaf6 Mon Sep 17 00:00:00 2001 From: Xiao Gui <xgui3783@gmail.com> Date: Thu, 25 Oct 2018 10:29:52 +0200 Subject: [PATCH] feat: allow for custom endpoints for plugins --- README.md | 6 +++++- package.json | 3 ++- src/atlasViewer/atlasViewer.dataService.service.ts | 4 +++- typings/index.d.ts | 2 +- webpack.staticassets.js | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d878c448c..67b125549 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,11 @@ To develop plugins for the interactive viewer, run: git clone https://github.com/HumanBrainProject/interactive-viewer cd interactive-viewer npm i -PLUGINDEV=true npm run dev-plugin +npm run dev-plugin + +/* or define your own endpoint that returns string of manifests */ +PLUGINDEV=http://mycustom.io/allPluginmanifest npm run dev-server + ``` The contents inside the folder in `./src/plugin_examples` will be automatically fetched by the dev instance of the interactive-viewer on load. diff --git a/package.json b/package.json index 40cd5ffae..44be1d461 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "build-aot": "GIT_HASH=`git rev-parse --short HEAD` webpack --config webpack.aot.js", "build-min": "webpack --config webpack.prod.js", "build": "webpack --config webpack.dev.js", - "dev-plugin": "PLUGINDEV=true npm run dev-server & node ./src/plugin_examples/server.js", + "dev-plugin": "PLUGINDEV=true npm run dev-server & npm run plugin-server", + "plugin-server": "node ./src/plugin_examples/server.js", "dev-server": "webpack-dev-server --config webpack.dev.js --mode development", "serve-plugins": "node src/plugin_examples/server.js", "test": "karma start spec/karma.conf.js" diff --git a/src/atlasViewer/atlasViewer.dataService.service.ts b/src/atlasViewer/atlasViewer.dataService.service.ts index bf763c4ee..a2d76416a 100644 --- a/src/atlasViewer/atlasViewer.dataService.service.ts +++ b/src/atlasViewer/atlasViewer.dataService.service.ts @@ -16,7 +16,9 @@ export class AtlasViewerDataService implements OnDestroy{ public promiseFetchedPluginManifests : Promise<PluginManifest[]> = new Promise((resolve,reject)=>{ Promise.all([ PLUGINDEV - ? fetch('http://localhost:10080/allPluginmanifests').then(res=>res.json()) + ? PLUGINDEV === 'true' + ? fetch('http://localhost:10080/allPluginmanifests').then(res=>res.json()) + : fetch(PLUGINDEV).then(res => res.json()) : Promise.resolve([]), Promise.all( BUNDLEDPLUGINS diff --git a/typings/index.d.ts b/typings/index.d.ts index aded50e45..2b6a130ea 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -8,6 +8,6 @@ declare module '*.css' { export = contents } -declare var PLUGINDEV : boolean +declare var PLUGINDEV : string declare var BUNDLEDPLUGINS : string[] declare var VERSION : string \ No newline at end of file diff --git a/webpack.staticassets.js b/webpack.staticassets.js index ae3714c2e..6b65ef86e 100644 --- a/webpack.staticassets.js +++ b/webpack.staticassets.js @@ -41,7 +41,7 @@ module.exports = { }, plugins : [ new webpack.DefinePlugin({ - PLUGINDEV : process.env.PLUGINDEV ? true : false, + PLUGINDEV : JSON.stringify(process.env.PLUGINDEV), BUNDLEDPLUGINS : process.env.BUNDLEDPLUGINS ? JSON.stringify(process.env.BUNDLEDPLUGINS.split(',')) : JSON.stringify([]), -- GitLab