mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-05 02:39:25 +00:00
add bulk status update in queue
This commit is contained in:
23
frontend/src/api/actions/updateDownloadQueueByFilter.ts
Normal file
23
frontend/src/api/actions/updateDownloadQueueByFilter.ts
Normal 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;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user