Skip to content

feat: web UI for the controller (Vue, in moip-toolkit's look) - #5

Merged
dodolia907 merged 8 commits into
mainfrom
feat/web-ui
Nov 22, 2026
Merged

dodolia907 merged 8 commits into
mainfrom
feat/web-ui

Conversation

@dodolia907

Copy link
Copy Markdown
Member

What

A web UI at /, embedded in the binary. It follows moip-toolkit's UI (same Tailwind theme, brand red, TechnoTUT header, status pills, light/dark), but as a plain Vue 3 + Vite single page, not Nuxt: the UI is one page that the Go binary embeds, so a framework with a server side and 820 packages (247 MB) is not needed; this one has 126 packages and builds in 2 seconds.

  • Nodes (left): one compact card each: receiver (source, resolution, fps, latency, dropped frames), sender, multi-view, signage, CPU and RAM. A node that moipctl cannot reach says so and cannot be selected.
  • NDI sources (right): merged from what the nodes see, with how many nodes see each and where it is shown.
  • Tick nodes, then "Show on N selected nodes": a running receiver is switched, a stopped one is started. A toast gives the result per node; failures come with their reason (and offline nodes are skipped, with the reason).
  • Stop a receiver, sender or multi-view, start or stop signage, rename a node. Everything updates by itself over /api/events.

This replaces looking up each node's IP and opening its own UI, which is what moipctl is for.

Security

The API has no authentication and is reachable from the DJ and AV networks, so putting a browser UI on it needed care:

  • CSRF: every write (POST, PUT) must now be Content-Type: application/json, and one that names another origin gets 403. A cross-site form or text/plain POST needs no preflight, so a web page open in an operator's browser could otherwise have driven the API. Breaking for scripts: curl needs -H 'Content-Type: application/json' (README updated).
  • XSS: the Content-Security-Policy allows only this origin, with no unsafe-inline or unsafe-eval (the built page has no inline script or style; the theme is applied by an external script). Names from the network (aliases, hostnames, NDI source names) are only ever rendered as text; a test sets a node's name to <img src=x onerror=...> and checks it is shown literally and not run.

Testing

  • Go: tests for the guard (415 for form/text/plain/no type, 403 for another origin, nothing reaches the node), the UI handler (headers, caching, 404, 405, a build without a UI), and that /api/ is not shadowed by the UI.
  • Frontend: the logic (health, merging sources, planning switch vs start, folding results) is plain functions with node --test; vue-tsc type check in strict mode.
  • make ui-check (test/ui/): five fake nodes in different states plus an unreachable one, a real moipctl with the UI embedded, and headless Chrome driven over the DevTools protocol. 21 checks: selecting, showing a source on two nodes (a switch and a start) and the toast, stopping a receiver, renaming (saved by the API), the hostile name, dark mode and that it survives a reload, no inline script, and no Content-Security-Policy violation in the console.
  • The container image builds with the new Node stage (18 s, 15.5 MB) and, run read-only as uid 10001 without capabilities, serves the UI, the headers and the guarded API.
  • CI gets a frontend job (tests, type check, build); the image workflow builds the UI through the Dockerfile.

Not done: a real browser on a real network with real nodes; accessibility beyond labels on the checkboxes; a layout for phones has only been looked at through the responsive classes, not tried.

🤖 Generated with Claude Code

dodolia907 and others added 8 commits November 22, 2026 21:52
The API has no authentication, and a web page open in an operator's
browser could drive it: a text/plain or form POST needs no preflight, so
the browser sends it. Every write now has to be application/json, which
makes a cross-site request non-simple (preflight, no CORS answer), and a
write whose Origin is not this host gets 403. Needed before the API gets a
web UI.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
internal/ui embeds internal/ui/dist (filled by `make frontend`) and serves
it at "/" with a Content-Security-Policy, nosniff and no framing; hashed
assets are cached for good, the page never. The API keeps everything under
/api/. Without a built UI the binary still builds and "/" says how to
build it, so go build and go test need no Node.js.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ts logic

A Vue 3 SPA built with Vite, styled with the same Tailwind setup and brand
colour (#C7000A) as moip-toolkit's frontend and with its logos, so that the
node UI and the controller UI look alike. No Nuxt: the UI is a single page
that is embedded in the Go binary, so a framework with a server side and
820 packages (247 MB) is not needed; this one is 126 packages.

The logic that decides what to show and what to send (node health, merging
the NDI sources the nodes see, planning a switch or a start per node,
folding the per-node results) is plain functions in src/logic.js, apart from
Vue, with tests that run under `node --test`. The lockfile is made with the
npm of Node 22, the one Docker and CI use.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Nodes on the left (one compact card each: receiver, sender, multi-view,
signage, CPU/RAM; an unreachable node says so and cannot be selected), the
NDI sources the nodes see on the right. Tick nodes, then "Show on N selected
nodes": a running receiver is switched, a stopped one started, and a toast
gives the result per node, failures with their reason. A card can stop its
receiver, sender or multi-view, start or stop signage, and rename the node.
Updates arrive over /api/events. Names that come from the network are only
ever shown as text, never as HTML. Light by default, dark on request and
remembered, with no inline script.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The built page has no inline script or style, so the policy now allows only
this origin and nothing can run or be styled from injected markup. Hashed
files are under /assets/ with Vite.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
`make frontend` builds the UI (Node.js) and copies it to internal/ui/dist,
where the binary embeds it; `make all` does both steps and `make test` also
runs the frontend's tests and type check. The Dockerfile gets a Node stage
that builds the UI before the Go build, so the image has it and nothing else
changes (15.5 MB). CI tests, type-checks and builds the frontend in its own
job.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
test/ui/run.sh starts five fake nodes in different states (and one that is
unreachable), a real moipctl with the UI embedded and headless Chrome, and
check.mjs drives the page over the DevTools protocol: selecting nodes,
showing a source on them (a switch and a start), the per-node toast, stopping
a receiver, renaming, the dark theme and its persistence, and that a hostile
node name is shown as text and not run. It also fails on a
Content-Security-Policy violation or an inline script. `make ui-check`.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@dodolia907
dodolia907 merged commit 8cdf49e into main Nov 22, 2026
3 checks passed
@dodolia907

Copy link
Copy Markdown
Member Author

Merged (merge commit) under the owner's standing go-ahead to merge PRs as needed, after CI passed (test, frontend, image with the new Node stage). Not released yet: tagging v0.2.0 (which publishes ghcr.io/technotut/moipctl:0.2.0) and moving the Infra manifests to it are the next steps and are waiting for the owner's go-ahead. Note for anyone with scripts: writes now need Content-Type: application/json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant