mirror of
https://github.com/go-gitea/gitea.git
synced 2025-04-18 00:47:48 -04:00
feat(bots): update runner data in html page
This commit is contained in:
parent
848a1ae309
commit
5b989e2a11
@ -74,6 +74,18 @@ func (r *Runner) OwnType() string {
|
|||||||
return r.Repo.FullName()
|
return r.Repo.FullName()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Runner) StatusType() string {
|
||||||
|
switch r.Status {
|
||||||
|
case runnerv1.RunnerStatus_RUNNER_STATUS_OFFLINE:
|
||||||
|
return "offline"
|
||||||
|
case runnerv1.RunnerStatus_RUNNER_STATUS_IDLE:
|
||||||
|
return "online"
|
||||||
|
case runnerv1.RunnerStatus_RUNNER_STATUS_ACTIVE:
|
||||||
|
return "online"
|
||||||
|
}
|
||||||
|
return "unknown"
|
||||||
|
}
|
||||||
|
|
||||||
// AllLabels returns agent and custom labels
|
// AllLabels returns agent and custom labels
|
||||||
func (r *Runner) AllLabels() []string {
|
func (r *Runner) AllLabels() []string {
|
||||||
return append(r.AgentLabels, r.CustomLabels...)
|
return append(r.AgentLabels, r.CustomLabels...)
|
||||||
|
@ -8,12 +8,16 @@ package admin
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
|
||||||
bots_model "code.gitea.io/gitea/models/bots"
|
bots_model "code.gitea.io/gitea/models/bots"
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
"code.gitea.io/gitea/modules/base"
|
"code.gitea.io/gitea/modules/base"
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
"code.gitea.io/gitea/modules/web"
|
||||||
|
"code.gitea.io/gitea/services/forms"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -88,18 +92,33 @@ func EditRunner(ctx *context.Context) {
|
|||||||
|
|
||||||
// EditRunnerPost response for editing runner
|
// EditRunnerPost response for editing runner
|
||||||
func EditRunnerPost(ctx *context.Context) {
|
func EditRunnerPost(ctx *context.Context) {
|
||||||
// form := web.GetForm(ctx).(*forms.AdminEditRunnerForm)
|
runner, err := bots_model.GetRunnerByID(ctx.ParamsInt64(":runnerid"))
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("EditRunnerPost.GetRunnerByID failed: %v, url: %s", err, ctx.Req.URL)
|
||||||
|
ctx.ServerError("EditRunnerPost.GetRunnerByID", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
form := web.GetForm(ctx).(*forms.AdminEditRunnerForm)
|
||||||
|
runner.Description = form.Description
|
||||||
|
runner.CustomLabels = strings.Split(form.CustomLabels, ",")
|
||||||
|
|
||||||
|
err = bots_model.UpdateRunner(ctx, runner, "description", "custom_labels")
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("EditRunnerPost.UpdateRunner failed: %v, url: %s", err, ctx.Req.URL)
|
||||||
|
ctx.Flash.Warning(ctx.Tr("admin.runners.edit_failed"))
|
||||||
|
ctx.Redirect(setting.AppSubURL + "/admin/runners/" + url.PathEscape(ctx.Params(":runnerid")))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
ctx.Data["Title"] = ctx.Tr("admin.runners.edit")
|
ctx.Data["Title"] = ctx.Tr("admin.runners.edit")
|
||||||
ctx.Data["PageIsAdmin"] = true
|
ctx.Data["PageIsAdmin"] = true
|
||||||
ctx.Data["PageIsAdminRunners"] = true
|
ctx.Data["PageIsAdminRunners"] = true
|
||||||
|
|
||||||
if ctx.HasError() {
|
log.Debug("EditRunnerPost success: %s", ctx.Req.URL)
|
||||||
ctx.HTML(http.StatusOK, tplUserEdit)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.Flash.Success(ctx.Tr("admin.users.update_profile_success"))
|
ctx.Flash.Success(ctx.Tr("admin.runners.edit_success"))
|
||||||
ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid")))
|
ctx.Redirect(setting.AppSubURL + "/admin/runners/" + url.PathEscape(ctx.Params(":runnerid")))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteRunner response for deleting a runner
|
// DeleteRunner response for deleting a runner
|
||||||
|
@ -86,8 +86,8 @@ func (f *AdminCreateRunnerForm) Validate(req *http.Request, errs binding.Errors)
|
|||||||
|
|
||||||
// AdminEditRunnerForm form for admin to create runner
|
// AdminEditRunnerForm form for admin to create runner
|
||||||
type AdminEditRunnerForm struct {
|
type AdminEditRunnerForm struct {
|
||||||
Name string `binding:"Required"`
|
Description string
|
||||||
Type string
|
CustomLabels string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate validates form fields
|
// Validate validates form fields
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
{{template "base/disable_form_autofill"}}
|
{{template "base/disable_form_autofill"}}
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<div class="runner-basic-info">
|
<div class="runner-basic-info">
|
||||||
|
<div class="field dib">
|
||||||
|
<label>{{.locale.Tr "admin.runners.status"}}</label>
|
||||||
|
<span class="runner-status-{{.Runner.StatusType}}">{{.Runner.StatusType}}</span>
|
||||||
|
</div>
|
||||||
<div class="field dib">
|
<div class="field dib">
|
||||||
<label>{{.locale.Tr "admin.runners.last_online"}}</label>
|
<label>{{.locale.Tr "admin.runners.last_online"}}</label>
|
||||||
<span>{{TimeSinceUnix .Runner.LastOnline $.locale}}</span>
|
<span>{{TimeSinceUnix .Runner.LastOnline $.locale}}</span>
|
||||||
@ -55,7 +59,7 @@
|
|||||||
{{.locale.Tr "admin.runner.task_list"}}
|
{{.locale.Tr "admin.runner.task_list"}}
|
||||||
</h4>
|
</h4>
|
||||||
<div class="ui attached segment">
|
<div class="ui attached segment">
|
||||||
Comming soon
|
Comming soon
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{{range .Runners}}
|
{{range .Runners}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>status</td>
|
<td><span class="runner-status-{{.StatusType}}">{{.StatusType}}</span></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{$.Link}}/{{.ID}}" class="tooltip" data-content="{{.Description}}">
|
<a href="{{$.Link}}/{{.ID}}" class="tooltip" data-content="{{.Description}}">
|
||||||
<span class="runner-id">#{{.ID}}</span>
|
<span class="runner-id">#{{.ID}}</span>
|
||||||
|
@ -10,4 +10,9 @@
|
|||||||
.runner-basic-info .dib {
|
.runner-basic-info .dib {
|
||||||
margin-right: 1em;
|
margin-right: 1em;
|
||||||
}
|
}
|
||||||
|
.runner-status-online{
|
||||||
|
.ui.label;
|
||||||
|
background-color: var(--color-green);
|
||||||
|
color: var(--color-white);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user