From a93688aed5fad3a34e3a878b0e2c3cc8bbffaccc Mon Sep 17 00:00:00 2001 From: fsdavid <daviti1@mail.com> Date: Tue, 22 Jun 2021 18:27:27 +0200 Subject: [PATCH] Fix connectivity issue --- common/util.js | 9 ++++++++- .../connectivityBrowser/connectivityBrowser.component.ts | 6 ++++-- .../connectivity/hasConnectivity.directive.ts | 8 +++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/common/util.js b/common/util.js index 6b6df94eb..42a5fe25c 100644 --- a/common/util.js +++ b/common/util.js @@ -72,6 +72,13 @@ exports.getIdObj = getIdObj + exports.getIdFromKgIdObj = kg => { + if(kg.kgId && kg.kgSchema) { + return `${kg.kgSchema}/${kg.kgId}` + } + return null + } + exports.getIdFromFullId = fullId => { const idObj = getIdObj(fullId) if (!idObj) return null @@ -117,7 +124,7 @@ await (() => new Promise(rs => setTimeout(rs, timeout)))() } } - + throw new Error(`fn failed ${retries} times. Aborting.`) } const flattenRegions = regions => regions.concat( diff --git a/src/atlasComponents/connectivity/connectivityBrowser/connectivityBrowser.component.ts b/src/atlasComponents/connectivity/connectivityBrowser/connectivityBrowser.component.ts index bb1854080..fa717adca 100644 --- a/src/atlasComponents/connectivity/connectivityBrowser/connectivityBrowser.component.ts +++ b/src/atlasComponents/connectivity/connectivityBrowser/connectivityBrowser.component.ts @@ -21,6 +21,8 @@ import { } from "src/services/state/viewerState/selectors"; import {HttpClient} from "@angular/common/http"; import {BS_ENDPOINT} from "src/util/constants"; +import {getIdFromKgIdObj} from "common/util"; + const CONNECTIVITY_NAME_PLATE = 'Connectivity' @@ -100,7 +102,7 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe } this.regionName = newRegionName - this.regionId = `${val.id.kg.kgSchema}/${val.id.kg.kgId}` + this.regionId = val.id? val.id.kg? getIdFromKgIdObj(val.id.kg) : val.id : null this.atlasId = val.context.atlas['@id'] this.parcellationId = val.context.parcellation['@id'] @@ -151,7 +153,7 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe public fullConnectivityLoadUrl: string ngOnInit(): void { - this.connectivityUrl = `${this.siibraApiUrl}/atlases/${encodeURIComponent(this.atlasId)}/parcellations/${encodeURIComponent(this.parcellationId)}/regions/${encodeURIComponent(this.regionId)}/features/ConnectivityProfile` + this.connectivityUrl = `${this.siibraApiUrl}/atlases/${encodeURIComponent(this.atlasId)}/parcellations/${encodeURIComponent(this.parcellationId)}/regions/${encodeURIComponent(this.regionId || this.regionName)}/features/ConnectivityProfile` this.httpClient.get<[]>(this.connectivityUrl).subscribe(res => { this.datasetList = res diff --git a/src/atlasComponents/connectivity/hasConnectivity.directive.ts b/src/atlasComponents/connectivity/hasConnectivity.directive.ts index 83731fc5d..c547b715a 100644 --- a/src/atlasComponents/connectivity/hasConnectivity.directive.ts +++ b/src/atlasComponents/connectivity/hasConnectivity.directive.ts @@ -3,6 +3,7 @@ import {of, Subscription} from "rxjs"; import {switchMap} from "rxjs/operators"; import {BS_ENDPOINT} from "src/util/constants"; import {HttpClient} from "@angular/common/http"; +import {getIdFromKgIdObj} from "common/util"; @Directive({ selector: '[has-connectivity]', @@ -27,10 +28,11 @@ export class HasConnectivity implements OnInit, OnDestroy { checkConnectivity(region) { const {atlas, parcellation, template} = region.context - if (region.id && region.id.kg) { - const regionId = `${region.id.kg.kgSchema}/${region.id.kg.kgId}` + if (region.id || region.name) { + const regionId = region.id? region.id.kg? getIdFromKgIdObj(region.id.kg) + : region.id : null - const connectivityUrl = `${this.siibraApiUrl}/atlases/${encodeURIComponent(atlas['@id'])}/parcellations/${encodeURIComponent(parcellation['@id'])}/regions/${encodeURIComponent(regionId)}/features/ConnectivityProfile` + const connectivityUrl = `${this.siibraApiUrl}/atlases/${encodeURIComponent(atlas['@id'])}/parcellations/${encodeURIComponent(parcellation['@id'])}/regions/${encodeURIComponent(regionId || region.name)}/features/ConnectivityProfile` this.subscriptions.push( this.httpClient.get<[]>(connectivityUrl).pipe(switchMap((res: any[]) => { -- GitLab