Streamd v0.2.0: rename, modules panel, stable/beta channels
All checks were successful
release / build-and-upload (push) Successful in 7m5s
All checks were successful
release / build-and-upload (push) Successful in 7m5s
- Rename product/host binary to streamd (drm compat copy still shipped) - Go module path streamd; STREAMD_* env aliases; agent UA streamd-agent - Panel Modules store + agent pull sync (modstore / modsync) - Rolling stable + beta download tags; README/docs channel curl blocks - Release notes in docs/releases/v0.2.0.md attached by Forgejo Actions
This commit is contained in:
parent
066e018749
commit
da8e1123ec
140 changed files with 2949 additions and 851 deletions
|
|
@ -26,6 +26,10 @@
|
|||
<span class="ico" aria-hidden="true"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M2 4h12M2 8h12M2 12h8"/></svg></span>
|
||||
Streams
|
||||
</a>
|
||||
<a href="#/modules" data-nav="/modules">
|
||||
<span class="ico" aria-hidden="true"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M3 3.5h4.5v4.5H3zM8.5 3.5H13v4.5H8.5zM3 8.5h4.5V13H3zM8.5 8.5H13V13H8.5z"/></svg></span>
|
||||
Modules
|
||||
</a>
|
||||
<a href="#/schedule" data-nav="/schedule">
|
||||
<span class="ico" aria-hidden="true"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="8" cy="8" r="5.5"/><path d="M8 5v3.5l2.5 1.5"/></svg></span>
|
||||
Schedule
|
||||
|
|
@ -81,7 +85,7 @@
|
|||
<form id="login-form" class="auth-card">
|
||||
<span class="logo big" aria-hidden="true"></span>
|
||||
<h2 id="gate-title">Sign in to streamd</h2>
|
||||
<p class="auth-sub">Null DRM restream control</p>
|
||||
<p class="auth-sub">Streamd control plane</p>
|
||||
<p id="gate-note" class="hint"></p>
|
||||
<label id="setup-row" hidden>Setup token
|
||||
<input name="setup_token" autocomplete="off" spellcheck="false" />
|
||||
|
|
|
|||
|
|
@ -640,6 +640,48 @@ dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(2px); }
|
|||
.table-wrap { margin: 0 -16px -16px; padding: 0 16px 4px; }
|
||||
}
|
||||
|
||||
/* ---------- modules dropzone / yaml editor ---------- */
|
||||
|
||||
.dropzone {
|
||||
border: 1.5px dashed var(--border-strong);
|
||||
border-radius: var(--radius);
|
||||
background: var(--bg-sunken);
|
||||
padding: 28px 20px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
transition: border-color var(--ease), background var(--ease);
|
||||
}
|
||||
.dropzone:hover, .dropzone:focus-visible {
|
||||
border-color: var(--accent);
|
||||
outline: none;
|
||||
}
|
||||
.dropzone.active {
|
||||
border-color: var(--accent);
|
||||
background: var(--accent-soft);
|
||||
}
|
||||
.dropzone-title {
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
color: var(--text);
|
||||
}
|
||||
.dropzone-sub {
|
||||
margin-top: 6px;
|
||||
font-size: 12.5px;
|
||||
color: var(--text-dim);
|
||||
max-width: 36rem;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
textarea.module-yaml {
|
||||
width: 100%;
|
||||
min-height: 28rem;
|
||||
font-family: var(--mono);
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
white-space: pre;
|
||||
tab-size: 2;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
* { transition: none !important; animation: none !important; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,4 +131,43 @@ export const api = {
|
|||
audit: (limit = 200) => api.get(`/api/audit?limit=${limit}`),
|
||||
agents: () => api.get("/api/agents"),
|
||||
apps: () => api.get("/api/apps"),
|
||||
|
||||
// --- modules ---
|
||||
modules: () => api.get("/api/modules"),
|
||||
module: (name, includeYaml) =>
|
||||
api.get(`/api/modules/${encodeURIComponent(name)}${includeYaml ? "?include=yaml" : ""}`),
|
||||
saveModuleYAML: (name, yaml) =>
|
||||
api.put(`/api/modules/${encodeURIComponent(name)}`, { yaml }),
|
||||
deleteModule: (name) => api.del(`/api/modules/${encodeURIComponent(name)}`),
|
||||
uploadModuleZip: async (file, name) => {
|
||||
const fd = new FormData();
|
||||
fd.append("file", file, file.name || "module.zip");
|
||||
if (name) fd.append("name", name);
|
||||
const headers = {};
|
||||
if (csrfToken) headers["X-CSRF-Token"] = csrfToken;
|
||||
const res = await fetch("/api/modules/upload", {
|
||||
method: "POST",
|
||||
headers,
|
||||
body: fd,
|
||||
credentials: "same-origin",
|
||||
});
|
||||
const text = await res.text();
|
||||
let data = null;
|
||||
if (text) {
|
||||
try {
|
||||
data = JSON.parse(text);
|
||||
} catch {
|
||||
data = { raw: text };
|
||||
}
|
||||
}
|
||||
if (res.status === 401) {
|
||||
for (const fn of onUnauthorized) fn(data);
|
||||
throw new ApiError((data && data.error) || "not signed in", 401, data);
|
||||
}
|
||||
if (!res.ok) {
|
||||
const msg = (data && data.error) || res.statusText || `upload failed (${res.status})`;
|
||||
throw new ApiError(msg, res.status, data);
|
||||
}
|
||||
return data;
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { dashboard } from "./views/dashboard.js";
|
|||
import { streams } from "./views/streams.js";
|
||||
import { streamView } from "./views/stream.js";
|
||||
import { scheduleView, settingsView, peopleView, auditView } from "./views/admin.js";
|
||||
import { modulesView } from "./views/modules.js";
|
||||
|
||||
const app = $("#app");
|
||||
const gate = $("#gate");
|
||||
|
|
@ -60,6 +61,11 @@ const ROUTES = [
|
|||
path: /^\/stream\/(\d+)(?:\/(live|config|debug))?$/, title: "Stream", nav: "/streams",
|
||||
mount: (root, m) => streamView(root, Number(m[1]), m[2] || "live"),
|
||||
},
|
||||
{ path: /^\/modules$/, title: "Modules", nav: "/modules", mount: (root) => modulesView(root) },
|
||||
{
|
||||
path: /^\/modules\/([^/]+)$/, title: "Edit module", nav: "/modules",
|
||||
mount: (root, m) => modulesView(root, decodeURIComponent(m[1])),
|
||||
},
|
||||
{ path: /^\/schedule$/, title: "Schedule", nav: "/schedule", mount: (root) => scheduleView(root) },
|
||||
{ path: /^\/settings$/, title: "Settings", nav: "/settings", admin: true, mount: (root) => settingsView(root) },
|
||||
{ path: /^\/people$/, title: "People & keys", nav: "/people", admin: true, mount: (root) => peopleView(root) },
|
||||
|
|
|
|||
|
|
@ -175,6 +175,9 @@ function openSocket() {
|
|||
case "claims_changed":
|
||||
scheduleRefresh(msg.type);
|
||||
break;
|
||||
case "modules_changed":
|
||||
emit("modules_changed");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
310
apps/streamd/internal/ui/static/js/views/modules.js
Normal file
310
apps/streamd/internal/ui/static/js/views/modules.js
Normal file
|
|
@ -0,0 +1,310 @@
|
|||
// Provider modules: drag-drop zip upload, list, YAML editor.
|
||||
|
||||
import {
|
||||
el, pill, toast, confirmDialog, fmtDateTime, clear, copyText,
|
||||
} from "../util.js";
|
||||
import { canEdit, subscribe } from "../store.js";
|
||||
import { api } from "../api.js";
|
||||
|
||||
function shortHash(h) {
|
||||
if (!h) return "—";
|
||||
return h.slice(0, 10);
|
||||
}
|
||||
|
||||
function fmtBytes(n) {
|
||||
if (!n) return "—";
|
||||
if (n < 1024) return `${n} B`;
|
||||
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
|
||||
return `${(n / (1024 * 1024)).toFixed(1)} MB`;
|
||||
}
|
||||
|
||||
export function modulesView(root, editName) {
|
||||
const stack = el("div.stack");
|
||||
root.append(stack);
|
||||
|
||||
let unsub = () => {};
|
||||
let disposed = false;
|
||||
|
||||
async function load() {
|
||||
if (disposed) return;
|
||||
clear(stack);
|
||||
if (editName) {
|
||||
await mountEditor(stack, editName, () => {
|
||||
location.hash = "#/modules";
|
||||
});
|
||||
return;
|
||||
}
|
||||
mountList(stack, load);
|
||||
}
|
||||
|
||||
load();
|
||||
unsub = subscribe((_s, reason) => {
|
||||
if (reason === "modules_changed" && !editName) load();
|
||||
});
|
||||
|
||||
return () => {
|
||||
disposed = true;
|
||||
unsub();
|
||||
if (stack._modulesUnload) stack._modulesUnload();
|
||||
};
|
||||
}
|
||||
|
||||
function mountList(stack, reload) {
|
||||
const body = el("tbody");
|
||||
const drop = el("div.dropzone", {
|
||||
tabindex: "0",
|
||||
role: "button",
|
||||
"aria-label": "Upload module zip",
|
||||
},
|
||||
el("div.dropzone-title", { text: "Drop a module .zip here" }),
|
||||
el("div.dropzone-sub", {
|
||||
text: "Release assets such as bbc.zip from modules-v* tags. Fill secrets in the YAML editor after upload.",
|
||||
}),
|
||||
el("div.row", { style: { marginTop: "10px", justifyContent: "center" } },
|
||||
el("button.sm", {
|
||||
type: "button",
|
||||
text: "Choose file…",
|
||||
onclick: (ev) => {
|
||||
ev.stopPropagation();
|
||||
fileInput.click();
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
const fileInput = el("input", {
|
||||
type: "file",
|
||||
accept: ".zip,application/zip",
|
||||
hidden: true,
|
||||
onchange: async () => {
|
||||
const f = fileInput.files && fileInput.files[0];
|
||||
fileInput.value = "";
|
||||
if (f) await uploadFile(f, reload);
|
||||
},
|
||||
});
|
||||
|
||||
if (canEdit()) {
|
||||
wireDropzone(drop, fileInput, reload);
|
||||
stack.append(el("div.card", drop, fileInput));
|
||||
}
|
||||
|
||||
stack.append(
|
||||
el("div.card",
|
||||
el("div.card-head",
|
||||
el("h2", { text: "Installed modules" }),
|
||||
el("span.spacer"),
|
||||
el("button.ghost.sm", { text: "Reload", onclick: () => reload() }),
|
||||
),
|
||||
el("p.hint", {
|
||||
text: "Agents pull package.zip and module.yaml from this panel. " +
|
||||
"Edit YAML here so every agent gets the same config.",
|
||||
}),
|
||||
el("div.table-wrap", el("table",
|
||||
el("thead", el("tr",
|
||||
el("th", { text: "Name" }),
|
||||
el("th", { text: "YAML" }),
|
||||
el("th", { text: "Package" }),
|
||||
el("th", { text: "Arches" }),
|
||||
el("th", { text: "Size" }),
|
||||
el("th", { text: "Updated" }),
|
||||
el("th", { text: "" }),
|
||||
)),
|
||||
body,
|
||||
)),
|
||||
),
|
||||
);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const d = await api.modules();
|
||||
const list = d.modules || [];
|
||||
clear(body);
|
||||
if (!list.length) {
|
||||
body.append(el("tr", el("td.empty", {
|
||||
colspan: "7",
|
||||
text: canEdit()
|
||||
? "No modules yet — drop a release zip above."
|
||||
: "No modules uploaded yet.",
|
||||
})));
|
||||
return;
|
||||
}
|
||||
for (const m of list) {
|
||||
body.append(moduleRow(m, reload));
|
||||
}
|
||||
} catch (err) {
|
||||
clear(body);
|
||||
body.append(el("tr", el("td.empty", { colspan: "7", text: err.message })));
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
function moduleRow(m, reload) {
|
||||
const arches = (m.arches || []).join(", ") || "—";
|
||||
const updated = m.yaml_updated_at || m.uploaded_at || "";
|
||||
return el("tr",
|
||||
el("td",
|
||||
el("div", { text: m.name }),
|
||||
el("div.sub.mono", { text: shortHash(m.package_sha256 || m.yaml_sha256) }),
|
||||
),
|
||||
el("td", m.has_yaml
|
||||
? el("span", { title: m.yaml_sha256 },
|
||||
pill("ok", "ok"),
|
||||
el("span.sub.mono", { text: " " + shortHash(m.yaml_sha256) }),
|
||||
)
|
||||
: pill("missing", "down")),
|
||||
el("td", m.has_package
|
||||
? el("span", { title: m.package_sha256 },
|
||||
pill("ok", "ok"),
|
||||
el("span.sub.mono", { text: " " + shortHash(m.package_sha256) }),
|
||||
)
|
||||
: pill("missing", "warn")),
|
||||
el("td.mono", { text: arches }),
|
||||
el("td", { text: fmtBytes(m.size_bytes) }),
|
||||
el("td", { text: updated ? fmtDateTime(updated) : "—" }),
|
||||
el("td.actions", el("div.row",
|
||||
canEdit() ? el("button.tiny.ghost", {
|
||||
text: "Edit YAML",
|
||||
onclick: () => { location.hash = `#/modules/${encodeURIComponent(m.name)}`; },
|
||||
}) : null,
|
||||
canEdit() ? el("button.tiny.danger", {
|
||||
text: "Delete",
|
||||
onclick: async () => {
|
||||
if (!(await confirmDialog(`Delete module ${m.name}?`,
|
||||
"Agents will stop receiving this module on the next sync.", "Delete"))) return;
|
||||
try {
|
||||
await api.deleteModule(m.name);
|
||||
toast(`Deleted ${m.name}`);
|
||||
reload();
|
||||
} catch (err) {
|
||||
toast(err.message, true);
|
||||
}
|
||||
},
|
||||
}) : null,
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
function wireDropzone(drop, fileInput, reload) {
|
||||
const setActive = (on) => drop.classList.toggle("active", on);
|
||||
drop.addEventListener("click", () => fileInput.click());
|
||||
drop.addEventListener("keydown", (ev) => {
|
||||
if (ev.key === "Enter" || ev.key === " ") {
|
||||
ev.preventDefault();
|
||||
fileInput.click();
|
||||
}
|
||||
});
|
||||
drop.addEventListener("dragenter", (ev) => { ev.preventDefault(); setActive(true); });
|
||||
drop.addEventListener("dragover", (ev) => { ev.preventDefault(); setActive(true); });
|
||||
drop.addEventListener("dragleave", () => setActive(false));
|
||||
drop.addEventListener("drop", async (ev) => {
|
||||
ev.preventDefault();
|
||||
setActive(false);
|
||||
const f = ev.dataTransfer && ev.dataTransfer.files && ev.dataTransfer.files[0];
|
||||
if (f) await uploadFile(f, reload);
|
||||
});
|
||||
}
|
||||
|
||||
async function uploadFile(file, reload) {
|
||||
if (!canEdit()) {
|
||||
toast("Operator role required to upload", true);
|
||||
return;
|
||||
}
|
||||
const lower = (file.name || "").toLowerCase();
|
||||
if (!lower.endsWith(".zip")) {
|
||||
toast("Upload a .zip module package", true);
|
||||
return;
|
||||
}
|
||||
toast(`Uploading ${file.name}…`);
|
||||
try {
|
||||
const res = await api.uploadModuleZip(file);
|
||||
const name = (res.module && res.module.name) || file.name;
|
||||
toast(`Uploaded ${name}`);
|
||||
reload();
|
||||
} catch (err) {
|
||||
toast(err.message || "Upload failed", true);
|
||||
}
|
||||
}
|
||||
|
||||
async function mountEditor(stack, name, onDone) {
|
||||
let data;
|
||||
try {
|
||||
data = await api.module(name, true);
|
||||
} catch (err) {
|
||||
stack.append(el("div.card",
|
||||
el("h2", { text: name }),
|
||||
el("p.msg.err", { text: err.message }),
|
||||
el("button.ghost", { text: "Back", onclick: onDone }),
|
||||
));
|
||||
return;
|
||||
}
|
||||
const m = data.module || { name };
|
||||
const ta = el("textarea.module-yaml", {
|
||||
value: data.yaml || "",
|
||||
spellcheck: "false",
|
||||
rows: "28",
|
||||
});
|
||||
let saved = data.yaml || "";
|
||||
const dirty = () => ta.value !== saved;
|
||||
|
||||
const form = el("div.card",
|
||||
el("div.card-head",
|
||||
el("h2", { text: `module.yaml — ${m.name}` }),
|
||||
el("span.spacer"),
|
||||
el("button.ghost.sm", { text: "Back", onclick: onDone }),
|
||||
),
|
||||
el("p.hint", {
|
||||
text: "Secrets and channel config live here. Saving updates every agent on the next sync (or immediately over websocket).",
|
||||
}),
|
||||
el("div.row", { style: { marginBottom: "8px", gap: "8px", flexWrap: "wrap" } },
|
||||
m.yaml_sha256 ? el("span.sub.mono", { text: `yaml ${shortHash(m.yaml_sha256)}` }) : null,
|
||||
m.package_sha256 ? el("span.sub.mono", { text: `pkg ${shortHash(m.package_sha256)}` }) : null,
|
||||
(m.arches || []).length ? el("span.sub", { text: (m.arches || []).join(", ") }) : null,
|
||||
),
|
||||
ta,
|
||||
el("div.row.end", { style: { marginTop: "14px" } },
|
||||
el("button.ghost", {
|
||||
text: "Copy",
|
||||
onclick: () => copyText(ta.value, "YAML"),
|
||||
}),
|
||||
el("button.ghost", {
|
||||
text: "Revert",
|
||||
onclick: () => {
|
||||
ta.value = saved;
|
||||
},
|
||||
}),
|
||||
el("button", {
|
||||
text: "Save YAML",
|
||||
onclick: async () => {
|
||||
if (!canEdit()) {
|
||||
toast("Operator role required", true);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await api.saveModuleYAML(m.name, ta.value);
|
||||
saved = ta.value;
|
||||
toast("YAML saved");
|
||||
if (res.module) {
|
||||
m.yaml_sha256 = res.module.yaml_sha256;
|
||||
}
|
||||
} catch (err) {
|
||||
toast(err.message, true);
|
||||
}
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
stack.append(form);
|
||||
|
||||
const onBeforeUnload = (ev) => {
|
||||
if (dirty()) {
|
||||
ev.preventDefault();
|
||||
ev.returnValue = "";
|
||||
}
|
||||
};
|
||||
window.addEventListener("beforeunload", onBeforeUnload);
|
||||
// Caller teardown should remove this; modulesView dispose covers navigation away.
|
||||
const prev = stack._modulesUnload;
|
||||
stack._modulesUnload = () => {
|
||||
window.removeEventListener("beforeunload", onBeforeUnload);
|
||||
if (prev) prev();
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue