diff --git a/src/atlasComponents/sapi/sapi.service.ts b/src/atlasComponents/sapi/sapi.service.ts index ae43869a35d2197fc387f234bda476087e8d941c..62ba0e2528a8633db52bc44acdcadd3e9e851e04 100644 --- a/src/atlasComponents/sapi/sapi.service.ts +++ b/src/atlasComponents/sapi/sapi.service.ts @@ -30,7 +30,7 @@ type RegistryType = SAPIAtlas | SAPISpace | SAPIParcellation @Injectable() export class SAPI{ - static bsEndpoint = `https://siibra-api-latest.apps-dev.hbp.eu/v2_0` || environment.BS_REST_URL + static bsEndpoint = environment.BS_REST_URL || `https://siibra-api-latest.apps-dev.hbp.eu/v2_0` public bsEndpoint = SAPI.bsEndpoint diff --git a/src/state/annotations/selectors.ts b/src/state/annotations/selectors.ts index d44a9e21167b54a7fc1a6b695bfa46c3c300955a..5504a6bb1fb7ab03a4053a365c24d55290a50036 100644 --- a/src/state/annotations/selectors.ts +++ b/src/state/annotations/selectors.ts @@ -2,7 +2,6 @@ import { createSelector } from "@ngrx/store" import { nameSpace } from "./const" import { Annotation, AnnotationState } from "./store" import { selectors as atlasSelectionSelectors } from "../atlasSelection" -import { annotation } from ".." const selectStore = state => state[nameSpace] as AnnotationState diff --git a/src/viewerModule/nehuba/annotation/effects.spec.ts b/src/viewerModule/nehuba/annotation/effects.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..6d18fc4adfdfab0a6e1b45b939be6f95748fe134 --- /dev/null +++ b/src/viewerModule/nehuba/annotation/effects.spec.ts @@ -0,0 +1,60 @@ +import { TestBed } from "@angular/core/testing" +import { provideMockActions } from "@ngrx/effects/testing" +import { Action } from "@ngrx/store" +import { MockStore, provideMockStore } from "@ngrx/store/testing" +import { hot } from "jasmine-marbles" +import { Observable } from "rxjs" +import { annotation, atlasAppearance } from "src/state" +import { NgAnnotationEffects } from "./effects" + +describe("effects.ts", () => { + describe("NgAnnotationEffects", () => { + let actions$: Observable<Action> + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [ + provideMockStore(), + provideMockActions(() => actions$), + NgAnnotationEffects, + ] + }) + }) + describe("onAnnotationHideQuadrant", () => { + describe("> when space filtered annotation does not exist", () => { + it("> should setOctantRemoval true", () => { + const mockStore = TestBed.inject(MockStore) + mockStore.overrideSelector(annotation.selectors.spaceFilteredAnnotations, []) + const effect = TestBed.inject(NgAnnotationEffects) + expect(effect.onAnnotationHideQuadrant).toBeObservable( + hot('a', { + a: atlasAppearance.actions.setOctantRemoval({ + flag: true + }) + }) + ) + }) + }) + describe("> when space filtered annotation exist", () => { + it("> should setOctantRemoval false", () => { + const mockStore = TestBed.inject(MockStore) + mockStore.overrideSelector(annotation.selectors.spaceFilteredAnnotations, [{} as any]) + const effect = TestBed.inject(NgAnnotationEffects) + expect(effect.onAnnotationHideQuadrant).toBeObservable( + hot('a', { + a: atlasAppearance.actions.setOctantRemoval({ + flag: false + }) + }) + ) + }) + }) + + describe("> on switch of space filtered annotations length", () => { + it("> should emit accordingly") + }) + describe("> on repeated emit of space filtered annotations length", () => { + it("> should only emit once") + }) + }) + }) +}) \ No newline at end of file diff --git a/src/viewerModule/nehuba/annotation/effects.ts b/src/viewerModule/nehuba/annotation/effects.ts index b4a6de67c1e0acdaaf3f4572c05a6cfa9ac51aff..10c510db4a0133b41962613926b72ea7159884f4 100644 --- a/src/viewerModule/nehuba/annotation/effects.ts +++ b/src/viewerModule/nehuba/annotation/effects.ts @@ -1,7 +1,7 @@ import { Injectable } from "@angular/core"; import { createEffect } from "@ngrx/effects"; import { select, Store } from "@ngrx/store"; -import { map } from "rxjs/operators"; +import { distinctUntilChanged, map } from "rxjs/operators"; import { annotation, atlasAppearance } from "src/state" @Injectable() @@ -10,8 +10,9 @@ export class NgAnnotationEffects{ onAnnotationHideQuadrant = createEffect(() => this.store.pipe( select(annotation.selectors.spaceFilteredAnnotations), - map(arr => { - const spaceFilteredAnnotationExists = arr.length > 0 + map(arr => arr.length > 0), + distinctUntilChanged(), + map(spaceFilteredAnnotationExists => { return atlasAppearance.actions.setOctantRemoval({ flag: !spaceFilteredAnnotationExists }) diff --git a/src/viewerModule/nehuba/nehubaViewerInterface/nehubaViewerTouch.directive.ts b/src/viewerModule/nehuba/nehubaViewerInterface/nehubaViewerTouch.directive.ts index 824db2f2e8adc80b51c1747eb3064a08bfe6f65b..0fbd2562a1d4f50bc39e6157aefe322747afe475 100644 --- a/src/viewerModule/nehuba/nehubaViewerInterface/nehubaViewerTouch.directive.ts +++ b/src/viewerModule/nehuba/nehubaViewerInterface/nehubaViewerTouch.directive.ts @@ -27,9 +27,20 @@ export class NehubaViewerTouchDirective implements OnDestroy{ public translate$: Observable<any> private nehubaUnit: NehubaViewerUnit + private htmlElementIndexMap = new WeakMap<HTMLElement, number>() private findPanelIndex(panel: HTMLElement){ if (!this.nehubaUnit) return null - return Array.from(this.nehubaUnit?.nehubaViewer?.ngviewer?.display?.panels || []).indexOf(panel) + if (!this.htmlElementIndexMap.has(panel)) { + Array.from(this.nehubaUnit?.nehubaViewer?.ngviewer?.display?.panels || []).forEach((el, idx) => { + if (el['element']) { + this.htmlElementIndexMap.set( + el['element'] as HTMLElement, + idx + ) + } + }) + } + return this.htmlElementIndexMap.get(panel) } private _exportNehuba: any