feat(server-fns): wire pages to live vervain-server data #8
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/wire-live-server-data"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Replaces the canned-data server fns with live proxies to vervain-server, adds a /login page, and makes fetch failures visible.
What changed
src/server_fns/control.rs: WebSocket client for vervain-server's/control.ashxcontrol channel. Connects with the browser's session token forwarded as themc_sessioncookie, then skims the connect burst (serverinfo,userinfo, ...) and unsolicitedeventframes until the matching action reply arrives. A 401 at upgrade maps to a stable "not signed in" marker the UI keys off.get_dashboard_stats,list_devices,get_device,list_meshes,list_users,list_events,list_pluginsnow map live control-channel replies (meshes,nodes,users,events,serverstats,plugins). Device rows resolve mesh names; mesh rows get device counts; events get a severity heuristic (the channel has no severity field).loginserver fn proxyingPOST /login(form-encoded): 303 +Set-Cookieon success re-issued as the HTTP-onlyvervain_sessioncookie (same pattern as the setup flow),err=otpreveals a TOTP field on the new/loginpage,err=1maps to a friendly bad-credentials message.Layoutredirects to/loginwhen the session cookie is missing; the setupNeedsFirstUserredirect still wins. Pages show aLoadErrorbanner on fetch failure (with a sign-in link for auth errors) instead of silently rendering empty tables.Server API caveats this codifies
serverstatsandpluginsare admin-only control actions the server silently ignores otherwise; they use a 3s timeout and the dashboard renders the Users/Relays KPIs as a dash for non-admins.icon) and the column is now "Platform".RelaySessions/RelayCountfromserverstatsuntil the server grows a relay API.Device.last_seenandMesh.createdbecameOption: never-connected devices and meshes without acreationfield render a dash.Verification
just checkclean (fmt, clippy -D warnings, server + wasm cargo check, tests).MESHCENTRAL_ENV=development, setup enabled): registered the first user, confirmed thePOST /logincontract with curl (303 + cookie on success,err=1on bad creds), then ran the built app withVERVAIN_SERVER_URLpointed at it. SSR with the session cookie showed live data on every page (user list with admin badge, login event on dashboard and events, KPIs Users=1 / Relays=0 / Events 24h=1, empty device/mesh tables for a fresh server); without the cookie the auth banner renders.Not in scope