diff --git a/package.json b/package.json index 680b422c36a7a7bc28f73d7407fa933a04231e96..da95574ca28f9028d89d09a5b698adaeef49aac1 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "@ngrx/store": "^9.1.1", "@types/node": "12.12.39", "export-nehuba": "0.0.2", - "hbp-connectivity-component": "^0.3.7", + "hbp-connectivity-component": "^0.3.12", "zone.js": "^0.10.2" } } diff --git a/src/ui/connectivityBrowser/connectivityBrowser.component.ts b/src/ui/connectivityBrowser/connectivityBrowser.component.ts index 682aed5c210552eab1a18a75dd38c9bd6552978e..7fd10f28ad5d8823316a8742f07a6cde23ac8ba3 100644 --- a/src/ui/connectivityBrowser/connectivityBrowser.component.ts +++ b/src/ui/connectivityBrowser/connectivityBrowser.component.ts @@ -7,6 +7,7 @@ import { Output, ViewChild, Input, + OnInit, } from "@angular/core"; import {select, Store} from "@ngrx/store"; import {fromEvent, Observable, Subscription, Subject, combineLatest} from "rxjs"; @@ -17,6 +18,7 @@ import { viewerStateNavigateToRegion } from "src/services/state/viewerState.stor import { ngViewerActionClearView } from "src/services/state/ngViewerState/actions"; import { ngViewerSelectorClearViewEntries } from "src/services/state/ngViewerState/selectors"; import { viewerStateAllRegionsFlattenedRegionSelector } from "src/services/state/viewerState/selectors"; +import { HttpClient } from "@angular/common/http"; const CONNECTIVITY_NAME_PLATE = 'Connectivity' @@ -24,7 +26,7 @@ const CONNECTIVITY_NAME_PLATE = 'Connectivity' selector: 'connectivity-browser', templateUrl: './connectivityBrowser.template.html', }) -export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy{ +export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDestroy{ private setColorMap$: Subject<boolean> = new Subject() @@ -35,6 +37,8 @@ export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy{ */ private _isFirstUpdate = true + public connectivityUrl = 'https://connectivity-query-v1-1-connectivity.apps-dev.hbp.eu/v1.1/studies' + @Input() set accordionExpanded(flag: boolean){ /** @@ -54,6 +58,11 @@ export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy{ @Output() setOpenState: EventEmitter<boolean> = new EventEmitter() + @Output() + connectivityLoadUrl: EventEmitter<string> = new EventEmitter() + + @Output() connectivityNumberReceived: EventEmitter<string> = new EventEmitter() + @Input() set region(val){ const newRegionName = val && val.name @@ -78,6 +87,7 @@ export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy{ public regionName: string public datasetList: any[] = [] public selectedDataset: any + public selectedDatasetDescription: string = '' public connectedAreas = [] private selectedParcellationFlatRegions$ = this.store$.pipe( @@ -96,6 +106,7 @@ export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy{ constructor( private store$: Store<any>, private changeDetectionRef: ChangeDetectorRef, + private httpClient: HttpClient ) { this.overwrittenColorMap$ = this.store$.pipe( @@ -106,6 +117,32 @@ export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy{ ) } + ngOnInit(): void { + this.httpClient.get<[]>(this.connectivityUrl).subscribe(res => { + this.datasetList = res + this.selectedDataset = this.datasetList[0].name + this.selectedDatasetDescription = this.datasetList[0].description + }) + } + + getLoadUrl(): string { + if (this.datasetList.length && this.selectedDataset) { + const selectedDatasetId = this.datasetList.find(d => d.name === this.selectedDataset).id + const url = selectedDatasetId? `${this.connectivityUrl}/${selectedDatasetId}` : null + this.connectivityLoadUrl.emit(url) + return url + } + } + + getFullConnectivityLoadUrl(): string { + if (this.datasetList.length && this.selectedDataset) { + const selectedDatasetId = this.datasetList.find(d => d.name === this.selectedDataset).id + const url = selectedDatasetId? `${this.connectivityUrl}/${selectedDatasetId}/full_matrix` : null + this.connectivityLoadUrl.emit(url) + return url + } + } + public ngAfterViewInit(): void { this.subscriptions.push( @@ -143,7 +180,7 @@ export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy{ map((e: CustomEvent) => e.detail) ) ).subscribe(([flag, connectedAreas]) => { - + this.connectivityNumberReceived.emit(connectedAreas.length) this.connectedAreas = connectedAreas if (flag) { @@ -170,16 +207,13 @@ export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy{ .subscribe((e: CustomEvent) => { this.expandMenuIndex = e.detail }), - fromEvent(this.connectivityComponentElement?.nativeElement, 'datasetDataReceived', { capture: true }) - .subscribe((e: CustomEvent) => { - this.datasetList = e.detail - this.selectedDataset = this.datasetList[0] - }), fromEvent(this.connectivityComponentElement?.nativeElement, 'customToolEvent', { capture: true }) .subscribe((e: CustomEvent) => { if (e.detail.name === 'export csv') { // ToDo Fix in future to use component + console.log('searching...') const a = document.querySelector('hbp-connectivity-matrix-row') + console.log(a) a.downloadCSV() } }), @@ -194,6 +228,7 @@ export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy{ // ToDo Affect on component changeDataset(event) { this.selectedDataset = event.value + this.selectedDatasetDescription = this.datasetList.find(d => d.name === this.selectedDataset).description } navigateToRegion(region) { diff --git a/src/ui/connectivityBrowser/connectivityBrowser.template.html b/src/ui/connectivityBrowser/connectivityBrowser.template.html index 776848eba9f58ff48085acc0402ba7f77b197d0f..e1e41a9230b42818102a28031084bbdf297a5c44 100644 --- a/src/ui/connectivityBrowser/connectivityBrowser.template.html +++ b/src/ui/connectivityBrowser/connectivityBrowser.template.html @@ -4,8 +4,7 @@ *ngIf="regionName" [region]="regionName" theme="dark" - loadurl="https://connectivityquery-connectivity.apps-dev.hbp.eu/connectivity" - dataset-url="https://connectivityquery-connectivity.apps-dev.hbp.eu/studies" + [loadurl]="getLoadUrl()" show-export="true" show-source="false" show-title="false" @@ -30,16 +29,16 @@ (selectionChange)="changeDataset($event)"> <mat-option *ngFor="let dataset of datasetList" - [value]="dataset"> - {{ dataset.title }} + [value]="dataset.name"> + {{ dataset.name }} </mat-option> </mat-select> </mat-form-field> - <ng-container *ngIf="selectedDataset && selectedDataset.description" > + <ng-container *ngIf="selectedDataset && selectedDatasetDescription" > <button class="flex-grow-0 flex-shrink-0" mat-icon-button iav-dataset-show-dataset-dialog - [iav-dataset-show-dataset-dialog-name]="selectedDataset.title" - [iav-dataset-show-dataset-dialog-description]="selectedDataset.description"> + [iav-dataset-show-dataset-dialog-name]="selectedDataset" + [iav-dataset-show-dataset-dialog-description]="selectedDatasetDescription"> <i class="fas fa-info"></i> </button> <button class="flex-grow-0 flex-shrink-0" @@ -84,7 +83,9 @@ </div> </hbp-connectivity-matrix-row> <full-connectivity-grid #fullConnectivityGrid - dataset-url="https://connectivityquery-connectivity.apps-dev.hbp.eu/studies" + [loadurl]="getFullConnectivityLoadUrl()" + [name]="selectedDataset" + [description]="selectedDatasetDescription" onlyExport="true"> </full-connectivity-grid> </div> \ No newline at end of file diff --git a/src/ui/nehubaContainer/nehubaContainer.component.ts b/src/ui/nehubaContainer/nehubaContainer.component.ts index 108e1409607fb9484ac1cd9755f33f8b87d70092..1522f205a305f3fb6be661dfdac6927ee24d6579 100644 --- a/src/ui/nehubaContainer/nehubaContainer.component.ts +++ b/src/ui/nehubaContainer/nehubaContainer.component.ts @@ -288,6 +288,7 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { public hoveredPanelIndices$: Observable<number> @ViewChild('connectivityComponent') public connectivityComponent: ConnectivityBrowserComponent + public connectivityNumber: string constructor( private pureConstantService: PureContantService, diff --git a/src/ui/nehubaContainer/nehubaContainer.template.html b/src/ui/nehubaContainer/nehubaContainer.template.html index e9283da7918052dad44496195b4a643be3236705..1d383a6f96cc86b56f629a3d42b1b371abb8bded 100644 --- a/src/ui/nehubaContainer/nehubaContainer.template.html +++ b/src/ui/nehubaContainer/nehubaContainer.template.html @@ -499,6 +499,7 @@ <connectivity-browser class="pe-all flex-shrink-1" [region]="region" (setOpenState)="expansionPanel.expanded = $event" + (connectivityNumberReceived)="connectivityNumber = $event" [accordionExpanded]="expansionPanel.expanded" #connectivityComponent> </connectivity-browser> @@ -508,7 +509,7 @@ <ng-container *ngTemplateOutlet="ngMatAccordionTmpl; context: { title: 'Connectivity', - desc: connectedCounterDir.value, + desc: connectivityNumber? connectivityNumber : connectedCounterDir.value, iconClass: 'fas fa-braille', iconTooltip: connectedCounterDir.value | regionAccordionTooltipTextPipe : 'connectivity', iavNgIf: selectedParcellation?.hasAdditionalViewMode?.includes('connectivity'),