Skip to content

Commit

Permalink
Merge pull request #859 from HumanBrainProject/staging
Browse files Browse the repository at this point in the history
v2.3.4
  • Loading branch information
xgui3783 authored Feb 3, 2021
2 parents 6e6624a + 5cd97c3 commit 85a4eb2
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/releases/v2.3.3.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# v2.3.2
# v2.3.3

## Bugfixes

Expand Down
5 changes: 5 additions & 0 deletions docs/releases/v2.3.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# v2.3.4

## Bugfixes

- fix connectivity dataset external link
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pages:
- Fetching datasets: 'advanced/datasets.md'
- Display non-atlas volumes: 'advanced/otherVolumes.md'
- Release notes:
- v2.3.4: 'releases/v2.3.4.md'
- v2.3.3: 'releases/v2.3.3.md'
- v2.3.2: 'releases/v2.3.2.md'
- v2.3.1: 'releases/v2.3.1.md'
Expand Down
78 changes: 78 additions & 0 deletions src/ui/connectivityBrowser/connectivityBrowser.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import {ConnectivityBrowserComponent} from "src/ui/connectivityBrowser/connectivityBrowser.component";
import {async, ComponentFixture, TestBed} from "@angular/core/testing";
import {Action} from "@ngrx/store";
import {
defaultRootState,
} from "src/services/stateStore.service";
import {HttpClientModule} from "@angular/common/http";
import {CUSTOM_ELEMENTS_SCHEMA} from "@angular/core";
import {DatabrowserModule} from "src/ui/databrowserModule";
import {provideMockActions} from "@ngrx/effects/testing";
import {provideMockStore} from "@ngrx/store/testing";
import {Observable, of} from "rxjs";

describe('ConnectivityComponent', () => {

let component: ConnectivityBrowserComponent;
let fixture: ComponentFixture<ConnectivityBrowserComponent>;
const actions$: Observable<Action> = of({type: 'TEST'})

let datasetList = [
{
id: 'id1',
name: 'n1',
description: 'd1',
kgId: 'kgId1',
kgschema: 'kgschema1'
}, {
id: 'id2',
name: 'n2',
description: 'd2',
kgId: 'kgId2',
kgschema: 'kgschema2'
}
]

beforeEach(async (() => {
TestBed.configureTestingModule({
imports: [
HttpClientModule,
DatabrowserModule
],
providers: [
provideMockActions(() => actions$),
provideMockStore({ initialState: defaultRootState })
],
declarations: [ConnectivityBrowserComponent],
schemas: [
CUSTOM_ELEMENTS_SCHEMA,
],
}).compileComponents()
}));

it('> component can be created', async () => {
fixture = TestBed.createComponent(ConnectivityBrowserComponent)
component = fixture.componentInstance
expect(component).toBeTruthy()
})

it('> change dataset changes description, kgId and kgschema', () => {
fixture = TestBed.createComponent(ConnectivityBrowserComponent)
component = fixture.componentInstance

component.datasetList = datasetList

component.changeDataset({value: 'n1'})

expect(component.selectedDatasetDescription).toEqual('d1')
expect(component.selectedDatasetKgId).toEqual('kgId1')
expect(component.selectedDatasetKgSchema).toEqual('kgschema1')

component.changeDataset({value: 'n2'})

expect(component.selectedDatasetDescription).toEqual('d2')
expect(component.selectedDatasetKgId).toEqual('kgId2')
expect(component.selectedDatasetKgSchema).toEqual('kgschema2')
})

});
30 changes: 18 additions & 12 deletions src/ui/connectivityBrowser/connectivityBrowser.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe
public datasetList: any[] = []
public selectedDataset: any
public selectedDatasetDescription: string = ''
public selectedDatasetKgId: string = ''
public selectedDatasetKgSchema: string = ''
public connectedAreas = []

