mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 03:40:14 +00:00
Add delete all ignored & pending
This commit is contained in:
parent
66c2799e7e
commit
2159b1d39d
@ -1,5 +1,4 @@
|
|||||||
import { Download } from "../types/download";
|
import { Download } from "../types/download";
|
||||||
import { DownloadResponse } from "../types/download";
|
|
||||||
import { getTAUrl } from "./constants";
|
import { getTAUrl } from "./constants";
|
||||||
|
|
||||||
const TA_BASE_URL = getTAUrl();
|
const TA_BASE_URL = getTAUrl();
|
||||||
@ -19,7 +18,7 @@ export const getDownloads = async (token: string, filter: boolean): Promise<Down
|
|||||||
return response.json();
|
return response.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const sendDownloads = async (token: string, input: string): Promise<DownloadResponse> => {
|
export const sendDownloads = async (token: string, input: string): Promise<Download> => {
|
||||||
var data = {
|
var data = {
|
||||||
"data": [{
|
"data": [{
|
||||||
"youtube_id": input,
|
"youtube_id": input,
|
||||||
@ -42,3 +41,20 @@ export const sendDownloads = async (token: string, input: string): Promise<Downl
|
|||||||
}
|
}
|
||||||
return response.json();
|
return response.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const sendDeleteAllQueuedIgnored = async (token: string, filter: string): Promise<Download> => {
|
||||||
|
const response = await fetch(`${TA_BASE_URL.server}/api/download/?filter=${filter}`, {
|
||||||
|
headers: {
|
||||||
|
Accept: "application/json",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: `Token ${token}`,
|
||||||
|
mode: "no-cors",
|
||||||
|
},
|
||||||
|
method: "DELETE"
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
// throw new Error("Error adding content to the download queue.");
|
||||||
|
// return response.json();
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
};
|
@ -5,7 +5,7 @@ import { dehydrate, QueryClient, useQuery } from "react-query";
|
|||||||
import { CustomHead } from "../components/CustomHead";
|
import { CustomHead } from "../components/CustomHead";
|
||||||
import { Layout } from "../components/Layout";
|
import { Layout } from "../components/Layout";
|
||||||
import NextImage from "next/image";
|
import NextImage from "next/image";
|
||||||
import { getDownloads } from "../lib/getDownloads";
|
import { getDownloads, sendDeleteAllQueuedIgnored } from "../lib/getDownloads";
|
||||||
import { sendDownloads } from "../lib/getDownloads";
|
import { sendDownloads } from "../lib/getDownloads";
|
||||||
import RescanIcon from "../images/icon-rescan.svg";
|
import RescanIcon from "../images/icon-rescan.svg";
|
||||||
import DownloadIcon from "../images/icon-download.svg";
|
import DownloadIcon from "../images/icon-download.svg";
|
||||||
@ -199,13 +199,13 @@ const Download: NextPage = () => {
|
|||||||
{ignoredStatus &&
|
{ignoredStatus &&
|
||||||
<div className="title-split">
|
<div className="title-split">
|
||||||
<h2>Ignored from download</h2>
|
<h2>Ignored from download</h2>
|
||||||
<button onClick={() => console.log("deleteQueue(this)")} data-id="ignore" title="Delete all previously ignored videos from the queue">Delete all ignored</button>
|
<button onClick={() => sendDeleteAllQueuedIgnored(session.ta_token.token, "ignore")} title="Delete all previously ignored videos from the queue">Delete all ignored</button>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
{!ignoredStatus &&
|
{!ignoredStatus &&
|
||||||
<div className="title-split">
|
<div className="title-split">
|
||||||
<h2>Download queue</h2>
|
<h2>Download queue</h2>
|
||||||
<button onClick={() => console.log("deleteQueue(this)")} data-id="pending" title="Delete all pending videos from the queue">Delete all queued</button>
|
<button onClick={() => sendDeleteAllQueuedIgnored(session.ta_token.token, "pending")} title="Delete all pending videos from the queue">Delete all queued</button>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
<h3>Total videos: {downloads?.data?.length} {!downloads?.data?.length && <p>No videos queued for download. Press rescan subscriptions to check if there are any new videos.</p>}</h3>
|
<h3>Total videos: {downloads?.data?.length} {!downloads?.data?.length && <p>No videos queued for download. Press rescan subscriptions to check if there are any new videos.</p>}</h3>
|
||||||
|
@ -2,13 +2,14 @@ export interface Download {
|
|||||||
data: Datum[];
|
data: Datum[];
|
||||||
config: Config;
|
config: Config;
|
||||||
paginate: boolean;
|
paginate: boolean;
|
||||||
}
|
|
||||||
|
|
||||||
export interface DownloadResponse {
|
|
||||||
data: Datum[];
|
|
||||||
message: string;
|
message: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// export interface DownloadResponse {
|
||||||
|
// data: Datum[];
|
||||||
|
// message: string;
|
||||||
|
// }
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
archive: Archive;
|
archive: Archive;
|
||||||
default_view: DefaultView;
|
default_view: DefaultView;
|
||||||
|
Loading…
Reference in New Issue
Block a user