Compare commits

...

2 Commits

Author SHA1 Message Date
miklo b927182e7d added "first in queue" info 2025-12-06 12:16:56 +01:00
miklo d808603091 Merge pull request 'infokiosk texts speed and scroll' (#1) from infokiosk into master
Reviewed-on: #1
2025-12-05 14:44:02 +00:00
3 changed files with 23 additions and 15 deletions

View File

@ -64,7 +64,7 @@ def infokiosk():
return render_template("infokiosk.html", current=current) 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") @app.route("/current")
def current_api(): def current_api():
db = get_db() db = get_db()
@ -76,7 +76,11 @@ def current_api():
"SELECT COUNT(*) AS cnt FROM items WHERE status='waiting'" "SELECT COUNT(*) AS cnt FROM items WHERE status='waiting'"
).fetchone() ).fetchone()
waiting_count = cur_wait["cnt"] if cur_wait else 0 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) # Admin UI: start/reset system by providing count of tickets (1..N)

View File

@ -17,20 +17,22 @@
try{ try{
const r = await fetch('/current'); const r = await fetch('/current');
const j = await r.json(); const j = await r.json();
const cont = document.getElementById('nums'); const cont = document.getElementById('nums');
cont.innerHTML = ''; cont.innerHTML = '';
const list = j.current || []; const list = j.current || [];
if(list.length === 0){ if(list.length == 0){
cont.textContent = '-'; cont.textContent = '-';
return; } else {
} list.forEach(n => {
list.forEach(n => { const el = document.createElement('div');
const el = document.createElement('div'); el.className = 'num';
el.className = 'num'; el.textContent = n;
el.textContent = n; cont.appendChild(el);
cont.appendChild(el); });
}); };
document.getElementById('waiting-count').textContent = (j.waiting != null) ? j.waiting : '0'; document.getElementById('waiting-count').textContent = (j.waiting != null) ? j.waiting : '0';
document.getElementById('first-waiting').textContent = (j.first != 0 ) ? j.first : '-';
}catch(e){} }catch(e){}
} }
setInterval(fetchCurrent, 5000); setInterval(fetchCurrent, 5000);
@ -43,6 +45,7 @@
<div id="waiting" style="margin-top:18px;color:#333"> <div id="waiting" style="margin-top:18px;color:#333">
<h3>Wszystkich osób oczekujących: <span id="waiting-count">0</span></h3> <h3>Wszystkich osób oczekujących: <span id="waiting-count">0</span></h3>
<h3>Pierwszy w kolejce numer <span id="first-waiting">-</span></h3>
</div> </div>
</body> </body>

View File

@ -116,11 +116,12 @@
const nums = j.current || []; const nums = j.current || [];
const waitingCount = j.waiting != null ? j.waiting : '0'; 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 => `<span class="num-inline">${n}</span>`).join(' '); const numsFormatted = nums.map(n => `<span class="num-inline">${n}</span>`).join(' ');
const numList = nums.length > 0 ? `| Zapraszamy z numerami: ${numsFormatted}` : ''; 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'); const scrollContentElement = document.getElementById('scroll-content');