diff --git a/libs/shared/src/features/photo/components/photo-view/photo-view.component.html b/libs/shared/src/features/photo/components/photo-view/photo-view.component.html
index d08b4d6d..41ea288a 100644
--- a/libs/shared/src/features/photo/components/photo-view/photo-view.component.html
+++ b/libs/shared/src/features/photo/components/photo-view/photo-view.component.html
@@ -1,10 +1,25 @@
@if(uri()){
-
+
-
} @if(errorMsg()){
{{ errorMsg() }}
}
+
+
+
+
+ close
+
+
+
+ delete
+
+
+
diff --git a/libs/shared/src/features/photo/components/photo-view/photo-view.component.scss b/libs/shared/src/features/photo/components/photo-view/photo-view.component.scss
index eac3870c..f9df14d1 100644
--- a/libs/shared/src/features/photo/components/photo-view/photo-view.component.scss
+++ b/libs/shared/src/features/photo/components/photo-view/photo-view.component.scss
@@ -26,3 +26,19 @@ button.delete-button.mat-mdc-icon-button.mat-mdc-button-base {
height: 100%;
border: 1px solid var(--color-light);
}
+
+.photo-dialog {
+ position: relative;
+ width: 100%;
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+
+ img {
+ max-width: 70vw;
+ max-height: 70vh;
+ object-fit: contain;
+ }
+}
diff --git a/libs/shared/src/features/photo/components/photo-view/photo-view.component.ts b/libs/shared/src/features/photo/components/photo-view/photo-view.component.ts
index 90dc0093..0b27269d 100644
--- a/libs/shared/src/features/photo/components/photo-view/photo-view.component.ts
+++ b/libs/shared/src/features/photo/components/photo-view/photo-view.component.ts
@@ -1,5 +1,7 @@
-import { Component, effect, input, signal } from '@angular/core';
+/* eslint-disable @typescript-eslint/no-explicit-any */
+import { Component, effect, Input, signal, TemplateRef, ViewChild } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
+import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
import { PicsaDialogService } from '../../../dialog';
@@ -9,27 +11,29 @@ import { IPhotoEntry } from '../../schema';
@Component({
selector: 'picsa-photo-view',
standalone: true,
- imports: [MatButtonModule, MatIconModule],
+ imports: [MatButtonModule, MatIconModule, MatDialogModule],
templateUrl: './photo-view.component.html',
- styleUrl: './photo-view.component.scss',
+ styleUrls: ['./photo-view.component.scss'],
})
export class PhotoViewComponent {
/** Input photo document ref */
- photo = input.required();
+ @Input() photo!: IPhotoEntry;
/** Path to resource for render */
uri = signal('');
/** Error message to display */
errorMsg = signal('');
- constructor(private service: PhotoService, private dialog: PicsaDialogService) {
+ @ViewChild('dialogTemplate') dialogTemplate!: TemplateRef;
+
+ constructor(private service: PhotoService, private dialog: PicsaDialogService, public photoDialog: MatDialog) {
effect(
async (onCleanup) => {
- const photo = this.photo();
+ const photo = this.photo;
const uri = await this.service.getPhotoAttachment(photo.id);
if (uri) {
this.uri.set(uri);
} else {
- console.error('[Photo] not found', this.photo());
+ console.error('[Photo] not found', this.photo);
this.errorMsg.set(`Photo not found`);
}
onCleanup(() => {
@@ -40,11 +44,18 @@ export class PhotoViewComponent {
);
}
+ openPhotoDialog() {
+ this.photoDialog.open(this.dialogTemplate, {
+ data: { photo: this.photo, uri: this.uri() },
+ });
+ }
+
public async promptDelete() {
const dialogRef = await this.dialog.open('delete');
dialogRef.afterClosed().subscribe(async (shouldDelete) => {
if (shouldDelete) {
- await this.service.deletePhoto(this.photo().id);
+ await this.service.deletePhoto(this.photo.id);
+ this.photoDialog.closeAll();
}
});
}