From 7be7c75db0dd41ec1c47f88d1b51e339ad0504e8 Mon Sep 17 00:00:00 2001 From: Daviti Gogshelidze <daviti1@mail.com> Date: Thu, 2 Mar 2023 17:22:34 +0100 Subject: [PATCH] fix lint and navigate --- .../region/rich/region.rich.template.html | 1 + src/features/category-acc.directive.ts | 2 - .../connectivityBrowser.component.ts | 53 +++++++++++-------- .../connectivityBrowser.template.html | 4 +- src/features/entry/entry.component.html | 1 + src/features/fetch.directive.ts | 2 +- .../layerCtrl.service/layerCtrl.effects.ts | 4 +- 7 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/atlasComponents/sapiViews/core/region/region/rich/region.rich.template.html b/src/atlasComponents/sapiViews/core/region/region/rich/region.rich.template.html index c3acb2dfb..a8814bb6a 100644 --- a/src/atlasComponents/sapiViews/core/region/region/rich/region.rich.template.html +++ b/src/atlasComponents/sapiViews/core/region/region/rich/region.rich.template.html @@ -83,6 +83,7 @@ </ng-template> <sxplr-feature-entry + [template]="template" [parcellation]="parcellation" [region]="region"> </sxplr-feature-entry> diff --git a/src/features/category-acc.directive.ts b/src/features/category-acc.directive.ts index b998efb0a..d578d36da 100644 --- a/src/features/category-acc.directive.ts +++ b/src/features/category-acc.directive.ts @@ -9,8 +9,6 @@ import { ListComponent } from './list/list.component'; }) export class CategoryAccDirective implements AfterContentInit, OnDestroy { - constructor() { } - public isBusy$ = new BehaviorSubject<boolean>(false) public total$ = new BehaviorSubject<number>(0) diff --git a/src/features/connectivity/connectivityBrowser/connectivityBrowser.component.ts b/src/features/connectivity/connectivityBrowser/connectivityBrowser.component.ts index 5b90b1c2c..9ad528f32 100644 --- a/src/features/connectivity/connectivityBrowser/connectivityBrowser.component.ts +++ b/src/features/connectivity/connectivityBrowser/connectivityBrowser.component.ts @@ -1,15 +1,16 @@ import {AfterViewInit, Component, ElementRef, OnDestroy, ViewChild, Input, ChangeDetectorRef} from "@angular/core"; import {select, Store} from "@ngrx/store"; import {fromEvent, Subscription, BehaviorSubject, Observable} from "rxjs"; -import {catchError, take} from "rxjs/operators"; +import {catchError, take, switchMap} from "rxjs/operators"; import { atlasAppearance } from "src/state"; import {SAPI} from "src/atlasComponents/sapi/sapi.service"; import { of } from "rxjs"; import {CustomLayer} from "src/state/atlasAppearance"; import { HttpClient } from "@angular/common/http"; -import { SxplrAtlas, SxplrParcellation, SxplrRegion } from "src/atlasComponents/sapi/sxplrTypes"; +import { SxplrAtlas, SxplrParcellation, SxplrRegion, SxplrTemplate } from "src/atlasComponents/sapi/sxplrTypes"; import { actions, selectors } from "src/state/atlasSelection"; +import { translateV3Entities } from "src/atlasComponents/sapi/translateV3"; @Component({ selector: 'sxplr-features-connectivity-browser', @@ -22,6 +23,9 @@ export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy { @Input('sxplr-features-connectivity-browser-atlas') atlas: SxplrAtlas + @Input('sxplr-features-connectivity-browser-template') + template: SxplrTemplate + @Input('sxplr-features-connectivity-browser-parcellation') parcellation: SxplrParcellation @@ -122,6 +126,7 @@ export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy { private store$: Store, private http: HttpClient, private changeDetectionRef: ChangeDetectorRef, + protected sapi: SAPI ) { SAPI.BsEndpoint$.pipe(take(1)).subscribe(en => this.endpoint = `${en}/feature/RegionalConnectivity`) } @@ -142,17 +147,9 @@ export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy { ) this.subscriptions.push( - fromEvent(this.connectivityComponentElement.nativeElement, 'customToolEvent', {capture: true}) - .subscribe((e: CustomEvent) => { - if (e.detail.name === 'export csv') { - // ToDo Fix in future to use component - const a = document.querySelector('hbp-connectivity-matrix-row'); - (a as any).downloadCSV() - } - }), fromEvent(this.connectivityComponentElement.nativeElement, 'connectedRegionClicked', {capture: true}) .subscribe((e: CustomEvent) => { - this.navigateToRegion(this.getRegionWithName(e.detail.name)) + this.navigateToRegion(e.detail.name) }), ) } @@ -318,18 +315,28 @@ export class ConnectivityBrowserComponent implements AfterViewInit, OnDestroy { this.setCustomLayer() } - //ToDo bestViewPoint is null for the most cases - navigateToRegion(region: SxplrRegion) { - const regionCentroid = region.centroid - if (regionCentroid) - this.store$.dispatch( - actions.navigateTo({ - navigation: { - position: regionCentroid.loc.map(v => v*1e6), - }, - animation: true - }) - ) + navigateToRegion(regionName: string) { + this.sapi.v3Get("/regions/{region_id}", { + path: {region_id: regionName}, + query: { + parcellation_id: this.parcellation.id, + space_id: this.template.id + } + }).pipe( + switchMap(r => translateV3Entities.translateRegion(r)) + ).subscribe(region => { + const centroid = region.centroid?.loc + if (centroid) { + this.store$.dispatch( + actions.navigateTo({ + navigation: { + position: centroid.map(v => v*1e6), + }, + animation: true + }) + ) + } + }) } getRegionWithName(region: string) { diff --git a/src/features/connectivity/connectivityBrowser/connectivityBrowser.template.html b/src/features/connectivity/connectivityBrowser/connectivityBrowser.template.html index 56847f3c9..87e51584a 100644 --- a/src/features/connectivity/connectivityBrowser/connectivityBrowser.template.html +++ b/src/features/connectivity/connectivityBrowser/connectivityBrowser.template.html @@ -84,8 +84,8 @@ </div> <hbp-connectivity-matrix-row #connectivityComponent - [style.visibility]="selectedCohort && (selectedSubjectIndex >= 0 || !averageDisabled)? 'visible' : 'hidden'" - *ngIf="regionName && !fetching && !noConnectivityForRegion" + [style.visibility]="regionName && !fetching && !noConnectivityForRegion && selectedCohort + && (selectedSubjectIndex >= 0 || !averageDisabled)? 'visible' : 'hidden'" [region]="regionName" [connections]="connectionsString" show-export="true" hide-export-view="true" theme="dark"> diff --git a/src/features/entry/entry.component.html b/src/features/entry/entry.component.html index a6355b145..97802ff5f 100644 --- a/src/features/entry/entry.component.html +++ b/src/features/entry/entry.component.html @@ -65,6 +65,7 @@ <sxplr-features-connectivity-browser class="pe-all flex-shrink-1" [region]="region" [sxplr-features-connectivity-browser-atlas]="atlas | async" + [sxplr-features-connectivity-browser-template]="template" [sxplr-features-connectivity-browser-parcellation]="parcellation" [accordionExpanded]="connectivityAccordion.expanded" [types]="connectivity[0].value"> diff --git a/src/features/fetch.directive.ts b/src/features/fetch.directive.ts index eb40e4fd0..d020b3caf 100644 --- a/src/features/fetch.directive.ts +++ b/src/features/fetch.directive.ts @@ -6,7 +6,7 @@ import { SxplrParcellation, SxplrRegion, SxplrTemplate } from 'src/atlasComponen import { FeatureType, SapiRoute } from 'src/atlasComponents/sapi/typeV3'; import { Feature, CorticalFeature, VoiFeature, TabularFeature } from "src/atlasComponents/sapi/sxplrTypes" -type ObservableOf<Obs extends Observable<unknown>> = Parameters<Obs['subscribe']>[0] extends Function +type ObservableOf<Obs extends Observable<unknown>> = Parameters<Obs['subscribe']>[0] extends () => void ? Parameters<Parameters<Obs['subscribe']>[0]>[0] : never diff --git a/src/viewerModule/nehuba/layerCtrl.service/layerCtrl.effects.ts b/src/viewerModule/nehuba/layerCtrl.service/layerCtrl.effects.ts index 39ddf875d..a12d8fcfd 100644 --- a/src/viewerModule/nehuba/layerCtrl.service/layerCtrl.effects.ts +++ b/src/viewerModule/nehuba/layerCtrl.service/layerCtrl.effects.ts @@ -26,9 +26,9 @@ export class LayerCtrlEffects { * TODO implement */ throw new Error(`IMPLEMENT ME`) - for (const volumeFormat in volumeModel.providedVolumes) { + // for (const volumeFormat in volumeModel.providedVolumes) { - } + // } return [] } -- GitLab