diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000000000000000000000000000000000..6de2f63d7e98adaa0c32f09013e16a7d57485681 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +*.spec.ts \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000000000000000000000000000000000000..386b904d3077ea117eca65c6487921bd38919c60 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,41 @@ +module.exports = { + root: true, + parser: '@typescript-eslint/parser', + plugins: [ + '@typescript-eslint', + ], + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + ], + rules: { + "@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 + // } + // }], + "@typescript-eslint/member-delimiter-style": [2, { + "multiline": { + "delimiter": "none", + "requireLast": true + }, + "singleline": { + "delimiter": "comma", + "requireLast": false + } + }], + "@typescript-eslint/no-unused-vars": ["warn", { + "argsIgnorePattern": "^_" + }], + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-use-before-define": "off" + } +}; \ No newline at end of file diff --git a/package.json b/package.json index e80196face70489c977e42eedab03f16e38efc0c..8f1950bde254af599a540f749cbf6fd16776966c 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "dev-server-all-interfaces": "webpack-dev-server --config webpack.dev.js --mode development --hot --host 0.0.0.0", "test": "karma start spec/karma.conf.js", "e2e": "protractor e2e/protractor.conf", - "lint": "tslint 'src/**/*.ts'", - "tslint": "tslint" + "lint": "eslint src --ext .ts", + "eslint": "eslint" }, "keywords": [], "author": "", @@ -44,11 +44,14 @@ "@types/jasmine": "^3.3.12", "@types/node": "^12.0.0", "@types/webpack-env": "^1.13.6", + "@typescript-eslint/eslint-plugin": "^2.12.0", + "@typescript-eslint/parser": "^2.12.0", "angular2-template-loader": "^0.6.2", "chart.js": "^2.7.2", "codelyzer": "^5.0.1", "core-js": "^3.0.1", "css-loader": "^3.2.0", + "eslint": "^6.8.0", "eslint-plugin-html": "^6.0.0", "file-loader": "^1.1.11", "hammerjs": "^2.0.8", @@ -77,7 +80,6 @@ "showdown": "^1.9.1", "ts-loader": "^4.3.0", "ts-node": "^8.1.0", - "tslint": "^5.16.0", "typescript": "3.2", "uglifyjs-webpack-plugin": "^1.2.5", "webpack": "^4.41.2", diff --git a/src/atlasViewer/atlasViewer.urlUtil.ts b/src/atlasViewer/atlasViewer.urlUtil.ts index 40e018c95f3206bc2d031be8e1215c2c5aa0f204..0f0821299d6fdb7ab0d65347acd07ff01ff279b0 100644 --- a/src/atlasViewer/atlasViewer.urlUtil.ts +++ b/src/atlasViewer/atlasViewer.urlUtil.ts @@ -58,17 +58,17 @@ export const cvtStateToSearchParam = (state: IavRootStoreInterface): URLSearchPa const initialNgState = templateSelected.nehubaConfig.dataset.initialNgState const { layers } = ngViewerState const additionalLayers = layers.filter(layer => - /^blob\:/.test(layer.name) && + /^blob:/.test(layer.name) && Object.keys(initialNgState.layers).findIndex(layerName => layerName === layer.name) < 0, ) - const niftiLayers = additionalLayers.filter(layer => /^nifti\:\/\//.test(layer.source)) + const niftiLayers = additionalLayers.filter(layer => /^nifti:\/\//.test(layer.source)) if (niftiLayers.length > 0) { searchParam.set('niftiLayers', niftiLayers.join('__')) } // plugin state const { initManifests } = pluginState const pluginStateParam = initManifests .filter(([ src ]) => src !== PLUGINSTORE_CONSTANTS.INIT_MANIFEST_SRC) - .map(([ src, url]) => url) + .map(([ _src, url]) => url) .join('__') if (initManifests.length > 0) { searchParam.set('pluginState', pluginStateParam) } @@ -80,7 +80,7 @@ export const cvtSearchParamToState = (searchparams: URLSearchParams, state: IavR const returnState = JSON.parse(JSON.stringify(state)) as IavRootStoreInterface - // tslint:disable-next-line:no-empty + /* eslint-disable-next-line @typescript-eslint/no-empty-function */ const warningCb = callback || (() => {}) const { TEMPLATE_NOT_FOUND, TEMPALTE_NOT_SET, PARCELLATION_NOT_UPDATED } = PARSING_SEARCHPARAM_ERROR diff --git a/src/atlasViewer/widgetUnit/widgetService.service.ts b/src/atlasViewer/widgetUnit/widgetService.service.ts index a8ee57e9c770ed15d3776bdff0f5c33d5c207395..db04c4b0017128a64e79053ef18b669e1d62897d 100644 --- a/src/atlasViewer/widgetUnit/widgetService.service.ts +++ b/src/atlasViewer/widgetUnit/widgetService.service.ts @@ -156,7 +156,7 @@ export class WidgetServices implements OnDestroy { this.widgetComponentRefs.delete(widgetRef) widgetRef.instance.container.detach( 0 ) const guestComopnent = widgetRef.instance.guestComponentRef - const cr = this.addNewWidget(guestComopnent, options) + this.addNewWidget(guestComopnent, options) widgetRef.destroy() } else { diff --git a/src/atlasViewerExports/export.module.ts b/src/atlasViewerExports/export.module.ts index 5334cd1da3061b50b9884bfea3f29f396b895f88..0aa2e3fc15b42432a815594e311682be0aba6a47 100644 --- a/src/atlasViewerExports/export.module.ts +++ b/src/atlasViewerExports/export.module.ts @@ -55,6 +55,6 @@ export class ExportModule { } - // tslint:disable-next-line:no-empty + /* eslint-disable-next-line @typescript-eslint/no-empty-function */ public ngDoBootstrap() {} } diff --git a/src/components/components.module.ts b/src/components/components.module.ts index bb218722c8118a688e279b8f4ae079371ab6dbfd..1c9daeec33d6faafde1ec4501292af2a145a974e 100644 --- a/src/components/components.module.ts +++ b/src/components/components.module.ts @@ -30,7 +30,6 @@ import { RadioList } from './radiolist/radiolist.component'; import { ReadmoreComponent } from './readmoore/readmore.component'; import { SleightOfHand } from './sleightOfHand/soh.component'; import { TimerComponent } from './timer/timer.component'; -import { ToastComponent } from './toast/toast.component'; import { TreeComponent } from './tree/tree.component'; import { TreeBaseDirective } from './tree/treeBase.directive'; @@ -51,7 +50,6 @@ import { TreeBaseDirective } from './tree/treeBase.directive'; TreeComponent, PanelComponent, PaginationComponent, - ToastComponent, FlatTreeComponent, TimerComponent, PillComponent, @@ -85,7 +83,6 @@ import { TreeBaseDirective } from './tree/treeBase.directive'; TreeComponent, PanelComponent, PaginationComponent, - ToastComponent, FlatTreeComponent, TimerComponent, PillComponent, diff --git a/src/components/flatTree/highlight.pipe.ts b/src/components/flatTree/highlight.pipe.ts index 31583a1a98a3b90b139499872c85c07f306fbef6..5976ba20b0abf0739390e6b2497a620c0f347735 100644 --- a/src/components/flatTree/highlight.pipe.ts +++ b/src/components/flatTree/highlight.pipe.ts @@ -1,5 +1,5 @@ -import { Pipe, PipeTransform, SecurityContext } from "@angular/core"; -import { DomSanitizer, SafeHtml } from "@angular/platform-browser"; +import { Pipe, PipeTransform } from "@angular/core"; +import { DomSanitizer } from "@angular/platform-browser"; @Pipe({ name : 'highlightPipe', diff --git a/src/components/parseAttribute.directive.ts b/src/components/parseAttribute.directive.ts index cb3b2dd942987f862dea0ed09640181b3ce73c4d..34a9b124841c32106a8f590f00d80d69f85d337b 100644 --- a/src/components/parseAttribute.directive.ts +++ b/src/components/parseAttribute.directive.ts @@ -1,5 +1,6 @@ import { Directive, OnChanges, SimpleChanges } from "@angular/core"; +// TODO deprecate this directive function parseAttribute(arg: any, expectedType: string) { // if( diff --git a/src/components/radiolist/radiolist.component.ts b/src/components/radiolist/radiolist.component.ts index ad1ae5658ac6fbad9c87a690f7a7364526b75e24..b9b97ad6f64f2f325c47ef051bfa81d8306a1cef 100644 --- a/src/components/radiolist/radiolist.component.ts +++ b/src/components/radiolist/radiolist.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output, TemplateRef, ViewChild } from "@angular/core"; +import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from "@angular/core"; @Component({ selector: 'radio-list', @@ -43,7 +43,7 @@ export class RadioList { } export interface IExtraButton { - name: string, + name: string faIcon: string class?: string } diff --git a/src/components/timer/timer.component.ts b/src/components/timer/timer.component.ts index eac84af1446d8bc7866a81aa2b9846561cc206be..c5b495cdacbf263846f25cefc1c31efeb33f6437 100644 --- a/src/components/timer/timer.component.ts +++ b/src/components/timer/timer.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, HostBinding, Input, OnDestroy, OnInit, Output } from "@angular/core"; +import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from "@angular/core"; import { timedValues } from "../../util/generator" @Component({ diff --git a/src/components/toast/toast.animation.ts b/src/components/toast/toast.animation.ts deleted file mode 100644 index 3ba3986fbcd59d664f4044672c6567c08e2fd6cb..0000000000000000000000000000000000000000 --- a/src/components/toast/toast.animation.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { animate, state, style, transition, trigger } from "@angular/animations"; - -export const toastAnimation = trigger('exists', [ - state('*', - style({ - height : '*', - opacity : 1, - })), - state('void', - style({ - height: '0em', - opacity : 0, - })), - transition('* => void', animate('180ms ease-in')), - transition('void => *', animate('180ms ease-out')), -]) diff --git a/src/components/toast/toast.component.ts b/src/components/toast/toast.component.ts deleted file mode 100644 index 8e347fdf1b102a1b72e3486dac9e5cf1be7217ef..0000000000000000000000000000000000000000 --- a/src/components/toast/toast.component.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { ChangeDetectionStrategy, Component, ElementRef, EventEmitter, HostBinding, HostListener, Input, NgZone, OnInit, Output, ViewChild, ViewContainerRef } from "@angular/core"; -import { toastAnimation } from "./toast.animation"; - -@Component({ - selector : 'toast', - templateUrl : './toast.template.html', - styleUrls : ['./toast.style.css'], - animations : [ - toastAnimation, - ], -}) - -export class ToastComponent { - @Input() public message: string - @Input() public htmlMessage: string - @Input() public timeout: number = 0 - @Input() public dismissable: boolean = true - - @Output() public dismissed: EventEmitter<boolean> = new EventEmitter() - - public progress: number = 0 - public hover: boolean - - @HostBinding('@exists') - public exists: boolean = true - - @ViewChild('messageContainer', {read: ViewContainerRef}) public messageContainer: ViewContainerRef - - public dismiss(event: MouseEvent) { - event.preventDefault() - event.stopPropagation() - - this.dismissed.emit(true) - } -} diff --git a/src/components/toast/toast.style.css b/src/components/toast/toast.style.css deleted file mode 100644 index e39cb38ee456c759dfd5dbe029d11a8c29a37407..0000000000000000000000000000000000000000 --- a/src/components/toast/toast.style.css +++ /dev/null @@ -1,47 +0,0 @@ -:host -{ - pointer-events: none; - text-align:center; - margin-bottom:5px; - min-height: 2em; -} - -div[container] -{ - display : inline-block; - align-items: center; - padding : 0.3em 1em 0em 1em; - pointer-events: all; - max-width:80%; -} - -:host-context([darktheme="false"]) div[container] -{ - background-color:rgba(240,240,240,0.8); - box-shadow: 0 6px 6px -2px rgba(10,10,10,0.2); -} - -:host-context([darktheme="true"]) div[container] -{ - background-color: rgba(50,50,50,0.8); - color : rgba(255,255,255,0.8); -} - -div[message] -{ - vertical-align: middle; -} - -div[message], -div[close] -{ - display:inline-block; -} - -timer-component -{ - flex: 0 0 0.5em; - margin: 0 -1em; - height:0.5em; - width: calc(100% + 2em); -} \ No newline at end of file diff --git a/src/components/toast/toast.template.html b/src/components/toast/toast.template.html deleted file mode 100644 index 7d1eb664845b73687c1be2bf1cdc110b789138ea..0000000000000000000000000000000000000000 --- a/src/components/toast/toast.template.html +++ /dev/null @@ -1,45 +0,0 @@ -<div - class="d-flex flex-column m-auto" - (mouseenter)="hover = true" - (mouseleave)="hover = false" - container> - - <!-- body --> - <div class="d-flex flex-row justify-content-between align-items-start"> - - <!-- contents --> - <div message> - <ng-template #messageContainer> - - </ng-template> - </div> - <div message - [innerHTML]="htmlMessage" - *ngIf = "htmlMessage"> - </div> - <div - message - *ngIf="message && !htmlMessage"> - {{ message }} - </div> - - <!-- dismiss btn --> - <div - (click)="dismiss($event)" - class="m-2" - *ngIf="dismissable" close> - <i class="fas fa-times"></i> - </div> - </div> - - <!-- timer --> - <timer-component - class="flex-" - *ngIf="timeout > 0" - (timerEnd)="dismissed.emit(false)" - [pause]="hover" - [timeout]="timeout" - timer> - </timer-component> - -</div> \ No newline at end of file diff --git a/src/layouts/floating/floating.component.ts b/src/layouts/floating/floating.component.ts index 1d546fd8a339a949e54e230deeeb91acb9c0801e..bb8ec5176576e4d6c0b2c06db51aea133237a5b9 100644 --- a/src/layouts/floating/floating.component.ts +++ b/src/layouts/floating/floating.component.ts @@ -1,4 +1,4 @@ -import { Component, HostBinding, Input, ViewChild } from "@angular/core"; +import { Component, HostBinding, Input } from "@angular/core"; @Component({ selector : 'layout-floating-container', diff --git a/src/main.module.ts b/src/main.module.ts index 52772356c764f50a8c292e8086460b4f6e52efc0..4262c65c6e225191ec7c7adee09acb36361f958b 100644 --- a/src/main.module.ts +++ b/src/main.module.ts @@ -26,7 +26,6 @@ import { WidgetServices } from './atlasViewer/widgetUnit/widgetService.service' import { WidgetUnit } from "./atlasViewer/widgetUnit/widgetUnit.component"; import { ConfirmDialogComponent } from "./components/confirmDialog/confirmDialog.component"; import { DialogComponent } from "./components/dialog/dialog.component"; -import { ToastComponent } from "./components/toast/toast.component"; import { AuthService } from "./services/auth.service"; import { DialogService } from "./services/dialogService.service"; import { UseEffects } from "./services/effect/effect"; @@ -115,7 +114,6 @@ import { LoggingService } from "./services/logging.service"; entryComponents : [ WidgetUnit, ModalUnit, - ToastComponent, PluginUnit, DialogComponent, ConfirmDialogComponent, @@ -148,13 +146,6 @@ export class MainModule { constructor( authServce: AuthService, - - /** - * instantiate singleton - * allow for pre fetching of dataentry - * TODO only fetch when traffic is idle - */ - dbSerivce: DatabrowserService, ) { authServce.authReloadState() } diff --git a/src/services/auth.service.ts b/src/services/auth.service.ts index 636f02f6249173d0b64471513dcb4c64702656fa..81add5950f138e5be60b233086dc4f0ddf9dd9b8 100644 --- a/src/services/auth.service.ts +++ b/src/services/auth.service.ts @@ -24,7 +24,7 @@ export class AuthService implements OnDestroy { constructor(private httpClient: HttpClient) { this.user$ = this.httpClient.get('user').pipe( - catchError(err => { + catchError(_err => { return of(null) }), shareReplay(1), diff --git a/src/services/effect/pluginUseEffect.ts b/src/services/effect/pluginUseEffect.ts index a61ae5a8445bb9646e301b907fd096cfb7b72359..f0841b9abf1dba4045cfb7ceb2d9766db72d27a6 100644 --- a/src/services/effect/pluginUseEffect.ts +++ b/src/services/effect/pluginUseEffect.ts @@ -36,7 +36,7 @@ export class PluginServiceUseEffect { filter(arr => arr.length > 0), map((arr: Array<[string, string|null]>) => { - for (const [source, url] of arr) { + for (const [_source, url] of arr) { fetch(url, constantService.getFetchOption()) .then(res => res.json()) .then(json => pluginService.launchNewWidget(json)) diff --git a/src/services/state/dataStore.store.ts b/src/services/state/dataStore.store.ts index 237e5cb36127f4f8f12c6f4f36b5b1c3e96adddf..a3896ddbf3982fb2659355ca255aef58e1869595 100644 --- a/src/services/state/dataStore.store.ts +++ b/src/services/state/dataStore.store.ts @@ -160,7 +160,7 @@ export interface IFile { name: string absolutePath: string byteSize: number - contentType: string, + contentType: string } export interface ViewerPreviewFile { diff --git a/src/services/state/ngViewerState.store.ts b/src/services/state/ngViewerState.store.ts index 4c5df81b315efe45b5cc3ba932ab0fe15dbb6ec0..bdcc9270c52793883424b57184b08484e4081846 100644 --- a/src/services/state/ngViewerState.store.ts +++ b/src/services/state/ngViewerState.store.ts @@ -99,13 +99,14 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: Stat // : {}) // }) } - case REMOVE_NG_LAYERS: + 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, @@ -131,12 +132,13 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: Stat ...prevState, forceShowSegment : action.forceShowSegment, } - case NEHUBA_READY: + case NEHUBA_READY: { const { nehubaReady } = action return { ...prevState, nehubaReady, } + } default: return prevState } } @@ -271,9 +273,7 @@ export class NgViewerUseEffect implements OnDestroy { const { payload } = action as ActionInterface const { index = 0 } = payload - const panelOrder = !!panelOrdersPrev - ? panelOrdersPrev - : [...panelOrders.slice(index), ...panelOrders.slice(0, index)].join('') + const panelOrder = panelOrdersPrev || [...panelOrders.slice(index), ...panelOrders.slice(0, index)].join('') return { type: ACTION_TYPES.SET_PANEL_ORDER, diff --git a/src/services/state/pluginState.store.ts b/src/services/state/pluginState.store.ts index ae851e5c669471b5ee6e9d2d972545695ed83c30..a9d11a6dc36a2fd5f86242b9a2e4984db350c4de 100644 --- a/src/services/state/pluginState.store.ts +++ b/src/services/state/pluginState.store.ts @@ -1,7 +1,7 @@ import { Action } from '@ngrx/store' export const defaultState: StateInterface = { - initManifests: [], + initManifests: [] } export interface StateInterface { @@ -10,8 +10,8 @@ export interface StateInterface { export interface ActionInterface extends Action { manifest: { - name: string, - initManifestUrl: string | null, + name: string + initManifestUrl?: string } } @@ -26,7 +26,7 @@ export const CONSTANTS = { export const getStateStore = ({ state = defaultState } = {}) => (prevState: StateInterface = state, action: ActionInterface): StateInterface => { switch (action.type) { - case ACTION_TYPES.SET_INIT_PLUGIN: + case ACTION_TYPES.SET_INIT_PLUGIN: { const newMap = new Map(prevState.initManifests ) // reserved source label for init manifest @@ -35,15 +35,16 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: Stat ...prevState, initManifests: Array.from(newMap), } - case ACTION_TYPES.CLEAR_INIT_PLUGIN: + } + 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 4668216887913724442444cd3282de7ecfcb2268..6f5c601fdfcb056828207774352c045a22ad4dae 100644 --- a/src/services/state/uiState.store.ts +++ b/src/services/state/uiState.store.ts @@ -1,11 +1,11 @@ -import {Injectable, TemplateRef} from '@angular/core'; -import {Action, select, Store} from '@ngrx/store' +import { Injectable, TemplateRef } from '@angular/core'; +import { Action, select, Store } from '@ngrx/store' -import {Effect} from "@ngrx/effects"; -import {Observable} from "rxjs"; -import {filter, map, mapTo, scan, startWith} from "rxjs/operators"; +import { Effect } from "@ngrx/effects"; +import { Observable } from "rxjs"; +import { filter, map, mapTo, scan, startWith } from "rxjs/operators"; import { COOKIE_VERSION, KG_TOS_VERSION, LOCAL_STORAGE_CONST } from 'src/util/constants' -import {GENERAL_ACTION_TYPES, IavRootStoreInterface} from '../stateStore.service' +import { IavRootStoreInterface } from '../stateStore.service' export const defaultState: StateInterface = { mouseOverSegments: [], @@ -32,30 +32,32 @@ export const defaultState: StateInterface = { export const getStateStore = ({ state = defaultState } = {}) => (prevState: StateInterface = state, action: ActionInterface) => { switch (action.type) { - case MOUSE_OVER_SEGMENTS: + case MOUSE_OVER_SEGMENTS: { const { segments } = action return { ...prevState, mouseOverSegments: segments, } - case MOUSE_OVER_SEGMENT: + } + case MOUSE_OVER_SEGMENT: return { ...prevState, mouseOverSegment : action.segment, } - case MOUSEOVER_USER_LANDMARK: + 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: + case SNACKBAR_MESSAGE: { const { snackbarMessage } = action /** * Need to use symbol here, or repeated snackbarMessage will not trigger new event @@ -64,6 +66,7 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: Stat ...prevState, snackbarMessage: Symbol(snackbarMessage), } + } case OPEN_SIDE_PANEL: return { ...prevState, @@ -102,7 +105,7 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: Stat ...prevState, sidePanelCurrentViewContent: 'Dataset', } - case AGREE_COOKIE: + case AGREE_COOKIE: { /** * TODO replace with server side logic */ @@ -111,7 +114,8 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: Stat ...prevState, agreedCookies: true, } - case AGREE_KG_TOS: + } + case AGREE_KG_TOS: { /** * TODO replace with server side logic */ @@ -120,14 +124,15 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: Stat ...prevState, agreedKgTos: true, } - case SHOW_BOTTOM_SHEET: - const { bottomSheetTemplate } = action - return { - ...prevState, - bottomSheetTemplate, - } - default: - return prevState + } + case SHOW_BOTTOM_SHEET: { + const { bottomSheetTemplate } = action + return { + ...prevState, + bottomSheetTemplate, + } + } + default: return prevState } } @@ -147,9 +152,9 @@ export function stateStore(state, action) { export interface StateInterface { mouseOverSegments: Array<{ layer: { - name: string, + name: string } - segment: any | null, + segment: any | null }> sidePanelIsOpen: boolean sidePanelCurrentViewContent: 'Connectivity' | 'Dataset' | null @@ -161,7 +166,7 @@ export interface StateInterface { focusedSidePanel: string | null - snackbarMessage: Symbol + snackbarMessage: symbol agreedCookies: boolean agreedKgTos: boolean @@ -175,10 +180,10 @@ export interface ActionInterface extends Action { focusedSidePanel?: string segments?: Array<{ layer: { - name: string, + name: string } - segment: any | null, - }>, + segment: any | null + }> snackbarMessage: string bottomSheetTemplate: TemplateRef<any> diff --git a/src/services/state/userConfigState.store.ts b/src/services/state/userConfigState.store.ts index fe2ddb16442f319280ebc075f3a0c8a83de29cb6..0e8495ebf583cdffa73393c2ee44d4505c4b2b3a 100644 --- a/src/services/state/userConfigState.store.ts +++ b/src/services/state/userConfigState.store.ts @@ -30,10 +30,10 @@ export interface RegionSelection { * for serialisation into local storage/database */ interface SimpleRegionSelection { - id: string, - name: string, - tName: string, - pName: string, + id: string + name: string + tName: string + pName: string rSelected: string[] } @@ -43,7 +43,7 @@ interface UserConfigAction extends Action { } export const defaultState: StateInterface = { - savedRegionsSelection: [], + savedRegionsSelection: [] } export const ACTION_TYPES = { @@ -57,17 +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: + case ACTION_TYPES.UPDATE_REGIONS_SELECTIONS: { const { config = {} } = action const { savedRegionsSelection } = config return { ...prevState, savedRegionsSelection, } - default: - return { - ...prevState, - } + } + default: return prevState } } diff --git a/src/services/state/viewerConfig.store.ts b/src/services/state/viewerConfig.store.ts index 425eaf25cc8c1a19e99b9ea66e94fb11cdf42ea8..6fec7738e86c325dfc2c95f14ad1d1365b011373 100644 --- a/src/services/state/viewerConfig.store.ts +++ b/src/services/state/viewerConfig.store.ts @@ -8,7 +8,7 @@ export interface StateInterface { } interface ViewerConfigurationAction extends Action { - config: Partial<StateInterface>, + config: Partial<StateInterface> payload: any } @@ -63,19 +63,20 @@ export const defaultState: StateInterface = { export const getStateStore = ({ state = defaultState } = {}) => (prevState: StateInterface = state, action: ViewerConfigurationAction) => { switch (action.type) { - case ACTION_TYPES.SET_MOBILE_UI: + 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: + case ACTION_TYPES.CHANGE_GPU_LIMIT: { const newGpuLimit = Math.min( CONFIG_CONSTANTS.gpuLimitMax, Math.max( @@ -86,6 +87,7 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: Stat ...prevState, gpuLimit: newGpuLimit, } + } default: return prevState } } diff --git a/src/services/state/viewerState.store.ts b/src/services/state/viewerState.store.ts index 45ece6088a477198bbd53ef67b559c2ecf5d94da..b206b193734f3b109e2d2960bfd8f4585f419861 100644 --- a/src/services/state/viewerState.store.ts +++ b/src/services/state/viewerState.store.ts @@ -69,7 +69,7 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: Part /** * TODO may be obsolete. test when nifti become available */ - case LOAD_DEDICATED_LAYER: + case LOAD_DEDICATED_LAYER: { const dedicatedView = prevState.dedicatedView ? prevState.dedicatedView.concat(action.dedicatedView) : [action.dedicatedView] @@ -77,6 +77,7 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: Part ...prevState, dedicatedView, } + } case UNLOAD_DEDICATED_LAYER: return { ...prevState, @@ -84,7 +85,8 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: Part ? prevState.dedicatedView.filter(dv => dv !== action.dedicatedView) : [], } - case NEWVIEWER: + case NEWVIEWER: { + const { selectParcellation: parcellation } = action // const parcellation = propagateNgId( selectParcellation ): parcellation const { regions, ...parcellationWORegions } = parcellation @@ -101,6 +103,7 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: Part navigation : {}, dedicatedView : null, } + } case FETCHED_TEMPLATE : { return { ...prevState, @@ -133,12 +136,13 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: Part }, } } - case SELECT_REGIONS: + case SELECT_REGIONS: { const { selectRegions } = action return { ...prevState, regionsSelected: selectRegions, } + } case DESELECT_LANDMARKS : { return { ...prevState, @@ -180,9 +184,10 @@ export const getStateStore = ({ state = defaultState } = {}) => (prevState: Part } } } - case GENERAL_ACTION_TYPES.APPLY_STATE: + case GENERAL_ACTION_TYPES.APPLY_STATE: { const { viewerState } = (action as any).state return viewerState + } case SET_CONNECTIVITY_REGION: return { ...prevState, @@ -286,7 +291,7 @@ export class ViewerStateUseEffect { landmarkMap.set(id, landmark) } } - const userLandmarks = Array.from(landmarkMap).map(([id, landmark]) => landmark) + const userLandmarks = Array.from(landmarkMap).map(([_id, landmark]) => landmark) return { type: USER_LANDMARKS, landmarks: userLandmarks, diff --git a/src/services/stateStore.service.ts b/src/services/stateStore.service.ts index c8a69fa0aa6bbe53051f37c64fa3b8b73c1117a3..1714bc8b92836c9467ae9e6b1c6880e3dc48194d 100644 --- a/src/services/stateStore.service.ts +++ b/src/services/stateStore.service.ts @@ -1,9 +1,7 @@ import { filter } from 'rxjs/operators'; -import { cvtSearchParamToState } from 'src/atlasViewer/atlasViewer.urlUtil'; import { defaultState as dataStoreDefaultState, - getStateStore as getDatasetStateStore, IActionInterface as DatasetAction, IStateInterface as DataStateInterface, stateStore as dataStore, @@ -11,40 +9,34 @@ import { import { ActionInterface as NgViewerActionInterface, defaultState as ngViewerDefaultState, - getStateStore as getNgViewerStateStore, StateInterface as NgViewerStateInterface, stateStore as ngViewerState, } from './state/ngViewerState.store' import { defaultState as pluginDefaultState, - getStateStore as pluginGetStateStore, StateInterface as PluginStateInterface, stateStore as pluginState, } from './state/pluginState.store' import { ActionInterface as UIActionInterface, defaultState as uiDefaultState, - getStateStore as getUiStateStore, StateInterface as UIStateInterface, stateStore as uiState, } from './state/uiState.store' import { ACTION_TYPES as USER_CONFIG_ACTION_TYPES, defaultState as userConfigDefaultState, - getStateStore as getuserConfigStateStore, StateInterface as UserConfigStateInterface, stateStore as userConfigState, } from './state/userConfigState.store' import { defaultState as viewerConfigDefaultState, - getStateStore as getViewerConfigStateStore, StateInterface as ViewerConfigStateInterface, stateStore as viewerConfigState, } from './state/viewerConfig.store' import { ActionInterface as ViewerActionInterface, defaultState as viewerDefaultState, - getStateStore as getViewerStateStore, StateInterface as ViewerStateInterface, stateStore as viewerState, } from './state/viewerState.store' @@ -75,22 +67,6 @@ export function safeFilter(key: string) { typeof state[key] !== 'undefined' && state[key] !== null) } -const inheritNgId = (region: any) => { - const {ngId = 'root', children = []} = region - return { - ngId, - ...region, - ...(children && children.map - ? { - children: children.map(c => inheritNgId({ - ngId, - ...c, - })), - } - : {}), - } -} - export function getNgIdLabelIndexFromRegion({ region }) { const { ngId, labelIndex } = region if (ngId && labelIndex) { return { ngId, labelIndex } } diff --git a/src/services/uiService.service.ts b/src/services/uiService.service.ts index 937b905793d7ea52d4ed32fac0a03ef51876bac5..9c65624f306538c566bb894f39589f8581542407 100644 --- a/src/services/uiService.service.ts +++ b/src/services/uiService.service.ts @@ -22,7 +22,7 @@ export class UIService { } toasthandler.hide = () => { - if (!!handle) { handle.dismiss() } + if (handle) { handle.dismiss() } handle = null } return toasthandler diff --git a/src/ui/config/config.component.ts b/src/ui/config/config.component.ts index dd8234c0b814c9a5b5a3ff8a587391d204ff7a35..d734ed7320c932a2afef6eea91b5dddcda784829 100644 --- a/src/ui/config/config.component.ts +++ b/src/ui/config/config.component.ts @@ -2,7 +2,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core' import { MatSliderChange, MatSlideToggleChange } from '@angular/material'; import { select, Store } from '@ngrx/store'; import { combineLatest, Observable, Subscription } from 'rxjs'; -import { debounceTime, distinctUntilChanged, map, startWith, tap } from 'rxjs/operators'; +import { debounceTime, distinctUntilChanged, map, startWith } from 'rxjs/operators'; import { AtlasViewerConstantsServices } from 'src/atlasViewer/atlasViewer.constantService.service'; import { NG_VIEWER_ACTION_TYPES, SUPPORTED_PANEL_MODES } from 'src/services/state/ngViewerState.store'; import { ACTION_TYPES as VIEWER_CONFIG_ACTION_TYPES, StateInterface as ViewerConfiguration } from 'src/services/state/viewerConfig.store' diff --git a/src/ui/connectivityBrowser/connectivityBrowser.component.ts b/src/ui/connectivityBrowser/connectivityBrowser.component.ts index 8db9fe893518abfd82172d6f7ec0fee1baf26459..9ad2ad5b74634287765c2b76e6b28f32e69f0a46 100644 --- a/src/ui/connectivityBrowser/connectivityBrowser.component.ts +++ b/src/ui/connectivityBrowser/connectivityBrowser.component.ts @@ -141,7 +141,6 @@ export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy { .map(r => r) if (areaAsRegion && areaAsRegion.length && areaAsRegion[0].ngId) { - // @ts-ignore colorMap.get(areaAsRegion[0].ngId).set(areaAsRegion[0].labelIndex, {red: area.color.r, green: area.color.g, blue: area.color.b}) } }) diff --git a/src/ui/databrowserModule/databrowser.module.ts b/src/ui/databrowserModule/databrowser.module.ts index 8ee5d1a2e4d839da88b34a075e69cbee31ff0954..ca573d51709bca4b6a550a9955ad3ac242baabf6 100644 --- a/src/ui/databrowserModule/databrowser.module.ts +++ b/src/ui/databrowserModule/databrowser.module.ts @@ -137,8 +137,8 @@ export class DatabrowserModule { if (chart.data.datasets) { chart.data.datasets = chart.data.datasets .map(dataset => { - if (dataset.label && /\_sd$/.test(dataset.label)) { - const originalDS = chart.data.datasets!.find(baseDS => typeof baseDS.label !== 'undefined' && (baseDS.label == dataset.label!.replace(/_sd$/, ''))) + if (dataset.label && /_sd$/.test(dataset.label)) { + const originalDS = chart.data.datasets.find(baseDS => typeof baseDS.label !== 'undefined' && (baseDS.label == dataset.label.replace(/_sd$/, ''))) if (originalDS) { return Object.assign({}, dataset, { data: (originalDS.data as number[]).map((datapoint, idx) => (Number(datapoint) + Number((dataset.data as number[])[idx]))), @@ -148,7 +148,7 @@ export class DatabrowserModule { return dataset } } else if (dataset.label) { - const sdDS = chart.data.datasets!.find(sdDS => typeof sdDS.label !== 'undefined' && (sdDS.label == dataset.label + '_sd')) + const sdDS = chart.data.datasets.find(sdDS => typeof sdDS.label !== 'undefined' && (sdDS.label == dataset.label + '_sd')) if (sdDS) { return Object.assign({}, dataset, { ...constantsService.chartBaseStyle, diff --git a/src/ui/databrowserModule/databrowser.service.ts b/src/ui/databrowserModule/databrowser.service.ts index 802ca6ac171c938865354af552e5836ceb18ef8c..264d3624966bc3447340143cb490ae83e7a27e42 100644 --- a/src/ui/databrowserModule/databrowser.service.ts +++ b/src/ui/databrowserModule/databrowser.service.ts @@ -53,7 +53,7 @@ export class DatabrowserService implements OnDestroy { public instantiatedWidgetUnits: WidgetUnit[] = [] public queryData: (arg: {regions: any[], template: any, parcellation: any}) => void = (arg) => { - const { dataBrowser, widgetUnit } = this.createDatabrowser(arg) + const { widgetUnit } = this.createDatabrowser(arg) this.instantiatedWidgetUnits.push(widgetUnit.instance) widgetUnit.onDestroy(() => { this.instantiatedWidgetUnits = this.instantiatedWidgetUnits.filter(db => db !== widgetUnit.instance) @@ -88,7 +88,7 @@ export class DatabrowserService implements OnDestroy { this.kgTos$ = this.http.get(`${this.constantService.backendUrl}datasets/tos`, { responseType: 'text', }).pipe( - catchError((err, obs) => { + catchError((err, _obs) => { this.log.warn(`fetching kgTos error`, err) return of(null) }), @@ -305,7 +305,7 @@ export class DatabrowserService implements OnDestroy { }) } - public dbComponentInit(db: DataBrowser) { + public dbComponentInit(_db: DataBrowser) { this.store.dispatch({ type: SHOW_KG_TOS, }) @@ -347,7 +347,7 @@ export function getModalityFromDE(dataentries: IDataEntry[]): CountedDataModalit export function getIdFromDataEntry(dataentry: IDataEntry) { const { id, fullId } = dataentry - const regex = /\/([a-zA-Z0-9\-]*?)$/.exec(fullId) + const regex = /\/([a-zA-Z0-9-]*?)$/.exec(fullId) return (regex && regex[1]) || id } diff --git a/src/ui/databrowserModule/databrowser/databrowser.component.ts b/src/ui/databrowserModule/databrowser/databrowser.component.ts index 772f07ec0ab6638b532dd399aa4c3bdbdd9d164f..0d0b3a3f2572df1b7d5b04738338c6dd00c3b390 100644 --- a/src/ui/databrowserModule/databrowser/databrowser.component.ts +++ b/src/ui/databrowserModule/databrowser/databrowser.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, TemplateRef, ViewChild } from "@angular/core"; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, ViewChild } from "@angular/core"; import { merge, Observable, Subscription } from "rxjs"; import { scan, shareReplay } from "rxjs/operators"; import { LoggingService } from "src/services/logging.service"; @@ -185,11 +185,11 @@ export class DataBrowser implements OnChanges, OnDestroy, OnInit { public filePreviewName: string public onShowPreviewDataset(payload: {datasetName: string, event: MouseEvent}) { - const { datasetName, event } = payload + const { datasetName } = payload this.filePreviewName = datasetName } - public resetFilters(event?: MouseEvent) { + public resetFilters(_event?: MouseEvent) { this.clearAll() } diff --git a/src/ui/databrowserModule/fileviewer/chart/chart.interface.ts b/src/ui/databrowserModule/fileviewer/chart/chart.interface.ts index 510f2a559f707595ed9b7c0b34638fd829dde285..9af31b70279ef4e6cee85c43f81a83d8983650fd 100644 --- a/src/ui/databrowserModule/fileviewer/chart/chart.interface.ts +++ b/src/ui/databrowserModule/fileviewer/chart/chart.interface.ts @@ -55,7 +55,7 @@ export interface Dataset { export interface LegendInterface { display?: boolean labels?: { - fontColor?: string, + fontColor?: string } } 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 a90751cb14a64c4e08961d8c663faf39e9d165b1..be48e8d321398b0d79e41659eef88b1e29e39486 100644 --- a/src/ui/databrowserModule/fileviewer/chart/line/line.chart.component.ts +++ b/src/ui/databrowserModule/fileviewer/chart/line/line.chart.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnChanges } from '@angular/core' import { applyOption, ChartColor, CommonChartInterface, DatasetInterface, LegendInterface, ScaleOptionInterface, TitleInterfacce } from '../chart.interface' -import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; +import { DomSanitizer } from '@angular/platform-browser'; import { ChartDataSets, ChartOptions, LinearTickOptions } from 'chart.js'; import { Color } from 'ng2-charts'; import { ChartBase } from '../chart.base'; @@ -169,7 +169,7 @@ export interface LineDatasetInputInterface { export interface LinearChartOptionInterface { scales?: { xAxes?: ScaleOptionInterface[] - yAxes?: ScaleOptionInterface[], + yAxes?: ScaleOptionInterface[] } legend?: LegendInterface title?: TitleInterfacce 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 3201db85b4644c36c9bc6a8afc737a517b6857ca..213d909eb9e0e95e433b371f182246cae30ebc3f 100644 --- a/src/ui/databrowserModule/fileviewer/chart/radar/radar.chart.component.ts +++ b/src/ui/databrowserModule/fileviewer/chart/radar/radar.chart.component.ts @@ -1,4 +1,4 @@ -import { Component, ElementRef, Input, OnChanges, OnDestroy, OnInit, ViewChild } from '@angular/core' +import { Component, Input, OnChanges, OnDestroy } from '@angular/core' import { DomSanitizer } from '@angular/platform-browser'; import { RadialChartOptions } from 'chart.js' diff --git a/src/ui/databrowserModule/fileviewer/dedicated/dedicated.component.ts b/src/ui/databrowserModule/fileviewer/dedicated/dedicated.component.ts index 6f917e3164ba3428f5dcc84032268b35d633df76..623c48aa3d5506387db09d2f676ba1018c60818e 100644 --- a/src/ui/databrowserModule/fileviewer/dedicated/dedicated.component.ts +++ b/src/ui/databrowserModule/fileviewer/dedicated/dedicated.component.ts @@ -1,6 +1,5 @@ import { Component, Input } from "@angular/core"; import { ViewerPreviewFile } from "src/services/state/dataStore.store"; -import { DatabrowserService } from "../../databrowser.service"; import { KgSingleDatasetService } from "../../kgSingleDatasetService.service"; @Component({ diff --git a/src/ui/databrowserModule/kgSingleDatasetService.service.ts b/src/ui/databrowserModule/kgSingleDatasetService.service.ts index 8c8a3998fda6ad3301403e0a10d6fd6daf187788..06c45708d49220725416492eb384ed32ca9a2b8b 100644 --- a/src/ui/databrowserModule/kgSingleDatasetService.service.ts +++ b/src/ui/databrowserModule/kgSingleDatasetService.service.ts @@ -35,7 +35,7 @@ export class KgSingleDatasetService implements OnDestroy { select('ngViewerState'), filter(v => !!v), ).subscribe(layersInterface => { - this.ngLayers = new Set(layersInterface.layers.map(l => l.source.replace(/^nifti\:\/\//, ''))) + this.ngLayers = new Set(layersInterface.layers.map(l => l.source.replace(/^nifti:\/\//, ''))) }), ) } @@ -87,7 +87,7 @@ export class KgSingleDatasetService implements OnDestroy { dataset, }) - const { position, name } = file + const { position } = file if (position) { this.snackBar.open(`Postion of interest found.`, 'Go there', { duration: 5000, diff --git a/src/ui/databrowserModule/singleDataset/singleDataset.base.ts b/src/ui/databrowserModule/singleDataset/singleDataset.base.ts index 9b07f874e454fb2fb98b5816beb8bdea8587670e..831330149fbedbfbec7392177623432b08429369 100644 --- a/src/ui/databrowserModule/singleDataset/singleDataset.base.ts +++ b/src/ui/databrowserModule/singleDataset/singleDataset.base.ts @@ -80,7 +80,7 @@ export class SingleDatasetBase implements OnInit { const { kgId, kgSchema, dataset } = this this.dlFromKgHref = this.singleDatasetService.getDownloadZipFromKgHref({ kgSchema, kgId }) if ( dataset ) { - const { name, description, kgReference, publications, files, preview, ...rest } = dataset + const { name, description, kgReference, publications, files, preview } = dataset this.name = name this.description = description this.kgReference = kgReference diff --git a/src/ui/databrowserModule/util/getKgSchemaIdFromFullId.pipe.ts b/src/ui/databrowserModule/util/getKgSchemaIdFromFullId.pipe.ts index 8872ee88f6a07ec4e06b5ebeaabf559445aca1b5..9c95af439bb65496d8d9cc5956b1839b8edf4fa9 100644 --- a/src/ui/databrowserModule/util/getKgSchemaIdFromFullId.pipe.ts +++ b/src/ui/databrowserModule/util/getKgSchemaIdFromFullId.pipe.ts @@ -7,7 +7,7 @@ import { Pipe, PipeTransform } from "@angular/core"; export class GetKgSchemaIdFromFullIdPipe implements PipeTransform { public transform(fullId: string): [string, string] { if (!fullId) { return [null, null] } - const match = /([\w\-\.]*\/[\w\-\.]*\/[\w\-\.]*\/[\w\-\.]*)\/([\w\-\.]*)$/.exec(fullId) + const match = /([\w\-.]*\/[\w\-.]*\/[\w\-.]*\/[\w\-.]*)\/([\w\-.]*)$/.exec(fullId) if (!match) { return [null, null] } return [match[1], match[2]] } diff --git a/src/ui/databrowserModule/util/pathToNestedChildren.pipe.ts b/src/ui/databrowserModule/util/pathToNestedChildren.pipe.ts index 5aec2dbee8ec9af49f8225760671357bbde7d26e..991d95d3690a76d28015d57efa4ece10e6070123 100644 --- a/src/ui/databrowserModule/util/pathToNestedChildren.pipe.ts +++ b/src/ui/databrowserModule/util/pathToNestedChildren.pipe.ts @@ -4,6 +4,8 @@ import { Pipe, PipeTransform } from "@angular/core"; * The pipe transforms a flat array to a nested array, based on the path property, following Unix file path rule */ +// TODO check what the hell prop should do + @Pipe({ name : 'pathToNestedChildren', }) diff --git a/src/ui/databrowserModule/util/resetCounterModality.pipe.ts b/src/ui/databrowserModule/util/resetCounterModality.pipe.ts index a44882f4ad3b09806c9ca05903698b8cf9faab4b..484c3aaaf5357ff9ec3eba57cee7b216d792d3e5 100644 --- a/src/ui/databrowserModule/util/resetCounterModality.pipe.ts +++ b/src/ui/databrowserModule/util/resetCounterModality.pipe.ts @@ -7,7 +7,7 @@ import { CountedDataModality } from "../databrowser.service"; export class ResetCounterModalityPipe implements PipeTransform { public transform(inc: CountedDataModality[]): CountedDataModality[] { - return inc.map(({ occurance, ...rest }) => { + return inc.map(({ occurance:_occurance, ...rest }) => { return { occurance: 0, ...rest, diff --git a/src/ui/layerbrowser/layerbrowser.component.ts b/src/ui/layerbrowser/layerbrowser.component.ts index 8002cfd69a8fe6b3c334be4b5b0a994ba7cc2dc0..a3bdfe67c7bd4c77cfb08d126555ddb2d5480875 100644 --- a/src/ui/layerbrowser/layerbrowser.component.ts +++ b/src/ui/layerbrowser/layerbrowser.component.ts @@ -1,7 +1,7 @@ import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, Pipe, PipeTransform } from "@angular/core"; import { select, Store } from "@ngrx/store"; import { combineLatest, Observable, Subscription } from "rxjs"; -import { debounceTime, distinctUntilChanged, filter, map, shareReplay, throttleTime } from "rxjs/operators"; +import { debounceTime, distinctUntilChanged, filter, map, shareReplay } from "rxjs/operators"; import { AtlasViewerConstantsServices } from "src/atlasViewer/atlasViewer.constantService.service"; import { LoggingService } from "src/services/logging.service"; import { NG_VIEWER_ACTION_TYPES } from "src/services/state/ngViewerState.store"; diff --git a/src/ui/logoContainer/logoContainer.component.ts b/src/ui/logoContainer/logoContainer.component.ts index 15b1607a15ad28181776107ee2c6fb69b84d0ab6..07d8281943dd0538f709952ca888378c412fdc49 100644 --- a/src/ui/logoContainer/logoContainer.component.ts +++ b/src/ui/logoContainer/logoContainer.component.ts @@ -1,4 +1,4 @@ -import { Component, HostBinding } from "@angular/core"; +import { Component } from "@angular/core"; @Component({ selector : 'logo-container', diff --git a/src/ui/nehubaContainer/mobileOverlay/mobileOverlay.component.ts b/src/ui/nehubaContainer/mobileOverlay/mobileOverlay.component.ts index 71405db1c4634b25112fa21df7d4b495ceb66cff..7d8c1de62bef47543e0a8029ee0d8a733f202f93 100644 --- a/src/ui/nehubaContainer/mobileOverlay/mobileOverlay.component.ts +++ b/src/ui/nehubaContainer/mobileOverlay/mobileOverlay.component.ts @@ -1,6 +1,6 @@ -import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, ViewChild } from "@angular/core"; +import { Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild } from "@angular/core"; import { combineLatest, concat, fromEvent, merge, Observable, of, Subject } from "rxjs"; -import { filter, map, scan, switchMap, take, takeUntil, tap } from "rxjs/operators"; +import { filter, map, scan, switchMap, takeUntil } from "rxjs/operators"; import { clamp } from "src/util/generator"; @Component({ diff --git a/src/ui/nehubaContainer/nehubaContainer.component.ts b/src/ui/nehubaContainer/nehubaContainer.component.ts index d8cfb72b3f6b3551cfb04ef079daba7effc9f02d..0db1bab47da2343d244613c86f64af361fb902f2 100644 --- a/src/ui/nehubaContainer/nehubaContainer.component.ts +++ b/src/ui/nehubaContainer/nehubaContainer.component.ts @@ -16,36 +16,6 @@ import { timedValues } from "../../util/generator"; import { computeDistance, NehubaViewerUnit } from "./nehubaViewer/nehubaViewer.component"; import { getFourPanel, getHorizontalOneThree, getSinglePanel, getVerticalOneThree } from "./util"; -const getProxyUrl = (ngUrl) => `nifti://${BACKEND_URL}preview/file?fileUrl=${encodeURIComponent(ngUrl.replace(/^nifti:\/\//, ''))}` -const getProxyOther = ({source}) => /AUTH_227176556f3c4bb38df9feea4b91200c/.test(source) -? { - transform: [ - [ - 1e6, - 0, - 0, - 0, - ], - [ - 0, - 1e6, - 0, - 0, - ], - [ - 0, - 0, - 1e6, - 0, - ], - [ - 0, - 0, - 0, - 1, - ], - ], -} : {} const isFirstRow = (cell: HTMLElement) => { const { parentElement: row } = cell const { parentElement: container } = row @@ -1126,7 +1096,7 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { moveToNavigationOri : (quat) => this.nehubaViewer.setNavigationState({ orientation : quat, }), - showSegment : (labelIndex) => { + showSegment : (_labelIndex) => { /** * TODO reenable with updated select_regions api */ @@ -1162,7 +1132,7 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { }, }) }, - hideSegment : (labelIndex) => { + hideSegment : (_labelIndex) => { /** * TODO reenable with updated select_regions api */ @@ -1195,7 +1165,7 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { }, segmentColourMap : new Map(), getLayersSegmentColourMap: () => this.nehubaViewer.multiNgIdColorMap, - applyColourMap : (map) => { + applyColourMap : (_map) => { throw new Error(`apply color map has been deprecated. use applyLayersColourMap instead`) }, applyLayersColourMap: (map) => { diff --git a/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts b/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts index 980bcbdd4d5d6b9faa699b8df0c5f4858fefd47c..464f4b7f296eca0fd8a07ca8959f20cc5e03a5b8 100644 --- a/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts +++ b/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts @@ -15,7 +15,7 @@ import 'third_party/export_nehuba/main.bundle.js' interface LayerLabelIndex { layer: { - name: string, + name: string } labelIndicies: number[] @@ -57,12 +57,12 @@ export class NehubaViewerUnit implements OnInit, OnDestroy { @Output() public debouncedViewerPositionChange: EventEmitter<any> = new EventEmitter() @Output() public mouseoverSegmentEmitter: EventEmitter<{ - segmentId: number | null, - segment: string | null, + segmentId: number | null + segment: string | null layer: { - name?: string, - url?: string, - }, + name?: string + url?: string + } }> = new EventEmitter() @Output() public mouseoverLandmarkEmitter: EventEmitter<number | null> = new EventEmitter() @Output() public mouseoverUserlandmarkEmitter: EventEmitter<number | null> = new EventEmitter() @@ -444,7 +444,8 @@ export class NehubaViewerUnit implements OnInit, OnDestroy { } } - this.onDestroyCb.push(() => LayerManager.prototype.invokeAction = (arg) => {}) + /* eslint-disable-next-line @typescript-eslint/no-empty-function */ + this.onDestroyCb.push(() => LayerManager.prototype.invokeAction = (_arg) => { /** in default neuroglancer, this function is invoked when selection occurs */ }) } private filterLayers(l: any, layerObj: any): boolean { @@ -576,7 +577,7 @@ export class NehubaViewerUnit implements OnInit, OnDestroy { }) } - public showSegs(array: number[] | string[]) { + public showSegs(array: (number|string)[]) { if (!this.nehubaViewer) { return } @@ -602,11 +603,6 @@ export class NehubaViewerUnit implements OnInit, OnDestroy { return newMap } - /** - * TODO - * AAAAAAARG TYPESCRIPT WHY YOU SO MAD - */ - // @ts-ignore const newMap: Map<string, number[]> = array.reduce(reduceFn, new Map()) /** @@ -723,7 +719,7 @@ export class NehubaViewerUnit implements OnInit, OnDestroy { this.hideAllSeg() } - this._s8$ = this.nehubaViewer.mouseOver.segment.subscribe(({segment: segmentId, layer, ...rest}) => { + this._s8$ = this.nehubaViewer.mouseOver.segment.subscribe(({segment: segmentId, layer }) => { const {name = 'unnamed'} = layer const map = this.multiNgIdsLabelIndexMap.get(name) @@ -815,7 +811,7 @@ export class NehubaViewerUnit implements OnInit, OnDestroy { const newlayer = this.nehubaViewer.ngviewer.layerManager.getLayerByName(id) if (newlayer) {newlayer.setVisible(true) } else { this.log.warn('could not find new layer', id) } - const regex = /^(\S.*?)\:\/\/(.*?)$/.exec(newlayer.sourceUrl) + const regex = /^(\S.*?):\/\/(.*?)$/.exec(newlayer.sourceUrl) if (!regex || !regex[2]) { this.log.error('could not parse baseUrl') diff --git a/src/ui/takeScreenshot/takeScreenshot.component.ts b/src/ui/takeScreenshot/takeScreenshot.component.ts index 7645ea1a25b7c93fe9afd12bafb4c335e1ccdf3a..553bbed918ddc6dcb65a82379a0dcbad0cf36469 100644 --- a/src/ui/takeScreenshot/takeScreenshot.component.ts +++ b/src/ui/takeScreenshot/takeScreenshot.component.ts @@ -1,23 +1,24 @@ import {DOCUMENT} from "@angular/common"; import { - ChangeDetectorRef, - Component, - ElementRef, - HostListener, - Inject, - OnInit, - Renderer2, - TemplateRef, - ViewChild, + ChangeDetectorRef, + Component, + ElementRef, + HostListener, + Inject, + OnInit, + Renderer2, + TemplateRef, + ViewChild, } from "@angular/core"; import {MatDialog, MatDialogRef} from "@angular/material/dialog"; import html2canvas from "html2canvas"; @Component({ - selector: 'take-screenshot', - templateUrl: './takeScreenshot.template.html', - styleUrls: ['./takeScreenshot.style.css'], + selector: 'take-screenshot', + templateUrl: './takeScreenshot.template.html', + styleUrls: ['./takeScreenshot.style.css'], }) + export class TakeScreenshotComponent implements OnInit { @ViewChild('screenshotPreviewCard', {read: ElementRef}) public screenshotPreviewCard: ElementRef @@ -64,203 +65,203 @@ export class TakeScreenshotComponent implements OnInit { ) {} public ngOnInit(): void { - this.windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth - this.windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight + this.windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth + this.windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight } @HostListener('window:resize', ['$event']) public onResize() { - this.windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth - this.windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight + this.windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth + this.windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight } @HostListener('window:keyup', ['$event']) public keyEvent(event: KeyboardEvent) { - if (this.takingScreenshot && event.key === 'Escape') { - this.cancelTakingScreenshot() - } + if (this.takingScreenshot && event.key === 'Escape') { + this.cancelTakingScreenshot() + } } public startScreenshot() { - this.previewingScreenshot = false - this.croppedCanvas = null - this.loadingScreenshot = false - this.takingScreenshot = true + this.previewingScreenshot = false + this.croppedCanvas = null + this.loadingScreenshot = false + this.takingScreenshot = true } public move(e: MouseEvent) { - if (this.mouseIsDown) { - this.isDragging = true + if (this.mouseIsDown) { + this.isDragging = true - this.endY = e.clientY - this.endX = e.clientX + this.endY = e.clientY + this.endX = e.clientX - if (this.endX >= this.startX && this.endY >= this.startY) { - // III quadrant - this.borderWidth = this.startY + 'px ' + if (this.endX >= this.startX && this.endY >= this.startY) { + // III quadrant + this.borderWidth = this.startY + 'px ' + (this.windowWidth - this.endX) + 'px ' + (this.windowHeight - this.endY) + 'px ' + this.startX + 'px' - this.boxTop = this.startY - this.boxLeft = this.startX - this.boxEndWidth = this.endX - this.startX - this.boxEndHeight = this.endY - this.startY + this.boxTop = this.startY + this.boxLeft = this.startX + this.boxEndWidth = this.endX - this.startX + this.boxEndHeight = this.endY - this.startY - this.screenshotStartX = this.startX - this.screenshotStartY = this.startY + this.screenshotStartX = this.startX + this.screenshotStartY = this.startY - } else if (this.endX <= this.startX && this.endY >= this.startY) { - // IV quadrant + } else if (this.endX <= this.startX && this.endY >= this.startY) { + // IV quadrant - this.borderWidth = this.startY + 'px ' + this.borderWidth = this.startY + 'px ' + (this.windowWidth - this.startX) + 'px ' + (this.windowHeight - this.endY) + 'px ' + this.endX + 'px' - this.boxLeft = this.endX - this.boxTop = this.startY - this.boxEndWidth = this.startX - this.endX - this.boxEndHeight = this.endY - this.startY + this.boxLeft = this.endX + this.boxTop = this.startY + this.boxEndWidth = this.startX - this.endX + this.boxEndHeight = this.endY - this.startY - this.screenshotStartX = this.endX - this.screenshotStartY = this.startY + this.screenshotStartX = this.endX + this.screenshotStartY = this.startY - } else if (this.endX >= this.startX && this.endY <= this.startY) { + } else if (this.endX >= this.startX && this.endY <= this.startY) { - // II quadrant + // II quadrant - this.borderWidth = this.endY + 'px ' + this.borderWidth = this.endY + 'px ' + (this.windowWidth - this.endX) + 'px ' + (this.windowHeight - this.startY) + 'px ' + this.startX + 'px' - this.boxLeft = this.startX - this.boxTop = this.endY - this.boxEndWidth = this.endX - this.startX - this.boxEndHeight = this.startY - this.endY + this.boxLeft = this.startX + this.boxTop = this.endY + this.boxEndWidth = this.endX - this.startX + this.boxEndHeight = this.startY - this.endY - this.screenshotStartX = this.startX - this.screenshotStartY = this.endY + this.screenshotStartX = this.startX + this.screenshotStartY = this.endY - } else if (this.endX <= this.startX && this.endY <= this.startY) { - // I quadrant + } else if (this.endX <= this.startX && this.endY <= this.startY) { + // I quadrant - this.boxLeft = this.endX - this.boxTop = this.endY - this.boxEndWidth = this.startX - this.endX - this.boxEndHeight = this.startY - this.endY + this.boxLeft = this.endX + this.boxTop = this.endY + this.boxEndWidth = this.startX - this.endX + this.boxEndHeight = this.startY - this.endY - this.borderWidth = this.endY + 'px ' + this.borderWidth = this.endY + 'px ' + (this.windowWidth - this.startX) + 'px ' + (this.windowHeight - this.startY) + 'px ' + this.endX + 'px' - this.screenshotStartX = this.endX - this.screenshotStartY = this.endY - - } else { - this.isDragging = false - } + this.screenshotStartX = this.endX + this.screenshotStartY = this.endY + } else { + this.isDragging = false } + + } } - public mouseDown(e: MouseEvent) { - this.borderWidth = this.windowWidth + 'px ' + this.windowHeight + 'px' + public mouseDown(event: MouseEvent) { + this.borderWidth = this.windowWidth + 'px ' + this.windowHeight + 'px' - this.startX = e.clientX - this.startY = e.clientY + this.startX = event.clientX + this.startY = event.clientY - this.mouseIsDown = true + this.mouseIsDown = true } - public mouseUp(e: MouseEvent) { - this.borderWidth = '0' + public mouseUp(_event: MouseEvent) { + this.borderWidth = '0' - this.isDragging = false - this.mouseIsDown = false + this.isDragging = false + this.mouseIsDown = false - this.takingScreenshot = false + this.takingScreenshot = false - if (this.boxEndWidth * window.devicePixelRatio <= 1 && this.boxEndHeight * window.devicePixelRatio <= 1) { - this.cancelTakingScreenshot() - } else { - this.loadScreenshot() - } + if (this.boxEndWidth * window.devicePixelRatio <= 1 && this.boxEndHeight * window.devicePixelRatio <= 1) { + this.cancelTakingScreenshot() + } else { + this.loadScreenshot() + } } public loadScreenshot() { - this.loadingScreenshot = true - this.dialogRef = this.matDialog.open(this.previewImageDialogTemplateRef, { - autoFocus: false, - }) - this.dialogRef.afterClosed().toPromise() - .then(result => { - switch (result) { - case 'again': { - this.startScreenshot() - this.cdr.markForCheck() - break - } - case 'cancel': { - this.cancelTakingScreenshot() - break - } - default: this.cancelTakingScreenshot() - } + this.loadingScreenshot = true + this.dialogRef = this.matDialog.open(this.previewImageDialogTemplateRef, { + autoFocus: false, + }) + this.dialogRef.afterClosed().toPromise() + .then(result => { + switch (result) { + case 'again': { + this.startScreenshot() + this.cdr.markForCheck() + break + } + case 'cancel': { + this.cancelTakingScreenshot() + break + } + default: this.cancelTakingScreenshot() + } }) - html2canvas(this.document.querySelector('#neuroglancer-container canvas')).then(canvas => { - this.croppedCanvas = null - this.croppedCanvas = this.renderer.createElement('canvas') + html2canvas(this.document.querySelector('#neuroglancer-container canvas')).then(canvas => { + this.croppedCanvas = null + this.croppedCanvas = this.renderer.createElement('canvas') - this.croppedCanvas.width = this.boxEndWidth * window.devicePixelRatio - this.croppedCanvas.height = this.boxEndHeight * window.devicePixelRatio + this.croppedCanvas.width = this.boxEndWidth * window.devicePixelRatio + this.croppedCanvas.height = this.boxEndHeight * window.devicePixelRatio - this.croppedCanvas.getContext('2d') - .drawImage(canvas, - this.screenshotStartX * window.devicePixelRatio, this.screenshotStartY * window.devicePixelRatio, - this.boxEndWidth * window.devicePixelRatio, this.boxEndHeight * window.devicePixelRatio, - 0, 0, - this.boxEndWidth * window.devicePixelRatio, this.boxEndHeight * window.devicePixelRatio) - }).then(() => { + this.croppedCanvas.getContext('2d') + .drawImage(canvas, + this.screenshotStartX * window.devicePixelRatio, this.screenshotStartY * window.devicePixelRatio, + this.boxEndWidth * window.devicePixelRatio, this.boxEndHeight * window.devicePixelRatio, + 0, 0, + this.boxEndWidth * window.devicePixelRatio, this.boxEndHeight * window.devicePixelRatio) + }).then(() => { - const d = new Date() - const n = `${d.getFullYear()}_${d.getMonth() + 1}_${d.getDate()}_${d.getHours()}_${d.getMinutes()}_${d.getSeconds()}` - this.screenshotName = `${n}_IAV.png` + const d = new Date() + const n = `${d.getFullYear()}_${d.getMonth() + 1}_${d.getDate()}_${d.getHours()}_${d.getMinutes()}_${d.getSeconds()}` + this.screenshotName = `${n}_IAV.png` - this.loadingScreenshot = false - this.imageUrl = this.croppedCanvas.toDataURL('image/png') - this.previewingScreenshot = true - this.clearStateAfterScreenshot() + this.loadingScreenshot = false + this.imageUrl = this.croppedCanvas.toDataURL('image/png') + this.previewingScreenshot = true + this.clearStateAfterScreenshot() - this.cdr.markForCheck() - }) + this.cdr.markForCheck() + }) } public cancelTakingScreenshot() { - this.takingScreenshot = false - this.previewingScreenshot = false - this.loadingScreenshot = false - this.croppedCanvas = null + this.takingScreenshot = false + this.previewingScreenshot = false + this.loadingScreenshot = false + this.croppedCanvas = null } public clearStateAfterScreenshot() { - this.mouseIsDown = false - this.isDragging = false - this.startX = 0 - this.startY = 0 - this.endX = 0 - this.endY = 0 - this.borderWidth = '' - this.boxTop = 0 - this.boxLeft = 0 - this.boxEndWidth = 0 - this.boxEndHeight = 0 - this.windowHeight = 0 - this.windowWidth = 0 - this.screenshotStartX = 0 - this.screenshotStartY = 0 + this.mouseIsDown = false + this.isDragging = false + this.startX = 0 + this.startY = 0 + this.endX = 0 + this.endY = 0 + this.borderWidth = '' + this.boxTop = 0 + this.boxLeft = 0 + this.boxEndWidth = 0 + this.boxEndHeight = 0 + this.windowHeight = 0 + this.windowWidth = 0 + this.screenshotStartX = 0 + this.screenshotStartY = 0 } } diff --git a/src/ui/templateParcellationCitations/templateParcellationCitations.component.ts b/src/ui/templateParcellationCitations/templateParcellationCitations.component.ts index 81278acc90203bada2057822f7cf957206084f54..3a04ab1b33c42badecdcf0dac78e32605ea145e2 100644 --- a/src/ui/templateParcellationCitations/templateParcellationCitations.component.ts +++ b/src/ui/templateParcellationCitations/templateParcellationCitations.component.ts @@ -2,7 +2,7 @@ import { Component } from "@angular/core"; import { select, Store } from "@ngrx/store"; import { Observable } from "rxjs"; import { map, switchMap } from "rxjs/operators"; -import { isDefined, safeFilter, ViewerStateInterface } from "../../services/stateStore.service"; +import { safeFilter, ViewerStateInterface } from "../../services/stateStore.service"; @Component({ selector : 'template-parcellation-citation-container', diff --git a/src/ui/ui.module.ts b/src/ui/ui.module.ts index 038ed5d6d37dd8541e6a57887e5d9e2ac97ac7e3..0411b1d707fadbebe8d4a5cd05d120d837890a14 100644 --- a/src/ui/ui.module.ts +++ b/src/ui/ui.module.ts @@ -7,7 +7,7 @@ import { NehubaContainer } from "./nehubaContainer/nehubaContainer.component"; import { NehubaViewerUnit } from "./nehubaContainer/nehubaViewer/nehubaViewer.component"; import { GetTemplateImageSrcPipe, ImgSrcSetPipe, SplashScreen } from "./nehubaContainer/splashScreen/splashScreen.component"; -import { filterRegionDataEntries } from "src/util/pipes/filterRegionDataEntries.pipe"; +import { FilterRegionDataEntries } from "src/util/pipes/filterRegionDataEntries.pipe"; import { GroupDatasetByRegion } from "src/util/pipes/groupDataEntriesByRegion.pipe"; import { GetUniquePipe } from "src/util/pipes/getUnique.pipe"; @@ -132,7 +132,7 @@ import { SimpleRegionComponent } from "./parcellationRegion/regionSimple/regionS /* pipes */ GroupDatasetByRegion, - filterRegionDataEntries, + FilterRegionDataEntries, GetUniquePipe, FlatmapArrayPipe, SafeStylePipe, diff --git a/src/ui/viewerStateController/regionHierachy/regionHierarchy.component.ts b/src/ui/viewerStateController/regionHierachy/regionHierarchy.component.ts index 6dcf1f69bce6d59bd2d75c35242c0d751c18da3c..9753904cc36be4cb4189c838d3db440d8f11499b 100644 --- a/src/ui/viewerStateController/regionHierachy/regionHierarchy.component.ts +++ b/src/ui/viewerStateController/regionHierachy/regionHierarchy.component.ts @@ -1,6 +1,6 @@ import { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, HostListener, Input, OnInit, Output, ViewChild } from "@angular/core"; -import { fromEvent, Subject, Subscription } from "rxjs"; -import { buffer, debounceTime, tap } from "rxjs/operators"; +import { fromEvent, Subject, Subscription } from "rxjs"; +import { buffer, debounceTime } from "rxjs/operators"; import { generateLabelIndexId } from "src/services/stateStore.service"; import { FilterNameBySearch } from "./filterNameBySearch.pipe"; diff --git a/src/ui/viewerStateController/regionSearch/regionSearch.component.ts b/src/ui/viewerStateController/regionSearch/regionSearch.component.ts index 2c452ad7940a14044f5a9ac8b789c1de17769f93..fc4f852a2a2afb50e09ded6ee50618383b300d7a 100644 --- a/src/ui/viewerStateController/regionSearch/regionSearch.component.ts +++ b/src/ui/viewerStateController/regionSearch/regionSearch.component.ts @@ -126,8 +126,7 @@ export class RegionTextSearchAutocomplete { }) } - public optionSelected(ev: MatAutocompleteSelectedEvent) { - const id = ev.option.value + public optionSelected(_ev: MatAutocompleteSelectedEvent) { this.autoTrigger.nativeElement.value = '' } @@ -150,7 +149,7 @@ export class RegionTextSearchAutocomplete { return this._focused } - public deselectAllRegions(event: MouseEvent) { + public deselectAllRegions(_event: MouseEvent) { this.store$.dispatch({ type: SELECT_REGIONS, selectRegions: [], @@ -170,7 +169,7 @@ export class RegionTextSearchAutocomplete { }) } - public showHierarchy(event: MouseEvent) { + public showHierarchy(_event: MouseEvent) { // mat-card-content has a max height of 65vh const dialog = this.dialog.open(this.regionHierarchyDialogTemplate, { height: '65vh', diff --git a/src/ui/viewerStateController/viewerState.base.ts b/src/ui/viewerStateController/viewerState.base.ts index 61cf9ea8706e89046a44516774d1b2479f452a26..583e11f01687316a3ea845bff2205c8c8e8c14c5 100644 --- a/src/ui/viewerStateController/viewerState.base.ts +++ b/src/ui/viewerStateController/viewerState.base.ts @@ -7,6 +7,16 @@ import { DialogService } from "src/services/dialogService.service"; import { RegionSelection } from "src/services/state/userConfigState.store"; import { IavRootStoreInterface, SELECT_REGIONS, USER_CONFIG_ACTION_TYPES } from "src/services/stateStore.service"; +const ACTION_TYPES = { + SINGLE_CLICK_ON_REGIONHIERARCHY: 'SINGLE_CLICK_ON_REGIONHIERARCHY', + DOUBLE_CLICK_ON_REGIONHIERARCHY: 'DOUBLE_CLICK_ON_REGIONHIERARCHY', + SELECT_TEMPLATE_WITH_NAME: 'SELECT_TEMPLATE_WITH_NAME', + SELECT_PARCELLATION_WITH_NAME: 'SELECT_PARCELLATION_WITH_NAME', + + TOGGLE_REGION_SELECT: 'TOGGLE_REGION_SELECT', + NAVIGATETO_REGION: 'NAVIGATETO_REGION', +} + const compareWith = (o, n) => !o || !n ? false : o.name === n.name @@ -28,8 +38,6 @@ export class ViewerStateBase implements OnInit { public savedRegionsSelections$: Observable<any[]> - private dismissToastHandler: () => void - public compareWith = compareWith private savedRegionBottomSheetRef: MatBottomSheetRef @@ -155,7 +163,7 @@ export class ViewerStateBase implements OnInit { return `<div class="d-flex"><small>Template</small> <small class = "flex-grow-1 mute-text">${template ? '(' + template.name + ')' : ''}</small> <span class = "fas fa-caret-down"></span></div>` } - public loadSelection(event: MouseEvent) { + public loadSelection(_event: MouseEvent) { this.focused = true this.savedRegionBottomSheetRef = this.bottomSheet.open(this.savedRegionBottomSheetTemplate) @@ -166,7 +174,7 @@ export class ViewerStateBase implements OnInit { }) } - public saveSelection(event: MouseEvent) { + public saveSelection(_event: MouseEvent) { this.focused = true this.dialogService.getUserInput({ defaultValue: `Saved Region`, @@ -183,13 +191,13 @@ export class ViewerStateBase implements OnInit { }) .catch(e => { /** - * USER CANCELLED, HANDLE + * TODO USER CANCELLED, HANDLE */ }) .finally(() => this.focused = false) } - public deselectAllRegions(event: MouseEvent) { + public deselectAllRegions(_event: MouseEvent) { this.store$.dispatch({ type: SELECT_REGIONS, selectRegions: [], @@ -198,14 +206,4 @@ export class ViewerStateBase implements OnInit { } -const ACTION_TYPES = { - SINGLE_CLICK_ON_REGIONHIERARCHY: 'SINGLE_CLICK_ON_REGIONHIERARCHY', - DOUBLE_CLICK_ON_REGIONHIERARCHY: 'DOUBLE_CLICK_ON_REGIONHIERARCHY', - SELECT_TEMPLATE_WITH_NAME: 'SELECT_TEMPLATE_WITH_NAME', - SELECT_PARCELLATION_WITH_NAME: 'SELECT_PARCELLATION_WITH_NAME', - - TOGGLE_REGION_SELECT: 'TOGGLE_REGION_SELECT', - NAVIGATETO_REGION: 'NAVIGATETO_REGION', -} - export const VIEWERSTATE_CONTROLLER_ACTION_TYPES = ACTION_TYPES diff --git a/src/ui/viewerStateController/viewerState.pipes.ts b/src/ui/viewerStateController/viewerState.pipes.ts index 331878e551baaa54856911c59876149dddb88d54..400ed875be821b17776f5623d11a3e7ebbed2159 100644 --- a/src/ui/viewerStateController/viewerState.pipes.ts +++ b/src/ui/viewerStateController/viewerState.pipes.ts @@ -14,7 +14,7 @@ export class BinSavedRegionsSelectionPipe implements PipeTransform { if (existing) { existing.push(regionSelection) } else { returnMap.set(key, [regionSelection]) } } return Array.from(returnMap) - .map(([_, regionSelections]) => { + .map(([_unused, regionSelections]) => { const {parcellationSelected = null, templateSelected = null} = regionSelections[0] || {} return { regionSelections, diff --git a/src/ui/viewerStateController/viewerState.useEffect.ts b/src/ui/viewerStateController/viewerState.useEffect.ts index 7b734139ab2bc28b01e12c240c9016f12b5d4be1..9087cc2bfb642cdb94b3cd33864a1345c038894d 100644 --- a/src/ui/viewerStateController/viewerState.useEffect.ts +++ b/src/ui/viewerStateController/viewerState.useEffect.ts @@ -84,7 +84,7 @@ export class ViewerStateControllerUseEffect implements OnInit, OnDestroy { if (parcellationSelected && parcellationSelected.name === name) { return false } return true }), - map(([name, _]) => name), + map(([name]) => name), withLatestFrom(viewerState$.pipe( select('templateSelected'), )), @@ -122,7 +122,7 @@ export class ViewerStateControllerUseEffect implements OnInit, OnDestroy { if (templateSelected && templateSelected.name === name) { return false } return true }), - map(([name, templateSelected]) => name), + map(([name]) => name), withLatestFrom(viewerState$.pipe( select('fetchedTemplates'), )), diff --git a/src/ui/viewerStateController/viewerStateCFull/viewerState.component.ts b/src/ui/viewerStateController/viewerStateCFull/viewerState.component.ts index 71bb0e8df64effe20ada23ac1e6c23b7b4e13393..b1200c808523a2fc75b667016bca27465c97e3dd 100644 --- a/src/ui/viewerStateController/viewerStateCFull/viewerState.component.ts +++ b/src/ui/viewerStateController/viewerStateCFull/viewerState.component.ts @@ -6,10 +6,6 @@ import { DialogService } from "src/services/dialogService.service"; import { IavRootStoreInterface } from "src/services/stateStore.service"; import { ViewerStateBase } from '../viewerState.base' -const compareWith = (o, n) => !o || !n - ? false - : o.name === n.name - @Component({ selector: 'viewer-state-controller', templateUrl: './viewerState.template.html', diff --git a/src/util/directives/FixedMouseContextualContainerDirective.directive.ts b/src/util/directives/FixedMouseContextualContainerDirective.directive.ts index d599da891736a16ab8ae78e56cf9a570d61089aa..92e93b952e0b07251390d628ccda01e7b789ec76 100644 --- a/src/util/directives/FixedMouseContextualContainerDirective.directive.ts +++ b/src/util/directives/FixedMouseContextualContainerDirective.directive.ts @@ -1,4 +1,4 @@ -import { Directive, ElementRef, EventEmitter, HostBinding, HostListener, Input, OnChanges, Output } from "@angular/core"; +import { Directive, ElementRef, EventEmitter, HostBinding, Input, Output } from "@angular/core"; @Directive({ selector: '[fixedMouseContextualContainerDirective]', diff --git a/src/util/directives/dragDrop.directive.ts b/src/util/directives/dragDrop.directive.ts index d1a08f762edeb01e7a2c084323617ce7ed5e65a6..f8f82509fef2e88d23bed73241fed5a8f255c7b0 100644 --- a/src/util/directives/dragDrop.directive.ts +++ b/src/util/directives/dragDrop.directive.ts @@ -1,7 +1,7 @@ import { Directive, ElementRef, EventEmitter, HostBinding, HostListener, Input, OnDestroy, OnInit, Output } from "@angular/core"; import { MatSnackBar, MatSnackBarRef, SimpleSnackBar } from "@angular/material"; -import { from, fromEvent, merge, Observable, of, Subscription } from "rxjs"; -import { debounceTime, distinctUntilChanged, map, scan, switchMap, takeUntil, tap } from "rxjs/operators"; +import { fromEvent, merge, Observable, of, Subscription } from "rxjs"; +import { debounceTime, map, scan, switchMap } from "rxjs/operators"; @Directive({ selector: '[drag-drop]', diff --git a/src/util/directives/pluginFactory.directive.ts b/src/util/directives/pluginFactory.directive.ts index 976d1bb52de69d77041a24fa12aa93fe3249a5aa..eb40319fb85ad6028ddfa681540ff07b4813efef 100644 --- a/src/util/directives/pluginFactory.directive.ts +++ b/src/util/directives/pluginFactory.directive.ts @@ -58,7 +58,7 @@ export class PluginFactoryDirective { libraries .filter((stringname) => SUPPORT_LIBRARY_MAP.get(stringname) !== null) .forEach(libname => { - const ledger = apiService.loadedLibraries.get(libname!) + const ledger = apiService.loadedLibraries.get(libname) if (!ledger) { this.log.warn('unload external libraries error. cannot find ledger entry...', libname, apiService.loadedLibraries) return @@ -70,9 +70,9 @@ export class PluginFactoryDirective { if (ledger.counter - 1 == 0) { rd2.removeChild(document.head, ledger.src) - apiService.loadedLibraries.delete(libname!) + apiService.loadedLibraries.delete(libname) } else { - apiService.loadedLibraries.set(libname!, { counter: ledger.counter - 1, src: ledger.src }) + apiService.loadedLibraries.set(libname, { counter: ledger.counter - 1, src: ledger.src }) } }) } diff --git a/src/util/pipes/doiPipe.pipe.ts b/src/util/pipes/doiPipe.pipe.ts index 686e914e2984d83532518953dadc603079338d5d..cb2041388d9f8b559eb11bb42fe70db3692f8e8d 100644 --- a/src/util/pipes/doiPipe.pipe.ts +++ b/src/util/pipes/doiPipe.pipe.ts @@ -6,7 +6,7 @@ import { Pipe, PipeTransform } from "@angular/core"; export class DoiParserPipe implements PipeTransform { public transform(s: string, prefix: string = 'https://doi.org/') { - const hasProtocol = /^https?\:\/\//.test(s) + const hasProtocol = /^https?:\/\//.test(s) return `${hasProtocol ? '' : prefix}${s}` } } diff --git a/src/util/pipes/filterRegionDataEntries.pipe.ts b/src/util/pipes/filterRegionDataEntries.pipe.ts index 3feb53a0da9a53b16dca731cbd43e42c1eabb912..204c3343d31ec5cfd30848ac6bf022894ea2729b 100644 --- a/src/util/pipes/filterRegionDataEntries.pipe.ts +++ b/src/util/pipes/filterRegionDataEntries.pipe.ts @@ -5,7 +5,7 @@ import { IDataEntry } from "../../services/stateStore.service"; name : 'filterRegionDataEntries', }) -export class filterRegionDataEntries implements PipeTransform { +export class FilterRegionDataEntries implements PipeTransform { public transform(arr: Array<{region: any|null, searchResults: IDataEntry[]}>, selectedRegions: any[]): Array<{region: any|null, searchResults: IDataEntry[]}> { return selectedRegions.length > 0 ? arr.filter(obj => obj.region !== null && selectedRegions.findIndex(r => obj.region.name === r.name) >= 0) : diff --git a/src/util/pipes/humanReadableFileSize.pipe.ts b/src/util/pipes/humanReadableFileSize.pipe.ts index 2a1e6f25966afc9fc2a7eadbadf12109bcdc69e6..7c4fb07dcf515442087829f149ccba5b5d7bee79 100644 --- a/src/util/pipes/humanReadableFileSize.pipe.ts +++ b/src/util/pipes/humanReadableFileSize.pipe.ts @@ -13,11 +13,11 @@ export const steps = [ }) export class HumanReadableFileSizePipe implements PipeTransform { - public transform(input: string | Number, precision: number = 2) { + public transform(input: string | number, precision: number = 2) { let _input = Number(input) if (!_input) { throw new Error(`HumanReadableFileSizePipe needs a string or a number that can be parsed to number`) } const _precision = Number(precision) - if (_precision === NaN) { throw new Error(`precision must be a number`) } + if (!isNaN(_precision)) { throw new Error(`precision must be a number`) } let counter = 0 while (_input > 1000 && counter < 4) { _input = _input / 1000 diff --git a/src/util/pipes/kgSearchBtnColor.pipe.ts b/src/util/pipes/kgSearchBtnColor.pipe.ts index e7d3bb25ffdd2eb0ddd7fa8f74f2a5a5185b8b00..c5e31baed32d1887bb16e29e13bdd48b1e6667f0 100644 --- a/src/util/pipes/kgSearchBtnColor.pipe.ts +++ b/src/util/pipes/kgSearchBtnColor.pipe.ts @@ -6,7 +6,7 @@ import { WidgetUnit } from "src/atlasViewer/widgetUnit/widgetUnit.component"; }) export class KgSearchBtnColorPipe implements PipeTransform { - public transform([minimisedWidgetUnit, themedBtnCls]: [Set<WidgetUnit>, string], wu: WidgetUnit ) { + public transform([minimisedWidgetUnit]: [Set<WidgetUnit>, string], wu: WidgetUnit ) { return minimisedWidgetUnit.has(wu) ? 'primary' : 'accent' diff --git a/src/util/pipes/pluginBtnFabColor.pipe.ts b/src/util/pipes/pluginBtnFabColor.pipe.ts index 71e9b45ad57934df56b13c96544571f16a21fda4..eb4d28a82683529a6e879840e8d5bef49c2ebf04 100644 --- a/src/util/pipes/pluginBtnFabColor.pipe.ts +++ b/src/util/pipes/pluginBtnFabColor.pipe.ts @@ -5,7 +5,7 @@ import { Pipe, PipeTransform } from "@angular/core"; }) export class PluginBtnFabColorPipe implements PipeTransform { - public transform([launchedSet, minimisedSet, themedBtnCls], pluginName) { + public transform([launchedSet, minimisedSet], pluginName) { return minimisedSet.has(pluginName) ? 'primary' : launchedSet.has(pluginName) diff --git a/src/util/pipes/safeHtml.pipe.ts b/src/util/pipes/safeHtml.pipe.ts index f0a074c8a685c965beb7c1babb3c3a5f41f27242..73b69a7afbf648cfef4e1d2442e93095e3e00e92 100644 --- a/src/util/pipes/safeHtml.pipe.ts +++ b/src/util/pipes/safeHtml.pipe.ts @@ -1,15 +1,10 @@ import { Pipe, PipeTransform } from '@angular/core'; -import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; @Pipe({ name : 'safeHtml', }) export class SafeHtmlPipe implements PipeTransform { - constructor() { - - } - public transform(html: string): string { return html // return this.ds.bypassSecurityTrustHtml(html) diff --git a/src/util/pipes/treeSearch.pipe.spec.ts b/src/util/pipes/treeSearch.pipe.spec.ts index 1c91e0ae8a37b35fafbed8688331d725478d292d..18056277559c98ff54eff92ddc298e0528b95b54 100644 --- a/src/util/pipes/treeSearch.pipe.spec.ts +++ b/src/util/pipes/treeSearch.pipe.spec.ts @@ -1,3 +1,5 @@ +/* eslint-disable */ + import { TreeSearchPipe } from './treeSearch.pipe' describe('TreeSearchPipe works as intended', () => { diff --git a/src/util/pluginHandlerClasses/modalHandler.ts b/src/util/pluginHandlerClasses/modalHandler.ts index 97e0b652c8d0659cde9610dc7391e98dcf0df04d..2afa36774891ced56a784d685f02dd159570ec58 100644 --- a/src/util/pluginHandlerClasses/modalHandler.ts +++ b/src/util/pluginHandlerClasses/modalHandler.ts @@ -10,5 +10,5 @@ export class ModalHandler { public body: string public footer: string - public dismissable: boolean = true + public dismissable = true } diff --git a/src/util/pluginHandlerClasses/toastHandler.ts b/src/util/pluginHandlerClasses/toastHandler.ts index 0f81cfcfc0a014e61160baadb6a5161a1d54c451..9bba88be2bd00bc936ba0da7609054ddc5ea769d 100644 --- a/src/util/pluginHandlerClasses/toastHandler.ts +++ b/src/util/pluginHandlerClasses/toastHandler.ts @@ -1,7 +1,7 @@ export class ToastHandler { - public message: string = 'Toast message' - public timeout: number = 3000 - public dismissable: boolean = true + public message = 'Toast message' + public timeout = 3000 + public dismissable = true public show: () => void public hide: () => void public htmlMessage: string