2025-08-20 07:32:40 -04:00
|
|
|
import React, { useState, useEffect, useRef } from "react";
|
|
|
|
|
import { toast } from "react-toastify";
|
2025-07-31 19:28:59 -04:00
|
|
|
import { DataTable } from "primereact/datatable";
|
|
|
|
|
import { Column } from "primereact/column";
|
|
|
|
|
import { Dropdown } from "primereact/dropdown";
|
|
|
|
|
import { Button } from "@mui/joy";
|
2025-08-01 15:17:25 -04:00
|
|
|
import { Dialog } from "primereact/dialog";
|
2025-08-21 15:07:10 -04:00
|
|
|
import { authFetch } from "@/utils/authFetch";
|
2025-07-31 20:25:02 -04:00
|
|
|
import { confirmDialog, ConfirmDialog } from "primereact/confirmdialog";
|
2025-07-31 19:28:59 -04:00
|
|
|
import BreadcrumbNav from "./BreadcrumbNav";
|
2025-08-20 07:32:40 -04:00
|
|
|
import { API_URL } from "@/config";
|
2025-12-05 14:21:52 -05:00
|
|
|
import "./RequestManagement.css";
|
2025-07-31 19:28:59 -04:00
|
|
|
|
2025-08-28 11:15:17 -04:00
|
|
|
const STATUS_OPTIONS = ["Queued", "Started", "Compressing", "Finished", "Failed"];
|
2025-08-21 15:07:10 -04:00
|
|
|
const TAR_BASE_URL = "https://codey.lol/m/m2"; // configurable prefix
|
2025-08-01 15:17:25 -04:00
|
|
|
|
2025-07-31 19:28:59 -04:00
|
|
|
export default function RequestManagement() {
|
2025-08-20 07:32:40 -04:00
|
|
|
const [requests, setRequests] = useState([]);
|
2025-07-31 19:28:59 -04:00
|
|
|
const [filterType, setFilterType] = useState(null);
|
|
|
|
|
const [filterStatus, setFilterStatus] = useState(null);
|
2025-08-20 07:32:40 -04:00
|
|
|
const [filteredRequests, setFilteredRequests] = useState([]);
|
2025-08-01 15:17:25 -04:00
|
|
|
const [selectedRequest, setSelectedRequest] = useState(null);
|
|
|
|
|
const [isDialogVisible, setIsDialogVisible] = useState(false);
|
2025-12-05 14:21:52 -05:00
|
|
|
const [isLoading, setIsLoading] = useState(true);
|
2025-08-20 07:32:40 -04:00
|
|
|
const pollingRef = useRef(null);
|
|
|
|
|
const pollingDetailRef = useRef(null);
|
|
|
|
|
|
|
|
|
|
|
2025-08-21 15:07:10 -04:00
|
|
|
const tarballUrl = (absPath, quality) => {
|
2025-08-20 07:32:40 -04:00
|
|
|
if (!absPath) return null;
|
|
|
|
|
const filename = absPath.split("/").pop(); // get "SOMETHING.tar.gz"
|
2025-08-21 15:07:10 -04:00
|
|
|
return `${TAR_BASE_URL}/${quality}/${filename}`;
|
2025-08-20 07:32:40 -04:00
|
|
|
};
|
|
|
|
|
|
2025-12-05 14:21:52 -05:00
|
|
|
const fetchJobs = async (showLoading = true) => {
|
2025-08-20 07:32:40 -04:00
|
|
|
try {
|
2025-12-05 14:21:52 -05:00
|
|
|
if (showLoading) setIsLoading(true);
|
2025-08-20 07:32:40 -04:00
|
|
|
const res = await authFetch(`${API_URL}/trip/jobs/list`);
|
|
|
|
|
if (!res.ok) throw new Error("Failed to fetch jobs");
|
|
|
|
|
const data = await res.json();
|
|
|
|
|
setRequests(Array.isArray(data.jobs) ? data.jobs : []);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error(err);
|
2025-08-20 15:57:59 -04:00
|
|
|
if (!toast.isActive('fetch-fail-toast')) {
|
|
|
|
|
toast.error("Failed to fetch jobs list", {
|
|
|
|
|
toastId: 'fetch-fail-toast',
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-12-05 14:21:52 -05:00
|
|
|
} finally {
|
|
|
|
|
setIsLoading(false);
|
2025-08-20 07:32:40 -04:00
|
|
|
}
|
|
|
|
|
};
|
2025-08-01 15:17:25 -04:00
|
|
|
|
2025-08-20 07:32:40 -04:00
|
|
|
const fetchJobDetail = async (jobId) => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await authFetch(`${API_URL}/trip/job/${jobId}`);
|
|
|
|
|
if (!res.ok) throw new Error("Failed to fetch job details");
|
|
|
|
|
return await res.json();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error(err);
|
2025-08-21 15:07:10 -04:00
|
|
|
if (!toast.isActive('fetch-job-fail-toast')) {
|
|
|
|
|
toast.error("Failed to fetch job details",
|
|
|
|
|
{
|
|
|
|
|
toastId: "fetch-job-fail-toast",
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-08-20 07:32:40 -04:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-07-31 19:28:59 -04:00
|
|
|
|
2025-08-20 07:32:40 -04:00
|
|
|
useEffect(() => { fetchJobs(); }, []);
|
2025-07-31 19:28:59 -04:00
|
|
|
useEffect(() => {
|
2025-08-20 07:32:40 -04:00
|
|
|
if (isDialogVisible && selectedRequest) {
|
|
|
|
|
// Start polling
|
|
|
|
|
const poll = async () => {
|
|
|
|
|
const updated = await fetchJobDetail(selectedRequest.id);
|
|
|
|
|
if (updated) setSelectedRequest(updated);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
pollingDetailRef.current = setInterval(poll, 1500);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
if (pollingDetailRef.current) {
|
|
|
|
|
clearInterval(pollingDetailRef.current);
|
|
|
|
|
pollingDetailRef.current = null;
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-07-31 19:28:59 -04:00
|
|
|
}
|
2025-08-20 07:32:40 -04:00
|
|
|
}, [isDialogVisible, selectedRequest?.id]);
|
|
|
|
|
useEffect(() => {
|
2025-08-28 11:15:17 -04:00
|
|
|
const hasActive = requests.some((j) => ["Queued", "Started", "Compressing"].includes(j.status));
|
2025-08-20 07:32:40 -04:00
|
|
|
if (hasActive && !pollingRef.current) pollingRef.current = setInterval(fetchJobs, 1500);
|
|
|
|
|
else if (!hasActive && pollingRef.current) {
|
|
|
|
|
clearInterval(pollingRef.current);
|
|
|
|
|
pollingRef.current = null;
|
2025-07-31 19:28:59 -04:00
|
|
|
}
|
2025-08-20 07:32:40 -04:00
|
|
|
return () => { if (pollingRef.current) clearInterval(pollingRef.current); pollingRef.current = null; };
|
|
|
|
|
}, [requests]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2025-08-20 15:57:59 -04:00
|
|
|
const filtered = requests.filter((r) => {
|
|
|
|
|
const typeMatch = !filterType || r.type === filterType;
|
|
|
|
|
const statusMatch = filterStatus === "all" || filterStatus === null || r.status === filterStatus;
|
|
|
|
|
return typeMatch && statusMatch;
|
|
|
|
|
});
|
2025-07-31 19:28:59 -04:00
|
|
|
setFilteredRequests(filtered);
|
|
|
|
|
}, [filterType, filterStatus, requests]);
|
|
|
|
|
|
2025-08-20 15:57:59 -04:00
|
|
|
|
2025-08-20 07:32:40 -04:00
|
|
|
const getStatusColorClass = (status) => {
|
2025-08-01 15:29:27 -04:00
|
|
|
switch (status) {
|
2025-08-28 11:15:17 -04:00
|
|
|
case "Queued": return "bg-yellow-700 text-white";
|
|
|
|
|
case "Started": return "bg-blue-700 text-white";
|
|
|
|
|
case "Compressing": return "bg-orange-700 text-white";
|
|
|
|
|
case "Finished": return "bg-green-700 text-white";
|
|
|
|
|
case "Failed": return "bg-red-700 text-white";
|
|
|
|
|
default: return "bg-gray-700 text-white";
|
2025-08-01 15:29:27 -04:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-08-21 15:07:10 -04:00
|
|
|
const getQualityColorClass = (quality) => {
|
|
|
|
|
switch (quality) {
|
2025-08-28 11:15:17 -04:00
|
|
|
case "FLAC": return "bg-green-700 text-white";
|
|
|
|
|
case "Lossy": return "bg-yellow-700 text-white";
|
|
|
|
|
default: return "bg-gray-700 text-white";
|
2025-08-21 15:07:10 -04:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 07:32:40 -04:00
|
|
|
const statusBodyTemplate = (rowData) => (
|
2025-12-05 14:21:52 -05:00
|
|
|
<span className={`inline-flex items-center justify-center min-w-[90px] px-3 py-1 rounded-full font-semibold text-xs ${getStatusColorClass(rowData.status)}`}>
|
2025-08-20 07:32:40 -04:00
|
|
|
{rowData.status}
|
|
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
|
2025-08-21 15:07:10 -04:00
|
|
|
const qualityBodyTemplate = (rowData) => (
|
2025-12-05 14:21:52 -05:00
|
|
|
<span className={`inline-flex items-center justify-center min-w-[50px] px-3 py-1 rounded-full font-semibold text-xs ${getQualityColorClass(rowData.quality)}`}>
|
2025-08-21 15:07:10 -04:00
|
|
|
{rowData.quality}
|
|
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 07:32:40 -04:00
|
|
|
const safeText = (val) => (val === 0 ? "0" : val || "—");
|
|
|
|
|
const textWithEllipsis = (val, width = "12rem") => (
|
|
|
|
|
<span className="truncate block" style={{ maxWidth: width }} title={val || ""}>{val || "—"}</span>
|
|
|
|
|
);
|
|
|
|
|
|
2025-08-21 15:07:10 -04:00
|
|
|
const truncate = (text, maxLen) =>
|
|
|
|
|
maxLen <= 3
|
|
|
|
|
? text.slice(0, maxLen)
|
|
|
|
|
: text.length <= maxLen
|
|
|
|
|
? text
|
|
|
|
|
: text.slice(0, maxLen - 3) + '...';
|
|
|
|
|
|
|
|
|
|
|
2025-08-20 07:32:40 -04:00
|
|
|
const basename = (p) => (typeof p === "string" ? p.split("/").pop() : "");
|
|
|
|
|
|
|
|
|
|
const formatProgress = (p) => {
|
|
|
|
|
if (p === null || p === undefined || p === "") return "—";
|
|
|
|
|
const num = Number(p);
|
|
|
|
|
if (Number.isNaN(num)) return "—";
|
2025-08-20 15:57:59 -04:00
|
|
|
const pct = num > 1 ? Math.round(num) : num;
|
2025-08-20 07:32:40 -04:00
|
|
|
return `${pct}%`;
|
|
|
|
|
};
|
2025-08-01 15:29:27 -04:00
|
|
|
|
2025-12-05 14:21:52 -05:00
|
|
|
const progressBarTemplate = (rowData) => {
|
|
|
|
|
const p = rowData.progress;
|
|
|
|
|
if (p === null || p === undefined || p === "") return "—";
|
|
|
|
|
const num = Number(p);
|
|
|
|
|
if (Number.isNaN(num)) return "—";
|
|
|
|
|
const pct = Math.min(100, Math.max(0, num > 1 ? Math.round(num) : num * 100));
|
|
|
|
|
|
|
|
|
|
const getProgressColor = () => {
|
|
|
|
|
if (rowData.status === "Failed") return "bg-red-500";
|
|
|
|
|
if (rowData.status === "Finished") return "bg-green-500";
|
|
|
|
|
if (pct < 30) return "bg-blue-400";
|
|
|
|
|
if (pct < 70) return "bg-blue-500";
|
|
|
|
|
return "bg-blue-600";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="progress-bar-container">
|
|
|
|
|
<div className="progress-bar-track">
|
|
|
|
|
<div
|
|
|
|
|
className={`progress-bar-fill ${getProgressColor()}`}
|
|
|
|
|
style={{ width: `${pct}%` }}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<span className="progress-bar-text">{pct}%</span>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-31 19:28:59 -04:00
|
|
|
const confirmDelete = (requestId) => {
|
|
|
|
|
confirmDialog({
|
|
|
|
|
message: "Are you sure you want to delete this request?",
|
|
|
|
|
header: "Confirm Delete",
|
|
|
|
|
icon: "pi pi-exclamation-triangle",
|
|
|
|
|
accept: () => deleteRequest(requestId),
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const deleteRequest = (requestId) => {
|
|
|
|
|
setRequests((prev) => prev.filter((r) => r.id !== requestId));
|
|
|
|
|
toast.success("Request deleted");
|
|
|
|
|
};
|
|
|
|
|
|
2025-08-20 07:32:40 -04:00
|
|
|
const actionBodyTemplate = (rowData) => (
|
|
|
|
|
<Button
|
|
|
|
|
color="neutral"
|
|
|
|
|
variant="outlined"
|
|
|
|
|
size="sm"
|
|
|
|
|
sx={{
|
|
|
|
|
color: "#e5e7eb",
|
|
|
|
|
borderColor: "#6b7280",
|
|
|
|
|
'&:hover': { backgroundColor: '#374151', borderColor: '#9ca3af' },
|
|
|
|
|
}}
|
|
|
|
|
onClick={(e) => { e.stopPropagation(); confirmDelete(rowData.id); }}
|
|
|
|
|
>
|
|
|
|
|
Delete
|
|
|
|
|
</Button>
|
|
|
|
|
);
|
2025-07-31 19:28:59 -04:00
|
|
|
|
2025-08-20 07:32:40 -04:00
|
|
|
const handleRowClick = async (e) => {
|
|
|
|
|
const detail = await fetchJobDetail(e.data.id);
|
|
|
|
|
if (detail) { setSelectedRequest(detail); setIsDialogVisible(true); }
|
2025-07-31 19:28:59 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2025-08-20 07:32:40 -04:00
|
|
|
|
2025-12-05 14:21:52 -05:00
|
|
|
<div className="trip-management-container my-10 p-4 sm:p-6 rounded-xl shadow-md
|
2025-08-20 07:32:40 -04:00
|
|
|
bg-white dark:bg-neutral-900
|
|
|
|
|
text-neutral-900 dark:text-neutral-100
|
2025-12-05 14:21:52 -05:00
|
|
|
border border-neutral-200 dark:border-neutral-700">
|
2025-08-01 15:17:25 -04:00
|
|
|
|
2025-07-31 19:28:59 -04:00
|
|
|
<BreadcrumbNav currentPage="management" />
|
2025-12-05 14:21:52 -05:00
|
|
|
<h2 className="text-2xl sm:text-3xl font-bold tracking-tight mb-6">Manage Requests</h2>
|
2025-07-31 19:28:59 -04:00
|
|
|
|
2025-12-05 14:21:52 -05:00
|
|
|
<div className="flex flex-wrap items-center gap-4 mb-6">
|
2025-07-31 19:28:59 -04:00
|
|
|
<Dropdown
|
|
|
|
|
value={filterStatus}
|
2025-08-20 15:57:59 -04:00
|
|
|
options={[{ label: "All Statuses", value: "all" }, ...STATUS_OPTIONS.map((s) => ({ label: s, value: s }))]}
|
2025-07-31 19:28:59 -04:00
|
|
|
onChange={(e) => setFilterStatus(e.value)}
|
|
|
|
|
placeholder="Filter by Status"
|
|
|
|
|
className="min-w-[180px]"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-12-05 14:21:52 -05:00
|
|
|
{isLoading ? (
|
|
|
|
|
<div className="table-skeleton">
|
|
|
|
|
{[...Array(5)].map((_, i) => (
|
|
|
|
|
<div key={i} className="skeleton-row">
|
|
|
|
|
<div className="skeleton-cell w-[10%]"><div className="skeleton-bar" /></div>
|
|
|
|
|
<div className="skeleton-cell w-[22%]"><div className="skeleton-bar" /></div>
|
|
|
|
|
<div className="skeleton-cell w-[10%]"><div className="skeleton-bar" /></div>
|
|
|
|
|
<div className="skeleton-cell w-[12%]"><div className="skeleton-bar" /></div>
|
|
|
|
|
<div className="skeleton-cell w-[16%]"><div className="skeleton-bar" /></div>
|
|
|
|
|
<div className="skeleton-cell w-[10%]"><div className="skeleton-bar" /></div>
|
|
|
|
|
<div className="skeleton-cell w-[20%]"><div className="skeleton-bar" /></div>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<div className="table-wrapper w-full">
|
|
|
|
|
<DataTable
|
|
|
|
|
value={filteredRequests}
|
|
|
|
|
paginator
|
|
|
|
|
rows={10}
|
|
|
|
|
removableSort
|
|
|
|
|
sortMode="multiple"
|
|
|
|
|
emptyMessage={
|
|
|
|
|
<div className="empty-state">
|
|
|
|
|
<i className="pi pi-inbox empty-state-icon" />
|
|
|
|
|
<p className="empty-state-text">No requests found</p>
|
|
|
|
|
<p className="empty-state-subtext">Requests you submit will appear here</p>
|
|
|
|
|
</div>
|
2025-09-12 22:39:35 -04:00
|
|
|
}
|
2025-12-05 14:21:52 -05:00
|
|
|
onRowClick={handleRowClick}
|
|
|
|
|
resizableColumns={false}
|
|
|
|
|
className="w-full"
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
<Column
|
|
|
|
|
field="id"
|
|
|
|
|
header="ID"
|
|
|
|
|
body={(row) => (
|
|
|
|
|
<span title={row.id}>
|
|
|
|
|
{row.id.split("-").slice(-1)[0]}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
<Column field="target" header="Target" sortable body={(row) => textWithEllipsis(row.target, "100%")} />
|
|
|
|
|
<Column field="tracks" header="# Tracks" body={(row) => row.tracks} />
|
|
|
|
|
<Column field="status" header="Status" body={statusBodyTemplate} style={{ textAlign: "center" }} sortable />
|
|
|
|
|
<Column field="progress" header="Progress" body={progressBarTemplate} style={{ textAlign: "center" }} sortable />
|
|
|
|
|
<Column
|
|
|
|
|
field="quality"
|
|
|
|
|
header="Quality"
|
|
|
|
|
body={qualityBodyTemplate}
|
|
|
|
|
style={{ textAlign: "center" }}
|
|
|
|
|
sortable />
|
|
|
|
|
<Column
|
|
|
|
|
field="tarball"
|
|
|
|
|
header={
|
|
|
|
|
<span className="flex items-center">
|
|
|
|
|
<i className="pi pi-download mr-1" />
|
|
|
|
|
Tarball
|
|
|
|
|
</span>
|
|
|
|
|
}
|
|
|
|
|
body={(row) => {
|
|
|
|
|
const url = tarballUrl(row.tarball, row.quality || "FLAC");
|
|
|
|
|
const encodedURL = encodeURI(url);
|
|
|
|
|
if (!url) return "—";
|
|
|
|
|
|
|
|
|
|
const fileName = url.split("/").pop();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<a
|
|
|
|
|
href={encodedURL}
|
|
|
|
|
target="_blank"
|
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
|
className="truncate text-blue-500 hover:underline"
|
|
|
|
|
title={fileName}
|
|
|
|
|
>
|
|
|
|
|
{truncate(fileName, 28)}
|
|
|
|
|
</a>
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</DataTable>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-08-20 07:32:40 -04:00
|
|
|
|
2025-07-31 20:25:02 -04:00
|
|
|
<ConfirmDialog />
|
2025-08-20 07:32:40 -04:00
|
|
|
|
2025-08-01 15:17:25 -04:00
|
|
|
<Dialog
|
|
|
|
|
header="Request Details"
|
|
|
|
|
visible={isDialogVisible}
|
|
|
|
|
style={{ width: "500px" }}
|
|
|
|
|
onHide={() => setIsDialogVisible(false)}
|
2025-08-20 07:32:40 -04:00
|
|
|
breakpoints={{ "960px": "95vw" }}
|
2025-08-01 15:29:27 -04:00
|
|
|
modal
|
|
|
|
|
dismissableMask
|
2025-08-20 07:32:40 -04:00
|
|
|
className="dark:bg-neutral-900 dark:text-neutral-100"
|
2025-08-01 15:17:25 -04:00
|
|
|
>
|
2025-08-20 07:32:40 -04:00
|
|
|
{selectedRequest ? (
|
2025-08-01 15:17:25 -04:00
|
|
|
<div className="space-y-4 text-sm">
|
2025-08-28 11:15:17 -04:00
|
|
|
|
|
|
|
|
{/* --- Metadata Card --- */}
|
|
|
|
|
<div className="p-3 bg-gray-100 dark:bg-neutral-800 rounded-md grid grid-cols-2 gap-4">
|
|
|
|
|
{selectedRequest.id && <p className="col-span-2 break-all"><strong>ID:</strong> {selectedRequest.id}</p>}
|
|
|
|
|
{selectedRequest.target && <p><strong>Target:</strong> {selectedRequest.target}</p>}
|
|
|
|
|
{selectedRequest.tracks && <p><strong># Tracks:</strong> {selectedRequest.tracks}</p>}
|
|
|
|
|
{selectedRequest.quality && (
|
|
|
|
|
<p>
|
|
|
|
|
<strong>Quality:</strong>{" "}
|
|
|
|
|
<span className={`px-2 py-0.5 rounded-full text-xs font-bold ${getQualityColorClass(selectedRequest.quality)}`}>
|
|
|
|
|
{selectedRequest.quality}
|
|
|
|
|
</span>
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* --- Status / Progress Card --- */}
|
|
|
|
|
<div className="p-3 bg-gray-100 dark:bg-neutral-800 rounded-md grid grid-cols-2 gap-4">
|
|
|
|
|
{selectedRequest.status && (
|
|
|
|
|
<p>
|
|
|
|
|
<strong>Status:</strong>{" "}
|
|
|
|
|
<span className={`px-2 py-0.5 rounded-full text-xs font-bold ${getStatusColorClass(selectedRequest.status)}`}>
|
|
|
|
|
{selectedRequest.status}
|
|
|
|
|
</span>
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
{selectedRequest.progress !== undefined && selectedRequest.progress !== null && (
|
2025-12-05 14:21:52 -05:00
|
|
|
<div className="col-span-2">
|
|
|
|
|
<strong>Progress:</strong>
|
|
|
|
|
<div className="progress-bar-container mt-2">
|
|
|
|
|
<div className="progress-bar-track progress-bar-track-lg">
|
|
|
|
|
<div
|
|
|
|
|
className={`progress-bar-fill ${selectedRequest.status === "Failed" ? "bg-red-500" : selectedRequest.status === "Finished" ? "bg-green-500" : "bg-blue-500"}`}
|
|
|
|
|
style={{ width: `${Math.min(100, Math.max(0, Number(selectedRequest.progress) > 1 ? Math.round(selectedRequest.progress) : selectedRequest.progress * 100))}%` }}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<span className="progress-bar-text">{formatProgress(selectedRequest.progress)}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-08-28 11:15:17 -04:00
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* --- Timestamps Card --- */}
|
|
|
|
|
<div className="p-3 bg-gray-100 dark:bg-neutral-800 rounded-md grid grid-cols-1 gap-2">
|
|
|
|
|
{selectedRequest.enqueued_at && <p><strong>Enqueued:</strong> {new Date(selectedRequest.enqueued_at).toLocaleString()}</p>}
|
|
|
|
|
{selectedRequest.started_at && <p><strong>Started:</strong> {new Date(selectedRequest.started_at).toLocaleString()}</p>}
|
|
|
|
|
{selectedRequest.ended_at && <p><strong>Ended:</strong> {new Date(selectedRequest.ended_at).toLocaleString()}</p>}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* --- Tarball Card --- */}
|
|
|
|
|
{
|
|
|
|
|
selectedRequest.tarball && (
|
|
|
|
|
<div className="p-3 bg-gray-100 dark:bg-neutral-800 rounded-md">
|
|
|
|
|
<p>
|
|
|
|
|
<strong>Tarball:</strong>{" "}
|
|
|
|
|
<a
|
2025-09-12 22:39:35 -04:00
|
|
|
href={encodeURI(tarballUrl(selectedRequest.tarball, selectedRequest.quality))}
|
2025-08-28 11:15:17 -04:00
|
|
|
target="_blank"
|
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
|
className="text-blue-500 hover:underline"
|
|
|
|
|
>
|
|
|
|
|
{tarballUrl(selectedRequest.tarball, selectedRequest.quality).split("/").pop()}
|
|
|
|
|
</a>
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</div >
|
2025-08-20 07:32:40 -04:00
|
|
|
) : (
|
|
|
|
|
<p>Loading...</p>
|
2025-08-21 15:07:10 -04:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
</Dialog >
|
2025-08-01 15:17:25 -04:00
|
|
|
|
2025-08-28 11:15:17 -04:00
|
|
|
|
2025-08-21 15:07:10 -04:00
|
|
|
</div >
|
2025-07-31 19:28:59 -04:00
|
|
|
);
|
|
|
|
|
}
|