Skip to content

Commit

Permalink
Merge pull request #1315 from FZJ-INM1-BDA/staging
Browse files Browse the repository at this point in the history
v2.10.3
  • Loading branch information
xgui3783 authored May 10, 2023
2 parents 8ae9264 + 5d9dc0d commit 8074a6e
Show file tree
Hide file tree
Showing 31 changed files with 632 additions and 669 deletions.
7 changes: 7 additions & 0 deletions docs/releases/v2.10.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# v2.10.3

## Bugfix

- restore the wireframe for VOI (enable via toggle)
- added "no spatial features found" where appropriate
- fixed messaging for adding swc layer
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ nav:
- Fetching datasets: 'advanced/datasets.md'
- Display non-atlas volumes: 'advanced/otherVolumes.md'
- Release notes:
- v2.10.3: 'releases/v2.10.3.md'
- v2.10.2: 'releases/v2.10.2.md'
- v2.10.1: 'releases/v2.10.1.md'
- v2.10.0: 'releases/v2.10.0.md'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "siibra-explorer",
"version": "2.10.2",
"version": "2.10.3",
"description": "siibra-explorer - explore brain atlases. Based on humanbrainproject/nehuba & google/neuroglancer. Built with angular",
"scripts": {
"lint": "eslint src --ext .ts",
Expand Down
39 changes: 38 additions & 1 deletion src/features/category-acc.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class CategoryAccDirective implements AfterContentInit, OnDestroy {
this.#unchecked$.next(val)
}

datasource: ParentDatasource<TranslatedFeature>
public datasource$ = combineLatest([
this.unchecked$,
this.#listCmps$,
Expand All @@ -111,11 +112,46 @@ export class CategoryAccDirective implements AfterContentInit, OnDestroy {
return combineLatest(
filteredListCmps.map(cmp => cmp.datasource$)
).pipe(
map(dss => new ParentDatasource({ children: dss })),
map(dss => {
this.datasource = new ParentDatasource({ children: dss })
return this.datasource
}),
)
})
)

constructor(){

/**
* On init, if current count is less than 50, and less than total, pull.
*/
this.#subscriptions.push(
combineLatest([
this.total$,
this.datasource$
]).pipe(
switchMap(([ total, ds ]) =>
ds.connect().pipe(
map(items => ({
total,
ds,
current: items.length
}))
)
)
).subscribe(async ({ total, current, ds }) => {
if (total > current && current < 50) {
try {
await ds.pull()
} catch (e) {
// if already pulling, ignore
}
}
})
)
}

