add bulk status update in queue

This commit is contained in:
Simon
2025-07-06 20:14:56 +07:00
parent 2a70f7ab58
commit 3947653595
6 changed files with 124 additions and 2 deletions

View File

@@ -0,0 +1,23 @@
import APIClient from '../../functions/APIClient';
type FilterType = 'ignore' | 'pending';
export type DownloadQueueStatus = 'ignore' | 'pending' | 'priority';
const updateDownloadQueueByFilter = async (
filter: FilterType,
channel: string | null,
vid_type: 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);
return APIClient(`/api/download/?${searchParams.toString()}`, {
method: 'PATCH',
body: { status: status },
});
};
export default updateDownloadQueueByFilter;

View File

@@ -6,7 +6,7 @@ import getCookie from './getCookie';
import Routes from '../configuration/routes/RouteList';
export interface ApiClientOptions extends Omit<RequestInit, 'body'> {
method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
body?: Record<string, unknown> | string;
}

View File

@@ -22,6 +22,9 @@ import { useUserConfigStore } from '../stores/UserConfigStore';
import updateUserConfig, { UserConfigType } from '../api/actions/updateUserConfig';
import { ApiResponseType } from '../functions/APIClient';
import deleteDownloadQueueByFilter from '../api/actions/deleteDownloadQueueByFilter';
import updateDownloadQueueByFilter, {
DownloadQueueStatus,
} from '../api/actions/updateDownloadQueueByFilter';
type Download = {
auto_start: boolean;
@@ -141,6 +144,16 @@ const Download = () => {
})();
}, [lastVideoCount, showIgnored]);
const handleBulkStatusUpdate = async (status: DownloadQueueStatus) => {
await updateDownloadQueueByFilter(
showIgnoredFilter,
channelFilterFromUrl,
vidTypeFilterFromUrl,
status,
);
setRefresh(true);
};
return (
<>
<title>TA | Downloads</title>
@@ -397,6 +410,18 @@ const Download = () => {
</span>
)}
</p>
<div>
{showIgnored ? (
<div className="button-box">
<Button onClick={() => handleBulkStatusUpdate('pending')}>Add to Queue</Button>
</div>
) : (
<div className="button-box">
<Button onClick={() => handleBulkStatusUpdate('ignore')}>Ignore</Button>
<Button onClick={() => handleBulkStatusUpdate('priority')}>Download Now</Button>
</div>
)}
</div>
<div className="button-box">
{showDeleteConfirm ? (
<>
@@ -416,7 +441,7 @@ const Download = () => {
<Button onClick={() => setShowDeleteConfirm(false)}>Cancel</Button>
</>
) : (
<Button onClick={() => setShowDeleteConfirm(!showDeleteConfirm)}>Delete</Button>
<Button onClick={() => setShowDeleteConfirm(!showDeleteConfirm)}>Forget</Button>
)}
</div>
</div>