diff --git a/automatizaciones.html b/automatizaciones.html index 45d8a2d..5ce07dc 100644 --- a/automatizaciones.html +++ b/automatizaciones.html @@ -84,62 +84,68 @@ } catch (e) { console.error(e); } } - function renderCards(activeServices) { - const container = document.getElementById('automation-list'); - if (activeServices.length === 0) { - container.innerHTML = ` -
- -

No hay automatismos en curso ahora

-
`; - lucide.createIcons(); - return; - } +function renderCards(activeServices) { + const container = document.getElementById('automation-list'); + if (activeServices.length === 0) { + container.innerHTML = `
+ +

No hay automatismos en curso

+
`; + lucide.createIcons(); + return; + } - container.innerHTML = activeServices.map(s => { - const raw = s.raw_data; - return ` -
-
-
- ${s.provider} - Ref: ${s.service_ref} -
-

${raw["Nombre Cliente"] || 'Sin nombre'}

-

📍 CP: ${raw["Código Postal"]} | ${raw["Gremio"] || 'Gremio'}

+ container.innerHTML = activeServices.map(s => { + const raw = s.raw_data; + // Calculamos el tiempo restante para la barra de progreso + const now = new Date(); + const expires = new Date(s.token_expires_at); + const diff = Math.max(0, Math.floor((expires - now) / 1000)); + const percent = Math.min(100, (diff / 300) * 100); // 300 seg = 5 min + + return ` +
+
+
+ ${s.provider} + Ref: ${s.service_ref} +
+

${raw["Nombre Cliente"] || raw["CLIENTE"] || 'Sin nombre'}

+

📍 CP: ${raw["Código Postal"] || raw["C.P."] || '---'}

+
+ +
+
+
+
- -
-
-
- -
-
-

Turno actual:

-

Marco Rincón

-
- -
-
- Tiempo de espera - 5m -
-
-
-
-
-
- -
- +
+

Turno actual:

+

${s.current_worker_name || 'Buscando...'}

- `; - }).join(''); - lucide.createIcons(); - } + +
+
+ Respuesta en + ${Math.floor(diff / 60)}m ${diff % 60}s +
+
+
+
+
+
+ +
+ +
+
+ `; + }).join(''); + lucide.createIcons(); +} function renderFailedTable(failedServices) { const tbody = document.getElementById('failed-list');