diff --git a/backend/middlewares/GalleryMWs.ts b/backend/middlewares/GalleryMWs.ts index 1014cb51..9ec1b2a0 100644 --- a/backend/middlewares/GalleryMWs.ts +++ b/backend/middlewares/GalleryMWs.ts @@ -52,6 +52,11 @@ export class GalleryMWs { return next(); } + //check if thumbnail already exist + if (fs.existsSync(fullImagePath) === false) { + return next(new Error(ErrorCodes.GENERAL_ERROR, "no such file :" + fullImagePath)); + } + req.resultPipe = fullImagePath; return next(); } diff --git a/backend/routes/GalleryRouter.ts b/backend/routes/GalleryRouter.ts index 245f4eb1..2124463e 100644 --- a/backend/routes/GalleryRouter.ts +++ b/backend/routes/GalleryRouter.ts @@ -19,7 +19,7 @@ export class GalleryRouter { private addDirectoryList() { this.app.get(["/api/gallery/content/:directory(*)", "/api/gallery/", "/api/gallery//"], - // AuthenticationMWs.authenticate, + AuthenticationMWs.authenticate, GalleryMWs.listDirectory, RenderingMWs.renderResult ); diff --git a/frontend/app/gallery/lightbox/lightbox.gallery.component.css b/frontend/app/gallery/lightbox/lightbox.gallery.component.css index aeee981d..1951514e 100644 --- a/frontend/app/gallery/lightbox/lightbox.gallery.component.css +++ b/frontend/app/gallery/lightbox/lightbox.gallery.component.css @@ -21,12 +21,42 @@ height: 100%; /* Full height */ background-color: black; } -img { - width: 100%; - height: 100%; + +.imgContainer img { + position: absolute; } .imgContainer{ justify-content: center; /* add to align horizontal */ align-items: center; /* add to align vertical */ +} +.navigation-arrow { + font-size: x-large; + width: 50%; + height: 100%; + position: static; + display: inline-block; + padding: 15px; + color: white; + opacity: 0.4; +} + +.navigation-arrow span { + top: 50%; +} + +.navigation-arrow:hover { + opacity: 1.0; +} + +#navigation-arrow-container { + width: 100%; + height: 100%; + left: 0; + position: fixed;; +} + +#rightArrow { + float: right; + text-align: right; } \ No newline at end of file diff --git a/frontend/app/gallery/lightbox/lightbox.gallery.component.html b/frontend/app/gallery/lightbox/lightbox.gallery.component.html index 6b5fb033..f835573d 100644 --- a/frontend/app/gallery/lightbox/lightbox.gallery.component.html +++ b/frontend/app/gallery/lightbox/lightbox.gallery.component.html @@ -1,15 +1,27 @@
-
+> +
- -
+ +
diff --git a/frontend/app/gallery/lightbox/lightbox.gallery.component.ts b/frontend/app/gallery/lightbox/lightbox.gallery.component.ts index 6d8cb96e..ca710dc2 100644 --- a/frontend/app/gallery/lightbox/lightbox.gallery.component.ts +++ b/frontend/app/gallery/lightbox/lightbox.gallery.component.ts @@ -16,9 +16,10 @@ export class GalleryLightboxComponent { @ViewChild('lightbox') lightBoxDiv:ElementRef; @ViewChild('blackCanvas') blackCanvasDiv:ElementRef; - @ViewChild('thImage') thIMageImg:ElementRef; - @ViewChild('image') imageImg:ElementRef; + @ViewChild('imgContainer') imgContainer:ElementRef; + + public imageSize = {width: "auto", height: "100"}; private activePhoto:GalleryPhotoComponent = null; public gridPhotoQL:QueryList; @@ -31,6 +32,54 @@ export class GalleryLightboxComponent { } + public nextImage() { + + let pcList = this.gridPhotoQL.toArray(); + for (let i = 0; i < pcList.length; i++) { + if (pcList[i] === this.activePhoto && i + 1 < pcList.length) { + this.activePhoto = pcList[i + 1]; + + let toImage = this.calcLightBoxPhotoDimension(this.activePhoto.gridPhoto.photo).toStyle(); + + this.forceAnimateFrom(toImage, + {}, + this.imgContainer.nativeElement); + + + this.setImageSize(); + return; + } + } + } + + public prevImage() { + let pcList = this.gridPhotoQL.toArray(); + for (let i = 0; i < pcList.length; i++) { + if (pcList[i] === this.activePhoto && i > 0) { + this.activePhoto = pcList[i - 1]; + + let toImage = this.calcLightBoxPhotoDimension(this.activePhoto.gridPhoto.photo).toStyle(); + + this.forceAnimateFrom(toImage, + {}, + this.imgContainer.nativeElement); + + this.setImageSize(); + return; + } + } + } + + private setImageSize() { + if (this.activePhoto.gridPhoto.photo.metadata.size.height > this.activePhoto.gridPhoto.photo.metadata.size.width) { + this.imageSize.height = "100"; + this.imageSize.width = null; + } else { + this.imageSize.height = null; + this.imageSize.width = "100"; + } + } + public show(photo:Photo) { let selectedPhoto = this.findPhotoComponenet(photo); if (selectedPhoto === null) { @@ -39,6 +88,7 @@ export class GalleryLightboxComponent { this.dom.setStyle(this.dom.query('body'), 'overflow', 'hidden'); this.activePhoto = selectedPhoto; + this.setImageSize(); let from = this.activePhoto.getDimension(); @@ -50,11 +100,7 @@ export class GalleryLightboxComponent { this.forceAnimateFrom(fromImage, toImage, - this.thIMageImg.nativeElement); - - this.forceAnimateFrom(fromImage, - toImage, - this.imageImg.nativeElement); + this.imgContainer.nativeElement); this.forceAnimateFrom(from.toStyle(), {height: "100%", width: "100%", "top": "0px", "left": "0px"}, @@ -94,11 +140,8 @@ export class GalleryLightboxComponent { this.forceAnimateTo(fromImage, toImage, - this.thIMageImg.nativeElement); - - this.forceAnimateTo(fromImage, - toImage, - this.imageImg.nativeElement); + this.imgContainer.nativeElement); + }