display waiting person counter
This commit is contained in:
parent
bf0b323e69
commit
701c638140
10
app.py
10
app.py
|
|
@ -55,11 +55,11 @@ def index():
|
||||||
@app.route("/current")
|
@app.route("/current")
|
||||||
def current_api():
|
def current_api():
|
||||||
db = get_db()
|
db = get_db()
|
||||||
cur = db.execute(
|
cur_called = db.execute("SELECT number FROM items WHERE status='called' ORDER BY id").fetchall()
|
||||||
"SELECT number FROM items WHERE status='called' ORDER BY id"
|
nums = [r["number"] for r in cur_called]
|
||||||
).fetchall()
|
cur_wait = db.execute("SELECT COUNT(*) AS cnt FROM items WHERE status='waiting'").fetchone()
|
||||||
nums = [r["number"] for r in cur]
|
waiting_count = cur_wait["cnt"] if cur_wait else 0
|
||||||
return jsonify(current=nums)
|
return jsonify(current=nums, waiting=waiting_count)
|
||||||
|
|
||||||
|
|
||||||
# Admin UI: start/reset system by providing count of tickets (1..N)
|
# Admin UI: start/reset system by providing count of tickets (1..N)
|
||||||
|
|
|
||||||
|
|
@ -30,14 +30,20 @@
|
||||||
el.textContent = n;
|
el.textContent = n;
|
||||||
cont.appendChild(el);
|
cont.appendChild(el);
|
||||||
});
|
});
|
||||||
|
document.getElementById('waiting-count').textContent = (j.waiting != null) ? j.waiting : '0';
|
||||||
}catch(e){}
|
}catch(e){}
|
||||||
}
|
}
|
||||||
setInterval(fetchCurrent, 2000);
|
setInterval(fetchCurrent, 5000);
|
||||||
window.addEventListener('load', fetchCurrent);
|
window.addEventListener('load', fetchCurrent);
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Zapraszamy do stanowiska osoby z numerem:</h1>
|
<h1>Zapraszamy do stanowiska osoby z numerem:</h1>
|
||||||
<div id="nums">-</div>
|
<div id="nums">-</div>
|
||||||
|
|
||||||
|
<div id="waiting" style="margin-top:18px;color:#333">
|
||||||
|
<h3>Liczba osób oczekujących: <span id="waiting-count">0</span></h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue