Skip to content

Commit

Permalink
fix: lint, test
Browse files Browse the repository at this point in the history
refct: remove unused code
  • Loading branch information
xgui3783 committed Feb 28, 2025
1 parent 4ba2ec2 commit a90f0c3
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 104 deletions.
9 changes: 0 additions & 9 deletions src/atlas-download/atlas-download.directive.spec.ts

This file was deleted.

33 changes: 0 additions & 33 deletions src/atlasComponents/sapi/core/base.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/atlasComponents/sapi/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { SAPIAtlas } from "./sapiAtlas"
export { SAPIParcellation } from "./sapiParcellation"

5 changes: 0 additions & 5 deletions src/atlasComponents/sapi/core/sapiAtlas.ts

This file was deleted.

30 changes: 0 additions & 30 deletions src/atlasComponents/sapi/core/sapiParcellation.ts

This file was deleted.

3 changes: 2 additions & 1 deletion src/atlasComponents/sapi/decisionCollapse.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Injectable } from "@angular/core";
import { take } from "rxjs/operators";

import { SAPI } from "./sapi.service";
import { SxplrAtlas, SxplrParcellation, SxplrTemplate } from "./sxplrTypes";
import { take } from "rxjs/operators";

type PossibleATP = {
atlases: SxplrAtlas[]
Expand Down
4 changes: 0 additions & 4 deletions src/atlasComponents/sapi/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
export { SAPIModule } from './module'

export { SAPI } from "./sapi.service"
export {
SAPIAtlas,
SAPIParcellation,
} from "./core"

export {
IDS
Expand Down
5 changes: 1 addition & 4 deletions src/main.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { DragDropModule } from '@angular/cdk/drag-drop'
import { CommonModule, DOCUMENT } from "@angular/common";
import { APP_INITIALIZER, NgModule } from "@angular/core";
import { FormsModule } from "@angular/forms";
import { Store, select } from "@ngrx/store";
import { AngularMaterialModule } from 'src/sharedModules'
import { AtlasViewer } from "./atlasViewer/atlasViewer.component";
import { ComponentsModule } from "./components/components.module";
Expand Down Expand Up @@ -36,12 +35,10 @@ import { Observable, of } from 'rxjs';
import { CANCELLABLE_DIALOG, CANCELLABLE_DIALOG_OPTS } from './util/interfaces';
import { NotSupportedCmp } from './notSupportedCmp/notSupported.component';
import {
atlasSelection,
RootStoreModule,
getStoreEffects,
} from "./state"
import { DARKTHEME } from './util/injectionTokens';
import { map } from 'rxjs/operators';
import { EffectsModule } from '@ngrx/effects';

// TODO check if there is a more logical place import put layerctrl effects ts
Expand Down Expand Up @@ -169,7 +166,7 @@ import { FreeModeModule } from './freeModeModule';
},
{
provide: APP_INITIALIZER,
useFactory: (authSvc: AuthService, darktheme$: Observable<boolean>) => {
useFactory: (authSvc: AuthService, _darktheme$: Observable<boolean>) => {
authSvc.authReloadState()
return () => Promise.resolve()
},
Expand Down
10 changes: 5 additions & 5 deletions src/viewerModule/nehuba/config.service/util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const defaultNehubaConfigObject = {
},
zoomFactor: defaultZoom
}
}
} as any

const bigbrainNehubaConfig = {
"showDefaultAnnotations": false,
Expand Down Expand Up @@ -63,7 +63,7 @@ const bigbrainNehubaConfig = {
-0.3195493221282959
],
"perspectiveZoom": 1922235.5293810747
}
} as any

