diff --git a/Dockerfile b/Dockerfile index 8836cc77e0413b92037ea01fc9c29e77bc8df320..f792361f3631761c26dc8a676e110052ed0585d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,28 @@ -FROM node:8 - -ARG PORT -ENV PORT=$PORT +FROM node:8 as builder COPY . /iv WORKDIR /iv +ENV VERSION=test + RUN npm i RUN npm run build-aot + +# prod container + +FROM node:8-alpine + +ARG PORT +ENV PORT=$PORT + +RUN apk --no-cache add ca-certificates +RUN mkdir /iv-app +WORKDIR /iv-app +COPY --from=builder /iv/dist . + EXPOSE $PORT -ENTRYPOINT [ "node", "dist/server.js" ] \ No newline at end of file +RUN npm i express + +ENTRYPOINT [ "node", "server.js" ] \ No newline at end of file diff --git a/src/atlasViewer/atlasViewer.constantService.service.ts b/src/atlasViewer/atlasViewer.constantService.service.ts index ead53d9e364375cbea6786064a70614751f329ae..d99fa429dc6819c5541b65e9185426a2191fe76e 100644 --- a/src/atlasViewer/atlasViewer.constantService.service.ts +++ b/src/atlasViewer/atlasViewer.constantService.service.ts @@ -56,7 +56,7 @@ export class AtlasViewerConstantsServices{ 'res/json/MNI152.json', 'res/json/waxholmRatV2_0.json', 'res/json/allenMouse.json', - 'res/json/test.json' + // 'res/json/test.json' ] /* to be provided by KG in future */ diff --git a/src/atlasViewer/atlasViewer.urlService.service.ts b/src/atlasViewer/atlasViewer.urlService.service.ts index 52408d9c10662c60503d7c5474475c556bf27728..d33ae8b6789cd0a91aac31fa475fa882eab2aead 100644 --- a/src/atlasViewer/atlasViewer.urlService.service.ts +++ b/src/atlasViewer/atlasViewer.urlService.service.ts @@ -231,13 +231,27 @@ export class AtlasViewerURLService{ this.pluginState$ ).pipe( /* TODO fix encoding of nifti path. if path has double underscore, this encoding will fail */ - map(([navigationState, niftiLayers, pluginState]) => Object.assign({}, navigationState, { pluginStates : Array.from(pluginState.initManifests.values()).filter(v => v !== null).length > 0 ? Array.from(pluginState.initManifests.values()).filter(v => v !== null).join('__') : null }, { niftiLayers : niftiLayers.length > 0 ? niftiLayers.map(layer => layer.name).join('__') : null })) + map(([navigationState, niftiLayers, pluginState]) => { + return { + ...navigationState, + pluginState: Array.from(pluginState.initManifests.values()).filter(v => v !== null).length > 0 + ? Array.from(pluginState.initManifests.values()).filter(v => v !== null).join('__') + : null, + niftiLayers : niftiLayers.length > 0 + ? niftiLayers.map(layer => layer.name).join('__') + : null + } + }) ).subscribe(cleanedState=>{ const url = new URL(window.location) const search = new URLSearchParams( window.location.search ) - Object.keys(cleanedState).forEach(key=>{ - cleanedState[key] ? search.set(key,cleanedState[key]) : search.delete(key) - }) + for (const key in cleanedState) { + if (cleanedState[key]) { + search.set(key, cleanedState[key]) + } else { + search.delete(key) + } + } url.search = search.toString() history.replaceState(null, '', url.toString()) diff --git a/src/main.module.ts b/src/main.module.ts index 65c41e5591377a13780af5e1d0555b8dae0d2939..911962ffb1a4ec2effbc47bc8632448c47dad34a 100644 --- a/src/main.module.ts +++ b/src/main.module.ts @@ -4,7 +4,7 @@ import { UIModule } from "./ui/ui.module"; import { LayoutModule } from "./layouts/layout.module"; import { AtlasViewer } from "./atlasViewer/atlasViewer.component"; import { StoreModule } from "@ngrx/store"; -import { viewerState, dataStore,spatialSearchState,uiState, ngViewerState, states } from "./services/stateStore.service"; +import { viewerState, dataStore,spatialSearchState,uiState, ngViewerState, exportedStates } from "./services/stateStore.service"; import { GetNamesPipe } from "./util/pipes/getNames.pipe"; import { CommonModule } from "@angular/common"; import { GetNamePipe } from "./util/pipes/getName.pipe"; @@ -44,12 +44,13 @@ import { FloatingMouseContextualContainerDirective } from "./util/directives/flo ModalModule.forRoot(), TooltipModule.forRoot(), StoreModule.forRoot({ - viewerState , - dataStore , + pluginState: exportedStates.pluginState, + viewerConfigState: exportedStates.viewerConfigState, + ngViewerState, + viewerState, + dataStore, spatialSearchState, uiState, - ngViewerState, - ...states }) ], declarations : [ @@ -100,5 +101,4 @@ import { FloatingMouseContextualContainerDirective } from "./util/directives/flo }) export class MainModule{ - } \ No newline at end of file diff --git a/src/services/state/pluginState.store.ts b/src/services/state/pluginState.store.ts index 35cc5dd1dcdfadda1493a7d6edd87e6f8bc7436a..93d6b1e9678128b624fbe146c26afb08f494306b 100644 --- a/src/services/state/pluginState.store.ts +++ b/src/services/state/pluginState.store.ts @@ -19,7 +19,7 @@ export const ACTION_TYPES = { export function pluginState(prevState:PluginInitManifestInterface = {initManifests : new Map()}, action:PluginInitManifestActionInterface):PluginInitManifestInterface{ switch(action.type){ case ACTION_TYPES.SET_INIT_PLUGIN: - const newMap = new Map(prevState.initManifests) + const newMap = new Map(prevState.initManifests ) return { ...prevState, initManifests: newMap.set(action.manifest.name, action.manifest.initManifestUrl) diff --git a/src/services/state/viewerConfig.store.ts b/src/services/state/viewerConfig.store.ts index 631def221573e6bfad560dce0f6d08cb830c99b0..230fb9941af4a133f0eaef88b50cac040ecfe1ed 100644 --- a/src/services/state/viewerConfig.store.ts +++ b/src/services/state/viewerConfig.store.ts @@ -15,7 +15,9 @@ export const CONFIG_CONSTANTS = { * byets */ gpuLimitMin: 1e8, - gpuLimitMax: 1e9 + gpuLimitMax: 1e9, + defaultGpuLimit: 1e9, + defaultAnimation: true } export const ACTION_TYPES = { @@ -23,7 +25,7 @@ export const ACTION_TYPES = { CHANGE_GPU_LIMIT: `CHANGE_GPU_LIMIT` } -export function viewerConfigState(prevState:ViewerConfiguration = {gpuLimit: 1e9, animation: true}, action:ViewerConfigurationAction) { +export function viewerConfigState(prevState:ViewerConfiguration = {animation: CONFIG_CONSTANTS.defaultAnimation, gpuLimit: CONFIG_CONSTANTS.defaultGpuLimit}, action:ViewerConfigurationAction) { switch (action.type) { case ACTION_TYPES.UPDATE_CONFIG: return { @@ -34,7 +36,7 @@ export function viewerConfigState(prevState:ViewerConfiguration = {gpuLimit: 1e9 const newGpuLimit = Math.min( CONFIG_CONSTANTS.gpuLimitMax, Math.max( - prevState.gpuLimit + action.payload.delta, + (prevState.gpuLimit || CONFIG_CONSTANTS.defaultGpuLimit) + action.payload.delta, CONFIG_CONSTANTS.gpuLimitMin )) diff --git a/src/services/stateStore.service.ts b/src/services/stateStore.service.ts index d33ea4df51702ed06d6187db37cd00e15e3f8883..5905dfe2699df9a88442d26b687727a8b57fbe05 100644 --- a/src/services/stateStore.service.ts +++ b/src/services/stateStore.service.ts @@ -4,10 +4,6 @@ import { UserLandmark } from '../atlasViewer/atlasViewer.apiService.service'; import { pluginState } from './state/pluginState.store' import { viewerConfigState } from './state/viewerConfig.store' -export const states = { - pluginState, - viewerConfigState -} export const NEWVIEWER = 'NEWVIEWER' @@ -452,4 +448,10 @@ export interface OtherLandmarkGeometry extends LandmarkGeometry{ export function isDefined(obj){ return typeof obj !== 'undefined' && obj !== null +} + + +export const exportedStates = { + pluginState, + viewerConfigState } \ No newline at end of file