package components import ( "context" "fmt" "github.com/starfleetcptn/gomft/internal/db" "time" ) type JobRunDetailsData struct { JobHistory db.JobHistory Job db.Job Config db.TransferConfig } templ JobRunDetails(ctx context.Context, data JobRunDetailsData) { @LayoutWithContext("Job Run Details", ctx) {

Job Run Details

if data.Job.Name != "" { { data.Job.Name } } else { { data.Config.Name } }

if data.JobHistory.Status == "completed" { Completed } else if data.JobHistory.Status == "failed" { Failed } else { { data.JobHistory.Status } }
if data.Job.Name != "" && data.Job.Name != data.Config.Name {

Config: { data.Config.Name }

}
Start Time
{ data.JobHistory.StartTime.Format("Jan 02, 2006 15:04:05") }
End Time
if data.JobHistory.EndTime != nil { { data.JobHistory.EndTime.Format("Jan 02, 2006 15:04:05") } } else { Still running... }
Duration
if data.JobHistory.EndTime != nil { { formatDuration(data.JobHistory.EndTime.Sub(data.JobHistory.StartTime)) } } else { { formatDuration(time.Since(data.JobHistory.StartTime)) } (ongoing) }
Data Transferred
{ formatBytes(data.JobHistory.BytesTransferred) }
Files Transferred
{ fmt.Sprint(data.JobHistory.FilesTransferred) }
Job Schedule
{ data.Job.Schedule }

Transfer Configuration

Source Type
{ data.Config.SourceType }
Destination Type
{ data.Config.DestinationType }
Source Path
if data.Config.SourceType == "sftp" { { data.Config.SourceUser } `@` { data.Config.SourceHost }:{ data.Config.SourcePath } } else { { data.Config.SourcePath } }
Destination Path
if data.Config.DestinationType == "sftp" { data.Config.DestUser@data.Config.DestHost:data.Config.DestinationPath } else { { data.Config.DestinationPath } }
File Pattern
{ data.Config.FilePattern }
if data.Config.ArchiveEnabled {
Archive Path
{ data.Config.ArchivePath }
}
if data.JobHistory.ErrorMessage != "" {

Error Details

{ data.JobHistory.ErrorMessage }
}
} } // formatDuration formats a duration in a human-readable way func formatDuration(d time.Duration) string { d = d.Round(time.Second) h := d / time.Hour d -= h * time.Hour m := d / time.Minute d -= m * time.Minute s := d / time.Second if h > 0 { return fmt.Sprintf("%dh %dm %ds", h, m, s) } if m > 0 { return fmt.Sprintf("%dm %ds", m, s) } return fmt.Sprintf("%ds", s) }