Add bulk retry to the index.
This commit is contained in:
parent
5c3d357019
commit
89a6a748cf
2 changed files with 85 additions and 8 deletions
|
|
@ -56,14 +56,25 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<button
|
<div fxLayout.lt-lg="column" fxLayout.gt-sm="row" fxLayoutGap="20px">
|
||||||
class="button is-danger"
|
<button
|
||||||
(click)="showDeleteModal()"
|
class="button is-danger"
|
||||||
[disabled]="selectedTorrents.length === 0"
|
(click)="showDeleteModal()"
|
||||||
*ngIf="torrents.length > 0"
|
[disabled]="selectedTorrents.length === 0"
|
||||||
>
|
*ngIf="torrents.length > 0"
|
||||||
Delete Selected
|
>
|
||||||
</button>
|
Delete Selected
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="button is-primary"
|
||||||
|
(click)="showRetryModal()"
|
||||||
|
[disabled]="selectedTorrents.length === 0"
|
||||||
|
*ngIf="torrents.length > 0"
|
||||||
|
>
|
||||||
|
Retry Selected
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal" [class.is-active]="isDeleteModalActive">
|
<div class="modal" [class.is-active]="isDeleteModalActive">
|
||||||
|
|
@ -116,3 +127,32 @@
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="modal" [class.is-active]="isRetryModalActive">
|
||||||
|
<div class="modal-background"></div>
|
||||||
|
<div class="modal-card">
|
||||||
|
<header class="modal-card-head">
|
||||||
|
<p class="modal-card-title">Retry selected torrents</p>
|
||||||
|
<button class="delete" aria-label="close" (click)="retryCancel()"></button>
|
||||||
|
</header>
|
||||||
|
<section class="modal-card-body">
|
||||||
|
<p>Are you sure you want to retry these torrent?</p>
|
||||||
|
<div class="notification is-danger is-light" *ngIf="retryError?.length > 0">
|
||||||
|
Error retrying torrent: {{ retryError }}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<footer class="modal-card-foot">
|
||||||
|
<button
|
||||||
|
class="button is-success"
|
||||||
|
(click)="retryOk()"
|
||||||
|
[disabled]="retrying"
|
||||||
|
[ngClass]="{ 'is-loading': deleting }"
|
||||||
|
>
|
||||||
|
Retry selected
|
||||||
|
</button>
|
||||||
|
<button class="button" (click)="retryCancel()" [disabled]="retrying" [ngClass]="{ 'is-loading': deleting }">
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,10 @@ export class TorrentTableComponent implements OnInit {
|
||||||
public deleteRdTorrent: boolean;
|
public deleteRdTorrent: boolean;
|
||||||
public deleteLocalFiles: boolean;
|
public deleteLocalFiles: boolean;
|
||||||
|
|
||||||
|
public isRetryModalActive: boolean;
|
||||||
|
public retryError: string;
|
||||||
|
public retrying: boolean;
|
||||||
|
|
||||||
constructor(private router: Router, private torrentService: TorrentService) {}
|
constructor(private router: Router, private torrentService: TorrentService) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
@ -101,4 +105,37 @@ export class TorrentTableComponent implements OnInit {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public showRetryModal(): void {
|
||||||
|
this.retryError = null;
|
||||||
|
|
||||||
|
this.isRetryModalActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public retryCancel(): void {
|
||||||
|
this.isRetryModalActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public retryOk(): void {
|
||||||
|
this.retrying = true;
|
||||||
|
|
||||||
|
let calls: Observable<void>[] = [];
|
||||||
|
|
||||||
|
this.selectedTorrents.forEach((torrentId) => {
|
||||||
|
calls.push(this.torrentService.retry(torrentId));
|
||||||
|
});
|
||||||
|
|
||||||
|
forkJoin(calls).subscribe({
|
||||||
|
complete: () => {
|
||||||
|
this.isRetryModalActive = false;
|
||||||
|
this.retrying = false;
|
||||||
|
|
||||||
|
this.selectedTorrents = [];
|
||||||
|
},
|
||||||
|
error: (err) => {
|
||||||
|
this.retryError = err.error;
|
||||||
|
this.retrying = false;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue