Added background jobs UI

This commit is contained in:
2018-04-28 21:17:44 +02:00
parent 59633707c1
commit 262b6018d1
7 changed files with 122 additions and 11 deletions

View File

@ -1,17 +1,39 @@
package jobs
import (
"sort"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
var running = map[string]bool{}
var lastRun = map[string]string{}
var jobInfo = map[string]*utils.JobInfo{
"anime-ratings": &utils.JobInfo{
Name: "anime-ratings",
},
"twist": &utils.JobInfo{
Name: "twist",
},
"refresh-osu": &utils.JobInfo{
Name: "refresh-osu",
},
}
var jobLogs = []string{}
// Overview shows all background jobs.
func Overview(ctx *aero.Context) string {
user := utils.GetUser(ctx)
jobs := []*utils.JobInfo{}
return ctx.HTML(components.EditorJobs(running, lastRun, ctx.URI(), user))
for _, job := range jobInfo {
jobs = append(jobs, job)
}
sort.Slice(jobs, func(i, j int) bool {
return jobs[i].Name < jobs[j].Name
})
return ctx.HTML(components.EditorJobs(jobs, jobLogs, ctx.URI(), user))
}