ui+store: dashboard polish — repo size projection + header alignment

- Project total_size_bytes onto hosts.repo_size_bytes inside the
  UpsertHostRepoStats transaction. The hosts row column has been
  unwritten since the initial schema in 0001, so the dashboard's
  Repo size cell has always rendered '—' even after backups. Now
  the column updates atomically alongside the host_repo_stats row,
  and FleetSummary's SUM(repo_size_bytes) becomes accurate too.
- Right-align the Alerts column header so it sits over its
  right-aligned value (was floating left of column, ambiguous).
- Add text-ink-mid to the 30d trend / Alerts / Tags headers so all
  column headers share the same brightness.
This commit is contained in:
2026-05-07 22:55:21 +01:00
parent 7011510092
commit c4dc9e9119
2 changed files with 18 additions and 3 deletions
+15
View File
@@ -211,6 +211,21 @@ func (s *Store) UpsertHostRepoStats(ctx context.Context, hostID string, patch Ho
); err != nil { ); err != nil {
return fmt.Errorf("store: upsert host_repo_stats: %w", err) return fmt.Errorf("store: upsert host_repo_stats: %w", err)
} }
// Project total_size_bytes onto the dashboard's host row so the
// "Repo size" column and FleetSummary.SUM(repo_size_bytes) stay in
// sync with the latest report. We only write a non-nil size — a
// patch that doesn't carry a size (e.g. a prune-only ack) leaves
// the prior row value alone.
if cur.TotalSizeBytes != nil {
if _, err = tx.ExecContext(ctx,
`UPDATE hosts SET repo_size_bytes = ? WHERE id = ?`,
*cur.TotalSizeBytes, hostID,
); err != nil {
return fmt.Errorf("store: project repo_size_bytes onto hosts row: %w", err)
}
}
return tx.Commit() return tx.Commit()
} }
+3 -3
View File
@@ -213,10 +213,10 @@
<div><a href="{{index $sortURL "os"}}" class="text-ink-mid hover:text-ink">OS · arch{{if eq $f.Sort "os"}} {{if eq $f.Dir "desc"}}↓{{else}}↑{{end}}{{end}}</a></div> <div><a href="{{index $sortURL "os"}}" class="text-ink-mid hover:text-ink">OS · arch{{if eq $f.Sort "os"}} {{if eq $f.Dir "desc"}}↓{{else}}↑{{end}}{{end}}</a></div>
<div><a href="{{index $sortURL "last_backup"}}" class="text-ink-mid hover:text-ink">Last backup{{if eq $f.Sort "last_backup"}} {{if eq $f.Dir "desc"}}↓{{else}}↑{{end}}{{end}}</a></div> <div><a href="{{index $sortURL "last_backup"}}" class="text-ink-mid hover:text-ink">Last backup{{if eq $f.Sort "last_backup"}} {{if eq $f.Dir "desc"}}↓{{else}}↑{{end}}{{end}}</a></div>
<div class="text-right"><a href="{{index $sortURL "repo_size"}}" class="text-ink-mid hover:text-ink">Repo size{{if eq $f.Sort "repo_size"}} {{if eq $f.Dir "desc"}}↓{{else}}↑{{end}}{{end}}</a></div> <div class="text-right"><a href="{{index $sortURL "repo_size"}}" class="text-ink-mid hover:text-ink">Repo size{{if eq $f.Sort "repo_size"}} {{if eq $f.Dir "desc"}}↓{{else}}↑{{end}}{{end}}</a></div>
<div>30d trend</div> <div class="text-ink-mid">30d trend</div>
<div class="text-right"><a href="{{index $sortURL "snapshot_count"}}" class="text-ink-mid hover:text-ink">Snapshots{{if eq $f.Sort "snapshot_count"}} {{if eq $f.Dir "desc"}}↓{{else}}↑{{end}}{{end}}</a></div> <div class="text-right"><a href="{{index $sortURL "snapshot_count"}}" class="text-ink-mid hover:text-ink">Snapshots{{if eq $f.Sort "snapshot_count"}} {{if eq $f.Dir "desc"}}↓{{else}}↑{{end}}{{end}}</a></div>
<div>Alerts</div> <div class="text-ink-mid text-right">Alerts</div>
<div>Tags</div> <div class="text-ink-mid">Tags</div>
<div></div> <div></div>
</div> </div>