ui+server: schedule next-run / last-run on dashboard + schedules tab

P2R-14. New store.LatestJobBySchedule query (per-schedule fired job).
Schedules-tab handler computes next-fire from cron + last-fire from
the jobs table per row. Schedules table grows two columns; dashboard
host row prepends 'next 12h ago/from now' to the existing last-backup
line when a single covering schedule is the run-now candidate.

Embeds store.Schedule into scheduleRow so existing template field
references keep working without bulk renames.
This commit is contained in:
2026-05-04 10:44:31 +01:00
parent e6fc9e9963
commit d02a093eeb
7 changed files with 201 additions and 4 deletions
+14
View File
@@ -124,6 +124,9 @@ type dashboardHostRow struct {
// match — in that case the row shows "Open →" instead of a Run-now
// button (the operator picks per-group from the host detail).
RunAllScheduleID string
// NextRun is the next-fire time of RunAllScheduleID (when set),
// computed server-side from its cron. nil otherwise.
NextRun *time.Time
}
// pickRunAllSchedule returns the ID of the single schedule whose
@@ -203,6 +206,17 @@ func (s *Server) handleUIDashboard(w stdhttp.ResponseWriter, r *stdhttp.Request)
slog.Warn("ui dashboard: list schedules", "host_id", h.ID, "err", serr)
}
row.RunAllScheduleID = pickRunAllSchedule(scheds, groups)
if row.RunAllScheduleID != "" {
for _, sc := range scheds {
if sc.ID == row.RunAllScheduleID {
if parsed, perr := cronParser.Parse(sc.CronExpr); perr == nil {
n := parsed.Next(time.Now().UTC()).UTC()
row.NextRun = &n
}
break
}
}
}
rows = append(rows, row)
}