Reload job in ui
This commit is contained in:
28
server/job.go
Normal file
28
server/job.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"local/firestormy/scheduler"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func toMap(j *scheduler.Job) map[string]interface{} {
|
||||
tz, err := time.LoadLocation("America/Denver")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
out := make(map[string]interface{})
|
||||
out["disabled"] = j.Disabled
|
||||
out["id"] = j.Name
|
||||
out["title"] = j.Title
|
||||
out["cron"] = j.Schedule
|
||||
out["language"] = j.Runner.String()
|
||||
out["script"] = j.Raw
|
||||
out["last"] = map[string]interface{}{
|
||||
"run": j.LastRun.In(tz).Format(`2006-01-02 15:04:05 MST`),
|
||||
"runtime": j.LastRuntime.String(),
|
||||
"output": strings.ReplaceAll(j.LastOutput, "\n", "<br>"),
|
||||
"status": j.LastStatus,
|
||||
}
|
||||
return out
|
||||
}
|
||||
Reference in New Issue
Block a user