package schedulehistoriesview import "github.com/tigorlazuardi/redmage/views" import "github.com/tigorlazuardi/redmage/views/components" import "time" import "github.com/tigorlazuardi/redmage/api" import "fmt" templ ScheduleHistoriesview(c *views.Context, data Data) { @components.Doctype() { @components.Head(c, components.HeadTitle("Schedule History"), ) @components.Body(c) { @ScheduleHistoriesContent(c, data) } } } templ ScheduleHistoriesContent(c *views.Context, data Data) {
@components.Container() { if data.Error != "" { @components.ErrorToast(data.Error) } else {

Schedule History ({ time.Local.String() })

if data.Total < 1 {

There are no history schedules to be found. You can populate this page's history by manually trigger a Subreddit { "for" } downloading.

} if data.Total > 0 {
for _, scheduleGroup := range data.splitByDays() {

{ scheduleGroup.Day.Format("Monday, _2 January 2006") }

for _, schedule := range scheduleGroup.Schedules {
{ time.Unix(schedule.CreatedAt, 10).In(time.Local).Format("15:04:05") }
if api.ScheduleStatus(schedule.Status) == api.ScheduleStatusDisabled { Subreddit @subredditLink(schedule.Subreddit) scheduler has been set to { api.ScheduleStatusDisabled.String() } status. } else if api.ScheduleStatus(schedule.Status) == api.ScheduleStatusEnabled { Subreddit @subredditLink(schedule.Subreddit) { " " } has been { api.ScheduleStatusEnabled.String() } { "for" } automatic scheduling. } else if api.ScheduleStatus(schedule.Status) == api.ScheduleStatusStandby { Subreddit @subredditLink(schedule.Subreddit) { " " } has finished { api.ScheduleStatusDownloading.String() } and turned to { api.ScheduleStatusStandby.String() } status. } else if api.ScheduleStatus(schedule.Status) == api.ScheduleStatusEnqueued { Subreddit @subredditLink(schedule.Subreddit) { " " } is { api.ScheduleStatusEnqueued.String() } { "for" } downloading. } else if api.ScheduleStatus(schedule.Status) == api.ScheduleStatusDownloading { Subreddit @subredditLink(schedule.Subreddit) { " " } has started { api.ScheduleStatusDownloading.String() }. } else if api.ScheduleStatus(schedule.Status) == api.ScheduleStatusError { Subreddit @subredditLink(schedule.Subreddit) { " " } finishes { api.ScheduleStatusDownloading.String() } with { api.ScheduleStatusError.String() } of "{ schedule.ErrorMessage }". }
} }
} } }
} templ subredditLink(subreddit string) { { subreddit } }