describe('> util.ts', () => {

Expand Down Expand Up @@ -126,13 +126,13 @@ describe('> util.ts', () => {
pose: {
position: {
voxelSize: bigbrainNehubaConfig.navigation.pose.position.voxelSize,
voxelCoordinates: [0, 1, 2].map(idx => position[idx] / bigbrainNehubaConfig.navigation.pose.position.voxelSize[idx])
voxelCoordinates: [0, 1, 2].map(idx => position[idx] / bigbrainNehubaConfig.navigation.pose.position.voxelSize[idx]) as [number, number, number]
},
orientation
orientation: orientation as [number, number, number, number]
},
zoomFactor: zoom
},
perspectiveOrientation: perspectiveOrientation,
perspectiveOrientation: perspectiveOrientation as [number, number, number, number],
perspectiveZoom: perspectiveZoom
})
})
Expand Down
6 changes: 3 additions & 3 deletions src/viewerModule/nehuba/config.service/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ export const spaceMiscInfoMap = new Map([

export function getNehubaConfig(space: SxplrTemplate): NehubaConfig {

const darkTheme = space.id !== "minds/core/referencespace/v1.0.0/a1655b99-82f1-420f-a3c2-fe80fd4c8588"
const { scale } = spaceMiscInfoMap.get(space.id) || { scale: 1 }
const darkTheme = space?.id !== "minds/core/referencespace/v1.0.0/a1655b99-82f1-420f-a3c2-fe80fd4c8588"
const { scale } = spaceMiscInfoMap.get(space?.id) || { scale: 1 }
const backgrd = darkTheme
? [0,0,0,1]
: [1,1,1,1]
Expand All @@ -318,7 +318,7 @@ export function getNehubaConfig(space: SxplrTemplate): NehubaConfig {

// enable surface parcellation
// otherwise, on segmentation selection, the unselected meshes will also be invisible
const surfaceParcellation = space.id === 'minds/core/referencespace/v1.0.0/7f39f7be-445b-47c0-9791-e971c0b6d992'
const surfaceParcellation = space?.id === 'minds/core/referencespace/v1.0.0/7f39f7be-445b-47c0-9791-e971c0b6d992'
return {
"configName": "",
"globals": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from "@angular/core"
import { TestBed, ComponentFixture, fakeAsync, tick } from "@angular/core/testing"
import { TestBed, ComponentFixture, fakeAsync, tick, flush, discardPeriodicTasks } from "@angular/core/testing"
import { By } from "@angular/platform-browser"
import { MockStore, provideMockStore } from "@ngrx/store/testing"
import { NehubaViewerUnit } from "../nehubaViewer/nehubaViewer.component"
Expand All @@ -8,6 +8,7 @@ import { NEVER, of, pipe, Subject } from "rxjs"
import { userPreference, atlasSelection, atlasAppearance } from "src/state"
import { LayerCtrlEffects } from "../layerCtrl.service/layerCtrl.effects"
import { mapTo } from "rxjs/operators"
import { translateV3Entities } from "src/atlasComponents/sapi/translateV3"

describe('> nehubaViewerInterface.directive.ts', () => {
let distinctATPSpy: jasmine.Spy
Expand Down Expand Up @@ -85,6 +86,7 @@ describe('> nehubaViewerInterface.directive.ts', () => {
let nehubaViewerInstanceSpy: jasmine.Spy
let elClearSpy: jasmine.Spy
let elCreateComponentSpy: jasmine.Spy
let translateSpaceToVolumeImageMetaSpy: jasmine.Spy
const spyNehubaViewerInstance = {
config: null,
lifecycle: null,
Expand All @@ -104,16 +106,16 @@ describe('> nehubaViewerInterface.directive.ts', () => {
}

const gpuLimit = 5e8
beforeEach(fakeAsync(() => {
beforeEach(() => {
const mockStore = TestBed.inject(MockStore)
mockStore.overrideSelector(userPreference.selectors.gpuLimit, gpuLimit)
translateSpaceToVolumeImageMetaSpy = spyOn(translateV3Entities, 'translateSpaceToVolumeImageMeta')
translateSpaceToVolumeImageMetaSpy.and.returnValue(Promise.resolve([]))

fixture = TestBed.createComponent(DummyCmp)
const directive = fixture.debugElement.query(
By.directive(NehubaViewerContainerDirective)
)

tick(300)

directiveInstance = directive.injector.get(NehubaViewerContainerDirective)

Expand All @@ -122,7 +124,7 @@ describe('> nehubaViewerInterface.directive.ts', () => {
// casting return value to any is not perfect, but since only 2 methods and 1 property is used, it's a quick way
// rather than allow component to be created
elCreateComponentSpy = spyOn(directiveInstance['el'], 'createComponent').and.returnValue(spyComRef as any)
}))
})

describe('> on createNehubaInstance called', () => {
const nehubaConfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { arrayOfPrimitiveEqual } from 'src/util/fn'
import { INavObj } from "../constants"
import { NehubaConfig, defaultNehubaConfig, getNehubaConfig } from "../config.service";
import { atlasAppearance, atlasSelection, userPreference } from "src/state";
import { SxplrAtlas, SxplrParcellation, SxplrTemplate } from "src/atlasComponents/sapi/sxplrTypes";
import { arrayEqual } from "src/util/array";
import { cvtNavigationObjToNehubaConfig } from "../config.service/util";
import { LayerCtrlEffects } from "../layerCtrl.service/layerCtrl.effects";
Expand Down Expand Up @@ -179,7 +178,7 @@ export class NehubaViewerContainerDirective implements OnDestroy{
this.store$.pipe(
select(atlasAppearance.selectors.customLayers),
map(cl => cl.filter(l => l.clType === "baselayer/nglayer") as atlasAppearance.const.NgLayerCustomLayer[]),
distinctUntilChanged(arrayEqual((oi, ni) => oi.id === ni.id)),
distinctUntilChanged(arrayEqual((oi, ni) => oi?.id === ni?.id)),
),
translateV3Entities.translateSpaceToVolumeImageMeta(template)
]).pipe(
Expand Down Expand Up @@ -219,6 +218,10 @@ export class NehubaViewerContainerDirective implements OnDestroy{
take(1)
).toPromise()

if (this.gpuLimit) {
config.dataset.initialNgState['gpuMemoryLimit'] = this.gpuLimit
}

await this.createNehubaInstance(config)

const ngIdSegmentsMap: Record<string, number[]> = {}
Expand Down Expand Up @@ -251,7 +254,6 @@ export class NehubaViewerContainerDirective implements OnDestroy{
}),

this.gpuLimit$.pipe(
debounceTime(160),
).subscribe(limit => {
this.gpuLimit = limit
if (this.nehubaViewerInstance && this.nehubaViewerInstance.nehubaViewer) {
Expand Down

0 comments on commit a90f0c3

Please sign in to comment.