dld stream
This commit is contained in:
parent
0f86fd5874
commit
dadcc4668d
@ -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;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user