diff --git a/example.env b/example.env index b51feaa..79fa11f 100644 --- a/example.env +++ b/example.env @@ -1,4 +1,4 @@ -IPSERVER = 192.168.82.156 +IPSERVER=192.168.82.156 PORT=5000 ORA_DIRECTORY="C:/oracle/product/11.2.0.4" DB_USER=CSMKIOSCOS @@ -8,7 +8,7 @@ DB_PORT=1521 DB_SID=REALRAC1 MODE="1" THEME="csm" -MONITOR_ID_1=1 -MONITOR_ID_2=2 +MONITOR_ID_1=0 +MONITOR_ID_2=0 IS_QUIRO_1=0 -IS_QUIRO_2=1 \ No newline at end of file +IS_QUIRO_2=0 \ No newline at end of file diff --git a/static/js/scripts.js b/static/js/scripts.js index c34cbe7..7dca3c5 100644 --- a/static/js/scripts.js +++ b/static/js/scripts.js @@ -1,13 +1,17 @@ const sonido = new Audio("/static/media/0457.wav"); -const estadoAnterior = {}; +sonido.preload = "auto"; +const estadoAnterior = {}; let ultimoFooter = ""; function cargarTabla(endpoint, tablaId, esQuiro) { + const tbody = document.getElementById(tablaId); + if (!tbody) return; + fetch(endpoint) .then(res => res.json()) .then(filas => { - const tbody = document.getElementById(tablaId); + tbody.innerHTML = ""; let sizeClass = ""; @@ -19,21 +23,16 @@ function cargarTabla(endpoint, tablaId, esQuiro) { filas.forEach(fila => { const id = fila[0]; - const tr = document.createElement("tr"); + // Crear celda 1 const td1 = document.createElement("td"); td1.textContent = fila[0]; td1.className = `border align-middle ${sizeClass} m`; - if (esQuiro === "1") { - td1.style.backgroundColor = "#008968"; - } else { - td1.style.backgroundColor = window.themeColors.bg1; - } + td1.style.backgroundColor = esQuiro === "1" ? "#008968" : window.themeColors.bg1; tr.appendChild(td1); const td2 = document.createElement("td"); - const estadoConsulta = fila[1]; const estadoTurno = fila[3]; @@ -42,16 +41,13 @@ function cargarTabla(endpoint, tablaId, esQuiro) { td2.className = `border bg-[#a9a9a9] align-middle ${sizeClass}`; } else if (estadoConsulta == 1) { td2.textContent = fila[2]; - if (esQuiro === "1") { - td2.style.backgroundColor = "#00aa7a"; - } else { - td2.style.backgroundColor = window.themeColors.bg2; - } + td2.style.backgroundColor = esQuiro === "1" ? "#008968" : window.themeColors.bg1; const originalText = fila[2]; const blinkText = `PASE A
CONSULTA
`; let blink = false; if (estadoTurno == 1) { + //Activar parapdeo td2.className = `border align-middle ${sizeClass}`; td2.innerHTML = originalText; td2.style.backgroundColor = '#ffff00'; @@ -105,15 +101,16 @@ function cargarTabla(endpoint, tablaId, esQuiro) { } if (estadoAnterior[id] === 2 && estadoTurno === 1) { - sonido.play(); + sonido.currentTime = 0; + sonido.play().catch(err => console.warn("No se pudo reproducir el sonido: ", err)); } estadoAnterior[id] = estadoTurno; - tr.appendChild(td2); tbody.appendChild(tr); }); - }); + }) + .catch(err => console.error("Error cargando tabla: ", err)); } function cargarFooter() { diff --git a/templates/index.html b/templates/index.html index 51ce574..237a778 100644 --- a/templates/index.html +++ b/templates/index.html @@ -10,7 +10,7 @@ const quiro2 = "{{ quiro2 }}"; - +