{{define "content"}}

Agents

{{template "agents-sub" .}}
Add agent
{{template "agents" .}}
{{end}} {{define "agents-sub"}}{{.Nav.AgentsTotal}} {{if eq .Nav.AgentsTotal 1}}machine{{else}}machines{{end}}{{if .MasterVersion}} · master {{.MasterVersion}}{{end}}{{end}} {{/* What /fragments/agents returns: the list, and the header count swapped in out of band. */}} {{define "agents-fragment"}} {{template "agents" .}} {{template "agents-sub" .}} {{end}} {{define "agents"}} {{range .Agents}}
{{.Name}}{{.Hostname}}
{{.Status}}
Agent{{.AgentVersion}}
Swarm{{.Role}}
Last seen{{if .Online}}now{{else}}{{with .LastSeenAt}}{{else}}—{{end}}{{end}}
{{if not .RevokedAt}}
Revoke
{{end}}
{{else}}

No agents yet.

{{end}} {{end}} {{/* The "add agent" panel beside the list. Step 1 asks for a name, step 2 shows the one-time token, step 3 waits for the agent to connect. */}} {{define "drawer"}} {{if .AddStep}}

Add agent

{{if eq .AddStep 1}}
{{template "steps" 1}}
{{if .Error}}{{end}}
Cancel
{{else}}
{{template "steps" 2}}
Name{{.Created.Name}}
This token is shown only once. Save the snippet as docker-compose.yml on the machine and run docker compose up -d.
docker-compose.yml
{{.Snippet}}
Token{{middle .Token}} Master key{{middle .MasterKey}}
{{template "connect" .}}
{{end}}
{{end}} {{end}} {{/* step is the one in progress (1 to 3); 4 marks all three as done. */}} {{define "steps"}}1Name2Deploy3Connect{{end}} {{/* Step 3. Until the agent has connected, Cancel revokes the token that was just created. */}} {{define "connect"}}{{if .Connected}}Connected · {{.Created.Hostname}} · {{.Created.AgentVersion}} Done
{{template "steps" 4}}
{{else}}Waiting for {{.Created.Name}}…
Done {{end}}{{end}}