diff --git a/src/app/components/gallery/gallery.component.html b/src/app/components/gallery/gallery.component.html new file mode 100644 index 0000000..1bfca86 --- /dev/null +++ b/src/app/components/gallery/gallery.component.html @@ -0,0 +1,26 @@ +@if (!modal) { +
+
+ @for (p of proofs(); track p) { + + } +
+
+} @else { +
+ + + + +
+} \ No newline at end of file diff --git a/src/app/components/gallery/gallery.component.scss b/src/app/components/gallery/gallery.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/components/gallery/gallery.component.ts b/src/app/components/gallery/gallery.component.ts new file mode 100644 index 0000000..7e84f91 --- /dev/null +++ b/src/app/components/gallery/gallery.component.ts @@ -0,0 +1,69 @@ +import {Component, inject, OnInit, signal} from '@angular/core'; +import {IonicModule, LoadingController, ToastController} from "@ionic/angular"; +import {GetUserProofDto, UsersService} from "../../services/api"; +import {firstValueFrom} from "rxjs"; +import {addIcons} from "ionicons"; +import {closeCircleOutline} from "ionicons/icons"; + +addIcons({ + 'close-circle-outline': closeCircleOutline +}) + +@Component({ + selector: 'app-gallery', + templateUrl: './gallery.component.html', + styleUrls: ['./gallery.component.scss'], + imports: [ + IonicModule + ] +}) +export class GalleryComponent implements OnInit { + private loadCtrl = inject(LoadingController); + private usersService = inject(UsersService); + private toastCtrl = inject(ToastController); + + proofs = signal([]); + selectedProof = signal(""); + + modal = false; + + async ngOnInit() { + const loading = await this.loadCtrl.create({ + message: 'Chargement...', + spinner: 'lines-sharp-small' + }); + await loading.present(); + + try { + const proofs = await firstValueFrom(this.usersService.getAllUserProofsEndpoint()); + this.proofs.set(proofs); + + await loading.dismiss(); + } catch { + const toast = await this.toastCtrl.create({ + message: 'Impossible de charger la galerie photos', + duration: 2000, + color: 'danger' + }); + await loading.dismiss(); + await toast.present(); + } + } + + async openProof(proof: string) { + const loading = await this.loadCtrl.create({ + message: 'Chargement...', + spinner: 'lines-sharp-small' + }); + await loading.present(); + + this.selectedProof.set(proof); + this.modal = true; + + await loading.dismiss(); + } + + closeProof() { + this.modal = false; + } +} diff --git a/src/app/pages/home/home.component.html b/src/app/pages/home/home.component.html index a0a5339..cd5bea9 100644 --- a/src/app/pages/home/home.component.html +++ b/src/app/pages/home/home.component.html @@ -109,9 +109,7 @@ } @case ('gallery') { -
-

Photos

-
+
} } diff --git a/src/app/pages/home/home.component.ts b/src/app/pages/home/home.component.ts index 8bf7cf7..b3441c3 100644 --- a/src/app/pages/home/home.component.ts +++ b/src/app/pages/home/home.component.ts @@ -24,6 +24,7 @@ import {ModalComponent} from "../../components/modal/modal.component"; import {ProfilFormComponent} from "../../components/profil-form/profil-form.component"; import {PasswordFormComponent} from "../../components/password-form/password-form.component"; import {DesignationFormComponent} from "../../components/designation-form/designation-form.component"; +import {GalleryComponent} from "../../components/gallery/gallery.component"; addIcons({ 'profile': personOutline, @@ -49,7 +50,8 @@ type View = 'menu' | 'profile' | 'password' | 'designation' | 'gallery'; ProfilFormComponent, PasswordFormComponent, PasswordFormComponent, - DesignationFormComponent + DesignationFormComponent, + GalleryComponent ] }) export class HomeComponent implements OnInit { diff --git a/src/app/services/api/model/get-user-proof-dto.ts b/src/app/services/api/model/get-user-proof-dto.ts index ebeca93..6be7733 100644 --- a/src/app/services/api/model/get-user-proof-dto.ts +++ b/src/app/services/api/model/get-user-proof-dto.ts @@ -10,7 +10,6 @@ export interface GetUserProofDto { - id?: number; proof?: string | null; }