From 4c3775232a840219428aaece3a31bd7ed44b829b Mon Sep 17 00:00:00 2001 From: apapachristou Date: Fri, 9 Oct 2020 13:04:38 +0300 Subject: [PATCH] Adds everywhere snackbar on download rda json failure --- .../recent-edited-activity.component.ts | 10 +++++++++- .../recent-edited-dmp-activity.component.ts | 10 +++++++++- .../src/app/ui/dmp/editor/dmp-editor.component.ts | 10 +++++++++- .../listing/listing-item/dmp-listing-item.component.ts | 10 +++++++++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts index 66347e8a3..80ae76eef 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts @@ -448,7 +448,15 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn const blob = new Blob([response.body], { type: 'application/json' }); const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); FileSaver.saveAs(blob, filename); - }) + }, async error => { + this.onExportCallbackError(error); + }); + } + + async onExportCallbackError(error: any) { + const errorJsonText = await error.error.text(); + const errorObj = JSON.parse(errorJsonText); + this.uiNotificationService.snackBarNotification(errorObj.message, SnackBarNotificationLevel.Error); } downloadPDF(dataset: DatasetListingModel): void { diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts index dba7a0808..e3725dfd8 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts @@ -394,7 +394,15 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O const blob = new Blob([response.body], { type: 'application/json' }); const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); FileSaver.saveAs(blob, filename); - }) + }, async error => { + this.onExportCallbackError(error); + }); + } + + async onExportCallbackError(error: any) { + const errorJsonText = await error.error.text(); + const errorObj = JSON.parse(errorJsonText); + this.uiNotificationService.snackBarNotification(errorObj.message, SnackBarNotificationLevel.Error); } getFilenameFromContentDispositionHeader(header: string): string { diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts index e91c3cd46..1a9925591 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts @@ -662,7 +662,15 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC const blob = new Blob([response.body], { type: 'application/json' }); const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); FileSaver.saveAs(blob, filename); - }) + }, async error => { + this.onExportCallbackError(error); + }); + } + + async onExportCallbackError(error: any) { + const errorJsonText = await error.error.text(); + const errorObj = JSON.parse(errorJsonText); + this.uiNotificationService.snackBarNotification(errorObj.message, SnackBarNotificationLevel.Error); } getFilenameFromContentDispositionHeader(header: string): string { diff --git a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts index a7e5d9522..46c2d3a0c 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts @@ -252,7 +252,15 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit { const blob = new Blob([response.body], { type: 'application/json' }); const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); FileSaver.saveAs(blob, filename); - }) + }, async error => { + this.onExportCallbackError(error); + }); + } + + async onExportCallbackError(error: any) { + const errorJsonText = await error.error.text(); + const errorObj = JSON.parse(errorJsonText); + this.uiNotificationService.snackBarNotification(errorObj.message, SnackBarNotificationLevel.Error); } getFilenameFromContentDispositionHeader(header: string): string {