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

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

smith/arm:smith/280-admin-s-the-arm-rests-on-the-table-now-b → main 1 commit fork

  • Merged. smith/280-admin-s-the-arm-rests-on-the-table-now-b was merged into main as 9e65041.

Review

Sign in to review this change.
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", () => {
2626 expect(owner).toContain('id="table-mm"');
2727 expect(owner).toContain('min="-100" max="100" step="1"');
2828 expect(owner).toContain('id="table-save"');
29 expect(owner).toContain('id="table-here"');
30 expect(owner).toContain("/settings/table-here");
2931 const mod = page(false);
32 expect(mod).not.toContain("table-here");
3033 expect(mod).not.toContain("table-mm");
3134 expect(mod).not.toContain("tableOffsetMm");
3235 });
Software/so101/src/admin-page.ts +10 −3
@@ -89,13 +89,20 @@ const TABLE_SCRIPT = `
8989 const input = document.getElementById("table-mm");
9090 const note = document.getElementById("table-note");
9191 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 });
9494 const data = await r.json().catch(() => ({}));
9595 if (!r.ok) throw new Error(typeof data.error === "string" ? data.error : "HTTP " + r.status);
9696 return data;
9797 };
9898 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 });
99106 document.getElementById("table-save").addEventListener("click", async () => {
100107 if (!input.reportValidity()) return;
101108 try {
@@ -226,7 +233,7 @@ ${p.canEdit ? `<div class="save"><button class="go">Save settings</button></div>
226233 </section>
227234 ${p.canEdit ? `<section aria-labelledby="table"><h2 id="table">Table height</h2>
228235 <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>
230237 </section>` : ""}
231238 <section aria-labelledby="health"><h2 id="health">Health</h2>${health(p.health ?? [])}</section>
232239 <section aria-labelledby="mods"><h2 id="mods">Moderators</h2>${mods}</section>

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs