package components import ( "context" "fmt" "github.com/starfleetcptn/gomft/internal/db" ) type HistoryData struct { History []db.JobHistory CurrentPage int TotalPages int SearchTerm string PageSize int Total int } // min returns the smaller of x or y func min(x, y int) int { if x < y { return x } return y } // HistoryContent renders only the content part of the history page for HTMX requests templ HistoryContent(ctx context.Context, data HistoryData) { if len(data.History) == 0 {
No results found for "{ data.SearchTerm }". Try a different search term or .
} else if data.CurrentPage > 1 {No more results on this page. .
} else {Transfer history will appear here once jobs have run.
}{ history.Job.Config.Name }
if history.Status == "completed" { Completed } else if history.Status == "failed" { Failed } else { { history.Status } }Started: { history.StartTime.Format("Jan 02, 2006 15:04:05") }
if history.EndTime != nil {Duration: { history.EndTime.Sub(history.StartTime).String() }
}{ formatBytes(history.BytesTransferred) } transferred
}Error: { history.ErrorMessage }
Showing { fmt.Sprint((data.CurrentPage-1)*data.PageSize + 1) } to { fmt.Sprint(min((data.CurrentPage)*data.PageSize, data.Total)) } of { fmt.Sprint(data.Total) } results