/**
* The NODE product's setup window: hub or agent, plus the agent's hub
* connection.
*
* This build stages the `@camstack/server` closure, so both of its roles run a
* real node. It offers NO viewer option: watching a hub needs none of the
* 1.1 GB this product carries and ships as its own reduced product instead
* (ADR-0402). A store still holding the retired `viewer` role arrives here
* already coerced to `hub` by `roleForProduct`.
*/
import { HUB_PROD_PORT } from '../role/node-url'
import { escapeHtml } from './escape-html'
import type { HubMode } from './hub-mode'
import { setupDocument } from './setup-document'
export interface NodeSetupInitial {
readonly isAgent: boolean
readonly hubMode: HubMode
readonly hubAddress: string
readonly hubPort: number
readonly agentName: string
/** What the agent will be called when the field is left empty. */
readonly defaultAgentName: string
}
export function renderNodeSetup(initial: NodeSetupInitial): string {
const isAuto = initial.hubMode === 'auto'
const isAgent = initial.isAgent
return setupDocument({
submitLabel: 'Save and start',
body: `
Set up this CamStack machine
Choose whether this machine runs the CamStack hub or joins an existing hub as a worker.
Role
This machine runs the full CamStack server and admin UI. Cameras, recording
and analytics are managed here. The window opens the admin UI on
https://localhost:${HUB_PROD_PORT}.
This machine joins your CamStack cluster as a worker node and offloads
inference/decoding for a hub elsewhere on the network.
Hub connection
The agent starts without a hub. On the hub open Cluster → Nodes, pick this
agent under "Agents found on the network" and confirm the same six digits
on both screens.
Specify the hub's IP address (or hostname). Use this when the hub is on a
different subnet or its address is already known.