From b927182e7dec6a06139dd52cc1ebd57258b5e0c4 Mon Sep 17 00:00:00 2001 From: miklo Date: Sat, 6 Dec 2025 12:16:56 +0100 Subject: [PATCH] added "first in queue" info --- src/app.py | 8 ++++++-- src/templates/index.html | 23 +++++++++++++---------- src/templates/infokiosk.html | 7 ++++--- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/app.py b/src/app.py index 75d8453..30a60b8 100644 --- a/src/app.py +++ b/src/app.py @@ -64,7 +64,7 @@ def infokiosk(): return render_template("infokiosk.html", current=current) -# API endpoint used by clients to poll current number (JSON) +# API endpoint used by clients to poll current number(s) (JSON) @app.route("/current") def current_api(): db = get_db() @@ -76,7 +76,11 @@ def current_api(): "SELECT COUNT(*) AS cnt FROM items WHERE status='waiting'" ).fetchone() waiting_count = cur_wait["cnt"] if cur_wait else 0 - return jsonify(current=nums, waiting=waiting_count) + cur_first = db.execute( + "SELECT number AS first FROM items WHERE status='waiting' ORDER BY id LIMIT 1" + ).fetchone() + first = cur_first["first"] if cur_first else 0 + return jsonify(current=nums, waiting=waiting_count, first=first) # Admin UI: start/reset system by providing count of tickets (1..N) diff --git a/src/templates/index.html b/src/templates/index.html index 8f33a9d..3c8645e 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -17,20 +17,22 @@ try{ const r = await fetch('/current'); const j = await r.json(); + const cont = document.getElementById('nums'); cont.innerHTML = ''; const list = j.current || []; - if(list.length === 0){ + if(list.length == 0){ cont.textContent = '-'; - return; - } - list.forEach(n => { - const el = document.createElement('div'); - el.className = 'num'; - el.textContent = n; - cont.appendChild(el); - }); - document.getElementById('waiting-count').textContent = (j.waiting != null) ? j.waiting : '0'; + } else { + list.forEach(n => { + const el = document.createElement('div'); + el.className = 'num'; + el.textContent = n; + cont.appendChild(el); + }); + }; + document.getElementById('waiting-count').textContent = (j.waiting != null) ? j.waiting : '0'; + document.getElementById('first-waiting').textContent = (j.first != 0 ) ? j.first : '-'; }catch(e){} } setInterval(fetchCurrent, 5000); @@ -43,6 +45,7 @@

Wszystkich osób oczekujących: 0

+

Pierwszy w kolejce numer -

diff --git a/src/templates/infokiosk.html b/src/templates/infokiosk.html index 1e08dc4..5774a23 100644 --- a/src/templates/infokiosk.html +++ b/src/templates/infokiosk.html @@ -116,11 +116,12 @@ const nums = j.current || []; const waitingCount = j.waiting != null ? j.waiting : '0'; + const first = j.first != 0 ? j.first : '-'; - const infoText = 'Chcesz spróbować swoich sił w lutowaniu? Odbierz numer i sprawdzaj kolejkę na queue.hswro.org'; + const infoText = 'Chcesz spróbować swoich sił w lutowaniu? Odbierz numer i sprawdzaj kolejkę tutaj lub na queue.hswro.org'; const numsFormatted = nums.map(n => `${n}`).join(' '); const numList = nums.length > 0 ? `| Zapraszamy z numerami: ${numsFormatted}` : ''; - const combinedText = `${infoText} | Oczekujących: ${waitingCount} ${numList}`; + const combinedText = `${infoText} | Liczba oczekujących: ${waitingCount} | Pierwszy w kolejce nr ${first} ${numList} `; const scrollContentElement = document.getElementById('scroll-content'); @@ -161,4 +162,4 @@ - \ No newline at end of file +