Compare commits
2 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
b927182e7d | |
|
|
d808603091 |
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
} 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 @@
|
|||
|
||||
<div id="waiting" style="margin-top:18px;color:#333">
|
||||
<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>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -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 => `<span class="num-inline">${n}</span>`).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');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue