ui: per-host Jobs sub-tab; drop unused Settings stub
Adds /hosts/{id}/jobs page listing recent jobs for the host (newest
first, capped at 100) with click-through to /jobs/{id}. Converts the
Jobs placeholder <div> to a real <a> nav link; removes the Settings
stub entirely. Also registers durationHuman template func and a
.jobs-row CSS grid to match the existing .schd-row idiom.
This commit is contained in:
@@ -75,6 +75,28 @@ func funcMap() template.FuncMap {
|
||||
return *p
|
||||
},
|
||||
"sub": func(a, b int) int { return a - b },
|
||||
// durationHuman formats the elapsed time between two *time.Time
|
||||
// values as a short human string: "350ms", "4.2s", "2m 15s",
|
||||
// "1h 4m". Returns "—" when either pointer is nil.
|
||||
"durationHuman": func(start, end *time.Time) string {
|
||||
if start == nil || end == nil {
|
||||
return "—"
|
||||
}
|
||||
d := end.Sub(*start)
|
||||
if d < 0 {
|
||||
d = -d
|
||||
}
|
||||
if d < time.Second {
|
||||
return fmt.Sprintf("%dms", d.Milliseconds())
|
||||
}
|
||||
if d < time.Minute {
|
||||
return fmt.Sprintf("%.1fs", d.Seconds())
|
||||
}
|
||||
if d < time.Hour {
|
||||
return fmt.Sprintf("%dm %ds", int(d.Minutes()), int(d.Seconds())%60)
|
||||
}
|
||||
return fmt.Sprintf("%dh %dm", int(d.Hours()), int(d.Minutes())%60)
|
||||
},
|
||||
// joinComma joins a slice with ", ". Used by the schedule list
|
||||
// to render retention summaries.
|
||||
"joinComma": func(parts []string) string { return strings.Join(parts, ", ") },
|
||||
|
||||
Reference in New Issue
Block a user