@@ -11,7 +11,7 @@ type CreateCloudBrainForm struct { | |||||
Command string `form:"command" binding:"Required"` | Command string `form:"command" binding:"Required"` | ||||
Attachment string `form:"attachment" binding:"Required"` | Attachment string `form:"attachment" binding:"Required"` | ||||
JobType string `form:"job_type" binding:"Required"` | JobType string `form:"job_type" binding:"Required"` | ||||
BenchmarkCategory string `form:"benchmark_category"` | |||||
BenchmarkCategory string `form:"get_benchmark_category"` | |||||
} | } | ||||
type CommitImageCloudBrainForm struct { | type CommitImageCloudBrainForm struct { | ||||
@@ -178,7 +178,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { | |||||
ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form) | ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form) | ||||
return | return | ||||
} | } | ||||
ctx.HTML(200, tplCloudBrainIndex) | |||||
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/cloudbrain") | |||||
} | } | ||||
func CloudBrainShow(ctx *context.Context) { | func CloudBrainShow(ctx *context.Context) { | ||||
@@ -261,16 +261,15 @@ func CloudBrainCommitImage(ctx *context.Context, form auth.CommitImageCloudBrain | |||||
func CloudBrainStop(ctx *context.Context) { | func CloudBrainStop(ctx *context.Context) { | ||||
var jobID = ctx.Params(":jobid") | var jobID = ctx.Params(":jobid") | ||||
log.Info(jobID) | |||||
task, err := models.GetCloudbrainByJobID(jobID) | task, err := models.GetCloudbrainByJobID(jobID) | ||||
if err != nil { | if err != nil { | ||||
ctx.ServerError("GetCloudbrainByJobID failed", err) | ctx.ServerError("GetCloudbrainByJobID failed", err) | ||||
return | return | ||||
} | } | ||||
if task.Status != string(models.JobRunning) { | |||||
log.Error("the job(%s) is not running", task.JobName) | |||||
ctx.ServerError("the job is not running", errors.New("the job is not running")) | |||||
if task.Status == string(models.JobStopped) { | |||||
log.Error("the job(%s) has been stopped", task.JobName) | |||||
ctx.ServerError("the job has been stopped", errors.New("the job has been stopped")) | |||||
return | return | ||||
} | } | ||||
@@ -297,9 +297,9 @@ | |||||
<!-- 停止 --> | <!-- 停止 --> | ||||
<div class="one wide column"> | <div class="one wide column"> | ||||
<div class="ui text center clipboard"> | <div class="ui text center clipboard"> | ||||
<form id="stopForm-{{.JobID}}" action="{{if ne .Status "RUNNING"}}javascript:void(0){{else}}{{$.Link}}/{{.JobID}}/stop{{end}}" method="post"> | |||||
<form id="stopForm-{{.JobID}}" action="{{if eq .Status "STOPPED"}}javascript:void(0){{else}}{{$.Link}}/{{.JobID}}/stop{{end}}" method="post"> | |||||
{{$.CsrfTokenHtml}} | {{$.CsrfTokenHtml}} | ||||
<a class="fitted" onclick="document.getElementById('stopForm-{{.JobID}}').submit();" style="{{if ne .Status "RUNNING"}}color:#CCCCCC{{end}}; font-size:16px; font-weight:bold">停止</a> | |||||
<a class="fitted" onclick="document.getElementById('stopForm-{{.JobID}}').submit();" style="{{if eq .Status "STOPPED"}}color:#CCCCCC{{end}}; font-size:16px; font-weight:bold">停止</a> | |||||
</form> | </form> | ||||
</div> | </div> | ||||
</div> | </div> | ||||