diff --git a/src/ui/databrowserModule/databrowser.service.ts b/src/ui/databrowserModule/databrowser.service.ts index af5c2b53a35289b6898d962d84b80ca1e9d94511..91bebdc587af9f035f8da69357c197531db50ead 100644 --- a/src/ui/databrowserModule/databrowser.service.ts +++ b/src/ui/databrowserModule/databrowser.service.ts @@ -369,6 +369,12 @@ export function getModalityFromDE(dataentries:DataEntry[]):CountedDataModality[] return dataentries.reduce((acc, de) => reduceDataentry(acc, de), []) } +export function getIdFromDataEntry(dataentry: DataEntry){ + const { id, fullId } = dataentry + const regex = /\/([a-zA-Z0-9\-]*?)$/.exec(fullId) + return (regex && regex[1]) || id +} + export interface CountedDataModality{ name: string diff --git a/src/ui/databrowserModule/databrowser.useEffect.ts b/src/ui/databrowserModule/databrowser.useEffect.ts index aeda75e0f6359d1688a965a6e6282e4ba7d074ea..f9a57b51905c88e841669aa192463b0947d3c6be 100644 --- a/src/ui/databrowserModule/databrowser.useEffect.ts +++ b/src/ui/databrowserModule/databrowser.useEffect.ts @@ -5,6 +5,7 @@ import { DATASETS_ACTIONS_TYPES, DataEntry } from "src/services/state/dataStore. import { Observable, of, from, merge, Subscription } from "rxjs"; import { withLatestFrom, map, catchError, filter, switchMap, scan, share, switchMapTo, shareReplay } from "rxjs/operators"; import { KgSingleDatasetService } from "./kgSingleDatasetService.service"; +import { getIdFromDataEntry } from "./databrowser.service"; @Injectable({ providedIn: 'root' @@ -73,10 +74,9 @@ export class DataBrowserUseEffect implements OnDestroy{ * * do not save anything else on localstorage. This could potentially be leaking sensitive information */ - const serialisedFavDataentries = favDataEntries.map(({ id, fullId }) => { - const regex = /\/([a-zA-Z0-9\-]*?)$/.exec(fullId) - const tempId = (regex && regex[1]) || id - return { id: tempId } + const serialisedFavDataentries = favDataEntries.map(dataentry => { + const id = getIdFromDataEntry(dataentry) + return { id } }) window.localStorage.setItem(LOCAL_STORAGE_CONST.FAV_DATASET, JSON.stringify(serialisedFavDataentries)) }) diff --git a/src/ui/nehubaContainer/nehubaContainer.component.ts b/src/ui/nehubaContainer/nehubaContainer.component.ts index 8682d740014cdf8da9cd788dc12dfa5db32bde6f..d1e7f5fa7bfb64db77e31ce90de821ef251f5240 100644 --- a/src/ui/nehubaContainer/nehubaContainer.component.ts +++ b/src/ui/nehubaContainer/nehubaContainer.component.ts @@ -15,6 +15,7 @@ import { SELECT_REGIONS_WITH_ID, NEHUBA_LAYER_CHANGED } from "src/services/state import { MatBottomSheet, MatButton } from "@angular/material"; import { DATASETS_ACTIONS_TYPES } from "src/services/state/dataStore.store"; import { KgSingleDatasetService } from "../databrowserModule/kgSingleDatasetService.service"; +import { getIdFromDataEntry } from "../databrowserModule/databrowser.service"; const getProxyUrl = (ngUrl) => `nifti://${BACKEND_URL}preview/file?fileUrl=${encodeURIComponent(ngUrl.replace(/^nifti:\/\//,''))}` const getProxyOther = ({source}) => /AUTH_227176556f3c4bb38df9feea4b91200c/.test(source) @@ -1175,7 +1176,8 @@ export class NehubaContainer implements OnInit, OnDestroy{ downloadDs(event: MouseEvent, ds: DataEntry, downloadBtn: MatButton){ downloadBtn.disabled = true - this.kgSingleDataset.downloadZipFromKg({kgId: ds.id}) + const id = getIdFromDataEntry(ds) + this.kgSingleDataset.downloadZipFromKg({kgId: id}) .finally(() => downloadBtn.disabled = false) } }