fix: Client signature

The functionality to store and show client signatures was broken.
This commit is contained in:
Ralph Hopman
2024-11-28 13:49:34 +01:00
committed by Adam Saghy
parent ea44be56a7
commit a27bd723d8
4 changed files with 12 additions and 8 deletions
@@ -11,5 +11,5 @@
<mat-dialog-actions align="end"> <mat-dialog-actions align="end">
<button mat-raised-button mat-dialog-close>{{"labels.buttons.Close" | translate}}</button> <button mat-raised-button mat-dialog-close>{{"labels.buttons.Close" | translate}}</button>
<button mat-raised-button *ngIf="signatureId" color="warn" [mat-dialog-close]="{ delete: true }">{{"labels.buttons.Delete" | translate}}</button> <button mat-raised-button *ngIf="signatureId" color="warn" [mat-dialog-close]="{ delete: true }">{{"labels.buttons.Delete" | translate}}</button>
<button mat-raised-button color="primary" [mat-dialog-close]="{ upload: true }">{{ signatureId ? 'Reupload' : 'Upload'}}</button> <button mat-raised-button *ngIf="!signatureId" color="primary" [mat-dialog-close]="{ upload: true }">{{"labels.buttons.Upload" | translate}}</button>
</mat-dialog-actions> </mat-dialog-actions>
@@ -6,6 +6,9 @@ import { DomSanitizer } from '@angular/platform-browser';
/** Custom Services */ /** Custom Services */
import { ClientsService } from 'app/clients/clients.service'; import { ClientsService } from 'app/clients/clients.service';
/** Node Types */
import { Buffer } from 'buffer';
/** /**
* View signature dialog component. * View signature dialog component.
*/ */
@@ -39,8 +42,9 @@ export class ViewSignatureDialogComponent implements OnInit {
ngOnInit() { ngOnInit() {
if (this.signatureId) { if (this.signatureId) {
this.clientsService.getClientSignatureImage(this.clientId, this.signatureId).subscribe( this.clientsService.getClientSignatureImage(this.clientId, this.signatureId).subscribe(
(base64Image: any) => { async (blob: any) => {
this.signatureImage = this.sanitizer.bypassSecurityTrustResourceUrl(base64Image); const buffer = Buffer.from(await blob.arrayBuffer())
this.signatureImage = 'data:' + blob.type + ';base64,' + buffer.toString('base64');
}, (error: any) => {} }, (error: any) => {}
); );
} }
+4 -4
View File
@@ -181,13 +181,13 @@ export class ClientsService {
uploadClientSignatureImage(clientId: string, signature: File) { uploadClientSignatureImage(clientId: string, signature: File) {
const formData = new FormData(); const formData = new FormData();
formData.append('file', signature); formData.append('file', signature);
formData.append('filename', signature.name); formData.append('name', 'clientSignature');
return this.http.post(`/clients/${clientId}/images`, formData); formData.append('description', 'Client signature');
return this.http.post(`/clients/${clientId}/documents`, formData);
} }
getClientSignatureImage(clientId: string, documentId: string) { getClientSignatureImage(clientId: string, documentId: string) {
const httpParams = new HttpParams().set('tenantIdentifier', 'default'); return this.http.get(`/clients/${clientId}/documents/${documentId}/attachment`, { responseType: 'blob' });
return this.http.get(`/clients/${clientId}/documents/${documentId}/attachment`, { params: httpParams, responseType: 'blob' });
} }
getClientFamilyMembers(clientId: string) { getClientFamilyMembers(clientId: string) {
+1 -1
View File
@@ -3,7 +3,7 @@
"compilerOptions": { "compilerOptions": {
"outDir": "../out-tsc/app", "outDir": "../out-tsc/app",
"baseUrl": "./", "baseUrl": "./",
"types": [] "types": ["node"]
}, },
"angularCompilerOptions": { "angularCompilerOptions": {
"enableIvy": true, "enableIvy": true,