gocron/templates/task/task_form.html

146 lines
5.6 KiB
HTML
Raw Normal View History

2017-04-07 01:13:36 +00:00
{{{ template "common/header" . }}}
<div class="ui grid">
{{{template "task/menu" .}}}
<div class="twelve wide column">
2017-04-07 09:26:46 +00:00
<div class="pageHeader">
<div class="segment">
<h3 class="ui dividing header">
<div class="content">
2017-04-17 10:04:30 +00:00
{{{.Title}}}
2017-04-07 09:26:46 +00:00
</div>
</h3>
</div>
</div>
2017-04-07 01:13:36 +00:00
<form class="ui form fluid vertical segment">
2017-04-17 10:04:30 +00:00
<input type="hidden" name="id" value="{{{.Task.Id}}}">
2017-04-07 01:13:36 +00:00
<div class="two fields">
<div class="field">
2017-04-23 06:11:53 +00:00
<div class="content">任务名称</div>
<div class="ui small input">
2017-04-21 05:36:45 +00:00
<input type="text" name="name" value="{{{.Task.Task.Name}}}">
2017-04-07 01:13:36 +00:00
</div>
</div>
</div>
<div class="two fields">
<div class="field">
<label>crontab表达式</label>
<div class="ui small left icon input">
<textarea rows="5" name="spec">{{{.Task.Spec}}}</textarea>
</div>
2017-04-07 01:13:36 +00:00
</div>
</div>
2017-04-23 06:11:53 +00:00
<div class="four fields">
2017-04-07 01:13:36 +00:00
<div class="field">
<label>协议</label>
<select name="protocol" id="protocol">
<option value="3" {{{if .Task}}} {{{if eq .Task.Protocol 3}}}selected{{{end}}} {{{end}}}>本地命令</option>
<option value="2" {{{if .Task}}} {{{if eq .Task.Protocol 2}}}selected{{{end}}} {{{end}}} data-match="host_id" data-validate-type="selectProtocol">SSH</option>
<option value="1" {{{if .Task}}} {{{if eq .Task.Protocol 1}}}selected{{{end}}} {{{end}}}>HTTP</option>
</select>
2017-04-07 01:13:36 +00:00
</div>
2017-04-23 06:11:53 +00:00
<div class="field">
<label>主机</label>
<select name="host_id" id="hostId">
<option value="">选择主机</option>
{{{range $i, $v := .Hosts}}}
<option value="{{{.Id}}}" {{{if $.Task}}}{{{if eq $.Task.HostId .Id }}} selected {{{end}}} {{{end}}}>{{{.Alias}}}-{{{.Name}}}</option>
</div>
{{{end}}}
</select>
2017-04-07 01:13:36 +00:00
</div>
2017-04-23 06:11:53 +00:00
</div>
2017-04-21 05:36:45 +00:00
<div class="two fields">
<div class="field">
<label>命令(shell命令|URL地址, 多条shell命令";"分隔)</label>
<textarea rows="5" name="command">{{{.Task.Command}}}</textarea>
</div>
2017-04-07 01:13:36 +00:00
</div>
2017-04-23 11:17:29 +00:00
<div class="three fields">
2017-04-07 01:13:36 +00:00
<div class="field">
<label>任务超时时间 (单位秒, 默认0不限制超时)</label>
2017-04-21 05:36:45 +00:00
<input type="text" name="timeout" value="{{{.Task.Timeout}}}">
2017-04-07 01:13:36 +00:00
</div>
<div class="field">
<label>任务重试次数 (默认0, 取值范围1-10)</label>
2017-04-21 09:41:59 +00:00
<input type="text" name="timeout" value="{{{.Task.Timeout}}}">
</div>
2017-04-13 09:35:59 +00:00
</div>
2017-04-21 09:41:59 +00:00
<div class="three fields">
2017-04-07 01:13:36 +00:00
<div class="field">
2017-04-13 09:35:59 +00:00
<label>任务状态 (任务添加成功后,是否立即调度)</label>
<select name="status">
<option value="2"{{{if .Task}}} {{{if eq .Task.Status 2}}}selected{{{end}}} {{{end}}}>暂停</option>
<option value="1" {{{if .Task}}} {{{if eq .Task.Status 1}}}selected{{{end}}} {{{end}}}>激活</option>
</select>
2017-04-07 01:13:36 +00:00
</div>
</div>
2017-04-21 05:36:45 +00:00
<div class="two fields">
2017-04-07 01:13:36 +00:00
<div class="field">
<label>备注</label>
2017-04-21 05:36:45 +00:00
<textarea rows="5" name="remark">{{{.Task.Remark}}}</textarea>
2017-04-07 01:13:36 +00:00
</div>
</div>
2017-04-17 10:04:30 +00:00
<div class="ui primary submit button">保存</div>
2017-04-07 01:13:36 +00:00
</form>
</div>
</div>
<script type="text/javascript">
2017-04-07 09:26:46 +00:00
$('.ui.checkbox')
.checkbox()
;
var $uiForm = $('.ui.form');
registerSelectFormValidation("selectProtocol", $uiForm, $('#protocol'), 'protocol');
$($uiForm).form(
2017-04-07 09:26:46 +00:00
{
onSuccess: function(event, fields) {
util.post('/task/store', fields, function(code, message) {
location.href = "/task"
2017-04-07 09:26:46 +00:00
});
2017-04-07 01:13:36 +00:00
2017-04-07 09:26:46 +00:00
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 : 'host_id',
2017-04-07 09:26:46 +00:00
rules: [
{
type : 'selectProtocol',
2017-04-07 09:26:46 +00:00
prompt : '请选择主机'
}
]
}
},
inline : true
});
2017-04-07 01:13:36 +00:00
</script>
{{{ template "common/footer" . }}}