Actualizar automatizaciones.html

This commit is contained in:
2026-02-15 21:54:13 +00:00
parent b07661f52c
commit 00e5867f45

View File

@@ -110,25 +110,32 @@
setInterval(loadAutomations, 20000); setInterval(loadAutomations, 20000);
}); });
async function loadAutomations() { async function loadAutomations() {
try { try {
const res = await fetch(`${API_URL}/providers/scraped`, { const res = await fetch(`${API_URL}/providers/scraped`, {
headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` }
}); });
const data = await res.json(); const data = await res.json();
if (data.ok) { if (data.ok) {
scrapedData = data.services || []; scrapedData = data.services || [];
activeIntervals.forEach(clearInterval); activeIntervals.forEach(clearInterval);
activeIntervals = []; activeIntervals = [];
const inQueue = scrapedData.filter(s => s.automation_status === 'in_progress' && s.current_worker_name !== null); // Filtrado estricto: Solo mostramos lo que NO es 'manual'
const failed = scrapedData.filter(s => s.automation_status === 'failed' || (s.automation_status === 'in_progress' && s.current_worker_name === null)); const inQueue = scrapedData.filter(s =>
s.automation_status === 'in_progress' && s.current_worker_name !== null
);
renderCards(inQueue); const failed = scrapedData.filter(s =>
renderFailedTable(failed); s.automation_status === 'failed' ||
} (s.automation_status === 'in_progress' && s.current_worker_name === null)
} catch (e) { console.error(e); } );
renderCards(inQueue);
renderFailedTable(failed);
} }
} catch (e) { console.error(e); }
}
function renderCards(activeServices) { function renderCards(activeServices) {
const container = document.getElementById('automation-list'); const container = document.getElementById('automation-list');