From 099b3793fd7ebacef1555ab61060d8e8c99df519 Mon Sep 17 00:00:00 2001 From: Xiao Gui <xgui3783@gmail.com> Date: Wed, 5 Sep 2018 14:58:19 +0200 Subject: [PATCH] additional layers potentially more informative --- src/ui/layerbrowser/layerbrowser.component.ts | 12 ++++++++++-- .../layerbrowser/layerbrowser.template.html | 2 +- src/ui/ui.module.ts | 3 ++- src/util/pipes/getLayerNamePipe.pipe.ts | 19 +++++++++++++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 src/util/pipes/getLayerNamePipe.pipe.ts diff --git a/src/ui/layerbrowser/layerbrowser.component.ts b/src/ui/layerbrowser/layerbrowser.component.ts index 174275636..b144220b6 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 8518e1ffa..a1675da87 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 126f68241..73348dbc7 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 000000000..264576084 --- /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 -- GitLab