Skip to content
Snippets Groups Projects
Unverified Commit 5cd97c37 authored by xgui3783's avatar xgui3783 Committed by GitHub
Browse files

Merge pull request #854 from HumanBrainProject/fix_connectivity_dataset_link

Fix connectivity dataset external link
parents 1b3bc2b9 44cb0238
No related branches found
No related tags found
No related merge requests found
# v2.3.2
# v2.3.3
## Bugfixes
......
# v2.3.4
## Bugfixes
- fix connectivity dataset external link
......@@ -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'
......
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')
})
});
\ No newline at end of file
......@@ -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(
......@@ -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()
})
}
......@@ -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)
......@@ -186,7 +189,7 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe
}
})
)
this.subscriptions.push(this.overwrittenColorMap$.subscribe(ocm => {
if (this.accordionIsExpanded && !ocm) {
......@@ -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]) => {
......@@ -278,7 +281,7 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe
this.restoreDefaultColormap()
this.subscriptions.forEach(s => s.unsubscribe())
}
clearViewer() {
this.store$.dispatch(
ngViewerActionClearView({
......@@ -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
......@@ -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})
......@@ -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
......@@ -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)
......@@ -400,7 +406,7 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe
}
public exportFullConnectivity() {
this.fullConnectivityGridElement.nativeElement['downloadCSV']()
this.fullConnectivityGridElement?.nativeElement['downloadCSV']()
}
}
......
......@@ -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"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment