diff --git a/src/ui/layerbrowser/layerbrowser.component.ts b/src/ui/layerbrowser/layerbrowser.component.ts index 174275636e8f9012221e26342070da6b246fc3ee..b144220b66e0ce2e5727436fd85244732540e8dd 100644 --- a/src/ui/layerbrowser/layerbrowser.component.ts +++ b/src/ui/layerbrowser/layerbrowser.component.ts @@ -1,7 +1,7 @@ import { Component, OnDestroy } from "@angular/core"; import { NgLayerInterface } from "../../atlasViewer/atlasViewer.component"; import { Store, select } from "@ngrx/store"; -import { ViewerStateInterface, isDefined, REMOVE_NG_LAYER, FORCE_SHOW_SEGMENT } from "../../services/stateStore.service"; +import { ViewerStateInterface, isDefined, REMOVE_NG_LAYER, FORCE_SHOW_SEGMENT, safeFilter } from "../../services/stateStore.service"; import { Subscription, Observable } from "rxjs"; import { filter, distinctUntilChanged, map, delay } from "rxjs/operators"; @@ -20,9 +20,18 @@ export class LayerBrowser implements OnDestroy{ public forceShowSegment$ : Observable<boolean|null> private subscriptions : Subscription[] = [] private disposeHandler : any + + /* TODO temporary measure. when datasetID can be used, will use */ + public fetchedDataEntries$ : Observable<any> constructor(private store : Store<ViewerStateInterface>){ + this.fetchedDataEntries$ = this.store.pipe( + select('dataStore'), + safeFilter('fetchedDataEntries'), + map(v=>v.fetchedDataEntries) + ) + this.forceShowSegment$ = this.store.pipe( select('ngViewerState'), filter(state => isDefined(state) && typeof state.forceShowSegment !== 'undefined'), @@ -124,7 +133,6 @@ export class LayerBrowser implements OnDestroy{ ${this.forceShowSegmentCurrentState === true ? 'always show' : this.forceShowSegmentCurrentState === false ? 'always hide' : 'auto'}` } - get segmentationAdditionalClass(){ return this.forceShowSegmentCurrentState === null ? 'blue' diff --git a/src/ui/layerbrowser/layerbrowser.template.html b/src/ui/layerbrowser/layerbrowser.template.html index 8518e1ffa69d9a362150b030d354d4b425ff7bb5..a1675da878dd112ca00affd97d675df4a5dfec07 100644 --- a/src/ui/layerbrowser/layerbrowser.template.html +++ b/src/ui/layerbrowser/layerbrowser.template.html @@ -42,7 +42,7 @@ [ngClass] = "{'muted-text muted' : !classVisible(ngLayer)}"> <div heading> - {{ ngLayer.name }} : {{ ngLayer.type }} + {{ ngLayer.name | getLayerNameFromDatasets : (fetchedDataEntries$ | async) }} : {{ ngLayer.type }} </div> <div body> diff --git a/src/ui/ui.module.ts b/src/ui/ui.module.ts index 126f68241632bc220e4c24b3c00ed427d28b38ef..73348dbc76cad14d8387f37ee84dbfe47e19fe03 100644 --- a/src/ui/ui.module.ts +++ b/src/ui/ui.module.ts @@ -30,6 +30,7 @@ import { LayerBrowser } from "./layerbrowser/layerbrowser.component"; import { TooltipModule } from "ngx-bootstrap/tooltip"; import { KgEntryViewer } from "./kgEntryViewer/kgentry.component"; import { SubjectViewer } from "./kgEntryViewer/subjectViewer/subjectViewer.component"; +import { GetLayerNameFromDatasets } from "../util/pipes/getLayerNamePipe.pipe"; @NgModule({ @@ -68,7 +69,7 @@ import { SubjectViewer } from "./kgEntryViewer/subjectViewer/subjectViewer.compo GetUniqueProperty, FilterDataEntriesbyType, SafeStylePipe, - + GetLayerNameFromDatasets ], entryComponents : [ diff --git a/src/util/pipes/getLayerNamePipe.pipe.ts b/src/util/pipes/getLayerNamePipe.pipe.ts new file mode 100644 index 0000000000000000000000000000000000000000..26457608432b4b15d2f66a5db20ce25fb524b545 --- /dev/null +++ b/src/util/pipes/getLayerNamePipe.pipe.ts @@ -0,0 +1,19 @@ +import { Pipe, PipeTransform } from "@angular/core"; + + +@Pipe({ + name : 'getLayerNameFromDatasets' +}) + +export class GetLayerNameFromDatasets implements PipeTransform{ + public transform(ngLayerName:string, datasets? : any[]):string{ + if(!datasets) + return ngLayerName + + const foundDataset = datasets.find(ds => ds.files.findIndex(file => file.url === ngLayerName) >= 0) + + return foundDataset + ? foundDataset.name + : ngLayerName + } +} \ No newline at end of file