fix(backups): off-box LastRun is an RFC3339 string — 500'd the backups page
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.
This commit is contained in:
@@ -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 "–"
|
||||
|
||||
@@ -123,9 +123,9 @@
|
||||
<div class="card" style="margin-bottom:1.5rem">
|
||||
{{if .Offbox}}
|
||||
<div class="stats-grid backup-page-cards">
|
||||
<div class="stat-card {{if eq .Offbox.LastStatus "ok"}}stat-running{{else if eq .Offbox.LastStatus "error"}}stat-stopped{{end}}">
|
||||
<div class="stat-card {{if eq .Offbox.LastStatus "error"}}stat-warn{{end}}">
|
||||
<div class="stat-value" style="font-size:1.15rem">{{if eq .Offbox.LastStatus "ok"}}✓ Rendben{{else if eq .Offbox.LastStatus "error"}}✗ Hiba{{else if eq .Offbox.LastStatus "running"}}Fut…{{else}}–{{end}}</div>
|
||||
<div class="stat-label">Utolsó NAS-mentés{{if .Offbox.LastRun}}<br><span class="relative-time">{{timeAgo .Offbox.LastRun}}</span>{{end}}</div>
|
||||
<div class="stat-label">Utolsó NAS-mentés{{if .Offbox.LastRun}}<br><span class="relative-time">{{timeAgoStr .Offbox.LastRun}}</span>{{end}}</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value" style="font-size:1.15rem">{{if .Offbox.RepoSizeHuman}}{{.Offbox.RepoSizeHuman}}{{else}}–{{end}}</div>
|
||||
@@ -136,7 +136,7 @@
|
||||
<div class="stat-label">{{if .Offbox.Enabled}}{{.Offbox.RepoPath}}{{else}}A NAS-mentés ki van kapcsolva{{end}}</div>
|
||||
</div>
|
||||
</div>
|
||||
{{if .Offbox.LastError}}<p class="form-hint" style="color:var(--danger,#c0392b)">Utolsó hiba: {{.Offbox.LastError}}</p>{{end}}
|
||||
{{if .Offbox.LastError}}<p class="form-hint" style="color:var(--crit)">Utolsó hiba: {{.Offbox.LastError}}</p>{{end}}
|
||||
{{if .OffboxConfigured}}
|
||||
<div class="schedule-actions" style="margin-top:1rem">
|
||||
<form method="POST" action="/backup/offbox/run" style="display:inline">{{.CSRFField}}
|
||||
|
||||
Reference in New Issue
Block a user