diff --git a/rotatyvote/app.py b/rotatyvote/app.py index 1609c6e..412656f 100644 --- a/rotatyvote/app.py +++ b/rotatyvote/app.py @@ -71,7 +71,7 @@ def admin_state(pid): "scans_required": p["scans_required"], "enrollment_open": bool(p["enrollment_open"]), "max_voters": p["max_voters"], "expected": p["expected"], "require_code": bool(p["require_code"]), "focus_qid": p["focus_qid"], - "vote_scans": p["vote_scans"], "code_style": p["code_style"], + "vote_scans": p["vote_scans"], "code_style": p["code_style"], "entry_big": bool(p["entry_big"]), }, "voters": db.voter_count(pid), "codes": codes_summary(pid), @@ -117,6 +117,7 @@ def screen_state(pid): "voters": db.voter_count(pid), "expected": p["expected"], "max_voters": p["max_voters"], "scans_required": p["scans_required"], "interval_ms": p["interval_ms"], "focus": focus, "presence": presence_check(p), "vote_scans": p["vote_scans"], "code_style": p["code_style"], + "entry_big": bool(p["entry_big"]), } @@ -459,6 +460,8 @@ async def admin_patch(request: Request): if d["code_style"] not in ("ring", "qr"): return err("bad_code_style") upd["code_style"] = d["code_style"] + if "entry_big" in d: + upd["entry_big"] = int(bool(d["entry_big"])) if "vote_scans" in d: upd["vote_scans"] = clamp_int(d["vote_scans"], 0, config.MAX_VOTE_SCANS, "vote_scans") if "focus_qid" in d: diff --git a/rotatyvote/db.py b/rotatyvote/db.py index 633a5da..dfa9a3d 100644 --- a/rotatyvote/db.py +++ b/rotatyvote/db.py @@ -89,6 +89,7 @@ class DB: ("polls", "code_style", "TEXT NOT NULL DEFAULT 'qr'"), ("polls", "trial", "INTEGER NOT NULL DEFAULT 0"), ("questions", "shown", "INTEGER NOT NULL DEFAULT 0"), + ("polls", "entry_big", "INTEGER NOT NULL DEFAULT 0"), ): cols = {r[1] for r in self.c.execute(f"PRAGMA table_info({table})")} if col not in cols: @@ -145,7 +146,7 @@ class DB: def update_poll(self, pid, **fields): allowed = {"title", "interval_ms", "scans_required", "enrollment_open", "max_voters", - "expected", "require_code", "focus_qid", "vote_scans", "code_style"} + "expected", "require_code", "focus_qid", "vote_scans", "code_style", "entry_big"} fields = {k: v for k, v in fields.items() if k in allowed} if not fields: return diff --git a/static/admin.html b/static/admin.html index 0ba2ce3..1174fc3 100644 --- a/static/admin.html +++ b/static/admin.html @@ -47,6 +47,11 @@ + +
diff --git a/static/css/screen.css b/static/css/screen.css index 2b2854a..529895e 100644 --- a/static/css/screen.css +++ b/static/css/screen.css @@ -30,6 +30,12 @@ body.split-on { --dock-qr: clamp(130px, min(26vh, 19vw), 380px); } .entry div { display: grid; gap: .2vh; font-size: clamp(.7rem, .95vw, 1rem); color: var(--ink-2); overflow-wrap: break-word; } .entry b { color: var(--ink); font-weight: 700; } body.has-entry .s-main:not(.split) .s-steps, body.has-entry .s-main.split #focus { padding-bottom: var(--dock-h); } +/* big mode: the entry qr takes the right column beside the ring, the steps give it the room. + translate, not transform: the entrance animation owns transform */ +body.entry-big { --dock-qr: clamp(180px, min(58vh, 34vw), 640px); } +body.entry-big .entry { top: 50%; bottom: auto; right: max(4vw, calc((50vw - var(--dock-qr)) / 2 - 2vw)); translate: 0 -46%; padding: 2vh; gap: 1.2vh; } +body.entry-big .entry div { font-size: clamp(.9rem, 1.4vw, 1.6rem); } +body.entry-big .s-main:not(.split) .s-steps { visibility: hidden; } /* the ring loop resizes the canvas bitmap every frame: its intrinsic size must not feed the layout, or safari widens the column, which grows the bitmap, which widens the column... */ #qr { width: 100%; height: 100%; min-width: 0; min-height: 0; contain: size; image-rendering: pixelated; image-rendering: crisp-edges; object-fit: contain; } @@ -95,6 +101,10 @@ body.has-entry .s-main:not(.split) .s-steps, body.has-entry .s-main.split #focus .s-main:not(.split) .s-enroll { grid-template-rows: minmax(0, 1fr) auto; gap: 3vh; height: 100%; } .s-main:not(.split) .qr-wrap { height: 100%; width: auto; max-width: 100%; max-height: none; } body.has-entry .s-main:not(.split) .s-steps { padding-bottom: 0; padding-right: calc(var(--dock-qr) + 6vw); } + /* no room beside the ring on an upright screen: the big qr stays a (bigger) corner one */ + body.entry-big { --dock-qr: clamp(140px, min(26vh, 40vw), 400px); } + body.entry-big .entry { top: auto; bottom: 1.5vh; right: 1.2vw; translate: none; } + body.entry-big .s-main:not(.split) .s-steps { visibility: visible; } /* upright + question: ring and title share one row above the question */ .s-main.split .s-enroll { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: none; height: auto; align-items: center; justify-items: stretch; } .s-main.split .qr-wrap { height: auto; width: 100%; max-height: 38vh; justify-self: center; } diff --git a/static/js/admin.js b/static/js/admin.js index 63724a6..6c018c5 100644 --- a/static/js/admin.js +++ b/static/js/admin.js @@ -78,6 +78,8 @@ function renderSettings(p) { if (active !== $("#s-max")) $("#s-max").value = p.max_voters ?? ""; if (active !== $("#s-vote-scans")) $("#s-vote-scans").value = String(p.vote_scans); if (active !== $("#s-code-style")) $("#s-code-style").value = p.code_style; + if (active !== $("#s-entry-big")) $("#s-entry-big").value = p.entry_big ? "1" : "0"; + $("#s-entry-big").disabled = p.code_style !== "ring"; $("#s-code").checked = p.require_code; $("#access-row").hidden = !p.require_code && !state.codes.access.total; const sum = (c, none) => (c.total ? `${c.used} utilisé${c.used > 1 ? "s" : ""} sur ${c.total}` : none); @@ -92,8 +94,8 @@ function renderQuestions() { box.append(h("p", { class: "empty" }, "Aucune question pour l'instant.")); return; } - const order = { open: 0, draft: 1, closed: 2 }; - const qs = [...state.questions].sort((a, b) => order[a.state] - order[b.state] || a.id - b.id); + // the open vote first, then newest first: a question just created or just closed stays at the top + const qs = [...state.questions].sort((a, b) => (b.state === "open") - (a.state === "open") || b.id - a.id); for (const q of qs) box.append(questionCard(q)); } @@ -207,6 +209,7 @@ const SETTINGS = { "#s-code": (el) => ({ require_code: el.checked }), "#s-vote-scans": (el) => ({ vote_scans: +el.value }), "#s-code-style": (el) => ({ code_style: el.value }), + "#s-entry-big": (el) => ({ entry_big: el.value === "1" }), }; for (const [sel, build] of Object.entries(SETTINGS)) { $(sel).addEventListener("change", async (e) => { diff --git a/static/js/screen.js b/static/js/screen.js index 2e9b567..b9f2da5 100644 --- a/static/js/screen.js +++ b/static/js/screen.js @@ -49,6 +49,10 @@ function layout() { const entryOn = !!(ring && st.enrollment_open && entry); reveal($("#entry"), entryOn); document.body.classList.toggle("has-entry", entryOn); + // big entry qr next to the ring (start of a meeting), back to the corner once a question is up + const big = entryOn && st.entry_big && !focus; + document.body.classList.toggle("entry-big", big); + $("#entry-hint").textContent = big ? "Scannez ici, puis visez le cercle" : "Pas encore sur la page ?"; $(".qr-wrap").classList.toggle("ring", ring); } diff --git a/static/screen.html b/static/screen.html index 9175938..1ce5a04 100644 --- a/static/screen.html +++ b/static/screen.html @@ -49,7 +49,7 @@