From 029dd68e5c1e728a7add12871fe941a6a585371b Mon Sep 17 00:00:00 2001 From: Braun Patrik Date: Sun, 16 Jul 2017 17:15:42 +0200 Subject: [PATCH] fixing infobar keyword error --- backend/model/threading/DiskMangerWorker.ts | 26 ++++++++++++++----- .../photo/photo.grid.gallery.component.html | 4 +-- .../photo/photo.grid.gallery.component.ts | 14 ++++++++-- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/backend/model/threading/DiskMangerWorker.ts b/backend/model/threading/DiskMangerWorker.ts index 1af8f6d3..9b692809 100644 --- a/backend/model/threading/DiskMangerWorker.ts +++ b/backend/model/threading/DiskMangerWorker.ts @@ -33,7 +33,7 @@ export class DiskMangerWorker { return reject({file: fullPath, error: err}); } const metadata: PhotoMetadata = { - keywords: {}, + keywords: [], cameraData: {}, positionData: null, size: {}, @@ -51,6 +51,7 @@ export class DiskMangerWorker { try { const exif = exif_parser.create(data).parse(); + console.log(exif); metadata.cameraData = { ISO: exif.tags.ISO, model: exif.tags.Model, @@ -69,9 +70,20 @@ export class DiskMangerWorker { }; } - metadata.size = {width: exif.imageSize.width, height: exif.imageSize.height}; + if (exif.tags.CreateDate || exif.tags.DateTimeOriginal || exif.tags.ModifyDate) { + metadata.creationDate = exif.tags.CreateDate || exif.tags.DateTimeOriginal || exif.tags.ModifyDate; + } + + + if (exif.imageSize) { + metadata.size = {width: exif.imageSize.width, height: exif.imageSize.height}; + } else if (exif.tags.RelatedImageWidth && exif.tags.RelatedImageHeight) { + metadata.size = {width: exif.tags.RelatedImageWidth, height: exif.tags.RelatedImageHeight}; + } else { + metadata.size = {width: 1, height: 1}; + } } catch (err) { - Logger.info(LOG_TAG, "Error parsing exif", fullPath); + Logger.debug(LOG_TAG, "Error parsing exif", fullPath, err); metadata.size = {width: 1, height: 1}; } @@ -83,13 +95,15 @@ export class DiskMangerWorker { metadata.positionData.state = iptcData.province_or_state; metadata.positionData.city = iptcData.city; } - metadata.keywords = (iptcData.keywords || []); - metadata.creationDate = (iptcData.date_time ? iptcData.date_time.getTime() : 0); + metadata.creationDate = (iptcData.date_time ? iptcData.date_time.getTime() : metadata.creationDate); + } catch (err) { - Logger.info(LOG_TAG, "Error parsing iptc data", fullPath, err); + Logger.debug(LOG_TAG, "Error parsing iptc data", fullPath, err); } + metadata.creationDate = metadata.creationDate || 0; + return resolve(metadata); } catch (err) { return reject({file: fullPath, error: err}); diff --git a/frontend/app/gallery/grid/photo/photo.grid.gallery.component.html b/frontend/app/gallery/grid/photo/photo.grid.gallery.component.html index c6657868..1851376c 100644 --- a/frontend/app/gallery/grid/photo/photo.grid.gallery.component.html +++ b/frontend/app/gallery/grid/photo/photo.grid.gallery.component.html @@ -1,4 +1,4 @@ -
+
-
+
#{{keyword}} diff --git a/frontend/app/gallery/grid/photo/photo.grid.gallery.component.ts b/frontend/app/gallery/grid/photo/photo.grid.gallery.component.ts index 9ac82b07..4ce8f775 100644 --- a/frontend/app/gallery/grid/photo/photo.grid.gallery.component.ts +++ b/frontend/app/gallery/grid/photo/photo.grid.gallery.component.ts @@ -86,14 +86,24 @@ export class GalleryPhotoComponent implements IRenderable, OnInit, OnDestroy { } - hover() { + mouseOver() { this.infoBar.visible = true; if (this.animationTimer != null) { clearTimeout(this.animationTimer); } this.animationTimer = setTimeout(() => { - this.infoBar.marginTop = -this.infoDiv.nativeElement.clientHeight; this.infoBar.background = "rgba(0,0,0,0.8)"; + + if (!this.infoDiv) { + this.animationTimer = setTimeout(() => { + if (!this.infoDiv) { + this.infoBar.marginTop = -50; + return; + } + this.infoBar.marginTop = -this.infoDiv.nativeElement.clientHeight; + }, 10); + return; + } }, 1); }