Merge pull request #386 from vkartk/feature/add-retry-button

[feature] Implement "Retry all failed downloads" (#327)
pull/389/head
Alex 2024-01-26 19:57:53 +02:00 committed by GitHub
commit 0da058987c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -152,6 +152,7 @@
<button type="button" class="btn btn-link text-decoration-none px-0 me-4" disabled #doneDelSelected (click)="delSelectedDownloads('done')"><fa-icon [icon]="faTrashAlt"></fa-icon>&nbsp; Clear selected</button>
<button type="button" class="btn btn-link text-decoration-none px-0 me-4" disabled #doneClearCompleted (click)="clearCompletedDownloads()"><fa-icon [icon]="faCheckCircle"></fa-icon>&nbsp; Clear completed</button>
<button type="button" class="btn btn-link text-decoration-none px-0 me-4" disabled #doneClearFailed (click)="clearFailedDownloads()"><fa-icon [icon]="faTimesCircle"></fa-icon>&nbsp; Clear failed</button>
<button type="button" class="btn btn-link text-decoration-none px-0 me-4" disabled #doneRetryFailed (click)="retryFailedDownloads()"><fa-icon [icon]="faRedoAlt"></fa-icon>&nbsp; Retry failed</button>
</th>
<th scope="col" >File Size</th>
<th scope="col" style="width: 2rem;"></th>
@ -179,6 +180,7 @@
</td>
<td>
<span *ngIf="download.value.size">{{ download.value.size | fileSize }}</span>
</td>
<td>
<button *ngIf="download.value.status == 'error'" type="button" class="btn btn-link" (click)="retryDownload(download.key, download.value)"><fa-icon [icon]="faRedoAlt"></fa-icon></button>
</td>

View File

@ -35,6 +35,8 @@ export class AppComponent implements AfterViewInit {
@ViewChild('doneDelSelected') doneDelSelected: ElementRef;
@ViewChild('doneClearCompleted') doneClearCompleted: ElementRef;
@ViewChild('doneClearFailed') doneClearFailed: ElementRef;
@ViewChild('doneRetryFailed') doneRetryFailed: ElementRef;
faTrashAlt = faTrashAlt;
faCheckCircle = faCheckCircle;
@ -83,6 +85,7 @@ export class AppComponent implements AfterViewInit {
});
this.doneClearCompleted.nativeElement.disabled = completed === 0;
this.doneClearFailed.nativeElement.disabled = failed === 0;
this.doneRetryFailed.nativeElement.disabled = failed === 0;
});
}
@ -221,6 +224,14 @@ export class AppComponent implements AfterViewInit {
this.downloads.delByFilter('done', dl => dl.status === 'error').subscribe();
}
retryFailedDownloads() {
this.downloads.done.forEach((dl, key) => {
if (dl.status === 'error') {
this.retryDownload(key, dl);
}
});
}
buildDownloadLink(download: Download) {
let baseDir = 'download/';
if (download.quality == 'audio' || download.filename.endsWith('.mp3')) {