Files
nixos-router/pkgs/router-webui/templates/update.html
T
nilsandClaude Sonnet 5.5 9cb2d28ea1 Put the Update and Packages pages on one Updates page
Router software and packages are two parts of one page, with one overlay,
one confirmation banner and both logs. /upgrade redirects to it; the
actions keep their addresses.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 22:55:54 +01:00

197 lines
9.1 KiB
HTML

{{define "content"}}
<div class="cols">
{{$u := .Data.Update}}{{$g := .Data.Upgrade}}
{{if $u.Status.Running}}
<div class="upload-overlay" role="dialog" aria-modal="true">
<div class="upload-card wide">
<h2>Updating…</h2>
<progress max="100" value="{{$u.Progress}}"></progress>
<p>{{$u.Step}}</p>
{{if $u.Status.Log}}<pre class="log">{{$u.Status.Log}}</pre>{{end}}
<p class="muted">This takes a few minutes. The page reloads when it is done; the web UI restarts when the new
version is switched on, and you log in again.</p>
</div>
</div>
{{else if $g.Run.Running}}
<div class="upload-overlay" role="dialog" aria-modal="true">
<div class="upload-card wide">
<h2>{{$g.Title}}</h2>
<progress max="100"></progress>
{{if $g.Run.Log}}<pre class="log">{{$g.Run.Log}}</pre>{{end}}
<p class="muted">The page reloads when it is done. The web UI restarts when an upgrade is switched on, and you log in again.</p>
</div>
</div>
{{else if $u.Pending}}
<section class="pending"><h2>Waiting for confirmation</h2>
<p>A new system is active and not confirmed yet. Confirm it on the <a href="/">Overview</a>, or the router goes back to the
previous one.</p></section>
{{end}}
<h2 class="part">Router software</h2>
<section>
<h2>Installed</h2>
<dl>
<dt>Version</dt><dd>{{or $u.Installed.Version "unknown"}}{{if $u.Installed.Rev}} <span class="muted">{{$u.Installed.Rev}}</span>{{end}}</dd>
<dt>Settings schema</dt><dd>{{$u.Installed.Schema}}</dd>
</dl>
</section>
<section>
<h2>Install a bundle</h2>
<p>A <code>.bundle</code> file made with <code>nix run .#release</code>. It is installed only if it is signed with
this router's update key. The settings are kept (and migrated if the new version needs it); the new version
must be confirmed afterwards, or the router goes back.</p>
<form method="post" action="/update/upload?csrf={{.CSRF}}" enctype="multipart/form-data" data-upload>
<p><label><input type="checkbox" name="force"> also install a version that is not newer</label></p>
<p><input type="file" name="bundle" required> <button>Upload and install</button></p>
</form>
</section>
<section>
<h2>Update server</h2>
<form method="post" action="/update/url" class="actions">
<input type="hidden" name="csrf" value="{{.CSRF}}">
<label>Address <input name="url" value="{{$u.URL}}" size="40" placeholder="https://updates.example.com/router"></label>
<button class="secondary">Save</button>
</form>
{{if $u.URL}}
<form method="post" action="/update/check" class="actions">
<input type="hidden" name="csrf" value="{{.CSRF}}">
<button class="secondary">Check for updates</button>
</form>
{{end}}
{{if $u.OfferErr}}<p class="error">Could not check: {{$u.OfferErr}}</p>{{end}}
{{with $u.Offer}}
<p>{{if .Newer}}Available: <strong>{{.Version}}</strong>{{if .Rev}} <span class="muted">{{.Rev}}</span>{{end}}.{{else}}Nothing newer: the server has {{.Version}}.{{end}}</p>
<form method="post" action="/update/install">
<input type="hidden" name="csrf" value="{{$.CSRF}}">
{{if not .Newer}}<p><label><input type="checkbox" name="force"> install it anyway</label></p>{{end}}
<button>{{if .Newer}}Install {{.Version}}{{else}}Install{{end}}</button>
</form>
{{end}}
<p class="hint">The server only has to serve static files: the <code>latest</code> file and <code>cache/</code> that
<code>nix run .#release</code> writes. The data is signed, so plain HTTP works too.</p>
</section>
<h2 class="part" id="packages">Packages</h2>
{{with $g.NewerRelease}}
<section class="notice">
<h2>NixOS {{.}} is out</h2>
<p>You follow {{$g.Channel}}. {{.}} is the newer stable release: switch the channel to it, then look for upgrades and
preview what would change. Nothing is installed until you upgrade, and NixOS cannot go back to the older release afterwards.</p>
<form method="post" action="/upgrade/channel" class="actions">
<input type="hidden" name="csrf" value="{{$.CSRF}}">
<input type="hidden" name="channel" value="{{.}}">
<button class="secondary">Follow {{.}}</button>
</form>
</section>
{{end}}
<section>
<h2>Channel</h2>
<p>Upgrades the kernel and all programs (NixOS) without a new release of nixos-router. Nothing is downloaded until
you ask for it, and an upgrade is activated like a settings change: unless you confirm it in time, the router
goes back to the previous system.</p>
<dl>
<dt>Running</dt><dd>{{or $g.Version "unknown"}}</dd>
</dl>
<form method="post" action="/upgrade/channel" class="actions">
<input type="hidden" name="csrf" value="{{.CSRF}}">
<label>Follow
<select name="channel">
{{range $g.Choices}}<option value="{{.Value}}"{{if eq .Value $g.Channel}} selected{{end}}>{{.Label}}</option>{{end}}
</select>
</label>
<button class="secondary">Save</button>
</form>
{{if $g.ReleasesSeen}}<p class="hint">Stable releases as the channel server listed them on {{$g.ReleasesSeen}}; Check for upgrades asks again.</p>{{end}}
<p class="hint">The channel only chooses what an upgrade offers; saving it changes nothing on the router. Going back to an older release
(unstable to 26.05) is refused unless you tick "downgrade anyway" when previewing; state written by the newer
release may not work with the older one.</p>
</section>
{{if $g.Channel}}
<section>
<h2>Check</h2>
<form method="post" action="/upgrade/check" class="actions">
<input type="hidden" name="csrf" value="{{.CSRF}}">
<button class="secondary"{{if or $g.Run.Running $g.Updating}} disabled{{end}}>Check for upgrades</button>
</form>
{{with $g.Check}}
<dl>
<dt>Channel</dt><dd>{{.Branch}}</dd>
<dt>Running</dt><dd>{{.Running.Version}}</dd>
<dt>Newest</dt><dd>{{printf "%.7s" .Newest.Rev}} <span class="muted">checked {{.Time}}</span></dd>
</dl>
{{if .UpToDate}}<p>Up to date.</p>{{else}}<p>A newer revision is available.</p>{{end}}
{{end}}
</section>
<section>
<h2>What would change</h2>
<form method="post" action="/upgrade/preview" class="actions">
<input type="hidden" name="csrf" value="{{.CSRF}}">
{{if and $g.Check $g.Check.UpToDate}}<label><input type="checkbox" name="force"> look anyway</label>{{end}}
<label><input type="checkbox" name="downgrade"> downgrade anyway</label>
<button class="secondary"{{if or $g.Run.Running $g.Updating}} disabled{{end}}>Preview</button>
</form>
<p class="hint">Works it out from the new revision's description: no package is downloaded.</p>
{{with $g.Preview}}
<p>{{$g.Version}} → <strong>{{.Version}}</strong> <span class="muted">{{printf "%.7s" .Rev}}, previewed {{.Time}}</span></p>
{{if .Changes}}
<table>
<thead><tr><th>Package</th><th>Now</th><th></th><th>New</th></tr></thead>
<tbody>{{range .Changes}}<tr><td>{{.Name}}</td><td>{{.From}}</td><td>→</td><td>{{.To}}</td></tr>{{end}}</tbody>
</table>
{{else}}<p>No package changes.</p>{{end}}
<p class="hint">The list shows the versions of programs the router runs; a program that is only rebuilt does not appear.</p>
<dl>
<dt>To download</dt><dd>{{or .Download "nothing, or the package cache cannot be reached"}}</dd>
<dt>Built here</dt><dd>{{.Builds}} derivation{{if ne .Builds 1}}s{{end}}{{if gt .Builds 50}} <span class="muted">(many: the package cache may not have them yet; this takes long)</span>{{end}}</dd>
{{if .RebootNeeded}}<dt>Kernel</dt><dd>A new kernel: it runs after the next reboot.</dd>{{end}}
</dl>
{{if .BuildNames}}
<details>
<summary>What is built here</summary>
<p class="hint">The system's own pieces (they carry the nixpkgs revision) and programs the package cache does not have yet.</p>
<ul>{{range .BuildNames}}<li>{{.}}</li>{{end}}</ul>
{{if .MoreBuilds}}<p class="muted">… and {{.MoreBuilds}} more</p>{{end}}
</details>
{{end}}
<div class="actions">
<form method="post" action="/upgrade/download">
<input type="hidden" name="csrf" value="{{$.CSRF}}">
<button class="secondary"{{if or $g.Run.Running $g.Updating $g.Pending}} disabled{{end}}>Download now</button>
</form>
<form method="post" action="/upgrade/apply">
<input type="hidden" name="csrf" value="{{$.CSRF}}">
<button{{if or $g.Run.Running $g.Updating $g.Pending}} disabled{{end}}>Upgrade to {{.Version}}</button>
</form>
</div>
<p class="hint">Downloading first lets you start the upgrade later without needing the internet. Upgrading
downloads what is missing, builds the system and switches to it; confirm it on the Overview.</p>
{{end}}
</section>
{{else}}
<section><p>Choose a channel to look for upgrades.</p></section>
{{end}}
{{if and $u.Status.Log (not $u.Status.Running)}}
<section>
<h2>Last update{{if $u.Status.Result}} — {{if eq $u.Status.Result "success"}}succeeded{{else}}failed ({{$u.Status.Result}}){{end}}{{end}}</h2>
<pre class="log">{{$u.Status.Log}}</pre>
</section>
{{end}}
{{if and $g.Run.Log (not $g.Run.Running)}}
<section>
<h2>Last package run{{if $g.Run.Result}} — {{if eq $g.Run.Result "success"}}succeeded{{else}}failed ({{$g.Run.Result}}){{end}}{{end}}</h2>
<pre class="log">{{$g.Run.Log}}</pre>
</section>
{{end}}
</div>
{{end}}