mirror of
https://github.com/go-gitea/gitea.git
synced 2025-04-08 17:05:45 +02:00
feat(runner): begin runner view ui
This commit is contained in:
parent
1a78fd3494
commit
206b2a104e
@ -19,6 +19,7 @@ import (
|
||||
|
||||
// ErrRunnerNotExist represents an error for bot runner not exist
|
||||
type ErrRunnerNotExist struct {
|
||||
ID int64
|
||||
UUID string
|
||||
Token string
|
||||
}
|
||||
@ -79,6 +80,7 @@ type FindRunnerOptions struct {
|
||||
db.ListOptions
|
||||
RepoID int64
|
||||
OwnerID int64
|
||||
Sort string
|
||||
}
|
||||
|
||||
func (opts FindRunnerOptions) toCond() builder.Cond {
|
||||
@ -140,6 +142,20 @@ func GetRunnerByUUID(uuid string) (*Runner, error) {
|
||||
return &runner, nil
|
||||
}
|
||||
|
||||
// GetRunnerByID returns a bot runner via id
|
||||
func GetRunnerByID(id int64) (*Runner, error) {
|
||||
var runner Runner
|
||||
has, err := db.GetEngine(db.DefaultContext).Where("id=?", id).Get(&runner)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !has {
|
||||
return nil, ErrRunnerNotExist{
|
||||
ID: id,
|
||||
}
|
||||
}
|
||||
return &runner, nil
|
||||
}
|
||||
|
||||
// GetRunnerByToken returns a bot runner via token
|
||||
func GetRunnerByToken(token string) (*Runner, error) {
|
||||
var runner Runner
|
||||
|
@ -65,43 +65,22 @@ func Runners(ctx *context.Context) {
|
||||
ctx.HTML(http.StatusOK, tplRunners)
|
||||
}
|
||||
|
||||
// NewRunner render adding a new runner page
|
||||
func NewRunner(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.runners.new")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminRunners"] = true
|
||||
|
||||
ctx.HTML(http.StatusOK, tplRunnerNew)
|
||||
}
|
||||
|
||||
// NewRunnerPost response for adding a new runner
|
||||
func NewRunnerPost(ctx *context.Context) {
|
||||
// form := web.GetForm(ctx).(*forms.AdminCreateRunnerForm)
|
||||
ctx.Data["Title"] = ctx.Tr("admin.runners.new")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminRunners"] = true
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(http.StatusOK, tplRunnerNew)
|
||||
return
|
||||
}
|
||||
|
||||
// ctx.Flash.Success(ctx.Tr("admin.runners.new_success", u.Name))
|
||||
// ctx.Redirect(setting.AppSubURL + "/admin/users/" + strconv.FormatInt(u.ID, 10))
|
||||
}
|
||||
|
||||
// EditRunner show editing runner page
|
||||
func EditRunner(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.runners.edit")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminRunners"] = true
|
||||
|
||||
prepareUserInfo(ctx)
|
||||
if ctx.Written() {
|
||||
runner, err := bots_model.GetBuildByID(ctx.ParamsInt64(":runnerid"))
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRunnerByID", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Runner"] = runner
|
||||
|
||||
ctx.HTML(http.StatusOK, tplUserEdit)
|
||||
// TODO: get task list for this runner
|
||||
|
||||
ctx.HTML(http.StatusOK, tplRunnerEdit)
|
||||
}
|
||||
|
||||
// EditRunnerPost response for editing runner
|
||||
@ -127,3 +106,30 @@ func DeleteRunner(ctx *context.Context) {
|
||||
"redirect": setting.AppSubURL + "/admin/runners",
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
// NewRunner render adding a new runner page
|
||||
func NewRunner(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.runners.new")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminRunners"] = true
|
||||
|
||||
ctx.HTML(http.StatusOK, tplRunnerNew)
|
||||
}
|
||||
|
||||
// NewRunnerPost response for adding a new runner
|
||||
func NewRunnerPost(ctx *context.Context) {
|
||||
// form := web.GetForm(ctx).(*forms.AdminCreateRunnerForm)
|
||||
ctx.Data["Title"] = ctx.Tr("admin.runners.new")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminRunners"] = true
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(http.StatusOK, tplRunnerNew)
|
||||
return
|
||||
}
|
||||
|
||||
// ctx.Flash.Success(ctx.Tr("admin.runners.new_success", u.Name))
|
||||
// ctx.Redirect(setting.AppSubURL + "/admin/users/" + strconv.FormatInt(u.ID, 10))
|
||||
}
|
||||
**/
|
||||
|
@ -628,7 +628,6 @@ func RegisterRoutes(m *web.Route) {
|
||||
|
||||
m.Group("/runners", func() {
|
||||
m.Get("", admin.Runners)
|
||||
m.Combo("/new").Get(admin.NewRunner).Post(bindIgnErr(forms.AdminCreateRunnerForm{}), admin.NewRunnerPost)
|
||||
m.Combo("/{runnerid}").Get(admin.EditRunner).Post(bindIgnErr(forms.AdminEditRunnerForm{}), admin.EditRunnerPost)
|
||||
m.Post("/{runnerid}/delete", admin.DeleteRunner)
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{template "base/head" .}}
|
||||
<div class="page-content admin user">
|
||||
<div class="page-content admin runner">
|
||||
{{template "admin/navbar" .}}
|
||||
<div class="ui container">
|
||||
{{template "base/alert" .}}
|
||||
@ -10,7 +10,7 @@
|
||||
</div>
|
||||
</h4>
|
||||
<div class="ui attached segment">
|
||||
<form class="ui form ignore-dirty" id="user-list-search-form">
|
||||
<form class="ui form ignore-dirty" id="user-list-search-form" action="{{$.Link}}">
|
||||
<!-- Search Text -->
|
||||
<div class="ui fluid action input" style="max-width: 70%;">
|
||||
<input name="q" value="{{.Keyword}}" placeholder="{{.locale.Tr "explore.search"}}..." autofocus>
|
||||
@ -22,26 +22,64 @@
|
||||
<table class="ui very basic striped table unstackable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-sortt-asc="oldest" data-sortt-desc="newest">ID</th>
|
||||
<th data-sortt-asc="online" data-sortt-desc="offline">{{.locale.Tr "admin.runners.status"}}</th>
|
||||
<th data-sortt-asc="alphabetically">
|
||||
{{.locale.Tr "admin.runners.name"}}
|
||||
{{.locale.Tr "admin.runners.id"}}
|
||||
</th>
|
||||
<th>{{.locale.Tr "admin.runners.own_type"}}</th>
|
||||
<th>{{.locale.Tr "admin.runners.uuid"}}</th>
|
||||
<th>{{.locale.Tr "admin.runners.created"}}</th>
|
||||
<th>{{.locale.Tr "admin.runners.edit"}}</th>
|
||||
<th>{{.locale.Tr "admin.runners.tags"}}</th>
|
||||
<th>{{.locale.Tr "admin.runners.latest_contact"}}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>online</td>
|
||||
<td><a href="?">
|
||||
<span class="runner-id">#1</span>
|
||||
<span class="runner-name">focused_mcclintock</span>
|
||||
</a></td>
|
||||
<td>shared</td>
|
||||
<td class="runner-tags">
|
||||
<span>linux</span>
|
||||
<span>amd64</span>
|
||||
</td>
|
||||
<td>3 days ago</td>
|
||||
<td class="runner-ops">
|
||||
<a href="#">{{svg "octicon-pencil"}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>offline</td>
|
||||
<td><a href="?">
|
||||
<span class="runner-id">#2</span>
|
||||
<span class="runner-name">lucid_khorana</span>
|
||||
</a></td>
|
||||
<td>shared</td>
|
||||
<td class="runner-tags">
|
||||
<span>linux</span>
|
||||
<span>aarch64</span>
|
||||
<span>self-host</span>
|
||||
<span>custom</span>
|
||||
</td>
|
||||
<td>3 minutes ago</td>
|
||||
<td class="runner-ops">
|
||||
<a href="#">{{svg "octicon-pencil"}}</a>
|
||||
<a href="#">{{svg "octicon-x-circle"}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{{range .Runners}}
|
||||
<tr>
|
||||
<td>{{.ID}}</td>
|
||||
<td>{{.Name}}</td>
|
||||
<td>{{.OwnType}}</td>
|
||||
<td>{{.UUID}}</td>
|
||||
<td>{{.Created}}</td>
|
||||
<td><a href="{{$.Link}}/{{.ID}}">{{svg "octicon-pencil"}}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{.ID}}</td>
|
||||
<td>{{.Name}}</td>
|
||||
<td>{{.OwnType}}</td>
|
||||
<td>{{.UUID}}</td>
|
||||
<td>{{.Created}}</td>
|
||||
<td class="runner-ops">
|
||||
<a href="#">{{svg "octicon-pencil"}}</a>
|
||||
<a href="#">{{svg "octicon-x-circle"}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
|
5
web_src/less/_runner.less
Normal file
5
web_src/less/_runner.less
Normal file
@ -0,0 +1,5 @@
|
||||
@import "variables.less";
|
||||
|
||||
.admin.runner{
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user