Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
workbenchthis machine
/admin's 'The arm rests on the table now' button sets the table there and shows the new height #354
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
smith/arm:smith/280-admin-s-the-arm-rests-on-the-table-now-b → main 1 commit fork
2 files
changed +13
−3
Software/so101/src/admin-page.test.ts +3
| @@ -26,7 +26,10 @@ test("the Table height field is the owner's alone", () => { | ||
| 26 | 26 | expect(owner).toContain('id="table-mm"'); |
| 27 | 27 | expect(owner).toContain('min="-100" max="100" step="1"'); |
| 28 | 28 | expect(owner).toContain('id="table-save"'); |
| 29 | expect(owner).toContain('id="table-here"'); | |
| 30 | expect(owner).toContain("/settings/table-here"); | |
| 29 | 31 | const mod = page(false); |
| 32 | expect(mod).not.toContain("table-here"); | |
| 30 | 33 | expect(mod).not.toContain("table-mm"); |
| 31 | 34 | expect(mod).not.toContain("tableOffsetMm"); |
| 32 | 35 | }); |
Software/so101/src/admin-page.ts +10 −3
| @@ -89,13 +89,20 @@ const TABLE_SCRIPT = ` | ||
| 89 | 89 | const input = document.getElementById("table-mm"); |
| 90 | 90 | const note = document.getElementById("table-note"); |
| 91 | 91 | const say = (text) => { note.textContent = text; }; |
| 92 | const settings = async (init) => { | |
| 93 | const r = await fetch("/settings", { cache: "no-store", credentials: "same-origin", ...init }); | |
| 92 | const settings = async ({ url = "/settings", ...init } = {}) => { | |
| 93 | const r = await fetch(url, { cache: "no-store", credentials: "same-origin", ...init }); | |
| 94 | 94 | const data = await r.json().catch(() => ({})); |
| 95 | 95 | if (!r.ok) throw new Error(typeof data.error === "string" ? data.error : "HTTP " + r.status); |
| 96 | 96 | return data; |
| 97 | 97 | }; |
| 98 | 98 | settings().then((s) => { input.value = String(s.tableOffsetMm); }).catch((e) => say(e.message)); |
| 99 | document.getElementById("table-here").addEventListener("click", async () => { | |
| 100 | try { | |
| 101 | const s = await settings({ method: "POST", url: "/settings/table-here", headers: { "content-type": "application/json" }, body: "{}" }); | |
| 102 | input.value = String(s.tableOffsetMm); | |
| 103 | say("The table is here: " + s.tableOffsetMm + " mm."); | |
| 104 | } catch (e) { say(e.message); } | |
| 105 | }); | |
| 99 | 106 | document.getElementById("table-save").addEventListener("click", async () => { |
| 100 | 107 | if (!input.reportValidity()) return; |
| 101 | 108 | try { |
| @@ -226,7 +233,7 @@ ${p.canEdit ? `<div class="save"><button class="go">Save settings</button></div> | ||
| 226 | 233 | </section> |
| 227 | 234 | ${p.canEdit ? `<section aria-labelledby="table"><h2 id="table">Table height</h2> |
| 228 | 235 | <div class="grid"><label>Table height<small>mm above the model's floor, -100 to 100; the safe zone keeps the arm above it</small><input id="table-mm" type="number" inputmode="numeric" min="-100" max="100" step="1"></label></div> |
| 229 | <div class="save"><button type="button" class="go" id="table-save">Save</button> <span id="table-note" role="status"></span></div> | |
| 236 | <div class="save"><button type="button" class="go" id="table-save">Save</button> <button type="button" id="table-here">The arm rests on the table now</button> <span id="table-note" role="status"></span></div> | |
| 230 | 237 | </section>` : ""} |
| 231 | 238 | <section aria-labelledby="health"><h2 id="health">Health</h2>${health(p.health ?? [])}</section> |
| 232 | 239 | <section aria-labelledby="mods"><h2 id="mods">Moderators</h2>${mods}</section> |
new above
offline