feat: update video jobs API calls to use backend URL and authorization headers

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-29 17:23:34 +02:00
parent d1c2b6da68
commit 81c06ad13b
+26 -7
View File
@@ -78,7 +78,14 @@ block content %}
async function fetchJobs() { async function fetchJobs() {
try { try {
const response = await fetch("/api/v1/admin/videos"); const response = await fetch(
"{{ config['BACKEND_URL'] }}/admin/videos",
{
headers: {
Authorization: "Bearer {{ session['access_token'] }}",
},
},
);
if (!response.ok) throw new Error("Failed to fetch jobs"); if (!response.ok) throw new Error("Failed to fetch jobs");
const jobs = await response.json(); const jobs = await response.json();
jobsTableBody.innerHTML = ""; jobsTableBody.innerHTML = "";
@@ -123,9 +130,15 @@ block content %}
purgeStatus.classList.remove("text-red-500", "text-green-500"); purgeStatus.classList.remove("text-red-500", "text-green-500");
try { try {
const response = await fetch("/api/v1/admin/videos/purge", { const response = await fetch(
method: "POST", "{{ config['BACKEND_URL'] }}/admin/videos/purge",
}); {
method: "POST",
headers: {
Authorization: "Bearer {{ session['access_token'] }}",
},
},
);
const data = await response.json(); const data = await response.json();
if (!response.ok) if (!response.ok)
throw new Error(data.detail || "Failed to purge jobs"); throw new Error(data.detail || "Failed to purge jobs");
@@ -145,9 +158,15 @@ block content %}
if (e.target.classList.contains("cancel-btn")) { if (e.target.classList.contains("cancel-btn")) {
const jobId = e.target.dataset.jobId; const jobId = e.target.dataset.jobId;
try { try {
const response = await fetch(`/api/v1/admin/videos/${jobId}/cancel`, { const response = await fetch(
method: "POST", `{{ config['BACKEND_URL'] }}/admin/videos/${jobId}/cancel`,
}); {
method: "POST",
headers: {
Authorization: "Bearer {{ session['access_token'] }}",
},
},
);
if (!response.ok) throw new Error("Failed to cancel job"); if (!response.ok) throw new Error("Failed to cancel job");
fetchJobs(); fetchJobs();
} catch (error) { } catch (error) {