diff --git a/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.ts b/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.ts index e2787c7eb75eaf231d3e7871f522e01b27becf4c..63420e73ef641219c1effac5a32891b221f5d32c 100644 --- a/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.ts +++ b/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.ts @@ -262,13 +262,19 @@ export class ResourceDownloadItemComponent implements OnInit { transformObjectToArray(object) { const array = []; - const keys = Object.keys(object); - keys.forEach((key) => { - array.push({ - name: key, - bbox: object[key], + let keys; + + if (object) { + keys = Object.keys(object); + + keys.forEach((key) => { + array.push({ + name: key, + bbox: object[key], + }); }); - }); + } + return array; } diff --git a/src/app/shared/components/download-button/download-button.component.ts b/src/app/shared/components/download-button/download-button.component.ts index 790b624ed26e805266ab43d9b6a55c3ab807e45a..0672bce39f2c8ab90f84473a3412cbf76f29dc25 100644 --- a/src/app/shared/components/download-button/download-button.component.ts +++ b/src/app/shared/components/download-button/download-button.component.ts @@ -27,7 +27,7 @@ export class DownloadButtonComponent implements OnInit, OnDestroy { private _http: HttpClient, ) { } - ngOnInit() {} + ngOnInit() { } download() { this.loading = true; @@ -35,7 +35,6 @@ export class DownloadButtonComponent implements OnInit, OnDestroy { takeUntil(this.ngUnsubscribe), ).subscribe( (response) => { - console.log('Reponse'); // Create a temporary link and click on it to launch the blob download const url = window.URL.createObjectURL(response.body); const a = document.createElement('a'); @@ -50,23 +49,23 @@ export class DownloadButtonComponent implements OnInit, OnDestroy { (err) => { let message = notificationMessages.general.failedDownloadFile; - if (err && err.status) { - switch (err.status) { - case 401: - message = notificationMessages.general.failedDownloadFileUnauthenticated; - break; - case 403: - message = notificationMessages.general.failedDownloadFileUnauthorized; - break; - } - this.abortDownload(); - this._notificationService.notify( - { - message, - type: 'error', - }, - ); + if (err && err.status === 401) { + + message = notificationMessages.general.failedDownloadFileUnauthenticated; + } + + if (err && err.status === 403) { + message = notificationMessages.general.failedDownloadFileUnauthorized; } + + this._notificationService.notify( + { + message, + type: 'error', + }, + ); + + this.abortDownload(); }, ); }