#subscriptions: Subscription[] = []
#changeSub: Subscription
ngAfterContentInit(): void {
this.#changeSub = this.listCmps.changes.subscribe(() => {
Expand All @@ -130,5 +166,6 @@ export class CategoryAccDirective implements AfterContentInit, OnDestroy {

ngOnDestroy(): void {
if (this.#changeSub) this.#changeSub.unsubscribe()
if (this.#subscriptions.length > 0) this.#subscriptions.pop().unsubscribe()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {SAPI} from "src/atlasComponents/sapi";
import {AngularMaterialModule} from "src/sharedModules";
import { HttpClientTestingModule, HttpTestingController } from "@angular/common/http/testing";
import { SxplrAtlas, SxplrParcellation } from "src/atlasComponents/sapi/sxplrTypes";
import { UtilModule } from "src/util";

/**
* injecting databrowser module is bad idea
Expand Down Expand Up @@ -71,7 +72,8 @@ describe('ConnectivityComponent', () => {
await TestBed.configureTestingModule({
imports: [
HttpClientTestingModule,
AngularMaterialModule
AngularMaterialModule,
UtilModule,
],
providers: [
provideMockActions(() => actions$),
Expand Down Expand Up @@ -106,35 +108,12 @@ describe('ConnectivityComponent', () => {

describe('> Select modality', async () => {
beforeEach(async () => {
fixture = TestBed.createComponent(ConnectivityBrowserComponent)
component = fixture.componentInstance

const atlas = 'atlases/juelich/iav/atlas/v1.0.0/1'
const parcellation = 'minds/core/parcellationatlas/v1.0.0/94c1125b-b87e-45e4-901c-00daee7f2579-290'
const endp = await SAPI.BsEndpoint$.toPromise()

component.atlas = { id: atlas } as SxplrAtlas
component.parcellation = { id: parcellation } as any
component.types = types

const url = `${endp}/atlases/${encodeURIComponent(atlas)}/parcellations/${encodeURIComponent(parcellation)}/features?type=${component.selectedType.id}&size=${100}&page=${1}`

req = httpTestingController.expectOne(`${url}`);

await req.flush({
page: 1,
size: 2,
total: 2,
items: datasetList
});
})

it('> Get request should be called', () => {
expect(req.request.method).toEqual('GET')
})

it('> Datasets are set correctly', () => {
expect(datasetList).toEqual(component.fetchedItems)
})

// it('> Cohorts are set correctly', () => {
Expand Down
91 changes: 0 additions & 91 deletions src/features/entry/entry.component.html

This file was deleted.

56 changes: 0 additions & 56 deletions src/features/entry/entry.component.scss

This file was deleted.

9 changes: 7 additions & 2 deletions src/features/entry/entry.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SAPIModule } from 'src/atlasComponents/sapi';

import { EntryComponent } from './entry.component';
import { provideMockStore } from '@ngrx/store/testing';
import { FeatureModule } from '../module';

describe('EntryComponent', () => {
let component: EntryComponent;
Expand All @@ -12,9 +14,12 @@ describe('EntryComponent', () => {
await TestBed.configureTestingModule({
imports: [
SAPIModule,
CommonModule,
FeatureModule,
],
declarations: [ EntryComponent ]
declarations: [ ],
providers: [
provideMockStore()
]
})
.compileComponents();

Expand Down
37 changes: 34 additions & 3 deletions src/features/entry/entry.component.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { AfterViewInit, Component, OnDestroy, QueryList, ViewChildren } from '@angular/core';
import { select, Store } from '@ngrx/store';
import { map, scan, switchMap, tap } from 'rxjs/operators';
import { map, scan, shareReplay, switchMap, tap } from 'rxjs/operators';
import { IDS, SAPI } from 'src/atlasComponents/sapi';
import { Feature } from 'src/atlasComponents/sapi/sxplrTypes';
import { FeatureBase } from '../base';
import * as userInteraction from "src/state/userInteraction"
import { atlasSelection } from 'src/state';
import { CategoryAccDirective } from "../category-acc.directive"
import { BehaviorSubject, combineLatest, merge, of, Subscription } from 'rxjs';
import { IsAlreadyPulling, PulledDataSource } from 'src/util/pullable';
import { DsExhausted, IsAlreadyPulling, PulledDataSource } from 'src/util/pullable';
import { TranslatedFeature } from '../list/list.directive';

const categoryAcc = <T extends Record<string, unknown>>(categories: T[]) => {
const returnVal: Record<string, T[]> = {}
Expand All @@ -32,6 +33,11 @@ const categoryAcc = <T extends Record<string, unknown>>(categories: T[]) => {
})
export class EntryComponent extends FeatureBase implements AfterViewInit, OnDestroy {

private _features$ = new BehaviorSubject<TranslatedFeature[]>([])
features$ = this._features$.pipe(
shareReplay(1)
)

@ViewChildren(CategoryAccDirective)
catAccDirs: QueryList<CategoryAccDirective>

Expand Down Expand Up @@ -139,11 +145,36 @@ export class EntryComponent extends FeatureBase implements AfterViewInit, OnDest
try {
await datasource.pull()
} catch (e) {
if (e instanceof IsAlreadyPulling) {
if (e instanceof IsAlreadyPulling || e instanceof DsExhausted) {
return
}
throw e
}
}
}

async pullAll(){
const dss = Array.from(this.catAccDirs).map(catAcc => catAcc.datasource)

this._features$.next([])
await Promise.all(
dss.map(async ds => {
// eslint-disable-next-line no-constant-condition
while (true) {
try {
await ds.pull()
} catch (e) {
if (e instanceof DsExhausted) {
break
}
if (e instanceof IsAlreadyPulling ) {
continue
}
throw e
}
}
})
)
this._features$.next(dss.flatMap(ds => ds.finalValue))
}
}
Loading

0 comments on commit 8074a6e

Please sign in to comment.