private selectedParcellationFlatRegions$ = this.store$.pipe(
Expand Down Expand Up @@ -151,7 +153,8 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe
this.datasetList = res.filter(dl => dl['parcellation id'] === this.parcellationId)
this.selectedDataset = this.datasetList[0].name
this.selectedDatasetDescription = this.datasetList[0].description

this.selectedDatasetKgId = this.datasetList[0].kgId
this.selectedDatasetKgSchema = this.datasetList[0].kgschema
this.changeDataset()
})
}
Expand All @@ -166,9 +169,9 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe
}
})
)
/**
* Listen to of clear view entries

/**
* Listen to of clear view entries
* can come from within the component (when connectivity is not available for the dataset)
* --> do not collapse
* or outside (user clicks x in chip)
Expand All @@ -186,7 +189,7 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe
}
})
)


this.subscriptions.push(this.overwrittenColorMap$.subscribe(ocm => {
if (this.accordionIsExpanded && !ocm) {
Expand All @@ -209,7 +212,7 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe
this.setColorMap$.pipe(
distinctUntilChanged()
),
fromEvent(this.connectivityComponentElement.nativeElement, 'connectivityDataReceived').pipe(
fromEvent(this.connectivityComponentElement?.nativeElement, 'connectivityDataReceived').pipe(
map((e: CustomEvent) => e.detail)
)
).subscribe(([flag, connectedAreas]) => {
Expand Down Expand Up @@ -278,7 +281,7 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe
this.restoreDefaultColormap()
this.subscriptions.forEach(s => s.unsubscribe())
}

clearViewer() {
this.store$.dispatch(
ngViewerActionClearView({
Expand All @@ -297,7 +300,10 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe
changeDataset(event = null) {
if (event) {
this.selectedDataset = event.value
this.selectedDatasetDescription = this.datasetList.find(d => d.name === this.selectedDataset).description
const foundDataset = this.datasetList.find(d => d.name === this.selectedDataset)
this.selectedDatasetDescription = foundDataset?.description
this.selectedDatasetKgId = foundDataset?.kgId || null
this.selectedDatasetKgSchema = foundDataset?.kgschema || null
}
if (this.datasetList.length && this.selectedDataset) {
const selectedDatasetId = this.datasetList.find(d => d.name === this.selectedDataset).id
Expand Down Expand Up @@ -355,7 +361,7 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe

const existingMap: Map<string, Map<number, { red: number, green: number, blue: number }>> = (getWindow().interactiveViewer.viewerHandle.getLayersSegmentColourMap())
const colorMap = new Map(existingMap)

this.allRegions.forEach(r => {
if (r.ngId) {
colorMap.get(r.ngId).set(r.labelIndex, {red: 255, green: 255, blue: 255})
Expand All @@ -365,7 +371,7 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe
this.connectedAreas.forEach(area => {
const areaAsRegion = this.allRegions
.filter(r => {

if (this.regionHemisphere) {
let regionName = area.name
let regionStatus = null
Expand All @@ -378,7 +384,7 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe
}
return r.name === regionName && r.status === regionStatus
}

return r.name === area.name
})
.map(r => r)
Expand All @@ -400,7 +406,7 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe
}

public exportFullConnectivity() {
this.fullConnectivityGridElement.nativeElement['downloadCSV']()
this.fullConnectivityGridElement?.nativeElement['downloadCSV']()
}

}
Expand Down
5 changes: 4 additions & 1 deletion src/ui/connectivityBrowser/connectivityBrowser.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
<button class="flex-grow-0 flex-shrink-0" mat-icon-button
iav-dataset-show-dataset-dialog
[iav-dataset-show-dataset-dialog-name]="selectedDataset"
[iav-dataset-show-dataset-dialog-description]="selectedDatasetDescription">
[iav-dataset-show-dataset-dialog-description]="selectedDatasetDescription"
[iav-dataset-show-dataset-dialog-kgid]="selectedDatasetKgId? selectedDatasetKgId : null"
[iav-dataset-show-dataset-dialog-kgschema]="selectedDatasetKgSchema? selectedDatasetKgSchema : null"
>
<i class="fas fa-info"></i>
</button>
<button class="flex-grow-0 flex-shrink-0"
Expand Down

0 comments on commit 85a4eb2

Please sign in to comment.