From 8e5df7119911623cf745b86b9a685f3baeef2b9b Mon Sep 17 00:00:00 2001 From: Daviti Gogshelidze <daviti1@mail.com> Date: Wed, 17 Jul 2019 15:08:33 +0200 Subject: [PATCH] Add external link for datasets --- deploy/datasets/query.js | 10 +++++++--- src/atlasViewer/atlasViewer.component.ts | 10 +++++++--- src/atlasViewer/atlasViewer.template.html | 12 ++++++------ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/deploy/datasets/query.js b/deploy/datasets/query.js index a99bdc807..e96e18713 100644 --- a/deploy/datasets/query.js +++ b/deploy/datasets/query.js @@ -240,7 +240,7 @@ const cachedMap = new Map() /** * TODO change to URL constructor to improve readability */ -const spatialQuery = 'https://kg.humanbrainproject.eu/query/neuroglancer/seeg/coordinate/v1.0.0/spatialWithCoordinates/instances?vocab=https%3A%2F%2Fschema.hbp.eu%2FmyQuery%2F' +const spatialQuery = 'https://kg.humanbrainproject.eu/query/neuroglancer/seeg/coordinate/v1.0.0/spatialWithCoordinatesNG/instances?vocab=https%3A%2F%2Fschema.hbp.eu%2FmyQuery%2F' const getXformFn = (templateSpace) => { const _ = {} @@ -302,10 +302,14 @@ const fetchSpatialDataFromKg = async ({ templateName, queryGeometry, queryArg, u const { voxelToNm } = getXformFn(templateName) - const _ = json.results.map(({ name, coordinates}) => { + const _ = json.results.map(({ name, coordinates, dataset}) => { return { name, templateSpace: templateName, + dataset: { + name: dataset[0].name, + externalLink: 'https://kg.humanbrainproject.eu/instances/Dataset/' + dataset[0].identifier, + }, geometry: { type: 'point', space: 'real', @@ -344,7 +348,7 @@ async function getUserKGRequestParam({ user }) { const option = accessToken || publicAccessToken ? { auth: { - 'bearer': accessToken || publicAccessToken + 'bearer': accessToken || publicAccessToken || process.env.ACCESS_TOKEN } } : {} diff --git a/src/atlasViewer/atlasViewer.component.ts b/src/atlasViewer/atlasViewer.component.ts index 5293ebc6e..3fddf7d71 100644 --- a/src/atlasViewer/atlasViewer.component.ts +++ b/src/atlasViewer/atlasViewer.component.ts @@ -79,7 +79,7 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit { public onhoverSegments$: Observable<string[]> public onhoverSegmentsForFixed$: Observable<string[]> public onhoverLandmarksForFixed$: Observable<any> - public onhoverLandmark$ : Observable<string | null> + public onhoverLandmark$ : Observable<{landmarkName: string, externalUrl: string} | null> private subscriptions: Subscription[] = [] /* handlers for nglayer */ @@ -186,7 +186,11 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit { const idx = Number(landmark.replace('label=','')) if(isNaN(idx)) return `Landmark index could not be parsed as a number: ${landmark}` - return spatialDatas[idx].name + return { + landmarkName: spatialDatas[idx].name, + externalUrl: (spatialDatas[idx].dataset + && spatialDatas[idx].dataset.externalLink)? spatialDatas[idx].dataset.externalLink : null + } }) ) @@ -482,7 +486,7 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit { openLandmarkUrl(landmark) { this.rClContextualMenu.hide() - window.open("https://www.google.com", "_blank"); + window.open(landmark.externalUrl, "_blank"); } @HostBinding('attr.version') diff --git a/src/atlasViewer/atlasViewer.template.html b/src/atlasViewer/atlasViewer.template.html index 341f86946..be75f32fb 100644 --- a/src/atlasViewer/atlasViewer.template.html +++ b/src/atlasViewer/atlasViewer.template.html @@ -151,20 +151,20 @@ <div body> <div - *ngIf="(onhoverSegmentsForFixed$ | async)?.length > 0 || (selectedRegions$ | async)?.length > 0 || (onhoverLandmarksForFixed$ | async)?.length > 0" + *ngIf="(onhoverSegmentsForFixed$ | async)?.length > 0 || (selectedRegions$ | async)?.length > 0 || (onhoverLandmarksForFixed$ | async)?.externalUrl.length > 0" class="p-2"> Search for data relating to: </div> <div *ngIf="(onhoverLandmarksForFixed$ | async) as onhoverLandmarksForFixed"> <div - *ngIf="onhoverLandmarksForFixed.length > 0" + *ngIf="onhoverLandmarksForFixed.externalUrl.length > 0" class="ws-no-wrap text-left pe-all btn btn-sm btn-secondary btn-block mt-0" data-toggle="tooltip" data-placement="top" (click)="openLandmarkUrl(onhoverLandmarksForFixed)" - [title]="onhoverLandmarksForFixed"> - Explore {{ onhoverLandmarksForFixed }} <i class="fas fa-external-link-alt"></i> + [title]="onhoverLandmarksForFixed.landmarkName"> + Explore dataset of {{ onhoverLandmarksForFixed.landmarkName }} <i class="fas fa-external-link-alt"></i> </div> </div> @@ -208,10 +208,10 @@ </panel-component> <div floatingMouseContextualContainer floatingMouseContextualContainerDirective> - <div + <div *ngIf="onhoverLandmark$ | async" contextualBlock> - {{ onhoverLandmark$ | async }} <i><small class = "mute-text">{{ toggleMessage }}</small></i> + {{ (onhoverLandmark$ | async)?.landmarkName }} <i><small class = "mute-text">{{ toggleMessage }}</small></i> </div> <div *ngIf="onhoverSegments$ | async; let onhoverSegments" -- GitLab