diff --git a/frontend/app/gallery/cache.gallery.service.ts b/frontend/app/gallery/cache.gallery.service.ts index defbc42f..d39cb23e 100644 --- a/frontend/app/gallery/cache.gallery.service.ts +++ b/frontend/app/gallery/cache.gallery.service.ts @@ -18,6 +18,11 @@ export class GalleryCacheService { if (value != null) { let directory:Directory = JSON.parse(value); + + directory.photos.forEach((photo:Photo) => { + photo.metadata.creationDate = new Date(photo.metadata.creationDate); + }); + directory.photos.forEach((photo:Photo) => { photo.directory = directory; }); diff --git a/frontend/app/gallery/gallery.service.ts b/frontend/app/gallery/gallery.service.ts index 4ac557ed..fc371e43 100644 --- a/frontend/app/gallery/gallery.service.ts +++ b/frontend/app/gallery/gallery.service.ts @@ -39,6 +39,11 @@ export class GalleryService { return; } + + message.result.directory.photos.forEach((photo:Photo) => { + photo.metadata.creationDate = new Date(photo.metadata.creationDate); + }); + message.result.directory.photos.forEach((photo:Photo) => { photo.directory = message.result.directory; }); diff --git a/frontend/app/gallery/grid/grid.gallery.component.ts b/frontend/app/gallery/grid/grid.gallery.component.ts index dcf62e75..f66bb4dd 100644 --- a/frontend/app/gallery/grid/grid.gallery.component.ts +++ b/frontend/app/gallery/grid/grid.gallery.component.ts @@ -76,6 +76,7 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit { this.updateContainerWidth(); + this.sortPhotos(); this.clearRenderedPhotos(); setImmediate(() => { this.renderPhotos(); @@ -87,14 +88,7 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit { private sortPhotos() { //sort pohots by date this.photos.sort((a:Photo, b:Photo) => { - if (a.metadata.creationDate > b.metadata.creationDate) { - return 1; - } - if (a.metadata.creationDate < b.metadata.creationDate) { - return -1; - } - // a must be equal to b - return 0; + return a.metadata.creationDate.getTime() - b.metadata.creationDate.getTime(); }); } @@ -171,7 +165,10 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit { } public renderARow():number { - + if (this.renderedPhotoIndex + 1 >= this.photos.length) { + return 0; + } + let maxRowHeight = window.innerHeight / this.MIN_ROW_COUNT; let minRowHeight = window.innerHeight / this.MAX_ROW_COUNT; @@ -188,7 +185,6 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit { }); this.renderedPhotoIndex += photoRowBuilder.getPhotoRow().length; - console.log(this.photosToRender.length); return rowHeight; } 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 60361ab8..a824c70a 100644 --- a/frontend/app/gallery/grid/photo/photo.grid.gallery.component.html +++ b/frontend/app/gallery/grid/photo/photo.grid.gallery.component.html @@ -19,7 +19,7 @@ {{getPositionText()}} - + {{gridPhoto.photo.metadata.creationDate | date:"yy-MM-dd HH:mm:ss"}}