Skip to content

Commit

Permalink
fix: Client signature
Browse files Browse the repository at this point in the history
The functionality to store and show client signatures was broken.
  • Loading branch information
rhopman authored and adamsaghy committed Nov 28, 2024
1 parent ea44be5 commit a27bd72
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ <h1 mat-dialog-title>{{"labels.heading.View Client Signature" | translate}}</h1>
<mat-dialog-actions align="end">
<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 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>
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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) => {}
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/app/clients/clients.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
"types": []
"types": ["node"]
},
"angularCompilerOptions": {
"enableIvy": true,
Expand Down

0 comments on commit a27bd72

Please sign in to comment.