From 8d025b31b77e02af301153ead51c76cbf4747951 Mon Sep 17 00:00:00 2001 From: DevSimon <73778205+Developer-Simon@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:42:47 +0100 Subject: [PATCH 1/9] feat(dashboard): read the system package versions Co-Authored-By: Claude Sonnet 5.5 --- dashboard/internal/versions/system.go | 183 +++++++++++++++++++++ dashboard/internal/versions/system_test.go | 122 ++++++++++++++ dashboard/internal/versions/versions.go | 6 +- 3 files changed, 310 insertions(+), 1 deletion(-) create mode 100644 dashboard/internal/versions/system.go create mode 100644 dashboard/internal/versions/system_test.go diff --git a/dashboard/internal/versions/system.go b/dashboard/internal/versions/system.go new file mode 100644 index 000000000..432998afb --- /dev/null +++ b/dashboard/internal/versions/system.go @@ -0,0 +1,183 @@ +package versions + +import ( + "bufio" + "encoding/json" + "os" + "path/filepath" + "strings" +) + +const ( + // DefaultDpkgStatus is dpkg's package database, readable by every user. + DefaultDpkgStatus = "/var/lib/dpkg/status" + // DefaultOSRelease names the distribution and its release. + DefaultOSRelease = "/etc/os-release" + // maxDpkgLine bounds one line of the database, far above real fields. + maxDpkgLine = 4 << 20 +) + +// SystemSources names the files System reads. An empty DpkgStatus or +// OSRelease means the default path. +type SystemSources struct { + DpkgStatus string + OSRelease string + StateDir string +} + +// SystemEntry is one row of the system card on the versions page. +type SystemEntry struct { + ID string `json:"id"` + Label string `json:"label"` + Version string `json:"version"` + Installed bool `json:"installed"` + // Pinned is the version the installed bundle pins, empty without a pin. + Pinned string `json:"pinned,omitempty"` + Outdated bool `json:"outdated"` +} + +// systemPackages are the Debian packages the node depends on, in page order. +var systemPackages = []struct{ id, label string }{ + {"caddy", "Caddy"}, + {"tailscale", "Tailscale"}, + {"mosquitto", "Mosquitto"}, + {"python3", "Python"}, +} + +// System reports the operating system and the system packages. What cannot be +// read is left out, so a machine without dpkg shows no package rows. +func System(src SystemSources) []SystemEntry { + if src.DpkgStatus == "" { + src.DpkgStatus = DefaultDpkgStatus + } + if src.OSRelease == "" { + src.OSRelease = DefaultOSRelease + } + var out []SystemEntry + if entry, ok := osEntry(src.OSRelease); ok { + out = append(out, entry) + } + installed, ok := dpkgVersions(src.DpkgStatus) + if !ok { + return out + } + pins := packagePins(src.StateDir) + for _, pkg := range systemPackages { + version, present := installed[pkg.id] + entry := SystemEntry{ID: pkg.id, Label: pkg.label, Version: upstreamVersion(version), Installed: present, Pinned: pins[pkg.id]} + entry.Outdated = present && isOlder(entry.Version, entry.Pinned) + out = append(out, entry) + } + return out +} + +// isOlder is true only when both versions start with a number and a is lower. +func isOlder(a, b string) bool { + return versionNumbers.MatchString(a) && versionNumbers.MatchString(b) && compareVersions(a, b) < 0 +} + +// upstreamVersion drops the epoch and the Debian revision of a dpkg version. +func upstreamVersion(version string) string { + if _, rest, found := strings.Cut(version, ":"); found { + version = rest + } + if i := strings.LastIndex(version, "-"); i >= 0 { + version = version[:i] + } + return version +} + +func osEntry(path string) (SystemEntry, bool) { + raw, err := os.ReadFile(path) + if err != nil { + return SystemEntry{}, false + } + fields := map[string]string{} + for _, line := range strings.Split(string(raw), "\n") { + if key, value, found := strings.Cut(strings.TrimSpace(line), "="); found { + fields[key] = strings.Trim(value, `"'`) + } + } + label := fields["NAME"] + if label == "" { + label = "Linux" + } + version, codename := fields["VERSION_ID"], fields["VERSION_CODENAME"] + switch { + case version == "": + version = codename + case codename != "": + version += " (" + codename + ")" + } + return SystemEntry{ID: "os", Label: label, Version: version, Installed: true}, true +} + +// dpkgVersions returns the version of every wanted package whose dpkg state +// ends in "installed" ("install ok installed", "hold ok installed"). ok is +// false when the database cannot be read. +func dpkgVersions(path string) (map[string]string, bool) { + file, err := os.Open(path) + if err != nil { + return nil, false + } + defer file.Close() + + wanted := map[string]bool{} + for _, pkg := range systemPackages { + wanted[pkg.id] = true + } + out := map[string]string{} + var name, status, version string + flush := func() { + state := strings.Fields(status) + if _, seen := out[name]; !seen && wanted[name] && len(state) > 0 && state[len(state)-1] == "installed" { + out[name] = version + } + name, status, version = "", "", "" + } + scanner := bufio.NewScanner(file) + scanner.Buffer(make([]byte, 64<<10), maxDpkgLine) + for scanner.Scan() { + line := scanner.Text() + if line == "" { + flush() + continue + } + // Continuation lines start with a space and match no field name. + switch key, value, _ := strings.Cut(line, ": "); key { + case "Package": + name = value + case "Status": + status = value + case "Version": + version = value + } + } + if scanner.Err() != nil { + return nil, false + } + flush() + return out, true +} + +// packagePins reads the package versions the installed bundle pins. A missing, +// old or broken manifest means no pins. +func packagePins(stateDir string) map[string]string { + out := map[string]string{} + raw, err := os.ReadFile(filepath.Join(stateDir, "installed-manifest.json")) + if err != nil { + return out + } + var manifest struct { + Packages map[string]struct { + Version string `json:"version"` + } `json:"packages"` + } + if json.Unmarshal(raw, &manifest) != nil { + return out + } + for name, pin := range manifest.Packages { + out[name] = pin.Version + } + return out +} diff --git a/dashboard/internal/versions/system_test.go b/dashboard/internal/versions/system_test.go new file mode 100644 index 000000000..ca1e683b1 --- /dev/null +++ b/dashboard/internal/versions/system_test.go @@ -0,0 +1,122 @@ +package versions_test + +import ( + "os" + "path/filepath" + "reflect" + "strings" + "testing" + + "github.com/Developer-Simon/energy-node-dashboard/internal/versions" +) + +const testOSRelease = "PRETTY_NAME=\"Raspbian GNU/Linux 12 (bookworm)\"\nNAME=\"Raspbian GNU/Linux\"\nVERSION_ID=\"12\"\nVERSION_CODENAME=bookworm\n" + +const testManifest = `{"version":"v0.11.20","packages":{"caddy":{"version":"2.11.9"},"tailscale":{"version":"1.62.0"}}}` + +func stanza(name, status, version string) string { + return "Package: " + name + "\nStatus: " + status + "\nVersion: " + version + "\nDescription: x\n more text\n Package: not-a-field\n\n" +} + +func systemSources(t *testing.T, dpkg, osRelease, manifest string) versions.SystemSources { + t.Helper() + dir := t.TempDir() + write := func(name, body string) string { + path := filepath.Join(dir, name) + if body != "" { + if err := os.WriteFile(path, []byte(body), 0o644); err != nil { + t.Fatal(err) + } + } + return path + } + write("installed-manifest.json", manifest) + return versions.SystemSources{DpkgStatus: write("status", dpkg), OSRelease: write("os-release", osRelease), StateDir: dir} +} + +func byID(entries []versions.SystemEntry) map[string]versions.SystemEntry { + out := map[string]versions.SystemEntry{} + for _, entry := range entries { + out[entry.ID] = entry + } + return out +} + +func TestSystemListsOSAndPackagesAndMarksAnOutdatedPin(t *testing.T) { + dpkg := stanza("caddy", "hold ok installed", "2.6.2-5+deb12u1") + + stanza("tailscale", "hold ok installed", "1.62.0") + + stanza("mosquitto", "install ok installed", "1:2.0.11-1.2+deb12u1") + + stanza("python3", "install ok installed", "3.11.2-1+b1") + got := versions.System(systemSources(t, dpkg, testOSRelease, testManifest)) + want := []versions.SystemEntry{ + {ID: "os", Label: "Raspbian GNU/Linux", Version: "12 (bookworm)", Installed: true}, + {ID: "caddy", Label: "Caddy", Version: "2.6.2", Installed: true, Pinned: "2.11.9", Outdated: true}, + {ID: "tailscale", Label: "Tailscale", Version: "1.62.0", Installed: true, Pinned: "1.62.0"}, + {ID: "mosquitto", Label: "Mosquitto", Version: "2.0.11", Installed: true}, + {ID: "python3", Label: "Python", Version: "3.11.2", Installed: true}, + } + if !reflect.DeepEqual(got, want) { + t.Fatalf("got %+v\nwant %+v", got, want) + } +} + +func TestSystemDoesNotMarkNewerEqualOrUncomparableVersions(t *testing.T) { + cases := map[string]string{"newer": "2.12.0-1", "equal with revision": "2.11.9-2", "no number": "unstable"} + for name, version := range cases { + got := byID(versions.System(systemSources(t, stanza("caddy", "install ok installed", version), "", testManifest))) + if got["caddy"].Outdated { + t.Errorf("%s: %q marked outdated", name, version) + } + } +} + +func TestSystemIgnoresPackageLeftovers(t *testing.T) { + dpkg := stanza("caddy", "deinstall ok config-files", "2.6.2-5") + stanza("tailscale", "install ok half-installed", "1.0.0") + got := byID(versions.System(systemSources(t, dpkg, "", testManifest))) + for _, id := range []string{"caddy", "tailscale"} { + entry := got[id] + if entry.Installed || entry.Version != "" || entry.Outdated || entry.Pinned == "" { + t.Errorf("%s = %+v, want not installed, no version, no mark, pin kept", id, entry) + } + } +} + +func TestSystemTakesTheInstalledStanzaOfAMultiarchPackage(t *testing.T) { + dpkg := stanza("python3", "deinstall ok config-files", "3.9.0-1") + stanza("python3", "install ok installed", "3.11.2-1") + got := byID(versions.System(systemSources(t, dpkg, "", ""))) + if !got["python3"].Installed || got["python3"].Version != "3.11.2" { + t.Fatalf("python3 = %+v", got["python3"]) + } +} + +func TestSystemSurvivesAVeryLongLine(t *testing.T) { + dpkg := "Package: big\nProvides: " + strings.Repeat("x", 200_000) + "\n\n" + stanza("caddy", "install ok installed", "2.11.9") + got := byID(versions.System(systemSources(t, dpkg, "", ""))) + if got["caddy"].Version != "2.11.9" { + t.Fatalf("caddy = %+v", got["caddy"]) + } +} + +func TestSystemKeepsRowsWithoutAUsableManifest(t *testing.T) { + for name, manifest := range map[string]string{"missing": "", "old": `{"version":"v0.9.0"}`, "broken": `{`} { + got := byID(versions.System(systemSources(t, stanza("caddy", "install ok installed", "2.6.2"), "", manifest))) + caddy := got["caddy"] + if !caddy.Installed || caddy.Pinned != "" || caddy.Outdated { + t.Errorf("%s: caddy = %+v", name, caddy) + } + } +} + +func TestSystemShowsOnlyWhatIsReadable(t *testing.T) { + onlyOS := versions.System(systemSources(t, "", testOSRelease, testManifest)) + if len(onlyOS) != 1 || onlyOS[0].ID != "os" { + t.Fatalf("without dpkg: %+v", onlyOS) + } + if got := versions.System(systemSources(t, "", "", testManifest)); len(got) != 0 { + t.Fatalf("nothing readable: %+v", got) + } + rolling := versions.System(systemSources(t, "", "NAME=Debian\nVERSION_CODENAME=forky\n", "")) + if len(rolling) != 1 || rolling[0].Version != "forky" { + t.Fatalf("without VERSION_ID: %+v", rolling) + } +} diff --git a/dashboard/internal/versions/versions.go b/dashboard/internal/versions/versions.go index 4167283ae..428efc5d2 100644 --- a/dashboard/internal/versions/versions.go +++ b/dashboard/internal/versions/versions.go @@ -2,7 +2,8 @@ // came from, the version of every component in it, and what changed. It only // reads the files the updater and the installer leave in the installer state // directory (installed-manifest.json, selection.json, changelog.json); it -// never writes and never talks to GitHub. +// never writes and never talks to GitHub. The system card also reads dpkg's +// database and os-release. package versions import ( @@ -83,6 +84,9 @@ type Snapshot struct { // (previous-manifest.json, kept by the updater and the installer). Nil on // a first install or before either kept one. Previous *Bundle `json:"previous"` + // System is the operating system and the system packages (System). Only + // set for sessions that may see them. + System []SystemEntry `json:"system,omitempty"` } type manifestFile struct { From 8e71270b720257c512f63e08a016a3b7e7f6c972 Mon Sep 17 00:00:00 2001 From: DevSimon <73778205+Developer-Simon@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:44:16 +0100 Subject: [PATCH 2/9] feat(dashboard): serve system versions to setup users GET /api/v1/versions adds the system field only for sessions with edit_setup. Guests get the versions without it, and requests without a user in the context (no accounts yet) keep the previous behaviour. The dpkg status and os-release paths can be overridden with ENERGY_NODE_DPKG_STATUS and ENERGY_NODE_OS_RELEASE for demo and smoke runs. Co-Authored-By: Claude Sonnet 5.5 --- dashboard/cmd/dashboard/main.go | 2 + dashboard/internal/httpapi/httpapi.go | 9 ++- dashboard/internal/httpapi/versions.go | 15 ++++- .../internal/httpapi/versions_system_test.go | 58 +++++++++++++++++++ 4 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 dashboard/internal/httpapi/versions_system_test.go diff --git a/dashboard/cmd/dashboard/main.go b/dashboard/cmd/dashboard/main.go index 16a1b448c..27bbc7c52 100644 --- a/dashboard/cmd/dashboard/main.go +++ b/dashboard/cmd/dashboard/main.go @@ -1465,6 +1465,8 @@ func main() { Usage: storageUsage, }, InstallerStateDir: installerStateDir, + DpkgStatusPath: os.Getenv("ENERGY_NODE_DPKG_STATUS"), + OSReleasePath: os.Getenv("ENERGY_NODE_OS_RELEASE"), AppConfigPath: *configPath, BridgeTargetPath: cfg.Dashboard.MosquittoBridgeTarget, Tailscale: tailscaleClient, diff --git a/dashboard/internal/httpapi/httpapi.go b/dashboard/internal/httpapi/httpapi.go index 12a7db6b9..f8263714b 100644 --- a/dashboard/internal/httpapi/httpapi.go +++ b/dashboard/internal/httpapi/httpapi.go @@ -219,6 +219,11 @@ type RouterDependencies struct { // (installed-manifest.json, selection.json, changelog.json), aus dem die // Versionsseite liest. Leer heisst versions.DefaultStateDir. InstallerStateDir string + // DpkgStatusPath und OSReleasePath ersetzen fuer Demo und Smoke-Test die + // Dateien der Systemkarte der Versionsseite. Leer heisst die Vorgabe aus + // internal/versions. + DpkgStatusPath string + OSReleasePath string // Version ist die aus dashboard/VERSION plus Branch-Suffix gebaute // Versionskennung (siehe main.buildVersion), leer bzw. "dev" ausserhalb // von Release-Builds. @@ -355,7 +360,9 @@ func NewRouterWithDependencies(reg *registry.Registry, configs *config.Manager, if stateDir == "" { stateDir = versions.DefaultStateDir } - g.HandleFunc("/api/v1/versions", handleVersions(stateDir, dependencies.Version)) + g.HandleFunc("/api/v1/versions", handleVersions(stateDir, dependencies.Version, versions.SystemSources{ + DpkgStatus: dependencies.DpkgStatusPath, OSRelease: dependencies.OSReleasePath, StateDir: stateDir, + })) g.HandleFunc("/api/v1/changelog", handleChangelog(stateDir)) g.HandleFunc("/api/v1/changelog/highlights", handleChangelogHighlights(stateDir)) if dependencies.UpdatesCache != nil { diff --git a/dashboard/internal/httpapi/versions.go b/dashboard/internal/httpapi/versions.go index b3d1f759d..ffbe5b9dd 100644 --- a/dashboard/internal/httpapi/versions.go +++ b/dashboard/internal/httpapi/versions.go @@ -5,6 +5,7 @@ import ( "net/http" "strconv" + "github.com/Developer-Simon/energy-node-dashboard/internal/auth" "github.com/Developer-Simon/energy-node-dashboard/internal/versions" "github.com/Developer-Simon/energy-node-webui/hostapi" ) @@ -12,7 +13,8 @@ import ( // handleVersions is GET /api/v1/versions: the bundle this node was installed // from and the version of every component in it. Readable by every signed-in // session, guests included -- it says nothing an operator may not see. -func handleVersions(stateDir, running string) http.HandlerFunc { +// The system field is the exception, see maySeeSystem. +func handleVersions(stateDir, running string, system versions.SystemSources) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { methodNotAllowed(w, http.MethodGet) @@ -23,10 +25,21 @@ func handleVersions(stateDir, running string) http.HandlerFunc { writeError(w, http.StatusInternalServerError, "versions_unreadable", "Versionsdaten konnten nicht gelesen werden") return } + if maySeeSystem(r) { + snapshot.System = versions.System(system) + } writeJSON(w, snapshot) } } +// maySeeSystem: operating system and package versions tell which known flaws +// apply, so a signed-in user needs edit_setup. Without a user in the context no +// gate applies, as before accounts existed. +func maySeeSystem(r *http.Request) bool { + user, ok := auth.UserFromContext(r.Context()) + return !ok || auth.HasRole(user, auth.RoleEditSetup) +} + // handleChangelog is GET /api/v1/changelog[?component=&bundles=]: the // installed changelog, optionally cut down to some components and to the // newest n bundle versions (0 or missing: all). diff --git a/dashboard/internal/httpapi/versions_system_test.go b/dashboard/internal/httpapi/versions_system_test.go new file mode 100644 index 000000000..aade33b71 --- /dev/null +++ b/dashboard/internal/httpapi/versions_system_test.go @@ -0,0 +1,58 @@ +package httpapi + +import ( + "net/http" + "net/http/httptest" + "path/filepath" + "strings" + "testing" + + "github.com/Developer-Simon/energy-node-dashboard/internal/auth" + "github.com/Developer-Simon/energy-node-dashboard/internal/config" + "github.com/Developer-Simon/energy-node-dashboard/internal/registry" + "github.com/Developer-Simon/energy-node-dashboard/internal/settings" + "github.com/Developer-Simon/energy-node-dashboard/internal/versions" +) + +func systemTestSources(t *testing.T) versions.SystemSources { + t.Helper() + dir := t.TempDir() + writeState(t, dir, "status", "Package: caddy\nStatus: hold ok installed\nVersion: 2.6.2-5\n\n") + writeState(t, dir, "os-release", "NAME=Debian\nVERSION_ID=12\n") + return versions.SystemSources{DpkgStatus: filepath.Join(dir, "status"), OSRelease: filepath.Join(dir, "os-release"), StateDir: dir} +} + +func TestVersionsSystemNeedsEditSetup(t *testing.T) { + src := systemTestSources(t) + manager, err := auth.NewManager(filepath.Join(t.TempDir(), "users.json"), "admin", "secret") + if err != nil { + t.Fatal(err) + } + router := NewAuthenticatedRouter(registry.New(), config.NewManager(t.TempDir()), settings.NewStore(t.TempDir()), nil, nil, nil, nil, nil, RouterDependencies{ + Auth: manager, InstallerStateDir: src.StateDir, DpkgStatusPath: src.DpkgStatus, OSReleasePath: src.OSRelease, + }) + + guest := getWith(router, loginAsGuest(t, router), "/api/v1/versions") + if guest.Code != http.StatusOK || strings.Contains(guest.Body.String(), `"system"`) { + t.Fatalf("guest: %d %s, want 200 without system", guest.Code, guest.Body.String()) + } + + cookie, _ := loginAsAdmin(t, router) + req := httptest.NewRequest(http.MethodGet, "/api/v1/versions", nil) + req.Header.Set("X-Forwarded-Proto", "https") + req.AddCookie(cookie) + rec := httptest.NewRecorder() + router.ServeHTTP(rec, req) + if rec.Code != http.StatusOK || !strings.Contains(rec.Body.String(), `"id":"caddy","label":"Caddy","version":"2.6.2"`) { + t.Fatalf("admin: %d %s", rec.Code, rec.Body.String()) + } +} + +func TestVersionsSystemWithoutAccountsIsShown(t *testing.T) { + src := systemTestSources(t) + rec := httptest.NewRecorder() + handleVersions(src.StateDir, "v1.0.0", src)(rec, httptest.NewRequest(http.MethodGet, "/api/v1/versions", nil)) + if !strings.Contains(rec.Body.String(), `"system":[{"id":"os"`) { + t.Fatalf("body = %s", rec.Body.String()) + } +} From f35f4ade2153bd0bf2ff57071d3c9c9c1031c275 Mon Sep 17 00:00:00 2001 From: DevSimon <73778205+Developer-Simon@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:46:28 +0100 Subject: [PATCH 3/9] feat(dashboard): show system versions on the versions page Co-Authored-By: Claude Sonnet 5.5 --- dashboard/internal/webui/catalogs/de.json | 4 ++ dashboard/internal/webui/catalogs/en.json | 4 ++ .../webui/static/css/settings-controls.css | 23 ++++++++++ .../internal/webui/static/js/versions.page.js | 9 ++++ .../internal/webui/templates/versions.html | 15 +++++++ dashboard/test/versions.page.test.mjs | 44 +++++++++++++++++++ 6 files changed, 99 insertions(+) diff --git a/dashboard/internal/webui/catalogs/de.json b/dashboard/internal/webui/catalogs/de.json index e1ecc0fef..3d68e5293 100644 --- a/dashboard/internal/webui/catalogs/de.json +++ b/dashboard/internal/webui/catalogs/de.json @@ -4877,6 +4877,10 @@ "settings.versions.package.running": "Dashboard läuft als", "settings.versions.package.title": "Installiertes Paket", "settings.versions.package.version": "Paketversion", + "settings.versions.system.no_package": "kein Paket", + "settings.versions.system.outdated": "veraltet", + "settings.versions.system.pinned": "Soll {version}", + "settings.versions.system.title": "System", "settings.versions.unknown": "unbekannt", "settings.versions.updates.auto_check.help_aria": "Erklärung zur automatischen Prüfung", "settings.versions.updates.auto_check.label": "Automatisch auf Updates prüfen", diff --git a/dashboard/internal/webui/catalogs/en.json b/dashboard/internal/webui/catalogs/en.json index ccdcae798..683fc1c9b 100644 --- a/dashboard/internal/webui/catalogs/en.json +++ b/dashboard/internal/webui/catalogs/en.json @@ -4877,6 +4877,10 @@ "settings.versions.package.running": "Dashboard runs as", "settings.versions.package.title": "Installed package", "settings.versions.package.version": "Package version", + "settings.versions.system.no_package": "no package", + "settings.versions.system.outdated": "outdated", + "settings.versions.system.pinned": "expected {version}", + "settings.versions.system.title": "System", "settings.versions.unknown": "unknown", "settings.versions.updates.auto_check.help_aria": "About the automatic check", "settings.versions.updates.auto_check.label": "Check for updates automatically", diff --git a/dashboard/internal/webui/static/css/settings-controls.css b/dashboard/internal/webui/static/css/settings-controls.css index 2b575f222..35b1017b0 100644 --- a/dashboard/internal/webui/static/css/settings-controls.css +++ b/dashboard/internal/webui/static/css/settings-controls.css @@ -624,6 +624,29 @@ .version-name { flex: 1 1 8rem; min-width: 0; overflow-wrap: anywhere; color: var(--text); font-size: .92rem; } .version-name.is-off { color: var(--text-faint); } .version-note { color: var(--warn); } +/* Systemkarte: installierte Version und Soll bilden eine Einheit und brechen + gemeinsam um. Die Soll-Spalte behaelt auch leer ihre Breite, damit die + Versionen untereinander stehen. */ +.version-values { + display: flex; + align-items: baseline; + justify-content: flex-end; + gap: .6rem; + margin-left: auto; + white-space: nowrap; +} +.version-pin { + min-width: 6.5rem; + color: var(--text-muted); + font-size: .78rem; + font-weight: 450; + letter-spacing: .01em; + font-variant-numeric: tabular-nums; +} +.version-chip.is-warn { background: var(--warn-bg); color: var(--warn); font-weight: 600; } +@media (prefers-contrast: more) { + .version-chip.is-warn { box-shadow: inset 0 0 0 1px var(--warn-line); } +} .release-list { padding: 0 0 .7rem; } .release + .release { margin-top: .8rem; } .release-title { margin: 0; font-size: .9rem; color: var(--text-strong); } diff --git a/dashboard/internal/webui/static/js/versions.page.js b/dashboard/internal/webui/static/js/versions.page.js index 9c9ef9398..ea4cc2007 100644 --- a/dashboard/internal/webui/static/js/versions.page.js +++ b/dashboard/internal/webui/static/js/versions.page.js @@ -58,6 +58,7 @@ bundle: null, running: {dashboard: ''}, components: [], + system: [], hasChangelog: false, // The bundle the node ran before its last version change, null when none is recorded. previous: null, @@ -99,6 +100,7 @@ this.components = body.components || []; this.hasChangelog = Boolean(body.has_changelog); this.previous = body.previous || null; + this.system = body.system || []; } catch (error) { this.error = error.message; } finally { @@ -262,6 +264,13 @@ } }, + // Version einer Zeile der Systemkarte. Ohne Paketeintrag kann das Programm + // trotzdem von Hand installiert sein, deshalb nicht "nicht installiert". + systemVersionText(entry) { + if (!entry.installed) return t('settings.versions.system.no_package'); + return entry.version || t('settings.versions.unknown'); + }, + // The releases of a component as the current view shows them. An // unflagged file is shown in full, there is nothing to pick from. shownReleases(id) { diff --git a/dashboard/internal/webui/templates/versions.html b/dashboard/internal/webui/templates/versions.html index 1dd233b11..66110b083 100644 --- a/dashboard/internal/webui/templates/versions.html +++ b/dashboard/internal/webui/templates/versions.html @@ -104,5 +104,20 @@

+

{{t "settings.versions.system.title"}}

+ + {{end}} diff --git a/dashboard/test/versions.page.test.mjs b/dashboard/test/versions.page.test.mjs index 7a4fde57f..aff6d791b 100644 --- a/dashboard/test/versions.page.test.mjs +++ b/dashboard/test/versions.page.test.mjs @@ -422,3 +422,47 @@ test('setChangelogHistory() restores the value and toasts when saving fails', as assert.equal(component.savingChangelogHistory, false); assert.deepEqual(component.$store.toasts.criticals, [de['error.settings_rejected']]); }); + +const read = (...parts) => fs.readFileSync(path.join(here, '..', 'internal', 'webui', ...parts), 'utf8'); +const SYSTEM = [ + { id: 'os', label: 'Debian GNU/Linux', version: '12 (bookworm)', installed: true, outdated: false }, + { id: 'caddy', label: 'Caddy', version: '2.6.2', installed: true, pinned: '2.11.9', outdated: true }, +]; + +test('load() fills the system rows and keeps them empty when the field is missing', async () => { + const withSystem = await loaded({ system: SYSTEM }); + assert.deepEqual(plain(withSystem.component.system.map((e) => e.id)), ['os', 'caddy']); + const guest = await loaded(); + assert.deepEqual(plain(guest.component.system), []); +}); + +test('systemVersionText names a missing package and an unreadable version', () => { + const { component } = createVersionsPanel(); + assert.equal(component.systemVersionText({ installed: true, version: '2.6.2' }), '2.6.2'); + assert.equal(component.systemVersionText({ installed: false, version: '' }), de['settings.versions.system.no_package']); + assert.equal(component.systemVersionText({ installed: true, version: '' }), de['settings.versions.unknown']); +}); + +test('the system card hides without rows and offers nothing to click', () => { + const template = read('templates', 'versions.html'); + const card = template.slice(template.indexOf('data-tour="versions-system"'), template.lastIndexOf('')); + assert.match(card, /x-show="system\.length"/); + assert.match(card, /class="version-chip is-warn" x-show="entry\.outdated"/); + assert.doesNotMatch(card, /x-on:click| { + const css = read('static', 'css', 'settings-controls.css'); + const rules = css.match(/\.version-(values|pin|chip\.is-warn)[^{]*\{[^}]*\}/g) || []; + assert.ok(rules.length >= 3); + for (const rule of rules) assert.doesNotMatch(rule, /transition|animation|transform|:hover/); +}); + +test('both catalogs carry the system card texts', () => { + const en = catalog('en'); + for (const key of ['title', 'outdated', 'no_package', 'pinned'].map((k) => `settings.versions.system.${k}`)) { + assert.ok(de[key], `de ${key}`); + assert.ok(en[key], `en ${key}`); + } +}); From 31ecbb806cc0e77ed4eb36b5753edf0d4daba47e Mon Sep 17 00:00:00 2001 From: DevSimon <73778205+Developer-Simon@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:47:05 +0100 Subject: [PATCH 4/9] chore(dashboard): bump the cache-bust marks for the system card Co-Authored-By: Claude Sonnet 5.5 --- dashboard/internal/webui/cache-bust-history.csv | 2 ++ dashboard/internal/webui/templates/base.html | 6 +++--- dashboard/internal/webui/templates/settings.html | 2 +- dashboard/internal/webui/webui_test.go | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/dashboard/internal/webui/cache-bust-history.csv b/dashboard/internal/webui/cache-bust-history.csv index 92992c44b..e966ada87 100644 --- a/dashboard/internal/webui/cache-bust-history.csv +++ b/dashboard/internal/webui/cache-bust-history.csv @@ -4,6 +4,8 @@ v0.11.22-pre.36,2026-11-23,js/monitoring-insight-model.js,1, v0.11.22-pre.36,2026-11-23,js/monitoring-insight.js,1, v0.11.22-pre.36,2026-11-23,js/monitoring-model.js,4, v0.11.22-pre.36,2026-11-23,js/monitoring.page.js,3, +v0.11.22-pre.36,2026-11-25,css/settings-controls.css,21,"settings, diagnostics: system card on the versions page" +v0.11.22-pre.36,2026-11-25,js/versions.page.js,11,"settings, diagnostics: system card on the versions page" v0.11.22-pre.35,2026-11-23,css/automations.css,25, v0.11.22-pre.35,2026-11-23,js/automation-suggestions.js,6, v0.11.22-pre.35,2026-11-23,js/automations.page.js,32, diff --git a/dashboard/internal/webui/templates/base.html b/dashboard/internal/webui/templates/base.html index ccdff6698..fe3a90303 100644 --- a/dashboard/internal/webui/templates/base.html +++ b/dashboard/internal/webui/templates/base.html @@ -239,14 +239,14 @@

{{t "no_access.title"}}

{{if and .Manager (index .Can "view_efficiency")}}

{{t "panel.efficiency_loading"}}

{{end}} {{if index .Can "view_monitoring"}}

{{t "panel.monitoring_loading"}}

{{end}} {{if .Manager}} -{{if index .Can "view_diagnostics"}}

{{t "panel.diagnostics_loading"}}

{{end}} +{{if index .Can "view_diagnostics"}}

{{t "panel.diagnostics_loading"}}

{{end}} {{if index .Can "view_config"}}

{{t "panel.config_loading"}}

{{end}} {{if index .Can "view_energy"}}

{{t "panel.energy_loading"}}

{{end}} {{if index .Can "view_device_map"}}

{{t "panel.devicemap_loading"}}

{{end}} -

{{t "panel.settings_loading"}}

+

{{t "panel.settings_loading"}}

{{if index .Can "view_automations"}} {{if index .InstalledServices "automation"}}

{{t "panel.automations_loading"}}

{{end}}{{end}} {{else}} -{{if index .Can "view_diagnostics"}}

{{t "panel.diagnostics_loading"}}

{{end}} +{{if index .Can "view_diagnostics"}}

{{t "panel.diagnostics_loading"}}

{{end}} {{end}}