diff --git a/.eslintrc.js b/.eslintrc.js index 386b904d3077ea117eca65c6487921bd38919c60..50daf71a8a04c39b3ed039d47ec2927a76edcafc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -13,14 +13,13 @@ module.exports = { "@typescript-eslint/no-inferrable-types": "off", "@typescript-eslint/interface-name-prefix":[0], // "no-unused-vars": "off", - // "@typescript-eslint/no-unused-var": [2], "semi": "off", - // "indent":["error", 2, { - // "FunctionDeclaration":{ - // "body":1, - // "parameters":2 - // } - // }], + "indent":["error", 2, { + "FunctionDeclaration":{ + "body":1, + "parameters":2 + } + }], "@typescript-eslint/member-delimiter-style": [2, { "multiline": { "delimiter": "none", diff --git a/src/atlasViewer/atlasViewer.apiService.service.ts b/src/atlasViewer/atlasViewer.apiService.service.ts index 6f39895df751b5bd4dcea1fc42e9c3987ef54149..b8da64e12f55949a4fcee0c1f13a838555ec6b9c 100644 --- a/src/atlasViewer/atlasViewer.apiService.service.ts +++ b/src/atlasViewer/atlasViewer.apiService.service.ts @@ -9,7 +9,7 @@ import { ModalHandler } from "../util/pluginHandlerClasses/modalHandler"; import { ToastHandler } from "../util/pluginHandlerClasses/toastHandler"; import { IPluginManifest } from "./atlasViewer.pluginService.service"; -declare var window +declare let window @Injectable({ providedIn : 'root', @@ -114,7 +114,7 @@ export class AtlasViewerAPIServices { /** * to be overwritten by atlas */ - launchNewWidget: (manifest) => { + launchNewWidget: (_manifest) => { return Promise.reject('Needs to be overwritted') }, @@ -156,8 +156,8 @@ export interface IInteractiveViewerInterface { loadedTemplates: any[] regionsLabelIndexMap: Map<number, any> | null layersRegionLabelIndexMap: Map<string, Map<number, any>> - datasetsBSubject: Observable<any[]>, - }, + datasetsBSubject: Observable<any[]> + } viewerHandle?: { setNavigationLoc: (coordinates: [number, number, number], realSpace?: boolean) => void @@ -193,7 +193,7 @@ export interface IInteractiveViewerInterface { */ mouseOverNehubaLayers: Observable<Array<{layer: {name: string}, segment: any | number }>> - getNgHash: () => string, + getNgHash: () => string } uiHandle: { @@ -201,13 +201,13 @@ export interface IInteractiveViewerInterface { getToastHandler: () => ToastHandler launchNewWidget: (manifest: IPluginManifest) => Promise<any> getUserInput: (config: IGetUserInputConfig) => Promise<string> - getUserConfirmation: (config: IGetUserConfirmation) => Promise<any>, + getUserConfirmation: (config: IGetUserConfirmation) => Promise<any> } pluginControl: { loadExternalLibraries: (libraries: string[]) => Promise<void> unloadExternalLibraries: (libraries: string[]) => void - [key: string]: any, + [key: string]: any } } diff --git a/src/atlasViewer/atlasViewer.component.ts b/src/atlasViewer/atlasViewer.component.ts index 6672c0c41d8530a659741d0d7df623ecd1ce7ad1..30e65d3a3c7a20b641eae9c7bddf3d993d8337e6 100644 --- a/src/atlasViewer/atlasViewer.component.ts +++ b/src/atlasViewer/atlasViewer.component.ts @@ -246,7 +246,7 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit { return filteredSeg.length > 0 ? segments.map(s => s.segment) : null - }), + }), ) this.selectedParcellation$ = this.store.pipe( @@ -265,7 +265,7 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit { this.subscriptions.push( this.bottomSheet$.subscribe(templateRef => { if (!templateRef) { - if (!!this.bottomSheetRef) { + if (this.bottomSheetRef) { this.bottomSheetRef.dismiss() } } else { @@ -319,7 +319,7 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit { // and https://github.com/angular/components/issues/11357 delay(0), ).subscribe(messageSymbol => { - if (!!this.snackbarRef) { this.snackbarRef.dismiss() } + if (this.snackbarRef) { this.snackbarRef.dismiss() } if (!messageSymbol) { return } @@ -402,18 +402,18 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit { map(([_, agreed]) => agreed), filter(flag => !flag), delay(0), - ).subscribe(val => { + ).subscribe(() => { this.kgTosDialogRef = this.matDialog.open(this.kgTosComponent) }) this.onhoverSegmentsForFixed$ = this.rClContextualMenu.onShow.pipe( - withLatestFrom(this.onhoverSegments$), - map(([_flag, onhoverSegments]) => onhoverSegments || []), + withLatestFrom(this.onhoverSegments$), + map(([_flag, onhoverSegments]) => onhoverSegments || []), ) } - public mouseDownNehuba(event) { + public mouseDownNehuba(_event) { this.regionToolsMenuVisible = false this.rClContextualMenu.hide() } diff --git a/src/atlasViewer/atlasViewer.constantService.service.ts b/src/atlasViewer/atlasViewer.constantService.service.ts index ace6a01a22e8617ba374838cd401e6ac55c2fccf..919f2b9134aa99d59da652e142baf4ad6882a876 100644 --- a/src/atlasViewer/atlasViewer.constantService.service.ts +++ b/src/atlasViewer/atlasViewer.constantService.service.ts @@ -2,7 +2,7 @@ import { HttpClient } from "@angular/common/http"; import { Injectable, OnDestroy } from "@angular/core"; import { select, Store } from "@ngrx/store"; import { merge, Observable, of, Subscription, throwError } from "rxjs"; -import { catchError, filter, map, shareReplay, switchMap, tap } from "rxjs/operators"; +import { catchError, map, shareReplay, switchMap, tap } from "rxjs/operators"; import { LoggingService } from "src/services/logging.service"; import { SNACKBAR_MESSAGE } from "src/services/state/uiState.store"; import { IavRootStoreInterface } from "../services/stateStore.service"; @@ -381,6 +381,7 @@ const encodeInt = (number: number) => { residual = Math.floor(number) } + /* eslint-disable-next-line no-constant-condition */ while (true) { rixit = residual % 64 // this.log.log("rixit : " + rixit) @@ -409,14 +410,14 @@ const defaultB64EncodingOption = { export const encodeNumber: (number: number, option?: IB64EncodingOption) => string = (number: number, { float = false }: IB64EncodingOption = defaultB64EncodingOption) => { - if (!float) { return encodeInt(number) } else { - const floatArray = new Float32Array(1) - floatArray[0] = number - const intArray = new Uint32Array(floatArray.buffer) - const castedInt = intArray[0] - return encodeInt(castedInt) + if (!float) { return encodeInt(number) } else { + const floatArray = new Float32Array(1) + floatArray[0] = number + const intArray = new Uint32Array(floatArray.buffer) + const castedInt = intArray[0] + return encodeInt(castedInt) + } } -} const decodetoInt = (encodedString: string) => { let _encodedString @@ -437,11 +438,11 @@ const decodetoInt = (encodedString: string) => { export const decodeToNumber: (encodedString: string, option?: IB64EncodingOption) => number = (encodedString: string, {float = false} = defaultB64EncodingOption) => { - if (!float) { return decodetoInt(encodedString) } else { - const _int = decodetoInt(encodedString) - const intArray = new Uint32Array(1) - intArray[0] = _int - const castedFloat = new Float32Array(intArray.buffer) - return castedFloat[0] + if (!float) { return decodetoInt(encodedString) } else { + const _int = decodetoInt(encodedString) + const intArray = new Uint32Array(1) + intArray[0] = _int + const castedFloat = new Float32Array(intArray.buffer) + return castedFloat[0] + } } -} diff --git a/src/atlasViewer/atlasViewer.history.service.ts b/src/atlasViewer/atlasViewer.history.service.ts index 2710552a22e0581a775bbf49c756049cf2210cf7..4427bbd77f66fcc3292f6d704a0bbf9a9ab34b25 100644 --- a/src/atlasViewer/atlasViewer.history.service.ts +++ b/src/atlasViewer/atlasViewer.history.service.ts @@ -80,7 +80,10 @@ export class AtlasViewerHistoryUseEffect implements OnDestroy { private currentStateSearchParam$ = this.store$.pipe( map(getSearchParamStringFromState), - catchError((err, obs) => of(null)), + catchError((err, _obs) => { + // TODO error parsing current state search param. let user know + return of(null) + }), filter(v => v !== null), ) diff --git a/src/atlasViewer/atlasViewer.pluginService.service.ts b/src/atlasViewer/atlasViewer.pluginService.service.ts index bfbc24f73aacbaabcb4859e0fe90f92f1e7e2858..2dbed3b36fe35d3bae5eb28e165167b77fa8d860 100644 --- a/src/atlasViewer/atlasViewer.pluginService.service.ts +++ b/src/atlasViewer/atlasViewer.pluginService.service.ts @@ -6,10 +6,9 @@ import { AtlasViewerAPIServices } from "./atlasViewer.apiService.service"; import { PluginUnit } from "./pluginUnit/pluginUnit.component"; import { WidgetServices } from "./widgetUnit/widgetService.service"; -import { Effect } from "@ngrx/effects"; import { select, Store } from "@ngrx/store"; import { BehaviorSubject, merge, Observable, of } from "rxjs"; -import { filter, map, shareReplay, startWith } from "rxjs/operators"; +import { filter, map, shareReplay } from "rxjs/operators"; import { LoggingService } from 'src/services/logging.service'; import { PluginHandler } from 'src/util/pluginHandler'; import '../res/css/plugin_styles.css' @@ -60,7 +59,7 @@ export class PluginServices { // trigger change detection in Angular // otherwise, model won't be updated until user input - // tslint:disable-next-line + /* eslint-disable-next-line @typescript-eslint/no-empty-function */ zone.run(() => { }) return arg2 }) @@ -277,7 +276,8 @@ export class PluginServices { const unsubscribeOnPluginDestroy = [] - handler.blink = (sec?: number) => { + // TODO deprecate sec + handler.blink = (_sec?: number) => { widgetCompRef.instance.blinkOn = true } diff --git a/src/atlasViewer/atlasViewer.urlUtil.ts b/src/atlasViewer/atlasViewer.urlUtil.ts index 0f0821299d6fdb7ab0d65347acd07ff01ff279b0..47486727311e07699f932bf3ea9fe7b961b211be 100644 --- a/src/atlasViewer/atlasViewer.urlUtil.ts +++ b/src/atlasViewer/atlasViewer.urlUtil.ts @@ -142,23 +142,20 @@ export const cvtSearchParamToState = (searchparams: URLSearchParams, state: IavR const selectRegionIds = [] for (const ngId in json) { - // see https://palantir.github.io/tslint/rules/forin/ - if (json.hasOwnProperty(ngId)) { - const val = json[ngId] - const labelIndicies = val.split(separator).map(n => { - try { - return decodeToNumber(n) - } catch (e) { - /** - * TODO poisonsed encoded char, send error message - */ - warningCb({ type: DECODE_CIPHER_ERROR, message: `cRegionSelectionParam is malformed: cannot decode ${n}` }) - return null - } - }).filter(v => !!v) - for (const labelIndex of labelIndicies) { - selectRegionIds.push( generateLabelIndexId({ ngId, labelIndex }) ) + const val = json[ngId] + const labelIndicies = val.split(separator).map(n => { + try { + return decodeToNumber(n) + } catch (e) { + /** + * TODO poisonsed encoded char, send error message + */ + warningCb({ type: DECODE_CIPHER_ERROR, message: `cRegionSelectionParam is malformed: cannot decode ${n}` }) + return null } + }).filter(v => !!v) + for (const labelIndex of labelIndicies) { + selectRegionIds.push( generateLabelIndexId({ ngId, labelIndex }) ) } } viewerState.regionsSelected = selectRegionIds.map(labelIndexId => getRegionFromlabelIndexId({ labelIndexId })) diff --git a/src/atlasViewer/widgetUnit/widgetService.service.ts b/src/atlasViewer/widgetUnit/widgetService.service.ts index db04c4b0017128a64e79053ef18b669e1d62897d..8a394417cc23f818ac4da219633be07375e9775f 100644 --- a/src/atlasViewer/widgetUnit/widgetService.service.ts +++ b/src/atlasViewer/widgetUnit/widgetService.service.ts @@ -27,7 +27,7 @@ export class WidgetServices implements OnDestroy { private constantServce: AtlasViewerConstantsServices, private injector: Injector, private log: LoggingService, - ) { + ) { this.widgetUnitFactory = this.cfr.resolveComponentFactory(WidgetUnit) this.minimisedWindow$ = new BehaviorSubject(this.minimisedWindow) diff --git a/src/components/flatTree/appendSiblingFlag.pipe.ts b/src/components/flatTree/appendSiblingFlag.pipe.ts index c4467283ace0f148a802a537724740ebc40861f4..c1a43fbd0411d714f6a1109f2d7379402d439879 100644 --- a/src/components/flatTree/appendSiblingFlag.pipe.ts +++ b/src/components/flatTree/appendSiblingFlag.pipe.ts @@ -8,15 +8,15 @@ export class AppendSiblingFlagPipe implements PipeTransform { public transform(objs: any[]): any[] { return objs .reduceRight((acc, curr) => ({ - acc : acc.acc.concat(Object.assign({}, curr, { - siblingFlags : curr.lvlId.split('_').map((v, idx) => typeof acc.flags[idx] !== 'undefined' - ? acc.flags[idx] - : false) - .slice(1) - .map(v => !v), - })), - flags: curr.lvlId.split('_').map((_, idx) => acc.flags[idx] ).slice(0, -1).concat(true), - }), { acc: [], flags : Array(256).fill(false) }) + acc : acc.acc.concat(Object.assign({}, curr, { + siblingFlags : curr.lvlId.split('_').map((v, idx) => typeof acc.flags[idx] !== 'undefined' + ? acc.flags[idx] + : false) + .slice(1) + .map(v => !v), + })), + flags: curr.lvlId.split('_').map((_, idx) => acc.flags[idx] ).slice(0, -1).concat(true), + }), { acc: [], flags : Array(256).fill(false) }) .acc.reverse() } } diff --git a/src/components/flatTree/filterCollapse.pipe.ts b/src/components/flatTree/filterCollapse.pipe.ts index ee3e653a8543d086113b3ff2f18b3e6c0fe05464..e936d7c7b486a70d1db83c9fbb4fa9b5125c7f98 100644 --- a/src/components/flatTree/filterCollapse.pipe.ts +++ b/src/components/flatTree/filterCollapse.pipe.ts @@ -9,10 +9,10 @@ export class FilterCollapsePipe implements PipeTransform { const isCollapsedById = (id) => { return collapsedLevels.has(id) - ? true - : uncollapsedLevels.has(id) - ? false - : !defaultCollapse + ? true + : uncollapsedLevels.has(id) + ? false + : !defaultCollapse } const returnArray = array.filter(item => { return !item.lvlId.split('_') diff --git a/src/components/flatTree/flattener.pipe.ts b/src/components/flatTree/flattener.pipe.ts index 3dfd9ab4862a46269772ba178751cd8badc753e7..d8d017a541e89359ba81f61204adf1040a57883e 100644 --- a/src/components/flatTree/flattener.pipe.ts +++ b/src/components/flatTree/flattener.pipe.ts @@ -11,12 +11,12 @@ export class FlattenTreePipe implements PipeTransform { private recursiveFlatten(obj, findChildren, flattenedTreeLevel, lvlId) { return [ - this.attachLvlAndLvlIdAndSiblingFlag( - obj, - flattenedTreeLevel, - lvlId, - ), - ].concat( + this.attachLvlAndLvlIdAndSiblingFlag( + obj, + flattenedTreeLevel, + lvlId, + ), + ].concat( ...findChildren(obj) .map((c, idx) => this.recursiveFlatten(c, findChildren, flattenedTreeLevel + 1, `${lvlId}_${idx}` )), ) diff --git a/src/main.module.ts b/src/main.module.ts index 4262c65c6e225191ec7c7adee09acb36361f958b..4105a93011e9e14fc1a3b2204b2b41eaa88e0db0 100644 --- a/src/main.module.ts +++ b/src/main.module.ts @@ -138,7 +138,7 @@ import { LoggingService } from "./services/logging.service"; AtlasViewer, ], schemas: [ - CUSTOM_ELEMENTS_SCHEMA, + CUSTOM_ELEMENTS_SCHEMA, ], }) diff --git a/src/services/localFile.service.ts b/src/services/localFile.service.ts index ae9b7dd55f88eb85df350b72d277725f88f447fd..2d49e4919759f9b1cee303c4b04f527825c058a9 100644 --- a/src/services/localFile.service.ts +++ b/src/services/localFile.service.ts @@ -31,12 +31,12 @@ export class LocalFileService { for (const file of files) { const ext = this.getExtension(file.name) switch (ext) { - case NII: { - this.handleNiiFile(file) - break; - } - default: - throw new Error(`File ${file.name} does not have a file handler`) + case NII: { + this.handleNiiFile(file) + break; + } + default: + throw new Error(`File ${file.name} does not have a file handler`) } } } catch (e) { diff --git a/src/services/state/dataStore.store.ts b/src/services/state/dataStore.store.ts index a3896ddbf3982fb2659355ca255aef58e1869595..209bddbc53abe7b8c8291e4a1e24ab24bbf0f3fb 100644 --- a/src/services/state/dataStore.store.ts +++ b/src/services/state/dataStore.store.ts @@ -19,26 +19,26 @@ export const defaultState = { export const getStateStore = ({ state: state = defaultState } = {}) => (prevState: IStateInterface = state, action: Partial<IActionInterface>) => { switch (action.type) { - case FETCHED_DATAENTRIES: { - return { - ...prevState, - fetchedDataEntries : action.fetchedDataEntries, - } + case FETCHED_DATAENTRIES: { + return { + ...prevState, + fetchedDataEntries : action.fetchedDataEntries, } - case FETCHED_SPATIAL_DATA : { - return { - ...prevState, - fetchedSpatialData : action.fetchedDataEntries, - } + } + case FETCHED_SPATIAL_DATA : { + return { + ...prevState, + fetchedSpatialData : action.fetchedDataEntries, } - case ACTION_TYPES.UPDATE_FAV_DATASETS: { - const { favDataEntries = [] } = action - return { - ...prevState, - favDataEntries, - } + } + case ACTION_TYPES.UPDATE_FAV_DATASETS: { + const { favDataEntries = [] } = action + return { + ...prevState, + favDataEntries, } - default: return prevState + } + default: return prevState } } diff --git a/src/services/state/ngViewerState.store.ts b/src/services/state/ngViewerState.store.ts index bdcc9270c52793883424b57184b08484e4081846..53fe04a19c044f2bf9a02a03db8edfd8a051fa1e 100644 --- a/src/services/state/ngViewerState.store.ts +++ b/src/services/state/ngViewerState.store.ts @@ -19,8 +19,8 @@ export function mixNgLayers(oldLayers: INgLayerInterface[], newLayers: INgLayerI return oldLayers.concat({ ...newLayers, ...( newLayers.mixability === 'nonmixable' && oldLayers.findIndex(l => l.mixability === 'nonmixable') >= 0 - ? {visible: false} - : {}), + ? {visible: false} + : {}), }) } } @@ -57,89 +57,89 @@ export const defaultState: StateInterface = { export const getStateStore = ({ state = defaultState } = {}) => (prevState: StateInterface = state, action: ActionInterface): StateInterface => { switch (action.type) { - case ACTION_TYPES.SET_PANEL_ORDER: { - const { payload } = action - const { panelOrder } = payload - - return { - ...prevState, - panelOrder, - } + case ACTION_TYPES.SET_PANEL_ORDER: { + const { payload } = action + const { panelOrder } = payload + + return { + ...prevState, + panelOrder, + } + } + case ACTION_TYPES.SWITCH_PANEL_MODE: { + const { payload } = action + const { panelMode } = payload + if (SUPPORTED_PANEL_MODES.indexOf(panelMode) < 0) { return prevState } + return { + ...prevState, + panelMode, } - case ACTION_TYPES.SWITCH_PANEL_MODE: { - const { payload } = action - const { panelMode } = payload - if (SUPPORTED_PANEL_MODES.indexOf(panelMode) < 0) { return prevState } - return { - ...prevState, - panelMode, - } + } + case ADD_NG_LAYER: + return { + ...prevState, + + /* this configration hides the layer if a non mixable layer already present */ + + /* this configuration does not the addition of multiple non mixable layers */ + // layers : action.layer.mixability === 'nonmixable' && prevState.layers.findIndex(l => l.mixability === 'nonmixable') >= 0 + // ? prevState.layers + // : prevState.layers.concat(action.layer) + + /* this configuration allows the addition of multiple non mixables */ + // layers : prevState.layers.map(l => mapLayer(l, action.layer)).concat(action.layer) + layers : mixNgLayers(prevState.layers, action.layer), + + // action.layer.constructor === Array + // ? prevState.layers.concat(action.layer) + // : prevState.layers.concat({ + // ...action.layer, + // ...( action.layer.mixability === 'nonmixable' && prevState.layers.findIndex(l => l.mixability === 'nonmixable') >= 0 + // ? {visible: false} + // : {}) + // }) + } + case REMOVE_NG_LAYERS: { + const { layers } = action + const layerNameSet = new Set(layers.map(l => l.name)) + return { + ...prevState, + layers: prevState.layers.filter(l => !layerNameSet.has(l.name)), } - case ADD_NG_LAYER: - return { - ...prevState, - - /* this configration hides the layer if a non mixable layer already present */ - - /* this configuration does not the addition of multiple non mixable layers */ - // layers : action.layer.mixability === 'nonmixable' && prevState.layers.findIndex(l => l.mixability === 'nonmixable') >= 0 - // ? prevState.layers - // : prevState.layers.concat(action.layer) - - /* this configuration allows the addition of multiple non mixables */ - // layers : prevState.layers.map(l => mapLayer(l, action.layer)).concat(action.layer) - layers : mixNgLayers(prevState.layers, action.layer), - - // action.layer.constructor === Array - // ? prevState.layers.concat(action.layer) - // : prevState.layers.concat({ - // ...action.layer, - // ...( action.layer.mixability === 'nonmixable' && prevState.layers.findIndex(l => l.mixability === 'nonmixable') >= 0 - // ? {visible: false} - // : {}) - // }) - } - case REMOVE_NG_LAYERS: { - const { layers } = action - const layerNameSet = new Set(layers.map(l => l.name)) - return { - ...prevState, - layers: prevState.layers.filter(l => !layerNameSet.has(l.name)), - } + } + case REMOVE_NG_LAYER: + return { + ...prevState, + layers : prevState.layers.filter(l => l.name !== action.layer.name), } - case REMOVE_NG_LAYER: - return { - ...prevState, - layers : prevState.layers.filter(l => l.name !== action.layer.name), - } - case SHOW_NG_LAYER: - return { - ...prevState, - layers : prevState.layers.map(l => l.name === action.layer.name - ? { ...l, visible: true } - : l), - } - case HIDE_NG_LAYER: - return { - ...prevState, - - layers : prevState.layers.map(l => l.name === action.layer.name - ? { ...l, visible: false } - : l), - } - case FORCE_SHOW_SEGMENT: - return { - ...prevState, - forceShowSegment : action.forceShowSegment, - } - case NEHUBA_READY: { - const { nehubaReady } = action - return { - ...prevState, - nehubaReady, - } + case SHOW_NG_LAYER: + return { + ...prevState, + layers : prevState.layers.map(l => l.name === action.layer.name + ? { ...l, visible: true } + : l), } - default: return prevState + case HIDE_NG_LAYER: + return { + ...prevState, + + layers : prevState.layers.map(l => l.name === action.layer.name + ? { ...l, visible: false } + : l), + } + case FORCE_SHOW_SEGMENT: + return { + ...prevState, + forceShowSegment : action.forceShowSegment, + } + case NEHUBA_READY: { + const { nehubaReady } = action + return { + ...prevState, + nehubaReady, + } + } + default: return prevState } } diff --git a/src/services/state/pluginState.store.ts b/src/services/state/pluginState.store.ts index a9d11a6dc36a2fd5f86242b9a2e4984db350c4de..5fed00e8d6d284f85b27335ff287aac9fc16edf4 100644 --- a/src/services/state/pluginState.store.ts +++ b/src/services/state/pluginState.store.ts @@ -26,25 +26,25 @@ export const CONSTANTS = { export const getStateStore = ({ state = defaultState } = {}) => (prevState: StateInterface = state, action: ActionInterface): StateInterface => { switch (action.type) { - case ACTION_TYPES.SET_INIT_PLUGIN: { - const newMap = new Map(prevState.initManifests ) - - // reserved source label for init manifest - if (action.manifest.name !== CONSTANTS.INIT_MANIFEST_SRC) { newMap.set(action.manifest.name, action.manifest.initManifestUrl) } - return { - ...prevState, - initManifests: Array.from(newMap), - } + case ACTION_TYPES.SET_INIT_PLUGIN: { + const newMap = new Map(prevState.initManifests ) + + // reserved source label for init manifest + if (action.manifest.name !== CONSTANTS.INIT_MANIFEST_SRC) { newMap.set(action.manifest.name, action.manifest.initManifestUrl) } + return { + ...prevState, + initManifests: Array.from(newMap), } - case ACTION_TYPES.CLEAR_INIT_PLUGIN: { - const { initManifests } = prevState - const newManifests = initManifests.filter(([source]) => source !== CONSTANTS.INIT_MANIFEST_SRC) - return { - ...prevState, - initManifests: newManifests, - } + } + case ACTION_TYPES.CLEAR_INIT_PLUGIN: { + const { initManifests } = prevState + const newManifests = initManifests.filter(([source]) => source !== CONSTANTS.INIT_MANIFEST_SRC) + return { + ...prevState, + initManifests: newManifests, } - default: return prevState + } + default: return prevState } } diff --git a/src/services/state/uiState.store.ts b/src/services/state/uiState.store.ts index 6f5c601fdfcb056828207774352c045a22ad4dae..595df963cc01870bd831a4f9abed7137184e9f99 100644 --- a/src/services/state/uiState.store.ts +++ b/src/services/state/uiState.store.ts @@ -32,107 +32,107 @@ export const defaultState: StateInterface = { export const getStateStore = ({ state = defaultState } = {}) => (prevState: StateInterface = state, action: ActionInterface) => { switch (action.type) { - case MOUSE_OVER_SEGMENTS: { - const { segments } = action - return { - ...prevState, - mouseOverSegments: segments, - } - } - case MOUSE_OVER_SEGMENT: - return { - ...prevState, - mouseOverSegment : action.segment, - } - case MOUSEOVER_USER_LANDMARK: { - const { payload = {} } = action - const { userLandmark: mouseOverUserLandmark = null } = payload - return { - ...prevState, - mouseOverUserLandmark, - } - } - case MOUSE_OVER_LANDMARK: - return { - ...prevState, - mouseOverLandmark : action.landmark, - } - case SNACKBAR_MESSAGE: { - const { snackbarMessage } = action - /** + case MOUSE_OVER_SEGMENTS: { + const { segments } = action + return { + ...prevState, + mouseOverSegments: segments, + } + } + case MOUSE_OVER_SEGMENT: + return { + ...prevState, + mouseOverSegment : action.segment, + } + case MOUSEOVER_USER_LANDMARK: { + const { payload = {} } = action + const { userLandmark: mouseOverUserLandmark = null } = payload + return { + ...prevState, + mouseOverUserLandmark, + } + } + case MOUSE_OVER_LANDMARK: + return { + ...prevState, + mouseOverLandmark : action.landmark, + } + case SNACKBAR_MESSAGE: { + const { snackbarMessage } = action + /** * Need to use symbol here, or repeated snackbarMessage will not trigger new event */ - return { - ...prevState, - snackbarMessage: Symbol(snackbarMessage), - } - } - case OPEN_SIDE_PANEL: - return { - ...prevState, - sidePanelIsOpen: true, - } - case CLOSE_SIDE_PANEL: - return { - ...prevState, - sidePanelIsOpen: false, - } - - case EXPAND_SIDE_PANEL_CURRENT_VIEW: - return { - ...prevState, - sidePanelExploreCurrentViewIsOpen: true, - } - case COLLAPSE_SIDE_PANEL_CURRENT_VIEW: - return { - ...prevState, - sidePanelExploreCurrentViewIsOpen: false, - } - - case SHOW_SIDE_PANEL_DATASET_LIST: - return { - ...prevState, - sidePanelCurrentViewContent: 'Dataset', - } - - case SHOW_SIDE_PANEL_CONNECTIVITY: - return { - ...prevState, - sidePanelCurrentViewContent: 'Connectivity', - } - case HIDE_SIDE_PANEL_CONNECTIVITY: - return { - ...prevState, - sidePanelCurrentViewContent: 'Dataset', - } - case AGREE_COOKIE: { - /** + return { + ...prevState, + snackbarMessage: Symbol(snackbarMessage), + } + } + case OPEN_SIDE_PANEL: + return { + ...prevState, + sidePanelIsOpen: true, + } + case CLOSE_SIDE_PANEL: + return { + ...prevState, + sidePanelIsOpen: false, + } + + case EXPAND_SIDE_PANEL_CURRENT_VIEW: + return { + ...prevState, + sidePanelExploreCurrentViewIsOpen: true, + } + case COLLAPSE_SIDE_PANEL_CURRENT_VIEW: + return { + ...prevState, + sidePanelExploreCurrentViewIsOpen: false, + } + + case SHOW_SIDE_PANEL_DATASET_LIST: + return { + ...prevState, + sidePanelCurrentViewContent: 'Dataset', + } + + case SHOW_SIDE_PANEL_CONNECTIVITY: + return { + ...prevState, + sidePanelCurrentViewContent: 'Connectivity', + } + case HIDE_SIDE_PANEL_CONNECTIVITY: + return { + ...prevState, + sidePanelCurrentViewContent: 'Dataset', + } + case AGREE_COOKIE: { + /** * TODO replace with server side logic */ - localStorage.setItem(LOCAL_STORAGE_CONST.AGREE_COOKIE, COOKIE_VERSION) - return { - ...prevState, - agreedCookies: true, - } - } - case AGREE_KG_TOS: { - /** + localStorage.setItem(LOCAL_STORAGE_CONST.AGREE_COOKIE, COOKIE_VERSION) + return { + ...prevState, + agreedCookies: true, + } + } + case AGREE_KG_TOS: { + /** * TODO replace with server side logic */ - localStorage.setItem(LOCAL_STORAGE_CONST.AGREE_KG_TOS, KG_TOS_VERSION) - return { - ...prevState, - agreedKgTos: true, - } - } - case SHOW_BOTTOM_SHEET: { - const { bottomSheetTemplate } = action - return { - ...prevState, - bottomSheetTemplate, - } - } - default: return prevState + localStorage.setItem(LOCAL_STORAGE_CONST.AGREE_KG_TOS, KG_TOS_VERSION) + return { + ...prevState, + agreedKgTos: true, + } + } + case SHOW_BOTTOM_SHEET: { + const { bottomSheetTemplate } = action + return { + ...prevState, + bottomSheetTemplate, + } + } + default: return prevState } } diff --git a/src/services/state/userConfigState.store.ts b/src/services/state/userConfigState.store.ts index 0e8495ebf583cdffa73393c2ee44d4505c4b2b3a..da025161c078f6b5d6c3af8e0f620fa0d00f6124 100644 --- a/src/services/state/userConfigState.store.ts +++ b/src/services/state/userConfigState.store.ts @@ -57,15 +57,15 @@ export const ACTION_TYPES = { export const getStateStore = ({ state = defaultState } = {}) => (prevState: StateInterface = state, action: UserConfigAction) => { switch (action.type) { - case ACTION_TYPES.UPDATE_REGIONS_SELECTIONS: { - const { config = {} } = action - const { savedRegionsSelection } = config - return { - ...prevState, - savedRegionsSelection, - } + case ACTION_TYPES.UPDATE_REGIONS_SELECTIONS: { + const { config = {} } = action + const { savedRegionsSelection } = config + return { + ...prevState, + savedRegionsSelection, } - default: return prevState + } + default: return prevState } } @@ -245,11 +245,11 @@ export class UserConfigStateUseEffect implements OnDestroy { * parcellation different, dispatch SELECT_PARCELLATION */ - this.store$.dispatch({ - type: SELECT_PARCELLATION, - selectParcellation: savedRegionsSelection.parcellationSelected, - }) - return this.parcellationSelected$.pipe( + this.store$.dispatch({ + type: SELECT_PARCELLATION, + selectParcellation: savedRegionsSelection.parcellationSelected, + }) + return this.parcellationSelected$.pipe( filter(p => p.updated), take(1), map(() => { diff --git a/src/services/state/viewerConfig.store.ts b/src/services/state/viewerConfig.store.ts index 6fec7738e86c325dfc2c95f14ad1d1365b011373..b3f32ec8b264eef4785537830284a74d21de5fb1 100644 --- a/src/services/state/viewerConfig.store.ts +++ b/src/services/state/viewerConfig.store.ts @@ -63,32 +63,32 @@ export const defaultState: StateInterface = { export const getStateStore = ({ state = defaultState } = {}) => (prevState: StateInterface = state, action: ViewerConfigurationAction) => { switch (action.type) { - case ACTION_TYPES.SET_MOBILE_UI: { - const { payload } = action - const { useMobileUI } = payload - return { - ...prevState, - useMobileUI, - } + case ACTION_TYPES.SET_MOBILE_UI: { + const { payload } = action + const { useMobileUI } = payload + return { + ...prevState, + useMobileUI, } - case ACTION_TYPES.UPDATE_CONFIG: - return { - ...prevState, - ...action.config, - } - case ACTION_TYPES.CHANGE_GPU_LIMIT: { - const newGpuLimit = Math.min( - CONFIG_CONSTANTS.gpuLimitMax, - Math.max( - (prevState.gpuLimit || CONFIG_CONSTANTS.defaultGpuLimit) + action.payload.delta, - CONFIG_CONSTANTS.gpuLimitMin, - )) - return { - ...prevState, - gpuLimit: newGpuLimit, - } + } + case ACTION_TYPES.UPDATE_CONFIG: + return { + ...prevState, + ...action.config, + } + case ACTION_TYPES.CHANGE_GPU_LIMIT: { + const newGpuLimit = Math.min( + CONFIG_CONSTANTS.gpuLimitMax, + Math.max( + (prevState.gpuLimit || CONFIG_CONSTANTS.defaultGpuLimit) + action.payload.delta, + CONFIG_CONSTANTS.gpuLimitMin, + )) + return { + ...prevState, + gpuLimit: newGpuLimit, } - default: return prevState + } + default: return prevState } } diff --git a/src/services/state/viewerState.store.ts b/src/services/state/viewerState.store.ts index b206b193734f3b109e2d2960bfd8f4585f419861..606ac579f63d2866c6b7d9779e4ec78726b773e7 100644 --- a/src/services/state/viewerState.store.ts +++ b/src/services/state/viewerState.store.ts @@ -66,140 +66,140 @@ export const defaultState: StateInterface = { export const getStateStore = ({ state = defaultState } = {}) => (prevState: Partial<StateInterface> = state, action: ActionInterface) => { switch (action.type) { - /** + /** * TODO may be obsolete. test when nifti become available */ - case LOAD_DEDICATED_LAYER: { - const dedicatedView = prevState.dedicatedView - ? prevState.dedicatedView.concat(action.dedicatedView) - : [action.dedicatedView] - return { - ...prevState, - dedicatedView, - } + case LOAD_DEDICATED_LAYER: { + const dedicatedView = prevState.dedicatedView + ? prevState.dedicatedView.concat(action.dedicatedView) + : [action.dedicatedView] + return { + ...prevState, + dedicatedView, } - case UNLOAD_DEDICATED_LAYER: - return { - ...prevState, - dedicatedView : prevState.dedicatedView - ? prevState.dedicatedView.filter(dv => dv !== action.dedicatedView) - : [], - } - case NEWVIEWER: { - - const { selectParcellation: parcellation } = action - // const parcellation = propagateNgId( selectParcellation ): parcellation - const { regions, ...parcellationWORegions } = parcellation - return { - ...prevState, - templateSelected : action.selectTemplate, - parcellationSelected : { - ...parcellationWORegions, - regions: null, - }, - // taken care of by effect.ts - // regionsSelected : [], - landmarksSelected : [], - navigation : {}, - dedicatedView : null, - } + } + case UNLOAD_DEDICATED_LAYER: + return { + ...prevState, + dedicatedView : prevState.dedicatedView + ? prevState.dedicatedView.filter(dv => dv !== action.dedicatedView) + : [], } - case FETCHED_TEMPLATE : { - return { - ...prevState, - fetchedTemplates: prevState.fetchedTemplates.concat(action.fetchedTemplate), - } + case NEWVIEWER: { + + const { selectParcellation: parcellation } = action + // const parcellation = propagateNgId( selectParcellation ): parcellation + const { regions, ...parcellationWORegions } = parcellation + return { + ...prevState, + templateSelected : action.selectTemplate, + parcellationSelected : { + ...parcellationWORegions, + regions: null, + }, + // taken care of by effect.ts + // regionsSelected : [], + landmarksSelected : [], + navigation : {}, + dedicatedView : null, } - case CHANGE_NAVIGATION : { - return { - ...prevState, - navigation : action.navigation, - } + } + case FETCHED_TEMPLATE : { + return { + ...prevState, + fetchedTemplates: prevState.fetchedTemplates.concat(action.fetchedTemplate), } - case SELECT_PARCELLATION : { - const { selectParcellation: sParcellation } = action - const { regions, ...sParcellationWORegions } = sParcellation - return { - ...prevState, - parcellationSelected: sParcellationWORegions, - // taken care of by effect.ts - // regionsSelected: [] - } + } + case CHANGE_NAVIGATION : { + return { + ...prevState, + navigation : action.navigation, } - case UPDATE_PARCELLATION: { - const { updatedParcellation } = action - return { - ...prevState, - parcellationSelected: { - ...updatedParcellation, - updated: true, - }, - } + } + case SELECT_PARCELLATION : { + const { selectParcellation: sParcellation } = action + const { regions, ...sParcellationWORegions } = sParcellation + return { + ...prevState, + parcellationSelected: sParcellationWORegions, + // taken care of by effect.ts + // regionsSelected: [] } - case SELECT_REGIONS: { - const { selectRegions } = action - return { - ...prevState, - regionsSelected: selectRegions, - } + } + case UPDATE_PARCELLATION: { + const { updatedParcellation } = action + return { + ...prevState, + parcellationSelected: { + ...updatedParcellation, + updated: true, + }, } - case DESELECT_LANDMARKS : { - return { - ...prevState, - landmarksSelected : prevState.landmarksSelected.filter(lm => action.deselectLandmarks.findIndex(dLm => dLm.name === lm.name) < 0), - } + } + case SELECT_REGIONS: { + const { selectRegions } = action + return { + ...prevState, + regionsSelected: selectRegions, } - case SELECT_LANDMARKS : { - return { - ...prevState, - landmarksSelected : action.landmarks, - } + } + case DESELECT_LANDMARKS : { + return { + ...prevState, + landmarksSelected : prevState.landmarksSelected.filter(lm => action.deselectLandmarks.findIndex(dLm => dLm.name === lm.name) < 0), } - case USER_LANDMARKS : { - return { - ...prevState, - userLandmarks: action.landmarks, - } + } + case SELECT_LANDMARKS : { + return { + ...prevState, + landmarksSelected : action.landmarks, + } + } + case USER_LANDMARKS : { + return { + ...prevState, + userLandmarks: action.landmarks, } - /** + } + /** * TODO * duplicated with ngViewerState.layers ? */ - case NEHUBA_LAYER_CHANGED: { - const viewer = getViewer() - if (!viewer) { - return { - ...prevState, - loadedNgLayers: [], - } - } else { - return { - ...prevState, - loadedNgLayers: (viewer.layerManager.managedLayers as any[]).map(obj => ({ - name : obj.name, - type : obj.initialSpecification.type, - source : obj.sourceUrl, - visible : obj.visible, - }) as INgLayerInterface), - } - } - } - case GENERAL_ACTION_TYPES.APPLY_STATE: { - const { viewerState } = (action as any).state - return viewerState - } - case SET_CONNECTIVITY_REGION: + case NEHUBA_LAYER_CHANGED: { + const viewer = getViewer() + if (!viewer) { return { ...prevState, - connectivityRegion: action.connectivityRegion, + loadedNgLayers: [], } - case CLEAR_CONNECTIVITY_REGION: + } else { return { ...prevState, - connectivityRegion: '', + loadedNgLayers: (viewer.layerManager.managedLayers as any[]).map(obj => ({ + name : obj.name, + type : obj.initialSpecification.type, + source : obj.sourceUrl, + visible : obj.visible, + }) as INgLayerInterface), } - default : - return prevState + } + } + case GENERAL_ACTION_TYPES.APPLY_STATE: { + const { viewerState } = (action as any).state + return viewerState + } + case SET_CONNECTIVITY_REGION: + return { + ...prevState, + connectivityRegion: action.connectivityRegion, + } + case CLEAR_CONNECTIVITY_REGION: + return { + ...prevState, + connectivityRegion: '', + } + default : + return prevState } } diff --git a/src/services/stateStore.service.ts b/src/services/stateStore.service.ts index 1714bc8b92836c9467ae9e6b1c6880e3dc48194d..0890905a4e97c6ce86ff0473e3f3cd5feb574baa 100644 --- a/src/services/stateStore.service.ts +++ b/src/services/stateStore.service.ts @@ -139,9 +139,9 @@ export function getLabelIndexMap(regions: any[]): Map<number, any> { export function getNgIds(regions: any[]): string[] { return regions && regions.map ? regions - .map(r => [r.ngId, ...getNgIds(r.children)]) - .reduce((acc, item) => acc.concat(item), []) - .filter(ngId => !!ngId) + .map(r => [r.ngId, ...getNgIds(r.children)]) + .reduce((acc, item) => acc.concat(item), []) + .filter(ngId => !!ngId) : [] } diff --git a/src/ui/connectivityBrowser/connectivityBrowser.component.ts b/src/ui/connectivityBrowser/connectivityBrowser.component.ts index 9ad2ad5b74634287765c2b76e6b28f32e69f0a46..1e9f33a59b14938be3918b1b62db642ee5609d22 100644 --- a/src/ui/connectivityBrowser/connectivityBrowser.component.ts +++ b/src/ui/connectivityBrowser/connectivityBrowser.component.ts @@ -1,9 +1,9 @@ import { - AfterViewInit, ChangeDetectorRef, - Component, - ElementRef, - OnDestroy, - ViewChild, + AfterViewInit, ChangeDetectorRef, + Component, + ElementRef, + OnDestroy, + ViewChild, } from "@angular/core"; import {select, Store} from "@ngrx/store"; import {fromEvent, Observable, Subscription} from "rxjs"; @@ -13,8 +13,8 @@ import {CLEAR_CONNECTIVITY_REGION, SET_CONNECTIVITY_REGION} from "src/services/s import {HIDE_SIDE_PANEL_CONNECTIVITY, isDefined, safeFilter} from "src/services/stateStore.service"; @Component({ - selector: 'connectivity-browser', - templateUrl: './connectivityBrowser.template.html', + selector: 'connectivity-browser', + templateUrl: './connectivityBrowser.template.html', }) export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy { @@ -34,131 +34,133 @@ export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy { @ViewChild('connectivityComponent', {read: ElementRef}) public connectivityComponentElement: ElementRef - constructor(private constantService: AtlasViewerConstantsServices, private store$: Store<any> , private changeDetectionRef: ChangeDetectorRef, + constructor( + private store$: Store<any>, + private changeDetectionRef: ChangeDetectorRef, ) { - this.selectedParcellation$ = this.store$.pipe( - select('viewerState'), - filter(state => isDefined(state) && isDefined(state.parcellationSelected)), - map(state => state.parcellationSelected), - distinctUntilChanged(), - ) - - this.connectivityRegion$ = this.store$.pipe( - select('viewerState'), - safeFilter('connectivityRegion'), - map(state => state.connectivityRegion), - ) + this.selectedParcellation$ = this.store$.pipe( + select('viewerState'), + filter(state => isDefined(state) && isDefined(state.parcellationSelected)), + map(state => state.parcellationSelected), + distinctUntilChanged(), + ) + + this.connectivityRegion$ = this.store$.pipe( + select('viewerState'), + safeFilter('connectivityRegion'), + map(state => state.connectivityRegion), + ) } public ngAfterViewInit(): void { - this.subscriptions.push( - this.selectedParcellation$.subscribe(parcellation => { - if (parcellation && parcellation.hasAdditionalViewMode && parcellation.hasAdditionalViewMode.includes('connectivity')) { - this.parcellationHasConnectivityData = true - if (parcellation.regions && parcellation.regions.length) { - this.allRegions = [] - this.getAllRegionsFromParcellation(parcellation.regions) - if (this.defaultColorMap) { - this.addNewColorMap() - } - } - } else { - this.parcellationHasConnectivityData = false - } - }), - this.connectivityRegion$.subscribe(cr => { - this.region = cr - this.areaHemisphere = cr.includes('left hemisphere') ? ' - left hemisphere' : ' - right hemisphere' - this.changeDetectionRef.detectChanges() - }), - ) - - this.subscriptions.push( - fromEvent(this.connectivityComponentElement.nativeElement, 'connectivityDataReceived', { capture: true }) - .subscribe((e: CustomEvent) => { - this.connectedAreas = e.detail - if (this.connectedAreas.length > 0) { this.addNewColorMap() } - }), - fromEvent(this.connectivityComponentElement.nativeElement, 'collapsedMenuChanged', { capture: true }) - .subscribe((e: CustomEvent) => { - this.expandMenuIndex = e.detail - }), - - ) - } - - public ngOnDestroy(): void { - this.setDefaultMap() - this.subscriptions.forEach(s => s.unsubscribe()) - } - - public updateConnevtivityRegion(regionName) { - this.store$.dispatch({ - type: SET_CONNECTIVITY_REGION, - connectivityRegion: regionName, - }) - } + this.subscriptions.push( + this.selectedParcellation$.subscribe(parcellation => { + if (parcellation && parcellation.hasAdditionalViewMode && parcellation.hasAdditionalViewMode.includes('connectivity')) { + this.parcellationHasConnectivityData = true + if (parcellation.regions && parcellation.regions.length) { + this.allRegions = [] + this.getAllRegionsFromParcellation(parcellation.regions) + if (this.defaultColorMap) { + this.addNewColorMap() + } + } + } else { + this.parcellationHasConnectivityData = false + } + }), + this.connectivityRegion$.subscribe(cr => { + this.region = cr + this.areaHemisphere = cr.includes('left hemisphere') ? ' - left hemisphere' : ' - right hemisphere' + this.changeDetectionRef.detectChanges() + }), + ) + + this.subscriptions.push( + fromEvent(this.connectivityComponentElement.nativeElement, 'connectivityDataReceived', { capture: true }) + .subscribe((e: CustomEvent) => { + this.connectedAreas = e.detail + if (this.connectedAreas.length > 0) { this.addNewColorMap() } + }), + fromEvent(this.connectivityComponentElement.nativeElement, 'collapsedMenuChanged', { capture: true }) + .subscribe((e: CustomEvent) => { + this.expandMenuIndex = e.detail + }), + + ) + } + + public ngOnDestroy(): void { + this.setDefaultMap() + this.subscriptions.forEach(s => s.unsubscribe()) + } + + public updateConnevtivityRegion(regionName) { + this.store$.dispatch({ + type: SET_CONNECTIVITY_REGION, + connectivityRegion: regionName, + }) + } public closeConnectivityView() { - this.setDefaultMap() - - this.store$.dispatch({ - type: HIDE_SIDE_PANEL_CONNECTIVITY, - }) - this.store$.dispatch({ - type: CLEAR_CONNECTIVITY_REGION, - }) + this.setDefaultMap() + + this.store$.dispatch({ + type: HIDE_SIDE_PANEL_CONNECTIVITY, + }) + this.store$.dispatch({ + type: CLEAR_CONNECTIVITY_REGION, + }) } public setDefaultMap() { - this.allRegions.forEach(r => { - if (r && r.ngId && r.rgb) { - this.defaultColorMap.get(r.ngId).set(r.labelIndex, {red: r.rgb[0], green: r.rgb[1], blue: r.rgb[2]}) - } - }) - getWindow().interactiveViewer.viewerHandle.applyLayersColourMap(this.defaultColorMap) + this.allRegions.forEach(r => { + if (r && r.ngId && r.rgb) { + this.defaultColorMap.get(r.ngId).set(r.labelIndex, {red: r.rgb[0], green: r.rgb[1], blue: r.rgb[2]}) + } + }) + getWindow().interactiveViewer.viewerHandle.applyLayersColourMap(this.defaultColorMap) } public addNewColorMap() { - this.defaultColorMap = new Map(getWindow().interactiveViewer.viewerHandle.getLayersSegmentColourMap()) + this.defaultColorMap = new Map(getWindow().interactiveViewer.viewerHandle.getLayersSegmentColourMap()) - const existingMap: Map<string, Map<number, {red: number, green: number, blue: number}>> = (getWindow().interactiveViewer.viewerHandle.getLayersSegmentColourMap()) + const existingMap: Map<string, Map<number, {red: number, green: number, blue: number}>> = (getWindow().interactiveViewer.viewerHandle.getLayersSegmentColourMap()) - const colorMap = new Map(existingMap) + const colorMap = new Map(existingMap) - this.allRegions.forEach(r => { + this.allRegions.forEach(r => { - if (r.ngId) { - colorMap.get(r.ngId).set(r.labelIndex, {red: 255, green: 255, blue: 255}) - } - }) + if (r.ngId) { + colorMap.get(r.ngId).set(r.labelIndex, {red: 255, green: 255, blue: 255}) + } + }) - this.connectedAreas.forEach(area => { - const areaAsRegion = this.allRegions - .filter(r => r.name === area.name + this.areaHemisphere) - .map(r => r) + this.connectedAreas.forEach(area => { + const areaAsRegion = this.allRegions + .filter(r => r.name === area.name + this.areaHemisphere) + .map(r => r) - if (areaAsRegion && areaAsRegion.length && areaAsRegion[0].ngId) { - colorMap.get(areaAsRegion[0].ngId).set(areaAsRegion[0].labelIndex, {red: area.color.r, green: area.color.g, blue: area.color.b}) - } - }) - getWindow().interactiveViewer.viewerHandle.applyLayersColourMap(colorMap) + if (areaAsRegion && areaAsRegion.length && areaAsRegion[0].ngId) { + colorMap.get(areaAsRegion[0].ngId).set(areaAsRegion[0].labelIndex, {red: area.color.r, green: area.color.g, blue: area.color.b}) + } + }) + getWindow().interactiveViewer.viewerHandle.applyLayersColourMap(colorMap) } public getAllRegionsFromParcellation = (regions) => { - for (const region of regions) { - if (region.children && region.children.length) { - this.getAllRegionsFromParcellation(region.children) - } else { - this.allRegions.push(region) - } + for (const region of regions) { + if (region.children && region.children.length) { + this.getAllRegionsFromParcellation(region.children) + } else { + this.allRegions.push(region) } + } } } function getWindow(): any { - return window + return window } diff --git a/src/ui/databrowserModule/fileviewer/chart/line/line.chart.component.ts b/src/ui/databrowserModule/fileviewer/chart/line/line.chart.component.ts index be48e8d321398b0d79e41659eef88b1e29e39486..983e682c6b7f11eae2cc93484c27d83468b4d588 100644 --- a/src/ui/databrowserModule/fileviewer/chart/line/line.chart.component.ts +++ b/src/ui/databrowserModule/fileviewer/chart/line/line.chart.component.ts @@ -11,8 +11,8 @@ import { ChartBase } from '../chart.base'; templateUrl : './line.chart.template.html', styleUrls : [ `./line.chart.style.css`, - ], - exportAs: 'iavLineChart', + ], + exportAs: 'iavLineChart', }) export class LineChart extends ChartBase implements OnChanges, CommonChartInterface { diff --git a/src/ui/databrowserModule/fileviewer/chart/radar/radar.chart.component.ts b/src/ui/databrowserModule/fileviewer/chart/radar/radar.chart.component.ts index 213d909eb9e0e95e433b371f182246cae30ebc3f..f86da382d5106de808a3e859e65819909724c701 100644 --- a/src/ui/databrowserModule/fileviewer/chart/radar/radar.chart.component.ts +++ b/src/ui/databrowserModule/fileviewer/chart/radar/radar.chart.component.ts @@ -10,8 +10,8 @@ import { applyOption, ChartColor, CommonChartInterface, DatasetInterface, Legend templateUrl : './radar.chart.template.html', styleUrls : [ `./radar.chart.style.css`, - ], - exportAs: 'iavRadarChart', + ], + exportAs: 'iavRadarChart', }) export class RadarChart extends ChartBase implements OnDestroy, OnChanges, CommonChartInterface { diff --git a/src/ui/databrowserModule/fileviewer/fileviewer.component.ts b/src/ui/databrowserModule/fileviewer/fileviewer.component.ts index 97588bf5f09c2ac230a7b0338f9b496fe90415bd..1ae371c7d48dfa85e5efca873734a7fede49826d 100644 --- a/src/ui/databrowserModule/fileviewer/fileviewer.component.ts +++ b/src/ui/databrowserModule/fileviewer/fileviewer.component.ts @@ -9,7 +9,7 @@ import { ChartBase } from './chart/chart.base'; templateUrl : './fileviewer.template.html' , styleUrls : [ './fileviewer.style.css', - ], + ], }) export class FileViewer implements OnChanges { diff --git a/src/ui/databrowserModule/preview/preview.component.ts b/src/ui/databrowserModule/preview/preview.component.ts index 4f19643b246bd2394c674c98df89426cb953fa8d..f5bf30d994669019aa11672bd8263e68e59de5cf 100644 --- a/src/ui/databrowserModule/preview/preview.component.ts +++ b/src/ui/databrowserModule/preview/preview.component.ts @@ -3,10 +3,10 @@ import { ViewerPreviewFile } from "src/services/state/dataStore.store"; import { DatabrowserService } from "../databrowser.service"; const getRenderNodeFn = ({name : activeFileName = ''} = {}) => ({name = '', path = 'unpathed'}) => name -? activeFileName === name - ? `<span class="text-warning">${name}</span>` - : name -: path + ? activeFileName === name + ? `<span class="text-warning">${name}</span>` + : name + : path @Component({ selector: 'preview-component', diff --git a/src/ui/databrowserModule/util/filterDataEntriesByMethods.pipe.ts b/src/ui/databrowserModule/util/filterDataEntriesByMethods.pipe.ts index e323975a62d6c6c49eef2926a18ebae1a8d88638..f482b6c5c41fe3bf3a94a428a477e921b7c227a8 100644 --- a/src/ui/databrowserModule/util/filterDataEntriesByMethods.pipe.ts +++ b/src/ui/databrowserModule/util/filterDataEntriesByMethods.pipe.ts @@ -14,10 +14,10 @@ export class FilterDataEntriesbyMethods implements PipeTransform { const includeEmpty = dataModalities.some(d => d.name === noMethodDisplayName) return dataEntries && dataModalities && dataModalities.length > 0 ? dataEntries.filter(dataEntry => { - return includeEmpty && dataEntry.methods.length === 0 + return includeEmpty && dataEntry.methods.length === 0 || dataEntry.methods.some(m => - dataModalities.findIndex(dm => dm.name === temporaryFilterDataentryName(m)) >= 0) - }) + dataModalities.findIndex(dm => dm.name === temporaryFilterDataentryName(m)) >= 0) + }) : dataEntries } } diff --git a/src/ui/databrowserModule/util/filterDataEntriesByRegion.pipe.ts b/src/ui/databrowserModule/util/filterDataEntriesByRegion.pipe.ts index afa527a672e0dc5d4c35bffb00c7769352f86f79..b666190984e62679cf2ace4b082e6c1333f5c04e 100644 --- a/src/ui/databrowserModule/util/filterDataEntriesByRegion.pipe.ts +++ b/src/ui/databrowserModule/util/filterDataEntriesByRegion.pipe.ts @@ -18,30 +18,30 @@ export class FilterDataEntriesByRegion implements PipeTransform { public transform(dataentries: IDataEntry[], selectedRegions: any[], flattenedAllRegions: any[]) { return dataentries && selectedRegions && selectedRegions.length > 0 ? dataentries - .map(de => { - /** + .map(de => { + /** * translate parcellationRegion to region representation */ - const newParcellationRegion = de.parcellationRegion.map(({name, id, ...rest}) => { + const newParcellationRegion = de.parcellationRegion.map(({name, id, ...rest}) => { - const found = flattenedAllRegions.find(r => { - /** + const found = flattenedAllRegions.find(r => { + /** * TODO replace pseudo id with real uuid */ - return (r.id && id && r.id === id) + return (r.id && id && r.id === id) || r.name === name || r.relatedAreas && r.relatedAreas.length && r.relatedAreas.some(syn => syn === name) - }) - return found - ? { name, id, ...rest, ...found } - : { name, id, ...rest } }) - return { - ...de, - parcellationRegion: newParcellationRegion, - } + return found + ? { name, id, ...rest, ...found } + : { name, id, ...rest } }) - .filter(de => filterSubSelect(de, selectedRegions)) + return { + ...de, + parcellationRegion: newParcellationRegion, + } + }) + .filter(de => filterSubSelect(de, selectedRegions)) : dataentries } } diff --git a/src/ui/databrowserModule/util/pathToNestedChildren.pipe.ts b/src/ui/databrowserModule/util/pathToNestedChildren.pipe.ts index 991d95d3690a76d28015d57efa4ece10e6070123..40bb657bcf31e8d409d659ffc9e0adb52f561519 100644 --- a/src/ui/databrowserModule/util/pathToNestedChildren.pipe.ts +++ b/src/ui/databrowserModule/util/pathToNestedChildren.pipe.ts @@ -37,13 +37,13 @@ export class PathToNestedChildren implements PipeTransform { finalPath ? curr : {}, { - path : this.getCurrentPath(curr), - children : finalPath ? - [] : - this.constructDoubleHeirachy( - [ this.getNextLevelHeirachy(curr) ], - ), - }) + path : this.getCurrentPath(curr), + children : finalPath ? + [] : + this.constructDoubleHeirachy( + [ this.getNextLevelHeirachy(curr) ], + ), + }) } private concatItem(item: NestedChildren, curr: HasPathProperty): NestedChildren { diff --git a/src/ui/kgEntryViewer/subjectViewer/subjectViewer.component.ts b/src/ui/kgEntryViewer/subjectViewer/subjectViewer.component.ts index 6fe19573473bfd3089c102244d09324c456d6acb..6b0a80cd18cd8dfa92517a54125e5fde870d6a2d 100644 --- a/src/ui/kgEntryViewer/subjectViewer/subjectViewer.component.ts +++ b/src/ui/kgEntryViewer/subjectViewer/subjectViewer.component.ts @@ -27,9 +27,9 @@ export class SubjectViewer { get groupBySex() { return this.isSingle ? [{ - name : this.subjects.children.sex.value, - count : 1, - }] + name : this.subjects.children.sex.value, + count : 1, + }] : this.subjects.reduce((acc: any[], curr) => acc.findIndex(item => item.name === curr.children.sex.value) >= 0 ? acc.map(item => item.name === curr.children.sex.value diff --git a/src/ui/nehubaContainer/landmarkUnit/landmarkUnit.component.ts b/src/ui/nehubaContainer/landmarkUnit/landmarkUnit.component.ts index f5a0da571abdab38017c7424b89029f30d4d449c..7b3f4e55584a278464941202929b20db4d838303 100644 --- a/src/ui/nehubaContainer/landmarkUnit/landmarkUnit.component.ts +++ b/src/ui/nehubaContainer/landmarkUnit/landmarkUnit.component.ts @@ -39,9 +39,9 @@ export class LandmarkUnit implements OnChanges { public calcOpacity(): number { return this.flatProjection ? this.calcOpacityFlatMode() : - this.positionZ >= 0 ? - 1 : - 0.4 + this.positionZ >= 0 ? + 1 : + 0.4 } public calcOpacityFlatMode(): number { diff --git a/src/ui/nehubaContainer/nehubaContainer.component.ts b/src/ui/nehubaContainer/nehubaContainer.component.ts index 0db1bab47da2343d244613c86f64af361fb902f2..4781d0408ef60914ca73be4174386280340a183b 100644 --- a/src/ui/nehubaContainer/nehubaContainer.component.ts +++ b/src/ui/nehubaContainer/nehubaContainer.component.ts @@ -284,7 +284,7 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { ? 'Loading auxiliary chunk' // : this.regionsLabelIndexMap.get(lastLoadedIdNum) // ? `Loading ${this.regionsLabelIndexMap.get(lastLoadedIdNum).name}` - : 'Loading meshes ...' + : 'Loading meshes ...' }), ) @@ -447,31 +447,31 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { if (!viewPanels.every(v => !!v)) { return } switch (mode) { - case H_ONE_THREE: { - const element = this.removeExistingPanels() - const newEl = getHorizontalOneThree(viewPanels) - element.appendChild(newEl) - break; - } - case V_ONE_THREE: { - const element = this.removeExistingPanels() - const newEl = getVerticalOneThree(viewPanels) - element.appendChild(newEl) - break; - } - case FOUR_PANEL: { - const element = this.removeExistingPanels() - const newEl = getFourPanel(viewPanels) - element.appendChild(newEl) - break; - } - case SINGLE_PANEL: { - const element = this.removeExistingPanels() - const newEl = getSinglePanel(viewPanels) - element.appendChild(newEl) - break; - } - default: + case H_ONE_THREE: { + const element = this.removeExistingPanels() + const newEl = getHorizontalOneThree(viewPanels) + element.appendChild(newEl) + break; + } + case V_ONE_THREE: { + const element = this.removeExistingPanels() + const newEl = getVerticalOneThree(viewPanels) + element.appendChild(newEl) + break; + } + case FOUR_PANEL: { + const element = this.removeExistingPanels() + const newEl = getFourPanel(viewPanels) + element.appendChild(newEl) + break; + } + case SINGLE_PANEL: { + const element = this.removeExistingPanels() + const newEl = getSinglePanel(viewPanels) + element.appendChild(newEl) + break; + } + default: } for (const panel of viewPanels) { (panel as HTMLElement).classList.add('neuroglancer-panel') @@ -511,16 +511,16 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { ? (data.geometry as IPointLandmarkGeometry).position : data.geometry.type === 'plane' ? [ - (data.geometry as IPlaneLandmarkGeometry).corners, - [[0, 1, 2], [0, 2, 3]], - ] + (data.geometry as IPlaneLandmarkGeometry).corners, + [[0, 1, 2], [0, 2, 3]], + ] : data.geometry.type === 'mesh' ? [ - (data.geometry as IOtherLandmarkGeometry).vertices, - (data.geometry as IOtherLandmarkGeometry).meshIdx, - ] + (data.geometry as IOtherLandmarkGeometry).vertices, + (data.geometry as IOtherLandmarkGeometry).meshIdx, + ] : null), - ) + ) } else { if (this.nehubaViewer && this.nehubaViewer.removeSpatialSearch3DLandmarks instanceof Function) { this.nehubaViewer.removeSpatialSearch3DLandmarks() @@ -658,7 +658,7 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { this.selectedRegionIndexSet.size > 0 ? this.nehubaViewer.showSegs([...this.selectedRegionIndexSet]) : this.nehubaViewer.showAllSeg() - }, + }, ), ) @@ -691,7 +691,7 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { if (this.nehubaViewer.removeLayer({ name : l.name, })) { - this.ngLayersRegister.layers = this.ngLayersRegister.layers.filter(rl => rl.name !== l.name) + this.ngLayersRegister.layers = this.ngLayersRegister.layers.filter(rl => rl.name !== l.name) } }) } @@ -1303,12 +1303,12 @@ export const identifySrcElement = (element: HTMLElement) => { return elementIsFirstCell && elementIsFirstRow ? 0 : !elementIsFirstCell && elementIsFirstRow - ? 1 - : elementIsFirstCell && !elementIsFirstRow - ? 2 - : !elementIsFirstCell && !elementIsFirstRow - ? 3 - : 4 + ? 1 + : elementIsFirstCell && !elementIsFirstRow + ? 2 + : !elementIsFirstCell && !elementIsFirstRow + ? 3 + : 4 } export const takeOnePipe = [ diff --git a/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts b/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts index 464f4b7f296eca0fd8a07ca8959f20cc5e03a5b8..0877f1dd3cde1b9196a177f3d69d68d47b93b52e 100644 --- a/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts +++ b/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts @@ -27,9 +27,9 @@ const scanFn: (acc: LayerLabelIndex[], curr: LayerLabelIndex) => LayerLabelIndex const foundIndex = acc.findIndex(({ layer }) => layer.name === name) if (foundIndex < 0) { return acc.concat(curr) } else { return acc.map((item, idx) => idx === foundIndex ? { - ...item, - labelIndicies: [...new Set([...item.labelIndicies, ...curr.labelIndicies])], - } + ...item, + labelIndicies: [...new Set([...item.labelIndicies, ...curr.labelIndicies])], + } : item) } } @@ -472,7 +472,7 @@ export class NehubaViewerUnit implements OnInit, OnDestroy { */ : false ), - ) + ) } // TODO single landmark for user landmark diff --git a/src/ui/nehubaContainer/pipes/mobileControlNubStyle.pipe.ts b/src/ui/nehubaContainer/pipes/mobileControlNubStyle.pipe.ts index 8c07d7f65e57c6a34524af8c98051d331585bca2..7e2e4e2a4844fa07fd57c6adc6c7a2276b4fadac 100644 --- a/src/ui/nehubaContainer/pipes/mobileControlNubStyle.pipe.ts +++ b/src/ui/nehubaContainer/pipes/mobileControlNubStyle.pipe.ts @@ -8,23 +8,23 @@ import { FOUR_PANEL, H_ONE_THREE, SINGLE_PANEL, V_ONE_THREE } from "src/services export class MobileControlNubStylePipe implements PipeTransform { public transform(panelMode: string): any { switch (panelMode) { - case SINGLE_PANEL: - return { - top: '80%', - left: '95%', - } - case V_ONE_THREE: - case H_ONE_THREE: - return { - top: '66.66%', - left: '66.66%', - } - case FOUR_PANEL: - default: - return { - top: '50%', - left: '50%', - } + case SINGLE_PANEL: + return { + top: '80%', + left: '95%', + } + case V_ONE_THREE: + case H_ONE_THREE: + return { + top: '66.66%', + left: '66.66%', + } + case FOUR_PANEL: + default: + return { + top: '50%', + left: '50%', + } } } } diff --git a/src/ui/nehubaContainer/statusCard/statusCard.component.ts b/src/ui/nehubaContainer/statusCard/statusCard.component.ts index ec04fc976b73aa142d6fb6290a0092ba223ff1f2..ffd58c2b0ed48b7386e7eaf22086e8f1ed9b48ce 100644 --- a/src/ui/nehubaContainer/statusCard/statusCard.component.ts +++ b/src/ui/nehubaContainer/statusCard/statusCard.component.ts @@ -5,10 +5,10 @@ import { CHANGE_NAVIGATION, ViewerStateInterface } from "src/services/stateStore import { NehubaViewerUnit } from "../nehubaViewer/nehubaViewer.component"; @Component({ - selector : 'ui-status-card', - templateUrl : './statusCard.template.html', - styleUrls : ['./statusCard.style.css'], - }) + selector : 'ui-status-card', + templateUrl : './statusCard.template.html', + styleUrls : ['./statusCard.style.css'], +}) export class StatusCardComponent { @Input() public selectedTemplate: any; diff --git a/src/ui/parcellationRegion/regionMenu/regionMenu.component.ts b/src/ui/parcellationRegion/regionMenu/regionMenu.component.ts index e2022355c35cc75b67c4bd23d33508b153a18d87..d6b84425c69210634101345df9b6d7cc802bed43 100644 --- a/src/ui/parcellationRegion/regionMenu/regionMenu.component.ts +++ b/src/ui/parcellationRegion/regionMenu/regionMenu.component.ts @@ -11,9 +11,9 @@ import { RegionBase } from '../region.base' }) export class RegionMenuComponent extends RegionBase { -constructor( - store$: Store<IavRootStoreInterface>, -) { - super(store$) + constructor( + store$: Store<IavRootStoreInterface>, + ) { + super(store$) } } diff --git a/src/ui/searchSideNav/searchSideNav.component.ts b/src/ui/searchSideNav/searchSideNav.component.ts index 5e00154b84eee8e60ad1864998131dac94ddfa44..b8533a630ee23712fe543613f74f7cd551b173d4 100644 --- a/src/ui/searchSideNav/searchSideNav.component.ts +++ b/src/ui/searchSideNav/searchSideNav.component.ts @@ -54,13 +54,13 @@ export class SearchSideNav implements OnDestroy { ) this.sidePanelExploreCurrentViewIsOpen$ = this.store$.pipe( - select('uiState'), - select("sidePanelExploreCurrentViewIsOpen"), + select('uiState'), + select("sidePanelExploreCurrentViewIsOpen"), ) this.sidePanelCurrentViewContent = this.store$.pipe( - select('uiState'), - select("sidePanelCurrentViewContent"), + select('uiState'), + select("sidePanelCurrentViewContent"), ) } diff --git a/src/ui/viewerStateController/regionHierachy/regionHierarchy.component.ts b/src/ui/viewerStateController/regionHierachy/regionHierarchy.component.ts index 9753904cc36be4cb4189c838d3db440d8f11499b..f57e80fc4799d492afc0baa81f0e173b6080fbb3 100644 --- a/src/ui/viewerStateController/regionHierachy/regionHierarchy.component.ts +++ b/src/ui/viewerStateController/regionHierachy/regionHierarchy.component.ts @@ -17,8 +17,8 @@ const getDisplayTreeNode: (searchTerm: string, selectedRegions: any[]) => (item: && selectedRegions.findIndex(re => generateLabelIndexId({ labelIndex: re.labelIndex, ngId: re.ngId }) === generateLabelIndexId({ ngId, labelIndex }), ) >= 0 - ? `<span class="cursor-default regionSelected">${insertHighlight(name, searchTerm)}</span>` + (status ? ` <span class="text-muted">(${insertHighlight(status, searchTerm)})</span>` : ``) - : `<span class="cursor-default regionNotSelected">${insertHighlight(name, searchTerm)}</span>` + (status ? ` <span class="text-muted">(${insertHighlight(status, searchTerm)})</span>` : ``) + ? `<span class="cursor-default regionSelected">${insertHighlight(name, searchTerm)}</span>` + (status ? ` <span class="text-muted">(${insertHighlight(status, searchTerm)})</span>` : ``) + : `<span class="cursor-default regionNotSelected">${insertHighlight(name, searchTerm)}</span>` + (status ? ` <span class="text-muted">(${insertHighlight(status, searchTerm)})</span>` : ``) } const getFilterTreeBySearch = (pipe: FilterNameBySearch, searchTerm: string) => (node: any) => pipe.transform([node.name, node.status], searchTerm) diff --git a/src/ui/viewerStateController/viewerState.base.ts b/src/ui/viewerStateController/viewerState.base.ts index 583e11f01687316a3ea845bff2205c8c8e8c14c5..be61afdff357ddf3c02af888ef5a881ad79b4fd3 100644 --- a/src/ui/viewerStateController/viewerState.base.ts +++ b/src/ui/viewerStateController/viewerState.base.ts @@ -18,8 +18,8 @@ const ACTION_TYPES = { } const compareWith = (o, n) => !o || !n -? false -: o.name === n.name + ? false + : o.name === n.name export class ViewerStateBase implements OnInit { diff --git a/src/util/directives/elementOutClick.directive.ts b/src/util/directives/elementOutClick.directive.ts index 1734eeaed04305233a535645535b729ae2256781..a690c8d6524aff6e43154f2078a90a384afb160f 100644 --- a/src/util/directives/elementOutClick.directive.ts +++ b/src/util/directives/elementOutClick.directive.ts @@ -1,19 +1,19 @@ import {Directive, ElementRef, EventEmitter, HostListener, Output} from "@angular/core"; @Directive({ - selector: '[elementOutClick]', + selector: '[elementOutClick]', }) export class ElementOutClickDirective { - constructor(private elRef: ElementRef) { } + constructor(private elRef: ElementRef) { } @Output() public outsideClick = new EventEmitter() @HostListener('document:click', ['$event', '$event.target']) public onclick(event: MouseEvent, targetElement: HTMLElement): void { - if (!targetElement) { - return - } + if (!targetElement) { + return + } - this.outsideClick.emit(!this.elRef.nativeElement.contains(targetElement)) + this.outsideClick.emit(!this.elRef.nativeElement.contains(targetElement)) } } diff --git a/src/util/directives/mouseOver.directive.ts b/src/util/directives/mouseOver.directive.ts index c0825cf0dadd3fc7f7c725addcb4a9c100098f4e..53dc7dadb23e306e57556f010f30f606b1bb2e90 100644 --- a/src/util/directives/mouseOver.directive.ts +++ b/src/util/directives/mouseOver.directive.ts @@ -89,11 +89,11 @@ export class MouseHoverDirective { ), map(([ arr, parcellationSelected ]) => parcellationSelected && parcellationSelected.auxillaryMeshIndices ? arr.filter(({ segment }) => { - // if segment is not a string (i.e., not labelIndexId) return true - if (typeof segment !== 'string') { return true } - const { labelIndex } = getNgIdLabelIndexFromId({ labelIndexId: segment }) - return parcellationSelected.auxillaryMeshIndices.indexOf(labelIndex) < 0 - }) + // if segment is not a string (i.e., not labelIndexId) return true + if (typeof segment !== 'string') { return true } + const { labelIndex } = getNgIdLabelIndexFromId({ labelIndexId: segment }) + return parcellationSelected.auxillaryMeshIndices.indexOf(labelIndex) < 0 + }) : arr), distinctUntilChanged((o, n) => o.length === n.length && n.every(segment => @@ -163,16 +163,16 @@ export class MouseOverTextPipe implements PipeTransform { private renderText = ({ label, obj }): SafeHtml[] => { switch (label) { - case 'landmark': - return [this.sanitizer.sanitize(SecurityContext.HTML, obj.landmarkName)] - case 'segments': - return obj.map(({ segment }) => this.transformOnHoverSegmentPipe.transform(segment)) - case 'userLandmark': - return [this.sanitizer.sanitize(SecurityContext.HTML, obj.id)] - default: - // ts-lint:disable-next-line - console.warn(`mouseOver.directive.ts#mouseOverTextPipe: Cannot be displayed: label: ${label}`) - return [this.sanitizer.bypassSecurityTrustHtml(`Cannot be displayed: label: ${label}`)] + case 'landmark': + return [this.sanitizer.sanitize(SecurityContext.HTML, obj.landmarkName)] + case 'segments': + return obj.map(({ segment }) => this.transformOnHoverSegmentPipe.transform(segment)) + case 'userLandmark': + return [this.sanitizer.sanitize(SecurityContext.HTML, obj.id)] + default: + // ts-lint:disable-next-line + console.warn(`mouseOver.directive.ts#mouseOverTextPipe: Cannot be displayed: label: ${label}`) + return [this.sanitizer.bypassSecurityTrustHtml(`Cannot be displayed: label: ${label}`)] } } @@ -201,26 +201,26 @@ export class MouseOverIconPipe implements PipeTransform { public transform(type: string): {fontSet: string, fontIcon: string} { switch (type) { - case 'landmark': - return { - fontSet: 'fas', - fontIcon: 'fa-map-marker-alt', - } - case 'segments': - return { - fontSet: 'fas', - fontIcon: 'fa-brain', - } - case 'userLandmark': - return { - fontSet: 'fas', - fontIcon: 'fa-map-marker-alt', - } - default: - return { - fontSet: 'fas', - fontIcon: 'fa-file', - } + case 'landmark': + return { + fontSet: 'fas', + fontIcon: 'fa-map-marker-alt', + } + case 'segments': + return { + fontSet: 'fas', + fontIcon: 'fa-brain', + } + case 'userLandmark': + return { + fontSet: 'fas', + fontIcon: 'fa-map-marker-alt', + } + default: + return { + fontSet: 'fas', + fontIcon: 'fa-file', + } } } } diff --git a/src/util/generator.ts b/src/util/generator.ts index 27e4d84ad2a1d047b6ae3163ac2cbe35c71b2ae9..9c9d14a9064fb6d113d7c648ae59c69575314c69 100644 --- a/src/util/generator.ts +++ b/src/util/generator.ts @@ -3,9 +3,9 @@ export function* timedValues(ms: number = 500, mode: string = 'linear') { const getValue = (fraction) => { switch (mode) { - case 'linear': - default: - return fraction < 1 ? fraction : 1 + case 'linear': + default: + return fraction < 1 ? fraction : 1 } } while ((Date.now() - startTime) < ms) { diff --git a/src/util/pipes/filterWithString.pipe.ts b/src/util/pipes/filterWithString.pipe.ts index 01d89e5731e190a3d610906df062702565c3ce65..ccb08335f550cf80c38c9c3c2bd1e135effb6ce8 100644 --- a/src/util/pipes/filterWithString.pipe.ts +++ b/src/util/pipes/filterWithString.pipe.ts @@ -1,14 +1,14 @@ import {Pipe, PipeTransform} from "@angular/core"; @Pipe({ - name: 'filterWithString', + name: 'filterWithString', }) export class FilterWithStringPipe implements PipeTransform { - public transform(value: any, ...args): any { - if (args[0]) { - return value.filter(pf => pf.name.toLowerCase().includes(args[0].toLowerCase())) - } else { - return value - } + public transform(value: any, ...args): any { + if (args[0]) { + return value.filter(pf => pf.name.toLowerCase().includes(args[0].toLowerCase())) + } else { + return value } + } } diff --git a/src/util/pipes/groupDataEntriesByRegion.pipe.ts b/src/util/pipes/groupDataEntriesByRegion.pipe.ts index 334495670b6db9408dcaf1040c43a84787622cfa..50f7a394c7228ea2aa023afa10d8dedddbf48bb7 100644 --- a/src/util/pipes/groupDataEntriesByRegion.pipe.ts +++ b/src/util/pipes/groupDataEntriesByRegion.pipe.ts @@ -19,18 +19,18 @@ export class GroupDatasetByRegion implements PipeTransform { ? Object.assign({}, v, {searchResults : v.searchResults.concat(curr)}) : v ) : acc2.concat({ - region : this.getRegionFromRegionName(reName.name, regions), - searchResults : [ curr ], - }) - }, acc) + region : this.getRegionFromRegionName(reName.name, regions), + searchResults : [ curr ], + }) + }, acc) : acc.findIndex(it => it.region == null) >= 0 ? acc.map(it => it.region === null ? Object.assign({}, it, {searchResults: it.searchResults.concat(curr)}) : it) : acc.concat({ - region : null, - searchResults : [curr], - }) + region : null, + searchResults : [curr], + }) }, [] as Array<{region: any|null, searchResults: IDataEntry[]}>) } diff --git a/src/util/pipes/newViewerDistinctViewToLayer.pipe.ts b/src/util/pipes/newViewerDistinctViewToLayer.pipe.ts index 16e1ae681c10b108c130f9e832bd807285afd623..c00db3f04631f1ab07825786d03562b9f1bdc3ce 100644 --- a/src/util/pipes/newViewerDistinctViewToLayer.pipe.ts +++ b/src/util/pipes/newViewerDistinctViewToLayer.pipe.ts @@ -15,17 +15,17 @@ export class NewViewerDisctinctViewToLayer implements PipeTransform { return [] .concat(newViewer ? Object.keys(newViewer.nehubaConfig.dataset.initialNgState.layers).map(key => ({ - name : key, - url : newViewer.nehubaConfig.dataset.initialNgState.layers[key].source, - type : newViewer.nehubaConfig.dataset.initialNgState.layers[key].type === 'image' - ? 'base' - : newViewer.nehubaConfig.dataset.initialNgState.layers[key].type === 'segmentation' - ? 'mixable' - : 'nonmixable', - transform : newViewer.nehubaConfig.dataset.initialNgState.layers[key].transform - ? newViewer.nehubaConfig.dataset.initialNgState.layers[key].transform.map(quat => Array.from(quat)) - : null, - })) + name : key, + url : newViewer.nehubaConfig.dataset.initialNgState.layers[key].source, + type : newViewer.nehubaConfig.dataset.initialNgState.layers[key].type === 'image' + ? 'base' + : newViewer.nehubaConfig.dataset.initialNgState.layers[key].type === 'segmentation' + ? 'mixable' + : 'nonmixable', + transform : newViewer.nehubaConfig.dataset.initialNgState.layers[key].transform + ? newViewer.nehubaConfig.dataset.initialNgState.layers[key].transform.map(quat => Array.from(quat)) + : null, + })) : []) .concat(dedicatedViewer ? { name : 'dedicated view', url : dedicatedViewer, type : 'nonmixable' } diff --git a/src/util/pipes/templateParcellationHasMoreInfo.pipe.ts b/src/util/pipes/templateParcellationHasMoreInfo.pipe.ts index 5c2003c6feede070992cf5cf3ec1eeb24998f49f..e94e975da6559d70133b60c203b2a3535673f6ba 100644 --- a/src/util/pipes/templateParcellationHasMoreInfo.pipe.ts +++ b/src/util/pipes/templateParcellationHasMoreInfo.pipe.ts @@ -35,14 +35,14 @@ export class TemplateParcellationHasMoreInfo implements PipeTransform { return hasMoreInfo ? { - name: pName || name, - description: pDescriptions || description, - publications: pPublications || publications, - originDatasets: notEmptyArray(originDatasets) - ? originDatasets - : [{ kgSchema: null, kgId: null }], - mindsId: pMindsId || mindsId, - } + name: pName || name, + description: pDescriptions || description, + publications: pPublications || publications, + originDatasets: notEmptyArray(originDatasets) + ? originDatasets + : [{ kgSchema: null, kgId: null }], + mindsId: pMindsId || mindsId, + } : null } }