handle error state bulk update, add bulk clear error

This commit is contained in:
Simon
2025-07-22 19:02:31 +07:00
parent 5cee7af233
commit 7e8ced001d
5 changed files with 41 additions and 7 deletions

View File

@@ -1,18 +1,20 @@
import APIClient from '../../functions/APIClient';
type FilterType = 'ignore' | 'pending';
export type DownloadQueueStatus = 'ignore' | 'pending' | 'priority';
export type DownloadQueueStatus = 'ignore' | 'pending' | 'priority' | 'clear_error';
const updateDownloadQueueByFilter = async (
filter: FilterType,
channel: string | null,
vid_type: string | null,
error: string | null,
status: DownloadQueueStatus,
) => {
const searchParams = new URLSearchParams();
if (filter) searchParams.append('filter', filter);
if (channel) searchParams.append('channel', channel);
if (vid_type) searchParams.append('vid_type', vid_type);
if (error) searchParams.append('error', error);
return APIClient(`/api/download/?${searchParams.toString()}`, {
method: 'PATCH',

View File

@@ -162,6 +162,7 @@ const Download = () => {
showIgnoredFilter,
channelFilterFromUrl,
vidTypeFilterFromUrl,
errorFilterFromUrl,
status,
);
setRefresh(true);
@@ -467,16 +468,22 @@ const Download = () => {
<h3>Bulk actions</h3>
<p>
Applied filtered by status <i>'{showIgnoredFilter}'</i>
{vidTypeFilterFromUrl && (
<span>
{' '}
and by type: <i>'{vidTypeFilterFromUrl}'</i>
</span>
)}
{channelFilterFromUrl && (
<span>
{' '}
and by channel: <i>'{channel_filter_name}'</i>
</span>
)}
{vidTypeFilterFromUrl && (
{errorFilterFromUrl && (
<span>
{' '}
and by type: <i>'{vidTypeFilterFromUrl}'</i>
and by error state: <i>'{errorFilterFromUrl}'</i>
</span>
)}
</p>
@@ -489,6 +496,9 @@ const Download = () => {
<div className="button-box">
<Button onClick={() => handleBulkStatusUpdate('ignore')}>Ignore</Button>
<Button onClick={() => handleBulkStatusUpdate('priority')}>Download Now</Button>
<Button onClick={() => handleBulkStatusUpdate('clear_error')}>
Clear Errors
</Button>
</div>
)}
</div>