From 8397638ec70b23e05ef490e15f5d7c5c05e52d1f Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 28 Nov 2026 08:54:05 +0100 Subject: feat(xbox): save a capture to the PC The viewer's "Save to PC" asks the server to download the capture into Pictures/Xbox (screenshots) or Videos/Xbox (clips), named by title and capture date; the old link stays as "Tablet". Co-Authored-By: Claude Opus 5.5 --- static/deck.css | 1 + static/modules/xbox.js | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'static') diff --git a/static/deck.css b/static/deck.css index 02c91aa..6e46154 100644 --- a/static/deck.css +++ b/static/deck.css @@ -972,6 +972,7 @@ dialog.vm-sheet::backdrop { background: color-mix(in srgb, var(--udt-crust) 55%, .xbox dialog.xb-view::backdrop { background: color-mix(in srgb, var(--udt-crust) 70%, transparent); } .xbox .xb-vmedia { width: 100%; max-height: 75vh; object-fit: contain; border-radius: 12px; background: var(--udt-crust); } .xbox .xb-vfoot { display: flex; align-items: center; justify-content: space-between; gap: 12px; } +.xbox .xb-vbtns { display: flex; gap: 8px; flex: none; } .xbox .xb-vdl { display: inline-flex; align-items: center; padding: 0 18px; font-size: 1rem; font-weight: 600; text-decoration: none; } .xbox .xb-gname {font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .xbox .xb-gmeta { color: var(--udt-subtext0); font-size: 0.857rem; } diff --git a/static/modules/xbox.js b/static/modules/xbox.js index 094b1c0..ad6eda2 100644 --- a/static/modules/xbox.js +++ b/static/modules/xbox.js @@ -213,14 +213,33 @@ function gameTile(t) { function view(c, dlg) { const media = c.kind === "clip" ? h("video", "xb-vmedia") : img(c.url, "xb-vmedia"); if (c.kind === "clip") Object.assign(media, { src: c.url, controls: true, autoplay: true, playsInline: true }); - const a = h("a", "ib xb-vdl", "Download"); + const a = h("a", "ib xb-vdl", "Tablet"); a.href = c.url; a.download = `${c.id}.${c.kind === "clip" ? "mp4" : "png"}`; a.referrerPolicy = "no-referrer"; + const meta = [c.title, new Date(c.date).toLocaleString(), + c.expires ? `kept until ${new Date(c.expires).toLocaleDateString()}` : null].filter(Boolean).join(" · "); + const info = h("div", "xb-gmeta", meta); + // The PC downloads it into Pictures/Xbox or Videos/Xbox; the answer names the file. + const pc = h("button", "ib xb-vdl", "Save to PC"); + pc.onclick = async () => { + pc.disabled = true; + info.textContent = "Saving…"; + try { + const r = await fetch("/api/xbox/save", { + method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ id: c.id }), + }); + if (!r.ok) throw new Error((await r.text()) || "save failed"); + info.textContent = `Saved: ${(await r.json()).path}`; + } catch (e) { + info.textContent = e.message; + } + pc.disabled = false; + }; const foot = h("div", "xb-vfoot"); - foot.append(h("div", "xb-gmeta", [c.title, new Date(c.date).toLocaleString(), - c.expires ? `kept until ${new Date(c.expires).toLocaleDateString()}` : null].filter(Boolean).join(" · "))); - foot.append(a); + const btns = h("div", "xb-vbtns"); + btns.append(pc, a); + foot.append(info, btns); const close = h("button", "ib nf xb-vclose", "\u{F0156}"); close.setAttribute("aria-label", "Close"); close.onclick = () => dlg.close(); -- cgit v1.2.3