diff --git a/deploy/auth/hbp-oidc.js b/deploy/auth/hbp-oidc.js index a6963750d8469a224c04018c1ef63209cfa9bfc8..a3dfb823b7e500535da14969f8ea966df5957140 100644 --- a/deploy/auth/hbp-oidc.js +++ b/deploy/auth/hbp-oidc.js @@ -2,10 +2,11 @@ const passport = require('passport') const { configureAuth } = require('./oidc') const HOSTNAME = process.env.HOSTNAME || 'http://localhost:3000' +const HOST_PATHNAME = process.env.HOST_PATHNAME || '' const clientId = process.env.HBP_CLIENTID || 'no hbp id' const clientSecret = process.env.HBP_CLIENTSECRET || 'no hbp client secret' const discoveryUrl = 'https://services.humanbrainproject.eu/oidc' -const redirectUri = `${HOSTNAME}/hbp-oidc/cb` +const redirectUri = `${HOSTNAME}${HOST_PATHNAME}/hbp-oidc/cb` const cb = (tokenset, {sub, given_name, family_name, ...rest}, done) => { return done(null, { id: `hbp-oidc:${sub}`, @@ -34,8 +35,8 @@ module.exports = async (app) => { passport.use('hbp-oidc', oidcStrategy) app.get('/hbp-oidc/auth', passport.authenticate('hbp-oidc')) app.get('/hbp-oidc/cb', passport.authenticate('hbp-oidc', { - successRedirect: '/', - failureRedirect: '/' + successRedirect: `${HOST_PATHNAME}/`, + failureRedirect: `${HOST_PATHNAME}/` })) } catch (e) { console.error(e) diff --git a/deploy/auth/index.js b/deploy/auth/index.js index 4f0f75a53c987f8207cd943cc7923acd704ef974..0ad0941dfe9804a442d131130410d6a4098acaea 100644 --- a/deploy/auth/index.js +++ b/deploy/auth/index.js @@ -1,6 +1,7 @@ const hbpOidc = require('./hbp-oidc') const passport = require('passport') const objStoreDb = new Map() +const HOST_PATHNAME = process.env.HOST_PATHNAME || '' module.exports = async (app) => { app.use(passport.initialize()) @@ -29,9 +30,8 @@ module.exports = async (app) => { }) app.get('/logout', (req, res) => { - if (req.user && req.user.id) - objStoreDb.delete(req.user.id) + if (req.user && req.user.id) objStoreDb.delete(req.user.id) req.logout() - res.redirect('/') + res.redirect(`${HOST_PATHNAME}/`) }) } \ No newline at end of file diff --git a/deploy/auth/util.js b/deploy/auth/util.js index 554d5f4970f6639e3f436eaabb5cddcc7949fb40..c9240bf3d7b1cd8cdec89a8b3df6b7b8520073db 100644 --- a/deploy/auth/util.js +++ b/deploy/auth/util.js @@ -2,10 +2,11 @@ const { configureAuth } = require('./oidc') const jwtDecode = require('jwt-decode') const HOSTNAME = process.env.HOSTNAME || 'http://localhost:3000' +const HOST_PATHNAME = process.env.HOST_PATHNAME || '' const clientId = process.env.HBP_CLIENTID || 'no hbp id' const clientSecret = process.env.HBP_CLIENTSECRET || 'no hbp client secret' const discoveryUrl = 'https://services.humanbrainproject.eu/oidc' -const redirectUri = `${HOSTNAME}/hbp-oidc/cb` +const redirectUri = `${HOSTNAME}${HOST_PATHNAME}/hbp-oidc/cb` let REFRESH_TOKEN = process.env.REFRESH_TOKEN || null const CLIENT_NOT_INIT = `Client is not initialised.` diff --git a/deploy/datasets/supplements/previewFile.js b/deploy/datasets/supplements/previewFile.js index 2600b01bb9615dab3c7ee4aa18878405bfb18070..7c3edcaab9e8f965b97b6ab94b74a45f6a3a9741 100644 --- a/deploy/datasets/supplements/previewFile.js +++ b/deploy/datasets/supplements/previewFile.js @@ -6,6 +6,7 @@ const DISABLE_JUBRAIN_PMAP = process.env.DISABLE_JUBRAIN_PMAP const DISABLE_JUBRAIN_PMAP_V17 = process.env.DISABLE_JUBRAIN_PMAP_V17 const DISABLE_DWM_PMAP = process.env.DISABLE_DWM_PMAP const HOSTNAME = process.env.HOSTNAME || 'http://localhost:3000' +const HOST_PATHNAME = process.env.HOST_PATHNAME || '' let previewMap = new Map(), previewMapKeySet = new Set() @@ -48,7 +49,7 @@ exports.getPreviewFile = ({ datasetName, templateSelected }) => previewMap.get(d ...file, ...(file.url && !/^http/.test(file.url) ? { - url: `${HOSTNAME}/${file.url}` + url: `${HOSTNAME}${HOST_PATHNAME}/${file.url}` } : {}) } diff --git a/deploy/server.js b/deploy/server.js index a29f239638094c61d0dde1f206e866e6a98eec53..ce483fb833f85430d3a557af0c66b267fd490fab 100644 --- a/deploy/server.js +++ b/deploy/server.js @@ -63,8 +63,14 @@ const PORT = process.env.PORT || 3000 // e.g. HOST_PATHNAME=/viewer // n.b. leading slash is important +// n.b. no trailing slash is important const HOST_PATHNAME = process.env.HOST_PATHNAME || '' +if(HOST_PATHNAME !== '') { + if (HOST_PATHNAME.slice(0,1) !== '/') throw new Error(`HOST_PATHNAME, if defined and non-empty, should start with a leading slash. HOST_PATHNAME: ${HOST_PATHNAME}`) + if (HOST_PATHNAME.slice(-1) === '/') throw new Error(`HOST_PATHNAME, if defined and non-emtpy, should NOT end with a slash. HOST_PATHNAME: ${HOST_PATHNAME}`) +} + server.disable('x-powered-by') server.use(HOST_PATHNAME, app) diff --git a/package.json b/package.json index 547d0115b29403034393405ed5be5e397dd09aaf..3f59dc8a0a646242e37d5452254256b028c5a702 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "build-min": "webpack --config webpack.prod.js", "build": "webpack --config webpack.dev.js", "plugin-server": "node ./src/plugin_examples/server.js", - "dev-server": "BACKEND_URL=http://localhost:3000/viewer/ webpack-dev-server --config webpack.dev.js --mode development", + "dev-server": "BACKEND_URL=http://localhost:3000/ webpack-dev-server --config webpack.dev.js --mode development", "dev": "npm run dev-server & (cd deploy; node server.js)", "dev-server-aot": "PRODUCTION=true GIT_HASH=`git log --pretty=format:'%h' --invert-grep --grep=^.ignore -1` webpack-dev-server --config webpack.aot.js", "dev-server-all-interfaces": "webpack-dev-server --config webpack.dev.js --mode development --hot --host 0.0.0.0", diff --git a/src/ui/nehubaContainer/splashScreen/splashScreen.style.css b/src/ui/nehubaContainer/splashScreen/splashScreen.style.css index 49774d56632717713c75fc404f681049c0e06e5c..105dc67a4356e82b8e3bbcc42997610af3ccc898 100644 --- a/src/ui/nehubaContainer/splashScreen/splashScreen.style.css +++ b/src/ui/nehubaContainer/splashScreen/splashScreen.style.css @@ -1,8 +1,9 @@ :host { - display: block; + display: inline-block; overflow: auto; height: 100%; + width: 100%; } .font-stretch diff --git a/src/ui/nehubaContainer/splashScreen/splashScreen.template.html b/src/ui/nehubaContainer/splashScreen/splashScreen.template.html index a63adbeb71157ff8282a9abda4d5e30e58d79924..71a731611707b5b9139c20bdad4a511e46259065 100644 --- a/src/ui/nehubaContainer/splashScreen/splashScreen.template.html +++ b/src/ui/nehubaContainer/splashScreen/splashScreen.template.html @@ -1,43 +1,47 @@ -<div - #parentContainer - class="m-5 d-flex flex-row flex-wrap justify-content-center align-items-stretch pe-none"> - <mat-card - (mousedown)="activatedTemplate$.next(template)" - matRipple - *ngFor="let template of loadedTemplate$ | async | filterNull" - class="m-3 col-md-12 col-lg-6 pe-all mw-400px"> - <mat-card-header> - <mat-card-title class="text-nowrap font-stretch"> - {{ template.properties.name }} - </mat-card-title> - </mat-card-header> - <img - [src]="template.properties.name | getTemplateImageSrcPipe" - [srcset]="template.properties.name | getTemplateImageSrcPipe | imgSrcSetPipe" - sizes="(max-width:576px) 90vw;(max-width: 768px) 50vw; 400px" - [alt]="'Screenshot of ' + template.properties.name" - mat-card-image /> - <mat-card-content> - {{ template.properties.description }} - </mat-card-content> +<!-- n.b. div wrapper is required for scrolling to work properly --> +<div class="h-100 w-100 overflow-auto"> - <mat-card-content> - <mat-card-subtitle class="text-nowrap"> - Parcellations available - </mat-card-subtitle> - <button - (mousedown)="$event.stopPropagation()" - (click)="$event.stopPropagation(); selectTemplateParcellation(template, parcellation)" - *ngFor="let parcellation of template.parcellations" - mat-button - color="primary"> - {{ parcellation.name }} - </button> - </mat-card-content> + <div + #parentContainer + class="p-5 w-100 d-flex flex-row flex-wrap justify-content-center align-items-stretch pe-all"> + <mat-card + (mousedown)="activatedTemplate$.next(template)" + matRipple + *ngFor="let template of loadedTemplate$ | async | filterNull" + class="m-3 col-md-12 col-lg-6 pe-all mw-400px"> + <mat-card-header> + <mat-card-title class="text-nowrap font-stretch"> + {{ template.properties.name }} + </mat-card-title> + </mat-card-header> + <img + [src]="template.properties.name | getTemplateImageSrcPipe" + [srcset]="template.properties.name | getTemplateImageSrcPipe | imgSrcSetPipe" + sizes="(max-width:576px) 90vw;(max-width: 768px) 50vw; 400px" + [alt]="'Screenshot of ' + template.properties.name" + mat-card-image /> + <mat-card-content> + {{ template.properties.description }} + </mat-card-content> - <!-- required... or on ripple, angular adds 16px margin to the bottom --> - <!-- see https://github.com/angular/components/issues/10898 --> - <mat-card-footer> - </mat-card-footer> - </mat-card> + <mat-card-content> + <mat-card-subtitle class="text-nowrap"> + Parcellations available + </mat-card-subtitle> + <button + (mousedown)="$event.stopPropagation()" + (click)="$event.stopPropagation(); selectTemplateParcellation(template, parcellation)" + *ngFor="let parcellation of template.parcellations" + mat-button + color="primary"> + {{ parcellation.name }} + </button> + </mat-card-content> + + <!-- required... or on ripple, angular adds 16px margin to the bottom --> + <!-- see https://github.com/angular/components/issues/10898 --> + <mat-card-footer> + </mat-card-footer> + </mat-card> + </div> </div> \ No newline at end of file