Added ability to pause and resume all downloads

Removed backend dependency on queue library
This commit is contained in:
Isaac Abadi
2021-08-25 23:45:56 -06:00
parent a36794fd4f
commit 865185d277
7 changed files with 64 additions and 16 deletions

View File

@@ -48,6 +48,9 @@ export class DownloadsComponent implements OnInit, OnDestroy {
valid_sessions_length = 0;
paused_download_exists = false;
running_download_exists = false;
STEP_INDEX_TO_LABEL = {
0: 'Creating download',
1: 'Getting info',
@@ -81,7 +84,7 @@ export class DownloadsComponent implements OnInit, OnDestroy {
}
}
getCurrentDownloadsRecurring() {
getCurrentDownloadsRecurring(): void {
if (!this.postsService.config['Extra']['enable_downloads_manager']) {
this.router.navigate(['/home']);
return;
@@ -108,6 +111,9 @@ export class DownloadsComponent implements OnInit, OnDestroy {
this.dataSource = new MatTableDataSource<Download>(this.downloads);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
this.paused_download_exists = this.downloads.find(download => download['paused'] && !download['error']);
this.running_download_exists = this.downloads.find(download => !download['paused'] && !download['finished']);
} else {
// failed to get downloads
}
@@ -142,6 +148,14 @@ export class DownloadsComponent implements OnInit, OnDestroy {
});
}
pauseAllDownloads(): void {
this.postsService.pauseAllDownloads().subscribe(res => {
if (!res['success']) {
this.postsService.openSnackBar('Failed to pause all downloads! See server logs for more info.');
}
});
}
resumeDownload(download_uid: string): void {
this.postsService.resumeDownload(download_uid).subscribe(res => {
if (!res['success']) {
@@ -150,6 +164,14 @@ export class DownloadsComponent implements OnInit, OnDestroy {
});
}
resumeAllDownloads(): void {
this.postsService.resumeAllDownloads().subscribe(res => {
if (!res['success']) {
this.postsService.openSnackBar('Failed to resume all downloads! See server logs for more info.');
}
});
}
restartDownload(download_uid: string): void {
this.postsService.restartDownload(download_uid).subscribe(res => {
if (!res['success']) {