// Archive View Component const { useState, useEffect } = React; const ArchiveView = () => { const toast = useToast(); const [jobs, setJobs] = useState([]); const [loading, setLoading] = useState(true); const [confirmDelete, setConfirmDelete] = useState(null); // jobId useEffect(() => { fetch('/queue/archived').then(r => r.json()).then(data => { if (data.status === 'success') setJobs(data.jobs || []); }).catch(console.error).finally(() => setLoading(false)); }, []); const handleDelete = (id) => { setConfirmDelete(id); }; const executeDelete = async () => { if (!confirmDelete) return; try { const r = await fetch(`/queue/job/${confirmDelete}/permanent`, { method: 'DELETE' }); if (r.ok) { toast('Lavoro eliminato', 'success'); setJobs(j => j.filter(x => x.id !== confirmDelete)); } setConfirmDelete(null); } catch (e) { toast('Errore eliminazione', 'error'); setConfirmDelete(null); } }; const handleRestore = async (id) => { try { const r = await fetch(`/queue/job/${id}/restore`, { method: 'POST' }); if (r.ok) { toast('Lavoro ripristinato in coda', 'success'); setJobs(j => j.filter(x => x.id !== id)); } else { const data = await r.json(); toast(data.detail || 'Errore ripristino', 'error'); } } catch (e) { toast('Errore ripristino', 'error'); } }; const getStatusInfo = (job) => { const isSuccess = job.result?.status === 'success'; const isCancelled = job.status === 'cancelled' || job.result?.status === 'cancelled'; if (isCancelled) { return { color: 'bg-orange-500', bgLight: 'bg-orange-100', textColor: 'text-orange-700', label: 'Annullato', percent: 0 }; } if (isSuccess) { return { color: 'bg-green-500', bgLight: 'bg-green-100', textColor: 'text-green-700', label: 'Completato', percent: 100 }; } return { color: 'bg-red-500', bgLight: 'bg-red-100', textColor: 'text-red-700', label: 'Fallito', percent: 0 }; }; const formatDate = (dateString) => { if (!dateString) return '-'; return new Date(dateString).toLocaleDateString('it-IT', { day: '2-digit', month: 'short', hour: '2-digit', minute: '2-digit' }); }; return (
Cronologia dei lavori archiviati
Caricamento archivio...
Archivio vuoto
I lavori archiviati appariranno qui