diff --git a/app.py b/app.py index 6af71a9..20f52bd 100644 --- a/app.py +++ b/app.py @@ -1,14 +1,12 @@ +from flask import Flask, render_template, jsonify import os from dotenv import load_dotenv import cx_Oracle -print("Usuario:", os.getenv("OraHome")) - -print("cx_Oracle version:", cx_Oracle.__version__) -print(cx_Oracle.clientversion()) - load_dotenv() +app = Flask(__name__) + user = os.getenv("DB_USER") password = os.getenv("DB_PASSWORD") host = os.getenv("DB_HOST") @@ -17,15 +15,17 @@ sid = os.getenv("DB_SID") dsn = cx_Oracle.makedsn(host, port, sid=sid) -try: - connection = cx_Oracle.connect(user=user, password=password, dsn=dsn) - cursor = connection.cursor() - cursor.execute("SELECT CODIGO_PERSONAL FROM FPERSONA WHERE APELLIDO1 LIKE '%ALFARO%' AND NOMBRE LIKE '%JESUS%'") +def conectar_oracle(user, password, dsn): + try: + connection = cx_Oracle.connect(user=user, password=password, dsn=dsn) + return connection + except cx_Oracle.DatabaseError as e: + print(f"Error de conexión: {e}") + raise - for row in cursor: - print(row) +@app.route('/') +def index(): + return render_template("index.html") - cursor.close() - connection.close() -except cx_Oracle.DatabaseError as e: - print(f"Error de conexión: {e}") \ No newline at end of file +if __name__ == '__main__': + app.run(debug=True) \ No newline at end of file diff --git a/example.env b/example.env index 7d673ea..1c091e0 100644 --- a/example.env +++ b/example.env @@ -1,5 +1,5 @@ -DB_USER=NOVAHIS -DB_PASSWORD=NOVAHIS +DB_USER=CSMKIOSCOS +DB_PASSWORD=CSMKIOSCOS DB_HOST=192.168.1.76 DB_PORT=1521 DB_SID=REALRAC1 \ No newline at end of file diff --git a/static/css/styles.css b/static/css/styles.css new file mode 100644 index 0000000..f2f10b2 --- /dev/null +++ b/static/css/styles.css @@ -0,0 +1,23 @@ +@keyframes scroll { + 0% { + transform: translateX(100%); + } + 100% { + transform: translateX(-100%); + } +} + +.animate-scroll { + display: inline-block; + animation: scroll 20s linear infinite; +} + + +@keyframes blink { + 0%, 100% { background-color: #0a6eb2} + 50% { background-color: #ffff00; color: black; } +} + +.blink-yellow { + animation: blink 3s steps(1,end) infinite; +} \ No newline at end of file diff --git a/static/js/scripts.js b/static/js/scripts.js new file mode 100644 index 0000000..672281c --- /dev/null +++ b/static/js/scripts.js @@ -0,0 +1,65 @@ +const sonido = new Audio("/static/media/0457.wav"); +const estadoAnterior = {}; + +function cargarTabla() { + fetch("/api/datos") + .then(res => res.json()) + .then(filas => { + const tbody = document.getElementById("turnos"); + tbody.innerHTML = ""; + filas.forEach(fila => { + const id = fila[0]; + + const tr = document.createElement("tr"); + + const td1 = document.createElement("td"); + td1.textContent = fila[0]; + td1.className = "border px-4 py-2 bg-[#114b94] align-middle"; + tr.appendChild(td1); + + const td2 = document.createElement("td"); + + const estadoConsulta = fila[1]; + const estadoTurno = fila[3]; + + if (estadoConsulta == 0) { + td2.textContent = "-"; + td2.className = "border px-4 py-2 bg-[#a9a9a9] align-middle"; + } else if (estadoConsulta == 1) { + td2.textContent = fila[2]; + if (estadoTurno == 1) { + sonido.play(); + td2.className = "border px-4 py-2 blink-yellow align-middle"; + } else { + td2.className = "border px-4 py-2 bg-[#0a6eb2] align-middle"; + } + } else { + td2.textContent = fila[2]; + td2.className = "border px-4 py-2 bg-[#a9a9a9] align-middle"; + } + + if (estadoAnterior[id] === 2 && estadoTurno === 1) { + sonido.play(); + } + + estadoAnterior[id] = estadoTurno; + + tr.appendChild(td2); + tbody.appendChild(tr); + }); + }); +} + +function cargarFooter() { + fetch("/api/footer") + .then(res => res.text()) + .then(data => { + const footerText = document.getElementById("footer-text"); + footerText.textContent = data.mensaje; + }); +} + +cargarFooter(); +cargarTabla(); +setInterval(cargarTabla, 30000); +setInterval(cargarFooter, 60000); diff --git a/static/js/utils.js b/static/js/utils.js new file mode 100644 index 0000000..ea879d3 --- /dev/null +++ b/static/js/utils.js @@ -0,0 +1,39 @@ +document.addEventListener("DOMContentLoaded", () => { + + function mostrarFecha() { + const hoy = new Date(); + + const opciones = { + weekday: 'long', + day: 'numeric', + month: 'long', + year: 'numeric' + }; + + const fechaFormateada = hoy.toLocaleDateString('es-ES', opciones); + + const divFecha = document.getElementById('fecha'); + if (divFecha) { + divFecha.textContent = fechaFormateada; + } + } + + function actualizarHora() { + const ahora = new Date(); + + const horas = String(ahora.getHours()).padStart(2, '0'); + const minutos = String(ahora.getMinutes()).padStart(2, '0'); + const segundos = String(ahora.getSeconds()).padStart(2, '0'); + + const horaFormateada = `${horas}:${minutos}:${segundos}`; + + const divHora = document.getElementById('hora'); + if (divHora) { + divHora.textContent = horaFormateada; + } + } + + mostrarFecha(); + actualizarHora(); + setInterval(actualizarHora, 1000); +}); \ No newline at end of file diff --git a/static/media/0457.wav b/static/media/0457.wav new file mode 100644 index 0000000..995e3c3 Binary files /dev/null and b/static/media/0457.wav differ diff --git a/static/media/CSM-HD.mp4 b/static/media/CSM-HD.mp4 new file mode 100644 index 0000000..7e9751e Binary files /dev/null and b/static/media/CSM-HD.mp4 differ diff --git a/static/media/csm.svg b/static/media/csm.svg new file mode 100644 index 0000000..d5a6f19 --- /dev/null +++ b/static/media/csm.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..4aee3ee --- /dev/null +++ b/templates/index.html @@ -0,0 +1,39 @@ + +
+ + + + + + + +| CONSULTA | +TURNO | +
|---|