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:
@@ -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(
|
||||||
|
"{{ config['BACKEND_URL'] }}/admin/videos/purge",
|
||||||
|
{
|
||||||
method: "POST",
|
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(
|
||||||
|
`{{ config['BACKEND_URL'] }}/admin/videos/${jobId}/cancel`,
|
||||||
|
{
|
||||||
method: "POST",
|
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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user