2018-04-28 17:44:44 +00:00
|
|
|
package jobs
|
|
|
|
|
|
|
|
import (
|
2018-04-28 19:17:44 +00:00
|
|
|
"sort"
|
|
|
|
|
2018-04-28 17:44:44 +00:00
|
|
|
"github.com/aerogo/aero"
|
|
|
|
"github.com/animenotifier/notify.moe/components"
|
|
|
|
"github.com/animenotifier/notify.moe/utils"
|
|
|
|
)
|
|
|
|
|
2018-04-28 19:17:44 +00:00
|
|
|
var jobInfo = map[string]*utils.JobInfo{
|
|
|
|
"anime-ratings": &utils.JobInfo{
|
|
|
|
Name: "anime-ratings",
|
|
|
|
},
|
2018-05-08 11:52:07 +00:00
|
|
|
"kitsu-import-anime": &utils.JobInfo{
|
|
|
|
Name: "kitsu-import-anime",
|
|
|
|
},
|
2018-04-28 19:17:44 +00:00
|
|
|
"twist": &utils.JobInfo{
|
|
|
|
Name: "twist",
|
|
|
|
},
|
|
|
|
"refresh-osu": &utils.JobInfo{
|
|
|
|
Name: "refresh-osu",
|
|
|
|
},
|
2018-04-28 20:10:47 +00:00
|
|
|
"mal-download": &utils.JobInfo{
|
|
|
|
Name: "mal-download",
|
|
|
|
},
|
|
|
|
"mal-parse": &utils.JobInfo{
|
|
|
|
Name: "mal-parse",
|
|
|
|
},
|
2018-06-30 05:03:07 +00:00
|
|
|
"mal-sync": &utils.JobInfo{
|
|
|
|
Name: "mal-sync",
|
|
|
|
},
|
|
|
|
"test": &utils.JobInfo{
|
|
|
|
Name: "test",
|
|
|
|
},
|
2018-04-28 19:17:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var jobLogs = []string{}
|
2018-04-28 17:44:44 +00:00
|
|
|
|
|
|
|
// Overview shows all background jobs.
|
|
|
|
func Overview(ctx *aero.Context) string {
|
|
|
|
user := utils.GetUser(ctx)
|
2018-04-28 19:17:44 +00:00
|
|
|
jobs := []*utils.JobInfo{}
|
|
|
|
|
|
|
|
for _, job := range jobInfo {
|
|
|
|
jobs = append(jobs, job)
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Slice(jobs, func(i, j int) bool {
|
|
|
|
return jobs[i].Name < jobs[j].Name
|
|
|
|
})
|
2018-04-28 17:44:44 +00:00
|
|
|
|
2018-04-28 19:17:44 +00:00
|
|
|
return ctx.HTML(components.EditorJobs(jobs, jobLogs, ctx.URI(), user))
|
2018-04-28 17:44:44 +00:00
|
|
|
}
|