Repository navigation
feat: web UI for the controller (Vue, in moip-toolkit's look) - #5
Merged
Merged
Conversation
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>
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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./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:
Content-Type: application/json, and one that names another origin gets 403. A cross-site form ortext/plainPOST needs no preflight, so a web page open in an operator's browser could otherwise have driven the API. Breaking for scripts:curlneeds-H 'Content-Type: application/json'(README updated).unsafe-inlineorunsafe-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
/api/is not shadowed by the UI.node --test;vue-tsctype 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.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