From a27bd723d8f13abd96fb7bca873b983c2881aee3 Mon Sep 17 00:00:00 2001 From: Ralph Hopman Date: Fri, 25 Oct 2024 10:02:06 +0200 Subject: [PATCH] fix: Client signature The functionality to store and show client signatures was broken. --- .../view-signature-dialog.component.html | 2 +- .../view-signature-dialog.component.ts | 8 ++++++-- src/app/clients/clients.service.ts | 8 ++++---- src/tsconfig.app.json | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/app/clients/clients-view/custom-dialogs/view-signature-dialog/view-signature-dialog.component.html b/src/app/clients/clients-view/custom-dialogs/view-signature-dialog/view-signature-dialog.component.html index 9ff6d0f84..d0b595311 100644 --- a/src/app/clients/clients-view/custom-dialogs/view-signature-dialog/view-signature-dialog.component.html +++ b/src/app/clients/clients-view/custom-dialogs/view-signature-dialog/view-signature-dialog.component.html @@ -11,5 +11,5 @@

{{"labels.heading.View Client Signature" | translate}}

- + diff --git a/src/app/clients/clients-view/custom-dialogs/view-signature-dialog/view-signature-dialog.component.ts b/src/app/clients/clients-view/custom-dialogs/view-signature-dialog/view-signature-dialog.component.ts index 9f92c46f6..f021ec23c 100644 --- a/src/app/clients/clients-view/custom-dialogs/view-signature-dialog/view-signature-dialog.component.ts +++ b/src/app/clients/clients-view/custom-dialogs/view-signature-dialog/view-signature-dialog.component.ts @@ -6,6 +6,9 @@ import { DomSanitizer } from '@angular/platform-browser'; /** Custom Services */ import { ClientsService } from 'app/clients/clients.service'; +/** Node Types */ +import { Buffer } from 'buffer'; + /** * View signature dialog component. */ @@ -39,8 +42,9 @@ export class ViewSignatureDialogComponent implements OnInit { ngOnInit() { if (this.signatureId) { this.clientsService.getClientSignatureImage(this.clientId, this.signatureId).subscribe( - (base64Image: any) => { - this.signatureImage = this.sanitizer.bypassSecurityTrustResourceUrl(base64Image); + async (blob: any) => { + const buffer = Buffer.from(await blob.arrayBuffer()) + this.signatureImage = 'data:' + blob.type + ';base64,' + buffer.toString('base64'); }, (error: any) => {} ); } diff --git a/src/app/clients/clients.service.ts b/src/app/clients/clients.service.ts index 40942c6f1..2ff74d71b 100644 --- a/src/app/clients/clients.service.ts +++ b/src/app/clients/clients.service.ts @@ -181,13 +181,13 @@ export class ClientsService { uploadClientSignatureImage(clientId: string, signature: File) { const formData = new FormData(); formData.append('file', signature); - formData.append('filename', signature.name); - return this.http.post(`/clients/${clientId}/images`, formData); + formData.append('name', 'clientSignature'); + formData.append('description', 'Client signature'); + return this.http.post(`/clients/${clientId}/documents`, formData); } getClientSignatureImage(clientId: string, documentId: string) { - const httpParams = new HttpParams().set('tenantIdentifier', 'default'); - return this.http.get(`/clients/${clientId}/documents/${documentId}/attachment`, { params: httpParams, responseType: 'blob' }); + return this.http.get(`/clients/${clientId}/documents/${documentId}/attachment`, { responseType: 'blob' }); } getClientFamilyMembers(clientId: string) { diff --git a/src/tsconfig.app.json b/src/tsconfig.app.json index 8ca7aa7ed..fb3e64c3a 100644 --- a/src/tsconfig.app.json +++ b/src/tsconfig.app.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "../out-tsc/app", "baseUrl": "./", - "types": [] + "types": ["node"] }, "angularCompilerOptions": { "enableIvy": true,