diff --git a/src/app.py b/src/app.py index c6daa40..df870a5 100644 --- a/src/app.py +++ b/src/app.py @@ -40,7 +40,7 @@ def close_db(exc): db.close() -# Main display for clients +# Main display for clients/mobile @app.route("/") def index(): db = get_db() @@ -52,19 +52,35 @@ def index(): return render_template("index.html", current=current) +# Main display for infokiosk +@app.route("/infokiosk") +def infokiosk(): + db = get_db() + cur = db.execute( + "SELECT number FROM items WHERE status='called' ORDER BY id DESC LIMIT 1" + ) + row = cur.fetchone() + current = row["number"] if row else "" + return render_template("infokiosk.html", current=current) + + # API endpoint used by clients to poll current number (JSON) @app.route("/current") def current_api(): db = get_db() - cur_called = db.execute("SELECT number FROM items WHERE status='called' ORDER BY id").fetchall() + cur_called = db.execute( + "SELECT number FROM items WHERE status='called' ORDER BY id" + ).fetchall() nums = [r["number"] for r in cur_called] - cur_wait = db.execute("SELECT COUNT(*) AS cnt FROM items WHERE status='waiting'").fetchone() + cur_wait = db.execute( + "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) # Admin UI: start/reset system by providing count of tickets (1..N) -# @app.route("/admin", methods=["GET", "POST"]) +# @app.route("/admin", methods=[":wGET", "POST"]) def admin(): db = get_db() @@ -72,7 +88,9 @@ def admin(): action = request.form.get("action") if action == "add": # dodaj nowy numer na końcu puli - cur = db.execute("SELECT number FROM items ORDER BY id DESC LIMIT 1").fetchone() + cur = db.execute( + "SELECT number FROM items ORDER BY id DESC LIMIT 1" + ).fetchone() if cur: try: last = int(cur["number"]) @@ -81,23 +99,34 @@ def admin(): new = last + 1 else: new = 1 - db.execute("INSERT INTO items (number, status) VALUES (?, 'waiting')", (str(new),)) + db.execute( + "INSERT INTO items (number, status) VALUES (?, 'waiting')", (str(new),) + ) db.commit() elif action == "call": num = request.form.get("num") - db.execute("UPDATE items SET status='called' WHERE number=? AND status='waiting'", (num,)) + db.execute( + "UPDATE items SET status='called' WHERE number=? AND status='waiting'", + (num,), + ) db.commit() elif action == "done": num = request.form.get("num") - db.execute("UPDATE items SET status='done' WHERE number=? AND status='called'", (num,)) + db.execute( + "UPDATE items SET status='done' WHERE number=? AND status='called'", + (num,), + ) db.commit() elif action == "return": num = request.form.get("num") if num: - db.execute("UPDATE items SET status='waiting' WHERE number=? AND status='called'", (num,)) + db.execute( + "UPDATE items SET status='waiting' WHERE number=? AND status='called'", + (num,), + ) db.commit() elif action == "reset": @@ -122,6 +151,7 @@ def admin(): done=[r["number"] for r in cur_done], ) + app.add_url_rule(ADMIN_PATH, endpoint="admin", view_func=admin, methods=["GET", "POST"]) diff --git a/src/static/background.mp4 b/src/static/background.mp4 new file mode 100644 index 0000000..50a1fa8 Binary files /dev/null and b/src/static/background.mp4 differ diff --git a/src/templates/infokiosk.html b/src/templates/infokiosk.html new file mode 100644 index 0000000..dfad5d2 --- /dev/null +++ b/src/templates/infokiosk.html @@ -0,0 +1,126 @@ + + + + + + Informacje + + + + + +
+
+ +
+ +
+
+ Zapraszamy z numerami: - +
+
+ Oczekujących: 0 +
+
+
+ + +