Fix Error: Solvento el error de carga de una segunda tabla y añado un log para ver posibles errores con el audio

This commit is contained in:
2025-09-17 08:34:33 +02:00
parent 400e0c19ff
commit e1f64ee861
3 changed files with 19 additions and 22 deletions
+3 -3
View File
@@ -8,7 +8,7 @@ DB_PORT=1521
DB_SID=REALRAC1 DB_SID=REALRAC1
MODE="1" MODE="1"
THEME="csm" THEME="csm"
MONITOR_ID_1=1 MONITOR_ID_1=0
MONITOR_ID_2=2 MONITOR_ID_2=0
IS_QUIRO_1=0 IS_QUIRO_1=0
IS_QUIRO_2=1 IS_QUIRO_2=0
+14 -17
View File
@@ -1,13 +1,17 @@
const sonido = new Audio("/static/media/0457.wav"); const sonido = new Audio("/static/media/0457.wav");
const estadoAnterior = {}; sonido.preload = "auto";
const estadoAnterior = {};
let ultimoFooter = ""; let ultimoFooter = "";
function cargarTabla(endpoint, tablaId, esQuiro) { function cargarTabla(endpoint, tablaId, esQuiro) {
const tbody = document.getElementById(tablaId);
if (!tbody) return;
fetch(endpoint) fetch(endpoint)
.then(res => res.json()) .then(res => res.json())
.then(filas => { .then(filas => {
const tbody = document.getElementById(tablaId);
tbody.innerHTML = ""; tbody.innerHTML = "";
let sizeClass = ""; let sizeClass = "";
@@ -19,21 +23,16 @@ function cargarTabla(endpoint, tablaId, esQuiro) {
filas.forEach(fila => { filas.forEach(fila => {
const id = fila[0]; const id = fila[0];
const tr = document.createElement("tr"); const tr = document.createElement("tr");
// Crear celda 1
const td1 = document.createElement("td"); const td1 = document.createElement("td");
td1.textContent = fila[0]; td1.textContent = fila[0];
td1.className = `border align-middle ${sizeClass} m`; td1.className = `border align-middle ${sizeClass} m`;
if (esQuiro === "1") { td1.style.backgroundColor = esQuiro === "1" ? "#008968" : window.themeColors.bg1;
td1.style.backgroundColor = "#008968";
} else {
td1.style.backgroundColor = window.themeColors.bg1;
}
tr.appendChild(td1); tr.appendChild(td1);
const td2 = document.createElement("td"); const td2 = document.createElement("td");
const estadoConsulta = fila[1]; const estadoConsulta = fila[1];
const estadoTurno = fila[3]; const estadoTurno = fila[3];
@@ -42,16 +41,13 @@ function cargarTabla(endpoint, tablaId, esQuiro) {
td2.className = `border bg-[#a9a9a9] align-middle ${sizeClass}`; td2.className = `border bg-[#a9a9a9] align-middle ${sizeClass}`;
} else if (estadoConsulta == 1) { } else if (estadoConsulta == 1) {
td2.textContent = fila[2]; td2.textContent = fila[2];
if (esQuiro === "1") { td2.style.backgroundColor = esQuiro === "1" ? "#008968" : window.themeColors.bg1;
td2.style.backgroundColor = "#00aa7a";
} else {
td2.style.backgroundColor = window.themeColors.bg2;
}
const originalText = fila[2]; const originalText = fila[2];
const blinkText = `<span class="text-[2.25rem]">PASE A<br>CONSULTA</span>`; const blinkText = `<span class="text-[2.25rem]">PASE A<br>CONSULTA</span>`;
let blink = false; let blink = false;
if (estadoTurno == 1) { if (estadoTurno == 1) {
//Activar parapdeo
td2.className = `border align-middle ${sizeClass}`; td2.className = `border align-middle ${sizeClass}`;
td2.innerHTML = originalText; td2.innerHTML = originalText;
td2.style.backgroundColor = '#ffff00'; td2.style.backgroundColor = '#ffff00';
@@ -105,15 +101,16 @@ function cargarTabla(endpoint, tablaId, esQuiro) {
} }
if (estadoAnterior[id] === 2 && estadoTurno === 1) { 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; estadoAnterior[id] = estadoTurno;
tr.appendChild(td2); tr.appendChild(td2);
tbody.appendChild(tr); tbody.appendChild(tr);
}); });
}); })
.catch(err => console.error("Error cargando tabla: ", err));
} }
function cargarFooter() { function cargarFooter() {
+1 -1
View File
@@ -10,7 +10,7 @@
const quiro2 = "{{ quiro2 }}"; const quiro2 = "{{ quiro2 }}";
</script> </script>
<script src="{{ url_for('static', filename='js/utils.js') }}"></script> <script src="{{ url_for('static', filename='js/utils.js') }}"></script>
<script src="{{ url_for('static', filename='js/scripts.js') }}"></script> <script src="{{ url_for('static', filename='js/scripts.js') }}" defer></script>
<style>:root {--blink-start-color: {{ theme_colors.bg2 }};}</style> <style>:root {--blink-start-color: {{ theme_colors.bg2 }};}</style>
</head> </head>