package schedulehistories import "github.com/tigorlazuardi/redmage/views" import "github.com/tigorlazuardi/redmage/views/components" import "github.com/tigorlazuardi/redmage/models" import "github.com/tigorlazuardi/redmage/api" import "fmt" import "time" import "github.com/tigorlazuardi/redmage/views/icons" type Data struct { ScheduleHistories models.ScheduleHistorySlice Params api.ScheduleHistoryListByDateParams Error string } func (data Data) isCurrentDay() bool { now := time.Now() return now.Format(time.DateOnly) == data.Params.Date.Format(time.DateOnly) } templ View(c *views.Context, data Data) { @components.Doctype() { @components.Head(c, components.HeadTitle("Schedule History"), ) @components.Body(c) { @components.Container() { @Content(c, data) } @components.NotificationContainer() { if data.Error != "" { @components.ErrorNotication(data.Error) } } } } } templ Content(c *views.Context, data Data) {

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

if data.isCurrentDay() { @icons.Refresh("w-6 h-6") } else { @icons.ChevronBoldLeft("w-6 h-6") } { data.Params.Date.Format("Monday, 02 January 2006") } { data.Params.Date.Format("Mon, 02 Jan") }
if len(data.ScheduleHistories) == 0 {

There are no history schedules found for current date.

} if len(data.ScheduleHistories) > 0 {
Time Event for i, schedule := range data.ScheduleHistories { if i > 0 {
}

{ time.Unix(schedule.CreatedAt, 0).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 } }