Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions changelog/highlights/299.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"de": {
"*": "Die Versionsseite zeigt Betriebssystem, Kernel und Systemprogramme des Nodes mit ihrer Version"
},
"en": {
"*": "Show system versions on the versions page"
},
"tour": {
"*": {
"steps": [
{
"device": "any",
"need": "edit_setup",
"page": "versions",
"panel": "settings-panel",
"target": "versions-system",
"text": {
"de": "Hier stehen Betriebssystem, Kernel und die Systemprogramme des Nodes mit ihrer Version. Liegt ein Programm hinter der erwarteten Version, ist es als veraltet markiert.",
"en": "This card lists the operating system, the kernel and the system programs of the node with their version. A program behind the expected version is marked as outdated."
},
"title": {
"de": "Systemversionen",
"en": "System versions"
}
}
]
}
}
}
13 changes: 10 additions & 3 deletions dashboard/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## v0.11.22-pre.36 (2026-11-06)
## v0.11.22-pre.37 (2026-11-06)

### Features

Expand Down Expand Up @@ -35,6 +35,11 @@
- **autolearn:** The node records minute values and keeps every regulator step as a base for learning (#293) (19e65e7)
- **autolearn:** Automation suggestions for surplus and load shifts are checked against your data (#295) (6c255ad)
- **autolearn:** Learning functions can take minute values from Home Assistant (#294) (7aa657e)
- **monitoring:** Monitoring shows the forecast check, a year comparison and the learned values as a usual day (#297) (4f93975)
- **dashboard:** read the system package versions (8d025b3)
- **dashboard:** serve system versions to setup users (8e71270)
- **dashboard:** show the kernel and the Debian point release (93d002d)
- **dashboard:** show system versions on the versions page (#299)
- **autolearn:** expose forecast days and the rules that read a learned value (25d731e)
- **demo:** seed a forecast check and a year of season weeks (4a39a77)
- **monitoring:** serve the forecast check and the season weeks from the api (d11383f)
Expand All @@ -49,7 +54,6 @@
- **monitoring:** show learned values as a usual day (1749c86)
- **monitoring:** style the usual day (72d192a)
- **monitoring:** add a tour target to the forecast tab (ca4f7a0)
- **monitoring:** Monitoring shows the forecast check, a year comparison and the learned values as a usual day (#297)
- **learnrec:** fetch minute values from Home Assistant through the companion (97e2665)
- **learnrec:** pause the own recording while Home Assistant delivers minutes (4086c45)
- **learnrec:** read own minutes first, then Home Assistant, and fetch gaps before the heavy run (44ee05d)
Expand Down Expand Up @@ -350,6 +354,7 @@
- **storage:** wipe old file system signatures before formatting a stick (#245) (aeafa63)
- **storage:** set up, back up and replug the additional drive reliably (#247) (b668394)
- **automations:** correct the learning feature after the full review (#296) (88f3c75)
- **backup:** A restore stays in place even when the battery state cannot be written (#288) (e5c5437)
- **monitoring:** keep texts and locale out of the insight model (57e2a44)
- **monitoring:** show the legend items for statistics weeks and gaps (82cde6e)
- **monitoring:** route locale formatting through I18n (a664db2)
Expand All @@ -358,7 +363,6 @@
- **monitoring:** keep the forecast view inside the screen and polish the usual day (7751f73)
- **monitoring:** keep one gap between the cards of the forecast and learned views (3168e41)
- **monitoring:** let the forecast view use the full tab width (2d6749e)
- **backup:** A restore stays in place even when the battery state cannot be written (#288) (e5c5437)
- **learning:** reset every learned state through one registry (594282c)
- **autolearn:** survive a detector panic and keep results of finished devices (102cad0)
- **autolearn:** keep harm first, cap open suggestions and give every value a spread (bde4c6a)
Expand Down Expand Up @@ -514,6 +518,7 @@

### Tests

- **demo:** fake the system packages for the versions page (ca2dc1e)
- **autolearn:** keep the cycle test window open until today (ab438d5)
- **webui:** follow the template cache-bust mark (c30a3db)
- **smoke:** probe the live push on the house load (5382341)
Expand All @@ -536,6 +541,8 @@

### Chores

- **dashboard:** bump the cache-bust marks for the system card (31ecbb8)
- **dashboard:** move the cache history rows to the current pre-release (8a60da5)
- **monitoring:** drop the texts of the old learned values list (d6da484)
- **webui:** bump cache marks for the monitoring assets (b29e739)
- **webui:** bump the cache-bust marks for the learning review fixes (6c82592)
Expand Down
2 changes: 1 addition & 1 deletion dashboard/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.11.22-pre.36
v0.11.22-pre.37
4 changes: 4 additions & 0 deletions dashboard/cmd/dashboard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,10 @@ func main() {
Usage: storageUsage,
},
InstallerStateDir: installerStateDir,
DpkgStatusPath: os.Getenv("ENERGY_NODE_DPKG_STATUS"),
OSReleasePath: os.Getenv("ENERGY_NODE_OS_RELEASE"),
DebianVersionPath: os.Getenv("ENERGY_NODE_DEBIAN_VERSION"),
KernelReleasePath: os.Getenv("ENERGY_NODE_KERNEL_RELEASE"),
AppConfigPath: *configPath,
BridgeTargetPath: cfg.Dashboard.MosquittoBridgeTarget,
Tailscale: tailscaleClient,
Expand Down
14 changes: 13 additions & 1 deletion dashboard/internal/httpapi/httpapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,15 @@ 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
// DebianVersionPath und KernelReleasePath ersetzen die Dateien mit dem
// Punkt-Release und dem laufenden Kernel. Leer heisst die Vorgabe.
DebianVersionPath string
KernelReleasePath string
// Version ist die aus dashboard/VERSION plus Branch-Suffix gebaute
// Versionskennung (siehe main.buildVersion), leer bzw. "dev" ausserhalb
// von Release-Builds.
Expand Down Expand Up @@ -355,7 +364,10 @@ 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,
DebianVersion: dependencies.DebianVersionPath, KernelRelease: dependencies.KernelReleasePath, StateDir: stateDir,
}))
g.HandleFunc("/api/v1/changelog", handleChangelog(stateDir))
g.HandleFunc("/api/v1/changelog/highlights", handleChangelogHighlights(stateDir))
if dependencies.UpdatesCache != nil {
Expand Down
15 changes: 14 additions & 1 deletion dashboard/internal/httpapi/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ 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"
)

// 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)
Expand All @@ -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=<id>&bundles=<n>]: the
// installed changelog, optionally cut down to some components and to the
// newest n bundle versions (0 or missing: all).
Expand Down
69 changes: 69 additions & 0 deletions dashboard/internal/httpapi/versions_system_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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")
writeState(t, dir, "debian_version", "12.11\n")
writeState(t, dir, "kernel", "6.12.47+rpt-rpi-v6\n")
return versions.SystemSources{
DpkgStatus: filepath.Join(dir, "status"), OSRelease: filepath.Join(dir, "os-release"),
DebianVersion: filepath.Join(dir, "debian_version"), KernelRelease: filepath.Join(dir, "kernel"), 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,
DebianVersionPath: src.DebianVersion, KernelReleasePath: src.KernelRelease,
})

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())
}
for _, want := range []string{`"version":"12.11"`, `"id":"kernel","label":"Kernel","version":"6.12.47+rpt-rpi-v6"`} {
if !strings.Contains(rec.Body.String(), want) {
t.Fatalf("admin lacks %s: %s", want, 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())
}
}
Loading
Loading