From b5bb7d5f63f6c7e5c97bd4046bc5690dd9fa7a02 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Wed, 13 Mar 2024 23:19:08 +0100 Subject: [PATCH] feat: New zone photo capture --- .../audit/zone-list/zone/zone.component.html | 49 +++++++++++-------- .../audit/zone-list/zone/zone.component.ts | 24 +++++---- 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/src/app/audit/zone-list/zone/zone.component.html b/src/app/audit/zone-list/zone/zone.component.html index 7d244e57..bc59e749 100644 --- a/src/app/audit/zone-list/zone/zone.component.html +++ b/src/app/audit/zone-list/zone/zone.component.html @@ -1,24 +1,31 @@ -
-
-

- - {{ zone?.zoneName | titlecase }} -

-
- Capture -
-
-

{{auditService.equipmentHeadingValue}} Progress {{auditService.completedFields}} / {{auditService.totalFields}}

-
-
{{auditService.progressPercentage}}
-
+

+ + {{ zone?.zoneName | titlecase }} +

+ +
+ + + +
+ +
+ {{ auditService.equipmentHeadingValue }} Progress: {{ auditService.completedFields }} / {{ auditService.totalFields }} +
+
+ {{ auditService.progressPercentage }}
- - -
+ + + + diff --git a/src/app/audit/zone-list/zone/zone.component.ts b/src/app/audit/zone-list/zone/zone.component.ts index b25f8e98..89029c6d 100644 --- a/src/app/audit/zone-list/zone/zone.component.ts +++ b/src/app/audit/zone-list/zone/zone.component.ts @@ -61,19 +61,17 @@ export class ZoneComponent implements OnInit { }); } - - public async captureDialog() { - let newPic: string | any; - // TODO - if (newPic) { - const formData = new FormData(); - formData.append('photo', newPic); - formData.append('auditId', this.route.snapshot.params.aid); - formData.append('zoneId', this.route.snapshot.params.zid); - this.auditService.uploadPhoto(this.route.snapshot.params.aid, formData).subscribe((res: any) => { - this.toastService.success('Success', 'Photo have been saved.') - }); + uploadPhoto(files: FileList | null) { + if (!files || !files.length) { + return; } + const {aid, zid} = this.route.snapshot.params; + const formData = new FormData(); + formData.append('auditId', aid); + formData.append('zoneId', zid); + formData.append('photo', files[0], files[0].name); + this.auditService.uploadPhoto(aid, formData).subscribe(() => { + this.toastService.success('Upload Zone Photo', `Sucessfully uploaded photo for Zone '${this.zone?.zoneName}'.`) + }); } - }