Skip to content
Snippets Groups Projects
Commit 8e5df711 authored by Daviti Gogshelidze's avatar Daviti Gogshelidze
Browse files

Add external link for datasets

parent 10f06b32
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
}
: {}
......
......@@ -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')
......
......@@ -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"
......
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