feat(runner-view): add task list in runnder details page, in admin

This commit is contained in:
fuxiaohei
2022-11-04 21:11:59 +08:00
committed by Jason Song
parent 8a8214113b
commit 8c3ed11ed9
8 changed files with 245 additions and 33 deletions

View File

@ -12,6 +12,7 @@ import (
"errors"
"fmt"
"io"
"strconv"
"time"
auth_model "code.gitea.io/gitea/models/auth"
@ -92,6 +93,64 @@ func (task *Task) TakeTime() time.Duration {
return time.Since(started).Truncate(time.Second)
}
func (task *Task) IsStopped() bool {
return task.Stopped > 0
}
func (task *Task) GetRepo() string {
return "xxxx"
}
func (task *Task) GetCommitSHA() string {
if task.Job == nil {
return ""
}
if task.Job.Run == nil {
return ""
}
return task.Job.Run.CommitSHA
}
func (task *Task) GetCommitSHAShort() string {
commitSHA := task.GetCommitSHA()
if len(commitSHA) > 8 {
return commitSHA[:8]
}
return commitSHA
}
func (task *Task) GetBuildViewLink() string {
if task.Job == nil || task.Job.Run == nil || task.Job.Run.Repo == nil {
return ""
}
return task.Job.Run.Repo.Link() + "/builds/runs/" + strconv.FormatInt(task.ID, 10)
}
func (task *Task) GetCommitLink() string {
if task.Job == nil || task.Job.Run == nil || task.Job.Run.Repo == nil {
return ""
}
if commitSHA := task.GetCommitSHA(); commitSHA != "" {
return task.Job.Run.Repo.CommitLink(commitSHA)
}
return ""
}
func (task *Task) GetRepoName() string {
if task.Job == nil || task.Job.Run == nil || task.Job.Run.Repo == nil {
return ""
}
return task.Job.Run.Repo.FullName()
}
func (task *Task) GetRepoLink() string {
if task.Job == nil || task.Job.Run == nil || task.Job.Run.Repo == nil {
return ""
}
return task.Job.Run.Repo.Link()
}
func (task *Task) LoadJob(ctx context.Context) error {
if task.Job == nil {
job, err := GetRunJobByID(ctx, task.JobID)