feat: add admin API endpoints for video management, update frontend to use new API routes

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-29 18:58:04 +02:00
parent 37edef716a
commit 2ca7ae538f
2 changed files with 39 additions and 10 deletions
+6 -10
View File
@@ -139,17 +139,13 @@
<script>
(function () {
const BACKEND = "{{ config['BACKEND_URL'] }}";
const TOKEN = "{{ session['access_token'] }}";
const headers = { Authorization: "Bearer " + TOKEN };
let allJobs = [];
async function loadJobs() {
document.getElementById("vj-tbody").innerHTML =
'<tr><td colspan="7" class="text-muted">Loading…</td></tr>';
try {
const r = await fetch(BACKEND + "/admin/videos", { headers });
const r = await fetch("/api/admin/videos");
if (!r.ok) throw new Error(await r.text());
allJobs = await r.json();
renderJobs();
@@ -233,7 +229,7 @@
}
async function apiPost(path) {
const r = await fetch(BACKEND + path, { method: "POST", headers });
const r = await fetch(path, { method: "POST" });
if (!r.ok) {
const d = await r.json().catch(() => ({}));
throw new Error(d.detail || r.statusText);
@@ -242,7 +238,7 @@
}
async function apiDelete(path) {
const r = await fetch(BACKEND + path, { method: "DELETE", headers });
const r = await fetch(path, { method: "DELETE" });
if (!r.ok) {
const d = await r.json().catch(() => ({}));
throw new Error(d.detail || r.statusText);
@@ -258,12 +254,12 @@
const id = btn.dataset.id;
try {
if (btn.classList.contains("vj-retry"))
await apiPost(`/admin/videos/${id}/retry`);
await apiPost(`/api/admin/videos/${id}/retry`);
if (btn.classList.contains("vj-cancel"))
await apiPost(`/admin/videos/${id}/cancel`);
await apiPost(`/api/admin/videos/${id}/cancel`);
if (btn.classList.contains("vj-delete")) {
if (!confirm("Permanently delete this video job?")) return;
await apiDelete(`/admin/videos/${id}`);
await apiDelete(`/api/admin/videos/${id}`);
}
await loadJobs();
} catch (err) {