feat(console): install instructions for new agents, outdated agents
Creating a checker or status page server now shows how to install it next to the one-time token: the one-liner of the platform's install script and the Compose files with .env, with the token and kind filled in, and a switch between the self-updating and the plain image. Agents behind the platform's release are marked outdated in the organization's and the admin's agent lists, which also show each agent's release and the platform's. Closes #131 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
0c382f814c
commit
e281bcd604
8 files changed
+931
-456
No files matched your search
@@ -25,6 +25,27 @@ type Agent struct {
|
||||
// AllowPrivate is set for an organization's checkers: whether they
|
||||
// may check private addresses.
|
||||
AllowPrivate *bool
|
||||
// Release is what the agent last reported; Outdated marks agents
|
||||
// behind the platform's release.
|
||||
Release string
|
||||
Outdated bool
|
||||
}
|
||||
|
||||
// InstallView fills the install instructions shown with a new agent's
|
||||
// token.
|
||||
type InstallView struct {
|
||||
// ScriptURL is the platform's install script.
|
||||
ScriptURL string
|
||||
// APIURL goes into UPTIME_API_URL.
|
||||
APIURL string
|
||||
// Image is the image name without -checker or -statuspage.
|
||||
Image string
|
||||
// Channel is the image tag following the platform: latest, beta or edge.
|
||||
Channel string
|
||||
// Compose holds the Compose file per agent kind.
|
||||
Compose map[string]string
|
||||
// Release is the platform's release.
|
||||
Release string
|
||||
}
|
||||
|
||||
// RegionsView is the data of the org regions page and the admin panel.
|
||||
@@ -38,6 +59,7 @@ type RegionsView struct {
|
||||
Next string
|
||||
// OwnRegions are the regions agents can be created in.
|
||||
OwnRegions []Region
|
||||
Install InstallView
|
||||
}
|
||||
|
||||
templ regionsBody(v RegionsView) {
|
||||
@@ -117,6 +139,7 @@ templ regionsBody(v RegionsView) {
|
||||
<div data-link-output hidden class="mt-6 border border-ink p-4">
|
||||
<p class="mb-2 text-sm">{ i18n.T(ctx, "agents.token_now") }</p>
|
||||
<input data-link readonly class="w-full border border-rule bg-transparent px-2 py-1.5 font-mono text-xs"/>
|
||||
@agentInstall(v.Install)
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
@@ -124,6 +147,9 @@ templ regionsBody(v RegionsView) {
|
||||
if len(v.Agents) > 0 {
|
||||
<section>
|
||||
@sectionHeading("agents.list")
|
||||
if v.Install.Release != "" {
|
||||
<p class="mb-3 text-xs text-muted">{ i18n.T(ctx, "agents.platform_release", "Release", v.Install.Release) }</p>
|
||||
}
|
||||
<ul class="divide-y divide-rule border-y border-rule text-sm">
|
||||
for _, a := range v.Agents {
|
||||
<li class="flex items-center justify-between gap-4 py-2">
|
||||
@@ -133,7 +159,15 @@ templ regionsBody(v RegionsView) {
|
||||
if a.Region != "" {
|
||||
<span class="text-muted">· { a.Region }</span>
|
||||
}
|
||||
<span class="block font-mono text-xs text-muted">{ a.Prefix }… · { a.LastSeen }</span>
|
||||
<span class="block font-mono text-xs text-muted">
|
||||
{ a.Prefix }… · { a.LastSeen }
|
||||
if a.Release != "" {
|
||||
· { a.Release }
|
||||
}
|
||||
if a.Outdated {
|
||||
<span class="text-degraded" title={ i18n.T(ctx, "agents.outdated_hint") }>· { i18n.T(ctx, "agents.outdated") }</span>
|
||||
}
|
||||
</span>
|
||||
</span>
|
||||
if a.AllowPrivate != nil {
|
||||
<form data-api={ v.APIBase + "/agents/" + a.ID } data-method="patch" data-autosave class="ml-auto">
|
||||
@@ -383,3 +417,31 @@ templ AdminOrgsPage(p Page, me Me, v OrgsView) {
|
||||
@orgsSection(v)
|
||||
}
|
||||
}
|
||||
|
||||
// agentInstall shows how to run the agent just created; the script fills
|
||||
// in the token, the kind chosen and whether it updates itself.
|
||||
templ agentInstall(in InstallView) {
|
||||
<div data-install data-channel={ in.Channel } class="mt-6 border-t border-rule pt-4">
|
||||
<h3 class="mb-2 text-sm font-medium">{ i18n.T(ctx, "agents.install_heading") }</h3>
|
||||
<label class="mb-1 flex items-center gap-2 text-sm">
|
||||
<input type="checkbox" data-install-auto checked class="accent-ink"/>
|
||||
{ i18n.T(ctx, "agents.install_auto") }
|
||||
</label>
|
||||
<p class="mb-4 ml-6 text-xs text-muted">{ i18n.T(ctx, "agents.install_auto_hint") }</p>
|
||||
<p class="mb-1 text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "agents.install_oneliner") }</p>
|
||||
<pre data-install-fill={ "curl -fsSL " + in.ScriptURL + " | sudo sh -s -- {kind} --token {token}{manual}" } class="mb-1 overflow-x-auto whitespace-pre-wrap break-all border border-rule p-2 font-mono text-xs"></pre>
|
||||
<p data-install-kind="statuspage" class="mb-4 text-xs text-muted">{ i18n.T(ctx, "agents.install_statuspage_hint") }</p>
|
||||
<details class="mt-4">
|
||||
<summary class="cursor-pointer text-sm">{ i18n.T(ctx, "agents.install_compose") }</summary>
|
||||
for _, kind := range []string{"checker", "statuspage"} {
|
||||
<div data-install-kind={ kind } class="mt-3">
|
||||
<p class="mb-1 font-mono text-xs text-muted">compose.yaml</p>
|
||||
<pre class="mb-3 max-h-64 overflow-auto border border-rule p-2 font-mono text-xs">{ in.Compose[kind] }</pre>
|
||||
<p class="mb-1 font-mono text-xs text-muted">.env</p>
|
||||
<pre data-install-fill={ "UPTIME_API_URL=" + in.APIURL + "\nUPTIME_AGENT_TOKEN={token}\nUPTIME_AGENT_IMAGE=" + in.Image + "\nUPTIME_AGENT_TAG={tag}" } class="overflow-x-auto border border-rule p-2 font-mono text-xs"></pre>
|
||||
<p class="mt-2 text-xs text-muted">{ i18n.T(ctx, "agents.install_compose_hint") }</p>
|
||||
</div>
|
||||
}
|
||||
</details>
|
||||
</div>
|
||||
}
|
||||
Reference in new issue
Block a user