diff --git a/apps/red-ui/src/app/upload-download/file-download.service.ts b/apps/red-ui/src/app/upload-download/file-download.service.ts index 7e600c6fd..3794da88f 100644 --- a/apps/red-ui/src/app/upload-download/file-download.service.ts +++ b/apps/red-ui/src/app/upload-download/file-download.service.ts @@ -4,7 +4,6 @@ import { interval, Observable } from 'rxjs'; import { AppConfigService } from '../app-config/app-config.service'; import { TranslateService } from '@ngx-translate/core'; import { DialogService } from '../dialogs/dialog.service'; -import { download } from '../utils/file-download-utils'; import { ProjectWrapper } from '../state/model/project.wrapper'; import { FileStatusWrapper } from '../screens/file/model/file-status.wrapper'; import { mergeMap, tap } from 'rxjs/operators'; @@ -58,31 +57,12 @@ export class FileDownloadService { return this._downloadControllerService.getDownloadStatus().pipe( tap((statusResponse) => { this.downloads = statusResponse.downloadStatus.map((d) => new DownloadStatusWrapper(d)); - this.hasPendingDownloads = !!this.downloads.find((f) => !f.lastDownload); + this.hasPendingDownloads = !!this.downloads.find((f) => !f.lastDownload && f.isReady); }) ); } public performDownload(status: DownloadStatusWrapper) { - status.inProgress = true; this._streamDownloadService.performDownload(status); - status.inProgress = false; - this._downloadControllerService - .downloadFile( - { - storageId: status.storageId - }, - false, - 'response' - ) - .subscribe( - (response) => { - download(response, status.filename); - status.inProgress = false; - }, - () => { - status.inProgress = false; - } - ); } } diff --git a/apps/red-ui/src/app/upload-download/model/download-status.wrapper.ts b/apps/red-ui/src/app/upload-download/model/download-status.wrapper.ts index a114f01cc..973e43f94 100644 --- a/apps/red-ui/src/app/upload-download/model/download-status.wrapper.ts +++ b/apps/red-ui/src/app/upload-download/model/download-status.wrapper.ts @@ -6,7 +6,7 @@ export class DownloadStatusWrapper { constructor(private _downloadStatus: DownloadStatus) {} get size() { - let i = this._downloadStatus.fileSize === 0 ? 0 : Math.floor(Math.log(this._downloadStatus.fileSize) / Math.log(1024)); + const i = this._downloadStatus.fileSize === 0 ? 0 : Math.floor(Math.log(this._downloadStatus.fileSize) / Math.log(1024)); return (this._downloadStatus.fileSize / Math.pow(1024, i)).toFixed(2) + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i]; } @@ -34,6 +34,10 @@ export class DownloadStatusWrapper { return this._downloadStatus.projectId; } + get isReady() { + return this._downloadStatus.status === 'READY'; + } + get status() { return this._downloadStatus.status; } diff --git a/apps/red-ui/src/app/utils/stream-download.service.ts b/apps/red-ui/src/app/utils/stream-download.service.ts index 0ac651b74..a99e36742 100644 --- a/apps/red-ui/src/app/utils/stream-download.service.ts +++ b/apps/red-ui/src/app/utils/stream-download.service.ts @@ -93,7 +93,7 @@ export class StreamDownloadService { window.onbeforeunload = (evt) => { if (this._activeDownloadCount > 0) { - evt.returnValue = this._translateService.instant('stream-download.abort'); + return this._translateService.instant('stream-download.abort'); } }; }