From 4906524c11d9ef2abb7fc35e46a72cdffb5ab158 Mon Sep 17 00:00:00 2001 From: kisfenyo Date: Thu, 2 Jul 2026 14:47:22 +0200 Subject: [PATCH] =?UTF-8?q?fix(backups):=20off-box=20LastRun=20is=20an=20R?= =?UTF-8?q?FC3339=20string=20=E2=80=94=20500'd=20the=20backups=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found during the D0 click-through: OffboxTarget.LastRun persists as an RFC3339 string (settings.json), but backups.html passed it to timeAgo (expects time.Time), so GET /backups returned 500 on any node where an off-box backup had ever run. Pre-existing since v0.93.0 (NAS Part B), unrelated to the re-skin. New timeAgoStr funcmap helper parses the string (falls back to the raw value); also v2-token fix for the offbox error hint (var(--danger) fallback hex) and the dead stat-running/ stat-stopped classes on the offbox status card. --- controller/internal/web/funcmap.go | 23 +++++++++++++++++++ .../internal/web/templates/backups.html | 6 ++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/controller/internal/web/funcmap.go b/controller/internal/web/funcmap.go index a1735c0..e64f082 100644 --- a/controller/internal/web/funcmap.go +++ b/controller/internal/web/funcmap.go @@ -229,6 +229,29 @@ func (s *Server) templateFuncMap() template.FuncMap { return fmt.Sprintf("%d napja", int(d.Hours()/24)) } }, + // timeAgoStr is timeAgo for RFC3339 string timestamps (e.g. OffboxTarget.LastRun, + // which persists as a string in settings.json). Found during D0: the backups page + // passed the raw string to timeAgo and 500'd once an off-box backup had ever run. + "timeAgoStr": func(s string) string { + t, err := time.Parse(time.RFC3339, s) + if err != nil { + return s + } + now := time.Now().In(loc) + d := now.Sub(t.In(loc)) + switch { + case d < time.Minute: + return "most" + case d < time.Hour: + return fmt.Sprintf("%d perce", int(d.Minutes())) + case d < 24*time.Hour: + return fmt.Sprintf("%d órája", int(d.Hours())) + case d < 48*time.Hour: + return "tegnap" + default: + return fmt.Sprintf("%d napja", int(d.Hours()/24)) + } + }, "fmtTime": func(t time.Time) string { if t.IsZero() { return "–" diff --git a/controller/internal/web/templates/backups.html b/controller/internal/web/templates/backups.html index 30cb4b8..7734cb2 100644 --- a/controller/internal/web/templates/backups.html +++ b/controller/internal/web/templates/backups.html @@ -123,9 +123,9 @@
{{if .Offbox}}
-
+
{{if eq .Offbox.LastStatus "ok"}}✓ Rendben{{else if eq .Offbox.LastStatus "error"}}✗ Hiba{{else if eq .Offbox.LastStatus "running"}}Fut…{{else}}–{{end}}
-
Utolsó NAS-mentés{{if .Offbox.LastRun}}
{{timeAgo .Offbox.LastRun}}{{end}}
+
Utolsó NAS-mentés{{if .Offbox.LastRun}}
{{timeAgoStr .Offbox.LastRun}}{{end}}
{{if .Offbox.RepoSizeHuman}}{{.Offbox.RepoSizeHuman}}{{else}}–{{end}}
@@ -136,7 +136,7 @@
{{if .Offbox.Enabled}}{{.Offbox.RepoPath}}{{else}}A NAS-mentés ki van kapcsolva{{end}}
- {{if .Offbox.LastError}}

Utolsó hiba: {{.Offbox.LastError}}

{{end}} + {{if .Offbox.LastError}}

Utolsó hiba: {{.Offbox.LastError}}

{{end}} {{if .OffboxConfigured}}
{{.CSRFField}}