diff --git a/admin-ui/src/app/core/services/httpinterceptor.ts b/admin-ui/src/app/core/services/httpinterceptor.ts index af16e422..3224e206 100644 --- a/admin-ui/src/app/core/services/httpinterceptor.ts +++ b/admin-ui/src/app/core/services/httpinterceptor.ts @@ -125,7 +125,6 @@ export class AuthInterceptor implements HttpInterceptor { }); } else { if (err.url.includes('validateToken')) { - this.translateService .getTranslation(this.appService.getConfig().primaryLangCode) .subscribe(response => { @@ -142,7 +141,8 @@ export class AuthInterceptor implements HttpInterceptor { disableClose: true }); }); - + }else if(err.url.includes('rid-digital-card')) { + console.log("download card"); }else{ this.translateService .getTranslation(this.appService.getConfig().primaryLangCode) diff --git a/admin-ui/src/app/features/download-card/download-card/download-card.component.ts b/admin-ui/src/app/features/download-card/download-card/download-card.component.ts index 1e7fb46c..1d516ef4 100644 --- a/admin-ui/src/app/features/download-card/download-card/download-card.component.ts +++ b/admin-ui/src/app/features/download-card/download-card/download-card.component.ts @@ -8,6 +8,7 @@ import { DialogComponent } from 'src/app/shared/dialog/dialog.component'; import { DomSanitizer } from '@angular/platform-browser'; import { saveAs } from 'file-saver'; import { ActivatedRoute, Router, NavigationEnd } from '@angular/router'; +import { HttpErrorResponse } from '@angular/common/http'; @Component({ selector: 'app-download-card', @@ -123,7 +124,8 @@ export class DownloadCardComponent implements OnInit { if(selection === 'true'){ this.auditService.audit(21, 'ADM-045', {'type':'download-card','actioned':'Verify and Download'}); this.dataStorageService - .downloadCard(this.id).subscribe(data => { + .downloadCard(this.id).subscribe( + (data) => { var fileName = this.id+".pdf"; const contentDisposition = data.headers.get('Content-Disposition'); if (contentDisposition) { @@ -135,8 +137,9 @@ export class DownloadCardComponent implements OnInit { } saveAs(data.body, fileName); }, - err => { - console.error(err); + (error: HttpErrorResponse) => { + const errorJson = JSON.parse(this.blobToString(error.error)); + this.showErrorPopup(errorJson.errors[0].message); }); }else{ this.auditService.audit(21, 'ADM-045', {'type':'download-card','actioned':'Reject'}); @@ -144,6 +147,15 @@ export class DownloadCardComponent implements OnInit { } } + private blobToString(blob): string { + const url = URL.createObjectURL(blob); + let xmlRequest = new XMLHttpRequest(); + xmlRequest.open('GET', url, false); + xmlRequest.send(); + URL.revokeObjectURL(url); + return xmlRequest.responseText; + } + viewMore() { this.showTimeline = !this.showTimeline; }