From e21e67cfc779a72b2463a237c4748f1435327f9d Mon Sep 17 00:00:00 2001 From: grasdk <115414609+grasdk@users.noreply.github.com> Date: Fri, 8 Mar 2024 00:01:23 +0100 Subject: [PATCH] Feature/location info (#9) * Show comma-separated city, state and country in infobox and in gallery mode. All of the values that are non-empty will be shown. * methodcall to isPhoto * Unit test and bugfix for CreationDate (#8) * fixed the DiskManagerWorker test * s (#10) * Unit test and bugfix for CreationDate (#8) * fixed the DiskManagerWorker test --------- Co-authored-by: Patrik J. Braun * s (#11) * Unit test and bugfix for CreationDate (#8) * fixed the DiskManagerWorker test --------- Co-authored-by: Patrik J. Braun * 9ij (#12) * Unit test and bugfix for CreationDate (#8) * fixed the DiskManagerWorker test --------- Co-authored-by: Patrik J. Braun --------- Co-authored-by: Patrik J. Braun --- .../grid/photo/photo.grid.gallery.component.ts | 4 ++-- .../controls.lightbox.gallery.component.ts | 13 ++++++++----- .../info-panel.lightbox.gallery.component.ts | 16 +++++----------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/frontend/app/ui/gallery/grid/photo/photo.grid.gallery.component.ts b/src/frontend/app/ui/gallery/grid/photo/photo.grid.gallery.component.ts index ce3716e0..ad69badb 100644 --- a/src/frontend/app/ui/gallery/grid/photo/photo.grid.gallery.component.ts +++ b/src/frontend/app/ui/gallery/grid/photo/photo.grid.gallery.component.ts @@ -134,10 +134,10 @@ export class GalleryPhotoComponent implements IRenderable, OnInit, OnDestroy { } getPositionText(): string { - if (!this.gridMedia || !this.gridMedia.isPhoto()) { + if (!this.gridMedia || !this.gridMedia.isPhoto() || !(this.gridMedia.media as PhotoDTO).metadata.positionData) { return ''; } - return ( + return ( //not much space in the gridview, so we only deliver city, or state or country (this.gridMedia.media as PhotoDTO).metadata.positionData.city || (this.gridMedia.media as PhotoDTO).metadata.positionData.state || (this.gridMedia.media as PhotoDTO).metadata.positionData.country || '' diff --git a/src/frontend/app/ui/gallery/lightbox/controls/controls.lightbox.gallery.component.ts b/src/frontend/app/ui/gallery/lightbox/controls/controls.lightbox.gallery.component.ts index 5638adc1..71c211ad 100644 --- a/src/frontend/app/ui/gallery/lightbox/controls/controls.lightbox.gallery.component.ts +++ b/src/frontend/app/ui/gallery/lightbox/controls/controls.lightbox.gallery.component.ts @@ -510,11 +510,14 @@ export class ControlsLightboxComponent implements OnDestroy, OnInit, OnChanges { case LightBoxTitleTexts.date: return this.datePipe.transform(m.metadata.creationDate, 'longDate', m.metadata.creationDateOffset); case LightBoxTitleTexts.location: - return ( - m.metadata.positionData?.city || - m.metadata.positionData?.state || - m.metadata.positionData?.country || '' - ).trim(); + if (!m.metadata.positionData) { + return ''; + } + return [ + m.metadata.positionData.city, + m.metadata.positionData.state, + m.metadata.positionData.country + ].filter(elm => elm).join(', ').trim(); //Filter removes empty elements, join concats the values separated by ', ' case LightBoxTitleTexts.camera: return m.metadata.cameraData?.model; case LightBoxTitleTexts.lens: diff --git a/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.ts b/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.ts index 542cc42f..fea2eb85 100644 --- a/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.ts +++ b/src/frontend/app/ui/gallery/lightbox/infopanel/info-panel.lightbox.gallery.component.ts @@ -183,17 +183,11 @@ export class InfoPanelLightboxComponent implements OnInit, OnChanges { if (!(this.media as PhotoDTO).metadata.positionData) { return ''; } - let str = - (this.media as PhotoDTO).metadata.positionData.city || - (this.media as PhotoDTO).metadata.positionData.state || - ''; - - if (str.length !== 0) { - str += ', '; - } - str += (this.media as PhotoDTO).metadata.positionData.country || ''; - - return str; + return [ + (this.media as PhotoDTO).metadata.positionData.city, + (this.media as PhotoDTO).metadata.positionData.state, + (this.media as PhotoDTO).metadata.positionData.country + ].filter(elm => elm).join(', ').trim(); //Filter removes empty elements, join concats the values separated by ', ' } close(): void {