From 50d6ee5954eb9e35114fba4363165aa8ed2315fd Mon Sep 17 00:00:00 2001 From: Xiao Gui <xgui3783@gmail.com> Date: Fri, 1 Apr 2022 14:13:09 +0200 Subject: [PATCH] fix lint fix annotation layer --- .../annotations/annotation.service.ts | 19 +++++++---- .../sapi/core/sapiParcellation.ts | 5 ++- .../region/rich/region.rich.component.ts | 7 ++-- .../regionsHierarchy.component.ts | 3 +- .../features/voi/voiQuery.directive.ts | 33 +++++++++++++++---- .../flatHierarchy/treeView/treeControl.ts | 2 +- .../treeView/treeView.component.ts | 2 +- .../currentLayout/currentLayout.component.ts | 2 -- .../routeStateTransform.service.ts | 4 +-- src/routerModule/router.service.ts | 2 +- src/state/atlasSelection/effects.ts | 4 +-- .../layerCtrl.service/layerCtrl.effects.ts | 8 ++--- .../nehuba.layoutOverlay.component.ts | 4 +-- .../nehubaViewer/nehubaViewer.component.ts | 7 ++-- .../nehubaViewerInterface.directive.ts | 13 -------- .../threeSurferGlue/threeSurfer.component.ts | 2 +- 16 files changed, 65 insertions(+), 52 deletions(-) diff --git a/src/atlasComponents/annotations/annotation.service.ts b/src/atlasComponents/annotations/annotation.service.ts index bf9d18fd9..1f7c8496e 100644 --- a/src/atlasComponents/annotations/annotation.service.ts +++ b/src/atlasComponents/annotations/annotation.service.ts @@ -35,7 +35,7 @@ export type TNgAnnotationPoint = { export type AnnotationSpec = TNgAnnotationLine | TNgAnnotationPoint | TNgAnnotationAABBox type _AnnotationSpec = Omit<AnnotationSpec, 'type'> & { type: number } -type AnnotationRef = {} +type AnnotationRef = Record<string, unknown> interface NgAnnotationLayer { layer: { @@ -95,11 +95,11 @@ export class AnnotationLayer { const payload = mouseState.active && !!mouseState.pickedAnnotationId && this.idset.has(mouseState.pickedAnnotationId) - ? { - id: mouseState.pickedAnnotationId, - offset: mouseState.pickedOffset - } - : null + ? { + id: mouseState.pickedAnnotationId, + offset: mouseState.pickedOffset + } + : null this._onHover.next(payload) }) this.onDestroyCb.push(res) @@ -109,7 +109,7 @@ export class AnnotationLayer { }) } setVisible(flag: boolean){ - this.nglayer.setVisible(flag) + this.nglayer && this.nglayer.setVisible(flag) } dispose() { this.nglayer = null @@ -118,12 +118,16 @@ export class AnnotationLayer { while(this.onDestroyCb.length > 0) this.onDestroyCb.pop()() try { this.viewer.layerManager.removeManagedLayer(this.nglayer) + // eslint-disable-next-line no-empty } catch (e) { } } addAnnotation(spec: AnnotationSpec){ + if (!this.nglayer) { + throw new Error(`layer has already been disposed`) + } const localAnnotations = this.nglayer.layer.localAnnotations this.idset.add(spec.id) const annSpec = this.parseNgSpecType(spec) @@ -132,6 +136,7 @@ export class AnnotationLayer { ) } removeAnnotation(spec: { id: string }) { + if (!this.nglayer) return const { localAnnotations } = this.nglayer.layer this.idset.delete(spec.id) const ref = localAnnotations.references.get(spec.id) diff --git a/src/atlasComponents/sapi/core/sapiParcellation.ts b/src/atlasComponents/sapi/core/sapiParcellation.ts index 5f9566209..bf4dd238d 100644 --- a/src/atlasComponents/sapi/core/sapiParcellation.ts +++ b/src/atlasComponents/sapi/core/sapiParcellation.ts @@ -3,7 +3,10 @@ import { SapiVolumeModel } from ".." import { SAPI } from "../sapi.service" import { SapiParcellationFeatureModel, SapiParcellationModel, SapiQueryParam, SapiRegionModel } from "../type" -type PaginationQuery = {} +type PaginationQuery = { + perPage: number + page: number +} export class SAPIParcellation{ constructor(private sapi: SAPI, public atlasId: string, public id: string){ diff --git a/src/atlasComponents/sapiViews/core/region/region/rich/region.rich.component.ts b/src/atlasComponents/sapiViews/core/region/region/rich/region.rich.component.ts index cf2e067d1..9cd06260d 100644 --- a/src/atlasComponents/sapiViews/core/region/region/rich/region.rich.component.ts +++ b/src/atlasComponents/sapiViews/core/region/region/rich/region.rich.component.ts @@ -1,6 +1,5 @@ -import { Component, EventEmitter, Inject, OnDestroy, Output } from "@angular/core"; -import { Observable, Subject, Subscription } from "rxjs"; -import { filter } from "rxjs/operators" +import { Component, EventEmitter, Inject, Output } from "@angular/core"; +import { Observable, Subject } from "rxjs"; import { DARKTHEME } from "src/util/injectionTokens"; import { SapiViewsCoreRegionRegionBase } from "../region.base.directive"; import { ARIA_LABELS, CONST } from 'common/constants' @@ -35,10 +34,12 @@ export class SapiViewsCoreRegionRegionRich extends SapiViewsCoreRegionRegionBase this.featureClicked.emit(feat) } + // eslint-disable-next-line @typescript-eslint/no-empty-function handleExpansionPanelClosedEv(title: string){ } + // eslint-disable-next-line @typescript-eslint/no-empty-function handleExpansionPanelAfterExpandEv(title: string) { } diff --git a/src/atlasComponents/sapiViews/core/rich/regionsHierarchy/regionsHierarchy.component.ts b/src/atlasComponents/sapiViews/core/rich/regionsHierarchy/regionsHierarchy.component.ts index fa7fc0cd6..e47751ef4 100644 --- a/src/atlasComponents/sapiViews/core/rich/regionsHierarchy/regionsHierarchy.component.ts +++ b/src/atlasComponents/sapiViews/core/rich/regionsHierarchy/regionsHierarchy.component.ts @@ -43,10 +43,11 @@ export class SapiViewsCoreRichRegionsHierarchy { placeholderText: string = 'Search all regions' passedRegions: SapiRegionModel[] = [] + + private _regions: SapiRegionModel[] = [] get regions(){ return this._regions } - private _regions: SapiRegionModel[] = [] @Input('sxplr-sapiviews-core-rich-regionshierarchy-regions') set regions(val: SapiRegionModel[]){ this._regions = val diff --git a/src/atlasComponents/sapiViews/features/voi/voiQuery.directive.ts b/src/atlasComponents/sapiViews/features/voi/voiQuery.directive.ts index 21f0225f9..e70d1ab45 100644 --- a/src/atlasComponents/sapiViews/features/voi/voiQuery.directive.ts +++ b/src/atlasComponents/sapiViews/features/voi/voiQuery.directive.ts @@ -1,6 +1,6 @@ -import { Directive, EventEmitter, Inject, Input, OnChanges, OnDestroy, Optional, Output } from "@angular/core"; -import { merge, Observable, of, Subject, Subscription } from "rxjs"; -import { debounceTime, pairwise, shareReplay, startWith, switchMap, tap } from "rxjs/operators"; +import { Directive, EventEmitter, Inject, Input, OnChanges, OnDestroy, Optional, Output, SimpleChanges } from "@angular/core"; +import { interval, merge, Observable, of, Subject, Subscription } from "rxjs"; +import { debounce, debounceTime, filter, pairwise, shareReplay, startWith, switchMap, take, tap } from "rxjs/operators"; import { AnnotationLayer, TNgAnnotationPoint, TNgAnnotationAABBox } from "src/atlasComponents/annotations"; import { SAPI } from "src/atlasComponents/sapi/sapi.service"; import { BoundingBoxConcept, SapiAtlasModel, SapiSpaceModel, SapiVOIDataResponse, OpenMINDSCoordinatePoint } from "src/atlasComponents/sapi/type"; @@ -64,7 +64,10 @@ export class SapiViewsFeaturesVoiQuery implements OnChanges, OnDestroy{ private hoveredFeat: SapiVOIDataResponse private onDestroyCb: (() => void)[] = [] private subscription: Subscription[] = [] - ngOnChanges(): void { + ngOnChanges(simpleChanges: SimpleChanges): void { + if (simpleChanges.space) { + this.voiBBoxSvc = null + } const { atlas, space, @@ -75,15 +78,17 @@ export class SapiViewsFeaturesVoiQuery implements OnChanges, OnDestroy{ ngOnDestroy(): void { if (this.voiBBoxSvc) this.voiBBoxSvc.dispose() while (this.subscription.length > 0) this.subscription.pop().unsubscribe() + while (this.voiSubs.length > 0) this.voiSubs.pop().unsubscribe() while(this.onDestroyCb.length > 0) this.onDestroyCb.pop()() } - handleOnHoverFeature(id: string){ + handleOnHoverFeature({ id }: { id?: string }){ const ann = this.annotationIdToFeature.get(id) this.hoveredFeat = ann this.onhover.emit(ann) } + private voiSubs: Subscription[] = [] private _voiBBoxSvc: AnnotationLayer get voiBBoxSvc(): AnnotationLayer { if (this._voiBBoxSvc) return this._voiBBoxSvc @@ -93,14 +98,22 @@ export class SapiViewsFeaturesVoiQuery implements OnChanges, OnDestroy{ SapiViewsFeaturesVoiQuery.VOI_ANNOTATION_COLOR ) this._voiBBoxSvc = layer - this.subscription.push( - layer.onHover.subscribe(val => this.handleOnHoverFeature(val?.id)) + this.voiSubs.push( + layer.onHover.subscribe(val => this.handleOnHoverFeature(val || {})) ) return layer } catch (e) { return null } } + set voiBBoxSvc(val) { + if (!!val) { + throw new Error(`cannot set voiBBoxSvc directly`) + } + while (this.voiSubs.length > 0) this.voiSubs.pop().unsubscribe() + this._voiBBoxSvc && this._voiBBoxSvc.dispose() + this._voiBBoxSvc = null + } constructor( private sapi: SAPI, @@ -117,6 +130,12 @@ export class SapiViewsFeaturesVoiQuery implements OnChanges, OnDestroy{ clickInterceptor.register(handle) this.subscription.push( this.features$.pipe( + debounce(() => + interval(16).pipe( + filter(() => !!this.voiBBoxSvc), + take(1), + ) + ), startWith([] as SapiVOIDataResponse[]), pairwise() ).subscribe(([ prev, curr ]) => { diff --git a/src/components/flatHierarchy/treeView/treeControl.ts b/src/components/flatHierarchy/treeView/treeControl.ts index e664e5984..7471dfbb8 100644 --- a/src/components/flatHierarchy/treeView/treeControl.ts +++ b/src/components/flatHierarchy/treeView/treeControl.ts @@ -1,7 +1,7 @@ type IsParent<T> = (child: T, parent: T) => boolean -export class Tree<T extends object>{ +export class Tree<T extends Record<string, unknown>>{ private _nodes: T[] = [] protected set nodes(nodes: T[]) { diff --git a/src/components/flatHierarchy/treeView/treeView.component.ts b/src/components/flatHierarchy/treeView/treeView.component.ts index 99d55b39d..f67f7cdc8 100644 --- a/src/components/flatHierarchy/treeView/treeView.component.ts +++ b/src/components/flatHierarchy/treeView/treeView.component.ts @@ -14,7 +14,7 @@ import { Tree } from "./treeControl" exportAs: 'flatHierarchyTreeView' }) -export class SxplrFlatHierarchyTreeView<T extends object> extends Tree<T> implements OnChanges{ +export class SxplrFlatHierarchyTreeView<T extends Record<string, unknown>> extends Tree<T> implements OnChanges{ @HostBinding('class') class = 'sxplr-custom-cmp' diff --git a/src/layouts/currentLayout/currentLayout.component.ts b/src/layouts/currentLayout/currentLayout.component.ts index 298ccbf6f..0e6a4b56d 100644 --- a/src/layouts/currentLayout/currentLayout.component.ts +++ b/src/layouts/currentLayout/currentLayout.component.ts @@ -23,6 +23,4 @@ export class CurrentLayout { } public panelMode: userInterface.PanelMode = null - - constructor() {} } diff --git a/src/routerModule/routeStateTransform.service.ts b/src/routerModule/routeStateTransform.service.ts index 3769be747..f28834de5 100644 --- a/src/routerModule/routeStateTransform.service.ts +++ b/src/routerModule/routeStateTransform.service.ts @@ -112,8 +112,8 @@ export class RouteStateTransformSvc { const returnState: MainState = defaultState const pathFragments: UrlSegment[] = fullPath.root.hasChildren() - ? fullPath.root.children['primary'].segments - : [] + ? fullPath.root.children['primary'].segments + : [] const returnObj: Partial<TUrlPathObj<string[], unknown>> = {} for (const f of pathFragments) { diff --git a/src/routerModule/router.service.ts b/src/routerModule/router.service.ts index 44f6983f9..b089d055e 100644 --- a/src/routerModule/router.service.ts +++ b/src/routerModule/router.service.ts @@ -120,7 +120,7 @@ export class RouterService { /** * does work too well =( */ - concat( + concat( onload$.pipe( mapTo(false) ), diff --git a/src/state/atlasSelection/effects.ts b/src/state/atlasSelection/effects.ts index 6b988a8db..75c1a0d6b 100644 --- a/src/state/atlasSelection/effects.ts +++ b/src/state/atlasSelection/effects.ts @@ -38,8 +38,8 @@ export class Effect { const { atlas, parcellation, template } = current return ( !!atlas && !!parcellation && !!template - ? this.sapiSvc.getParcRegions(atlas["@id"], parcellation["@id"], template["@id"]) - : of([]) + ? this.sapiSvc.getParcRegions(atlas["@id"], parcellation["@id"], template["@id"]) + : of([]) ).pipe( map(regions => { return { diff --git a/src/viewerModule/nehuba/layerCtrl.service/layerCtrl.effects.ts b/src/viewerModule/nehuba/layerCtrl.service/layerCtrl.effects.ts index 33e41b96c..1aef3e7c8 100644 --- a/src/viewerModule/nehuba/layerCtrl.service/layerCtrl.effects.ts +++ b/src/viewerModule/nehuba/layerCtrl.service/layerCtrl.effects.ts @@ -144,8 +144,8 @@ export class LayerCtrlEffects { } const parcVolumes$ = !parcellation - ? of([]) - : forkJoin([ + ? of([]) + : forkJoin([ this.sapi.getParcellation(atlas["@id"], parcellation["@id"]).getRegions(template["@id"]).pipe( map(regions => { @@ -193,10 +193,10 @@ export class LayerCtrlEffects { ) const spaceVols$ = !!template - ? this.sapi.getSpace(atlas["@id"], template["@id"]).getVolumes().pipe( + ? this.sapi.getSpace(atlas["@id"], template["@id"]).getVolumes().pipe( shareReplay(1), ) - : of([]) + : of([]) return forkJoin({ tmplVolumes: spaceVols$.pipe( diff --git a/src/viewerModule/nehuba/layoutOverlay/nehuba.layoutOverlay/nehuba.layoutOverlay.component.ts b/src/viewerModule/nehuba/layoutOverlay/nehuba.layoutOverlay/nehuba.layoutOverlay.component.ts index 0b2c606a7..913ea82df 100644 --- a/src/viewerModule/nehuba/layoutOverlay/nehuba.layoutOverlay/nehuba.layoutOverlay.component.ts +++ b/src/viewerModule/nehuba/layoutOverlay/nehuba.layoutOverlay/nehuba.layoutOverlay.component.ts @@ -247,8 +247,8 @@ export class NehubaLayoutOverlay implements OnDestroy, AfterViewInit{ ]).pipe( debounce(() => nehubaUnit?.nehubaViewer?.ngviewer - ? of(true) - : interval(16).pipe( + ? of(true) + : interval(16).pipe( filter(() => nehubaUnit?.nehubaViewer?.ngviewer), take(1) ) diff --git a/src/viewerModule/nehuba/nehubaViewer/nehubaViewer.component.ts b/src/viewerModule/nehuba/nehubaViewer/nehubaViewer.component.ts index 6a8df82b7..b739d5904 100644 --- a/src/viewerModule/nehuba/nehubaViewer/nehubaViewer.component.ts +++ b/src/viewerModule/nehuba/nehubaViewer/nehubaViewer.component.ts @@ -373,9 +373,9 @@ export class NehubaViewerUnit implements OnDestroy { debounce(() => this._nehubaReady ? of(true) : interval(160).pipe( - filter(() => this._nehubaReady), - take(1), - ) + filter(() => this._nehubaReady), + take(1), + ) ), ).subscribe(layersLabelIndex => { let totalMeshes = 0 @@ -447,7 +447,6 @@ export class NehubaViewerUnit implements OnDestroy { public loadNehuba() { this.nehubaViewer = this.exportNehuba.createNehubaViewer(this.config, (err: string) => { /* print in debug mode */ - debugger this.log.error(err) }) diff --git a/src/viewerModule/nehuba/nehubaViewerInterface/nehubaViewerInterface.directive.ts b/src/viewerModule/nehuba/nehubaViewerInterface/nehubaViewerInterface.directive.ts index 93ca4407b..a43176fe1 100644 --- a/src/viewerModule/nehuba/nehubaViewerInterface/nehubaViewerInterface.directive.ts +++ b/src/viewerModule/nehuba/nehubaViewerInterface/nehubaViewerInterface.directive.ts @@ -319,19 +319,6 @@ export class NehubaViewerContainerDirective implements OnDestroy{ } this.nehubaViewerSubscriptions.push( - this.nehubaViewerInstance.errorEmitter.subscribe(e => { - console.log(e) - }), - - this.nehubaViewerInstance.layersChanged.subscribe(() => { - - }), - - this.nehubaViewerInstance.nehubaReady.subscribe(() => { - /** - * TODO when user selects new template, window.viewer - */ - }), this.nehubaViewerInstance.mouseoverSegmentEmitter.pipe( scan(accumulatorFn, new Map()), diff --git a/src/viewerModule/threeSurfer/threeSurferGlue/threeSurfer.component.ts b/src/viewerModule/threeSurfer/threeSurferGlue/threeSurfer.component.ts index 5fb33aa85..4ce0c8e6a 100644 --- a/src/viewerModule/threeSurfer/threeSurferGlue/threeSurfer.component.ts +++ b/src/viewerModule/threeSurfer/threeSurferGlue/threeSurfer.component.ts @@ -47,7 +47,7 @@ type TCameraOrientation = { type TThreeGeometry = { visible: boolean } -type GiiInstance = {} +type GiiInstance = unknown type TThreeSurfer = { loadMesh: (url: string) => Promise<TThreeGeometry> unloadMesh: (geom: TThreeGeometry) => void -- GitLab