Actualizar automatizaciones.html
This commit is contained in:
@@ -69,21 +69,33 @@
|
|||||||
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) {
|
||||||
activeIntervals.forEach(clearInterval);
|
activeIntervals.forEach(clearInterval);
|
||||||
activeIntervals = [];
|
activeIntervals = [];
|
||||||
|
|
||||||
renderCards(data.services.filter(s => s.automation_status === 'in_progress'));
|
// Solo mostramos arriba los que están en progreso Y TIENEN un operario con el turno activo
|
||||||
renderFailedTable(data.services.filter(s => s.automation_status === 'failed'));
|
const inQueue = data.services.filter(s =>
|
||||||
}
|
s.automation_status === 'in_progress' && s.current_worker_name !== null
|
||||||
} catch (e) { console.error(e); }
|
);
|
||||||
|
|
||||||
|
// Se consideran fallidos los que están marcados como 'failed'
|
||||||
|
// O los que están 'in_progress' pero ya no tienen a nadie en turno (ronda terminada)
|
||||||
|
const failed = data.services.filter(s =>
|
||||||
|
s.automation_status === 'failed' ||
|
||||||
|
(s.automation_status === 'in_progress' && s.current_worker_name === null)
|
||||||
|
);
|
||||||
|
|
||||||
|
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');
|
||||||
|
|||||||
Reference in New Issue
Block a user