diff --git a/README.md b/README.md index fc2c32b090546193a5a96342cd375b1648db5104..d0b76d06a393c69ce00b65ebc66fddd079c37770 100644 --- a/README.md +++ b/README.md @@ -50,8 +50,10 @@ The contents inside the folder in `./src/plugin_examples` will be automatically ## AOT compilation +Define `BUNDLEPLUGINS` as a comma separated environment variables to bundle the plugins. + ``` -npm run build-aot +[BUNDLEDPLUGINS=pluginDir1[,pluginDir2...]] npm run build-aot ``` ## JIT Compilation diff --git a/package.json b/package.json index 6c1cc0050f0485f023f3afc55a6e3e46cd5acb2d..40cd5ffaef30350fbf0be073a085bf8e34f6aac2 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build-export": "webpack --config webpack.export.js", "build-export-min": "webpack --config webpack.export.min.js", "build-export-aot": "webpack --config webpack.export.aot.js", - "build-aot": "webpack --config webpack.aot.js", + "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", diff --git a/src/atlasViewer/atlasViewer.component.ts b/src/atlasViewer/atlasViewer.component.ts index f82a6f1da2cbc36e340407255164e83f4f44f96e..13a7758d75cfa34d755f4a4366f40291ca1828e2 100644 --- a/src/atlasViewer/atlasViewer.component.ts +++ b/src/atlasViewer/atlasViewer.component.ts @@ -484,6 +484,9 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit { this.mousePos = [event.clientX, event.clientY] } + @HostBinding('attr.version') + public _version : string = VERSION + get floatingMouseContextualContainerTransform() { return `translate(${this.mousePos[0]}px,${this.mousePos[1]}px)` } diff --git a/src/atlasViewer/atlasViewer.dataService.service.ts b/src/atlasViewer/atlasViewer.dataService.service.ts index cfe257e147bf026958ce0a7de3ac6282a039f2c2..bf763c4ee5993336b1499225d9dbf108c9110b60 100644 --- a/src/atlasViewer/atlasViewer.dataService.service.ts +++ b/src/atlasViewer/atlasViewer.dataService.service.ts @@ -18,15 +18,14 @@ export class AtlasViewerDataService implements OnDestroy{ PLUGINDEV ? fetch('http://localhost:10080/allPluginmanifests').then(res=>res.json()) : Promise.resolve([]), - BUNDLEPLUGIN - ? fetch('pluginsManifests.json').then(res => res.json()) - : Promise.resolve([]), - fetch('res/plugins/manifest.json') - .then(res => res.json()) - .then(json => [json]) - .catch(e => Promise.resolve([])) + Promise.all( + BUNDLEDPLUGINS + .filter(v => typeof v === 'string') + .map(v => fetch(`res/plugin_examples/${v}/manifest.json`).then(res => res.json())) + ) + .then(arr => arr.reduce((acc,curr) => acc.concat(curr) ,[])) ]) - .then(arr => resolve(arr[0].concat(arr[1], arr[2]))) + .then(arr => resolve( [ ... arr[0], ... arr[1] ] )) .catch(reject) }) diff --git a/src/main-aot.ts b/src/main-aot.ts index cae586c5666a0d017c9492f7935a0c4406a150d7..cf870859593a08cc494d4ff02fc9557fa2631fce 100644 --- a/src/main-aot.ts +++ b/src/main-aot.ts @@ -7,9 +7,9 @@ import { enableProdMode } from '@angular/core'; const requireAll = (r:any) => {r.keys().forEach(r)} requireAll(require.context('./res/ext', false, /\.json$/)) requireAll(require.context('./res/images', true, /\.jpg|\.png/)) -requireAll(require.context('./plugin_examples/jugex', false)) +requireAll(require.context(`./plugin_examples`, true)) -/* aot = production mode */ +/* aot === production mode */ enableProdMode() platformBrowserDynamic().bootstrapModule(MainModule) \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 6565a7e5014b40530b32d087dfaf65918c31387c..5eec78190f22de8b0a62e4d71eb812efc3a842ab 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,6 +6,6 @@ import { MainModule } from './main.module'; const requireAll = (r:any) => {r.keys().forEach(r)} requireAll(require.context('./res/ext',false, /\.json$/)) requireAll(require.context('./res/images',true,/\.jpg|\.png/)) -requireAll(require.context('./plugin_examples/jugex', false)) +requireAll(require.context(`./plugin_examples`, true)) platformBrowserDynamic().bootstrapModule(MainModule) \ No newline at end of file diff --git a/src/plugin_examples/newWebJugex/manifest.json b/src/plugin_examples/newWebJugex/manifest.json index ed04ef1098d403150a097767052b710e5139efb2..97462a280738efbf6d57588f74b58bcf8e303c24 100644 --- a/src/plugin_examples/newWebJugex/manifest.json +++ b/src/plugin_examples/newWebJugex/manifest.json @@ -2,6 +2,6 @@ "name" : "fzj.xg.webjugex", "displayName":"JuGEx differential gene expression analysis", "type" : "plugin", - "templateURL" : "http://localhost:10080/newWebJugex/template.html", - "scriptURL" : "http://localhost:10080/newWebJugex/script.js" + "templateURL" : "res/plugin_examples/newWebJugex/template.html", + "scriptURL" : "res/plugin_examples/newWebJugex/script.js" } \ No newline at end of file diff --git a/src/plugin_examples/newWebJugex/script.js b/src/plugin_examples/newWebJugex/script.js index 3636770221611a7b709f616eb6d8a79fff969b5b..95655365e6e4d4dba2aa2ef4c9512a17aa648e37 100644 --- a/src/plugin_examples/newWebJugex/script.js +++ b/src/plugin_examples/newWebJugex/script.js @@ -22,7 +22,7 @@ // }]) const backendRoot = null - const srcRoot = 'http://localhost:10080/newWebJugex' + const srcRoot = 'res/plugin_examples/newWebJugex' const manifestID = 'fzj.xg.webjugex' /* so that on shutdown, we could unload these libraries */ diff --git a/typings/index.d.ts b/typings/index.d.ts index 66994ab974e7f7ff997b7ef2ec5d9e2f4a98ea50..aded50e457631fea7598fe6df98c075f5538012f 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -9,4 +9,5 @@ declare module '*.css' { } declare var PLUGINDEV : boolean -declare var BUNDLEPLUGIN : boolean \ No newline at end of file +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 54db495c1eb75f0540d73bfa04bac36d10cc3b2f..ae3714c2e254fdd64e033a51c1d785218352da19 100644 --- a/webpack.staticassets.js +++ b/webpack.staticassets.js @@ -31,8 +31,9 @@ module.exports = { use : [{ loader : 'file-loader', options : { - name : '[name].[ext]', - outputPath : 'res/plugins' + name : '[path][name].[ext]', + outputPath : 'res', + context : 'src' } }] } @@ -41,7 +42,15 @@ module.exports = { plugins : [ new webpack.DefinePlugin({ PLUGINDEV : process.env.PLUGINDEV ? true : false, - BUNDLEPLUGIN : process.env.BUNDLEPLUGIN ? true : false + BUNDLEDPLUGINS : process.env.BUNDLEDPLUGINS + ? JSON.stringify(process.env.BUNDLEDPLUGINS.split(',')) + : JSON.stringify([]), + VERSION : process.env.VERSION + ? JSON.stringify(process.env.VERSION) + : process.env.GIT_HASH + ? JSON.stringify(process.env.GIT_HASH) + : JSON.stringify('unspecificied hash') }) + // ...ignoreArr.map(dirname => new webpack.IgnorePlugin(/\.\/plugin_examples/)) ] } \ No newline at end of file