Adds everywhere snackbar on download rda json failure

This commit is contained in:
apapachristou 2020-10-09 13:04:38 +03:00
parent 02c36c1f61
commit 4c3775232a
4 changed files with 36 additions and 4 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {