mirror of https://github.com/ouqiang/gocron
164 lines
6.4 KiB
HTML
164 lines
6.4 KiB
HTML
{{{ template "common/header" . }}}
|
|
|
|
<div class="ui grid">
|
|
{{{template "task/menu" .}}}
|
|
<div class="twelve wide column">
|
|
<div class="pageHeader">
|
|
<div class="segment">
|
|
<h3 class="ui dividing header">
|
|
<i class="large add icon"></i>
|
|
<div class="content">
|
|
{{{.Title}}}
|
|
</div>
|
|
</h3>
|
|
</div>
|
|
</div>
|
|
<form class="ui form fluid vertical segment">
|
|
<input type="hidden" name="id" value="{{{.Task.Id}}}">
|
|
<div class="two fields">
|
|
<div class="field">
|
|
<label>任务名称</label>
|
|
<div class="ui small left icon input">
|
|
<input type="text" placeholder="数据库备份" name="name" value="{{{.Task.Task.Name}}}">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="two fields">
|
|
<div class="field">
|
|
<label>crontab表达式 (每行一个表达式)</label>
|
|
<textarea rows="5" name="spec" placeholder="*/5 * * * * * *">{{{.Task.Spec}}}</textarea>
|
|
</div>
|
|
</div>
|
|
<div class="three fields">
|
|
<div class="field">
|
|
<label>协议</label>
|
|
<div class="ui dropdown selection">
|
|
{{{if .Task}}}
|
|
<input type="hidden" name="protocol" value="{{{if (gt .Task.Protocol 0)}}}{{{.Task.Protocol}}}{{{else}}}3{{{end}}}">
|
|
{{{else}}}
|
|
<input type="hidden" name="protocol" value="3">
|
|
{{{end}}}
|
|
<div class="default text">本地命令</div>
|
|
<i class="dropdown icon"></i>
|
|
<div class="menu">
|
|
<div class="item" data-value="3">本地命令</div>
|
|
<div class="item" data-value="2">SSH</div>
|
|
<div class="item" data-value="1">HTTP</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="field">
|
|
<label>主机</label>
|
|
<div class="inline fields">
|
|
{{{range $i, $v := .Hosts}}}
|
|
<div class="field">
|
|
<div class="ui radio checkbox">
|
|
{{{if $.Task}}}
|
|
<input type="radio" name="host_id" tabindex="0" class="hidden" value="{{{.Id}}}"
|
|
{{{if and .Task (eq $.TaskId .Id)}}} checked {{{end}}}
|
|
>
|
|
{{{else}}}
|
|
<input type="radio" name="host_id" tabindex="0" class="hidden">
|
|
{{{end}}}
|
|
<label>{{{.Alias}}}-{{{.Name}}}</label>
|
|
</div>
|
|
</div>
|
|
{{{end}}}
|
|
</div>
|
|
</div>
|
|
<div class="field">
|
|
<label>命令(shell命令|URL地址, 多条shell命令";"分隔)</label>
|
|
<input type="text" name="command" placeholder="tail -n 10 /var/log/nginx/error.log" value="{{{.Task.Command}}}">
|
|
</div>
|
|
<div class="three fields">
|
|
<div class="field">
|
|
<label>任务超时时间 (单位秒,0不限制,不能超过24小时)</label>
|
|
<input type="text" name="timeout" placeholder="0" value="{{{.Task.Timeout}}}">
|
|
</div>
|
|
</div>
|
|
<div class="three fields">
|
|
<div class="field">
|
|
<label>任务状态 (任务添加成功后,是否立即调度)</label>
|
|
<div class="ui dropdown selection">
|
|
{{{if .Task}}}
|
|
<input type="hidden" name="status" value="{{{if and .Task.Status (eq .Task.Status 1)}}}1{{{else}}}2{{{end}}}">
|
|
{{{else}}}
|
|
<input type="hidden" name="status" value="2">
|
|
{{{end}}}
|
|
<div class="default text">暂停</div>
|
|
<i class="dropdown icon"></i>
|
|
<div class="menu">
|
|
<div class="item" data-value="2">暂停</div>
|
|
<div class="item" data-value="1">激活</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="two field">
|
|
<div class="field">
|
|
<label>备注</label>
|
|
<textarea rows="5" name="remark" placeholder="任务备注">{{{.Task.Remark}}}</textarea>
|
|
</div>
|
|
</div>
|
|
<div class="ui primary submit button">保存</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script type="text/javascript">
|
|
$('.ui.checkbox')
|
|
.checkbox()
|
|
;
|
|
$('.ui.form').form(
|
|
{
|
|
onSuccess: function(event, fields) {
|
|
util.post('/task/store', fields, function(code, message) {
|
|
location.href = "/task"
|
|
});
|
|
|
|
return false;
|
|
},
|
|
fields: {
|
|
name: {
|
|
identifier : 'name',
|
|
rules: [
|
|
{
|
|
type : 'empty',
|
|
prompt : '请输入任务名称'
|
|
}
|
|
]
|
|
},
|
|
spec: {
|
|
identifier : 'spec',
|
|
rules: [
|
|
{
|
|
type : 'empty',
|
|
prompt : '请输入crontab格式表达式'
|
|
}
|
|
]
|
|
},
|
|
command: {
|
|
identifier : 'command',
|
|
rules: [
|
|
{
|
|
type : 'empty',
|
|
prompt : '请输入任务命令'
|
|
}
|
|
]
|
|
}, hosts: {
|
|
identifier : 'hosts',
|
|
rules: [
|
|
{
|
|
type : 'checked',
|
|
prompt : '请选择主机'
|
|
}
|
|
]
|
|
}
|
|
},
|
|
inline : true
|
|
});
|
|
</script>
|
|
|
|
{{{ template "common/footer" . }}} |