2018-01-28 07:48:37 +00:00
|
|
|
|
{% template "common/header" . %}
|
2017-04-07 01:13:36 +00:00
|
|
|
|
<div class="ui grid">
|
2018-01-28 07:48:37 +00:00
|
|
|
|
{%template "task/menu" .%}
|
2017-04-07 01:13:36 +00:00
|
|
|
|
<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">
|
2018-01-28 07:48:37 +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">
|
2018-01-28 07:48:37 +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-24 05:57:39 +00:00
|
|
|
|
<label>
|
|
|
|
|
<div class="content">任务名称</div>
|
|
|
|
|
</label>
|
2017-04-23 06:11:53 +00:00
|
|
|
|
<div class="ui small input">
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<input type="text" name="name" placeholder="任务名称" value="{%.Task.Name%}">
|
2017-04-07 01:13:36 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2017-09-07 13:32:53 +00:00
|
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
|
<label>
|
|
|
|
|
<div class="content">标签名称</div>
|
|
|
|
|
</label>
|
|
|
|
|
<div class="ui small input">
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<input type="text" name="tag" placeholder="标签用于任务分类" value="{%.Task.Tag%}">
|
2017-09-07 13:32:53 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2017-04-07 01:13:36 +00:00
|
|
|
|
</div>
|
|
|
|
|
<div class="two fields">
|
|
|
|
|
<div class="field">
|
2017-04-24 05:57:39 +00:00
|
|
|
|
<label>
|
2017-06-08 10:04:55 +00:00
|
|
|
|
<div class="content">任务类型</div>
|
|
|
|
|
<div class="ui message">
|
|
|
|
|
主任务可以配置多个子任务, 当主任务执行完成后,自动执行子任务<br>
|
|
|
|
|
任务类型新增后不能变更
|
2017-04-24 05:57:39 +00:00
|
|
|
|
</div>
|
|
|
|
|
</label>
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<select name="level" id="level" {%if .Task%}disabled="disabled"{%end%}>
|
|
|
|
|
<option value="1" {%if .Task%} {%if eq .Task.Level 1%}selected{%end%} {%end%}>主任务</option>
|
|
|
|
|
<option value="2" {%if .Task%} {%if eq .Task.Level 2%}selected{%end%} {%end%}>子任务</option>
|
2017-06-08 10:04:55 +00:00
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="parent-task">
|
|
|
|
|
<div class="two fields">
|
|
|
|
|
<div class="field">
|
|
|
|
|
<label>
|
|
|
|
|
<div class="content">依赖关系</div>
|
|
|
|
|
<div class="ui message">
|
|
|
|
|
强依赖: 主任务执行成功,才会运行子任务 <br>
|
|
|
|
|
弱依赖: 无论主任务执行是否成功,都会运行子任务
|
|
|
|
|
</div>
|
|
|
|
|
</label>
|
|
|
|
|
<select name="dependency_status" id="dependency_status">
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<option value="1" {%if .Task%} {%if eq .Task.DependencyStatus 1%}selected{%end%} {%end%}>强依赖</option>
|
|
|
|
|
<option value="2" {%if .Task%} {%if eq .Task.DependencyStatus 2%}selected{%end%} {%end%}>弱依赖</option>
|
2017-06-08 10:04:55 +00:00
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="field">
|
|
|
|
|
<label>
|
|
|
|
|
<div class="content">子任务ID</div>
|
|
|
|
|
<div class="ui message">
|
|
|
|
|
多个任务ID逗号分隔 <br>
|
|
|
|
|
子任务并发执行
|
|
|
|
|
</div>
|
|
|
|
|
</label>
|
|
|
|
|
<div class="ui small input">
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<input type="text" name="dependency_task_id" placeholder="可选" value="{%.Task.DependencyTaskId%}">
|
2017-06-08 10:04:55 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="two fields">
|
|
|
|
|
<div class="field">
|
|
|
|
|
<label>
|
|
|
|
|
<div class="content">
|
|
|
|
|
crontab表达式
|
|
|
|
|
</div>
|
|
|
|
|
</label>
|
|
|
|
|
<div class="ui small input">
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<input type="text" name="spec" value="{%.Task.Spec%}" placeholder="秒 分 时 天 月 周"/>
|
2017-06-08 10:04:55 +00:00
|
|
|
|
</div>
|
2017-04-22 15:39:33 +00:00
|
|
|
|
</div>
|
2017-04-07 01:13:36 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2017-04-24 05:57:39 +00:00
|
|
|
|
<div class="three fields">
|
2017-04-07 01:13:36 +00:00
|
|
|
|
<div class="field">
|
2017-05-04 02:47:14 +00:00
|
|
|
|
<label>执行方式</label>
|
2017-04-22 15:39:33 +00:00
|
|
|
|
<select name="protocol" id="protocol">
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<option value="2" {%if .Task%} {%if eq .Task.Protocol 2%}selected{%end%} {%end%}
|
2017-08-06 14:49:24 +00:00
|
|
|
|
data-validate-type="selectProtocol">SHELL</option>
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<option value="1" {%if .Task%} {%if eq .Task.Protocol 1%}selected{%end%} {%end%}>HTTP</option>
|
2017-04-22 15:39:33 +00:00
|
|
|
|
</select>
|
2017-04-07 01:13:36 +00:00
|
|
|
|
</div>
|
2017-04-24 05:57:39 +00:00
|
|
|
|
</div>
|
2017-08-06 14:49:24 +00:00
|
|
|
|
<div class="fields" id="hostField">
|
2017-04-23 06:11:53 +00:00
|
|
|
|
<div class="field">
|
2017-08-06 14:49:24 +00:00
|
|
|
|
<label>选择任务节点</label>
|
|
|
|
|
<div id="hostId">
|
2018-01-28 07:48:37 +00:00
|
|
|
|
{%range $i, $v := .Hosts%}
|
2017-08-06 14:49:24 +00:00
|
|
|
|
<label>
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<input type="checkbox" value="{%.Id%}" {%if $.Task%}{%if $v.Selected%} checked {%end%}{%end%} style="width:25px;height: 25px;">{%.Alias%}-{%.Name%}
|
|
|
|
|
{%if (HostFormat $i) %}<br>{%end%}
|
2017-08-06 14:49:24 +00:00
|
|
|
|
</label>
|
2018-01-28 07:48:37 +00:00
|
|
|
|
{%end%}
|
2017-08-06 14:49:24 +00:00
|
|
|
|
</div> <br> <a class="ui blue button" href="/host/create" target="_blank">添加节点</a>
|
2017-04-28 03:54:46 +00:00
|
|
|
|
|
|
|
|
|
</div>
|
2017-04-23 06:11:53 +00:00
|
|
|
|
</div>
|
2018-01-27 10:08:46 +00:00
|
|
|
|
<div class="two fields" id="http-method" style="display: none">
|
|
|
|
|
<div class="field">
|
|
|
|
|
<label>请求方法</label>
|
|
|
|
|
<select name="http_method">
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<option value="1" {%if .Task%} {%if eq .Task.HttpMethod 1%}selected{%end%} {%end%}>GET</option>
|
|
|
|
|
<option value="2" {%if .Task%} {%if eq .Task.HttpMethod 2%}selected{%end%} {%end%}
|
2018-01-27 10:08:46 +00:00
|
|
|
|
data-validate-type="selectProtocol">POST</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2017-04-21 05:36:45 +00:00
|
|
|
|
<div class="two fields">
|
|
|
|
|
<div class="field">
|
2017-04-24 05:57:39 +00:00
|
|
|
|
<label>命令</label>
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<textarea rows="5" name="command" placeholder="请输入系统命令" id="command">{%.Task.Command%}</textarea>
|
2017-04-21 05:36:45 +00:00
|
|
|
|
</div>
|
2017-04-07 01:13:36 +00:00
|
|
|
|
</div>
|
2017-12-09 03:01:48 +00:00
|
|
|
|
<div class="two fields">
|
2017-04-07 01:13:36 +00:00
|
|
|
|
<div class="field">
|
2017-06-08 10:04:55 +00:00
|
|
|
|
<label>任务超时时间(秒, 0-86400)</label>
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<input type="text" name="timeout" placeholder="默认0, 不限制" value="{%if .Task%} {%.Task.Timeout%} {%else%}0{%end%}">
|
2017-04-07 01:13:36 +00:00
|
|
|
|
</div>
|
2017-04-25 17:47:38 +00:00
|
|
|
|
<div class="field">
|
2017-04-26 08:17:18 +00:00
|
|
|
|
<label>允许多实例同时运行</label>
|
2017-04-25 17:47:38 +00:00
|
|
|
|
<select name="multi">
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<option value="2" {%if .Task%} {%if eq .Task.Multi 0%}selected{%end%} {%end%}>否</option>
|
|
|
|
|
<option value="1"{%if .Task%} {%if eq .Task.Multi 1%}selected{%end%} {%end%}>是</option>
|
2017-04-25 17:47:38 +00:00
|
|
|
|
</select>
|
|
|
|
|
</div>
|
2017-12-09 03:01:48 +00:00
|
|
|
|
</div>
|
2017-06-21 12:19:59 +00:00
|
|
|
|
|
2017-12-09 03:01:48 +00:00
|
|
|
|
<div class="two fields">
|
|
|
|
|
<div class="field">
|
|
|
|
|
<label>任务失败重试次数 (0-10)</label>
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<input type="text" name="retry_times" placeholder="默认0, 不重试" value="{%if .Task%} {%.Task.RetryTimes%} {%else%}0{%end%}">
|
2017-12-09 03:01:48 +00:00
|
|
|
|
</div>
|
|
|
|
|
<div class="field">
|
|
|
|
|
<label>任务失败重试间隔时间 (秒, 0-3600)</label>
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<input type="text" name="retry_interval" placeholder="默认0, 执行默认重试策略" value="{%if .Task%} {%.Task.RetryInterval%} {%else%}0{%end%}">
|
2017-12-09 03:01:48 +00:00
|
|
|
|
</div>
|
2017-04-25 17:47:38 +00:00
|
|
|
|
</div>
|
2017-12-09 03:01:48 +00:00
|
|
|
|
|
2017-04-30 17:12:07 +00:00
|
|
|
|
<div class="three fields">
|
|
|
|
|
<div class="field">
|
|
|
|
|
<label>任务通知</label>
|
|
|
|
|
<select name="notify_status" id="task-status">
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<option value="1"{%if .Task%} {%if eq .Task.NotifyStatus 0%}selected{%end%} {%end%}>不通知</option>
|
|
|
|
|
<option value="2" {%if .Task%} {%if eq .Task.NotifyStatus 1%}selected{%end%} {%end%}>失败通知</option>
|
|
|
|
|
<option value="3" {%if .Task%} {%if eq .Task.NotifyStatus 2%}selected{%end%} {%end%}>执行结束通知</option>
|
2017-04-30 17:12:07 +00:00
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="two fields" style="display: none" id="task-notify-type">
|
|
|
|
|
<div class="field" >
|
|
|
|
|
<label>通知类型</label>
|
|
|
|
|
<select name="notify_type">
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<option value="1"{%if .Task%} {%if eq .Task.NotifyType 0%}selected{%end%} {%end%}>请选择</option>
|
|
|
|
|
<option value="2" {%if .Task%} {%if eq .Task.NotifyType 1%}selected{%end%} {%end%}>邮件</option>
|
|
|
|
|
<option value="3" {%if .Task%} {%if eq .Task.NotifyType 2%}selected{%end%} {%end%}>Slack</option>
|
2017-04-30 17:12:07 +00:00
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="inline fields" style="display: none" id="receiver-id"></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>
|
2018-01-28 07:48:37 +00:00
|
|
|
|
<textarea rows="5" name="remark" placeholder="任务备注信息">{%.Task.Remark%}</textarea>
|
2017-04-07 01:13:36 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2017-05-12 02:13:42 +00:00
|
|
|
|
<div class="ui primary submit button">保存</div> <a class="ui button" onclick="location.href='/task';">取消</a>
|
2017-04-07 01:13:36 +00:00
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2017-04-30 17:12:07 +00:00
|
|
|
|
<script type="x-handlerbar-template" id="mail-template">
|
|
|
|
|
{{#each MailUsers}}
|
|
|
|
|
<div class="field">
|
|
|
|
|
<div class="ui checkbox">
|
|
|
|
|
<input type="checkbox" name="receiver[]" {{#if checked}}checked{{/if}} value="{{Id}}" />
|
|
|
|
|
<label>{{Username}}-{{Email}}</label>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{{else}}
|
2017-05-04 06:02:50 +00:00
|
|
|
|
<a class="ui blue button" href="/manage/mail/edit" target="_blank">邮箱配置</a><br><br>
|
2017-04-30 17:12:07 +00:00
|
|
|
|
{{/each}}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<script type="x-handlervar-template" id="slack-template">
|
|
|
|
|
{{#each Channels}}
|
|
|
|
|
<div class="field">
|
|
|
|
|
<div class="ui checkbox">
|
|
|
|
|
<input type="checkbox" name="receiver[]" {{#if checked}}checked{{/if}} value="{{Id}}" />
|
|
|
|
|
<label>{{Name}}</label>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{{else}}
|
2017-05-04 06:02:50 +00:00
|
|
|
|
<a class="ui blue button" href="/manage/slack/edit" target="_blank">Slack配置</a>
|
2017-04-30 17:12:07 +00:00
|
|
|
|
{{/each}}
|
|
|
|
|
</script>
|
2017-04-07 01:13:36 +00:00
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
2017-04-26 08:17:18 +00:00
|
|
|
|
$(function() {
|
2017-05-12 01:59:22 +00:00
|
|
|
|
changeCommandPlaceholder();
|
2017-06-08 10:04:55 +00:00
|
|
|
|
changeLevel();
|
2017-04-26 08:17:18 +00:00
|
|
|
|
changeProtocol();
|
2017-04-30 17:12:07 +00:00
|
|
|
|
showNotify();
|
2017-04-26 08:17:18 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#protocol').change(function() {
|
2017-05-12 01:59:22 +00:00
|
|
|
|
changeCommandPlaceholder();
|
|
|
|
|
changeProtocol();
|
2017-04-26 08:17:18 +00:00
|
|
|
|
});
|
|
|
|
|
|
2017-06-08 10:04:55 +00:00
|
|
|
|
$('#level').change(function() {
|
|
|
|
|
changeLevel();
|
|
|
|
|
});
|
2017-05-12 01:59:22 +00:00
|
|
|
|
|
2017-04-30 17:12:07 +00:00
|
|
|
|
$('#task-status').change(function() {
|
|
|
|
|
var selected = $(this).val();
|
|
|
|
|
if (selected == 1) {
|
|
|
|
|
$('#task-notify-type').hide();
|
|
|
|
|
$('#receiver-id').hide();
|
|
|
|
|
$('#task-notify-type').find('select').val('1');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$('#task-notify-type').show();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#task-notify-type').change(function() {
|
|
|
|
|
changeNotify();
|
|
|
|
|
});
|
|
|
|
|
|
2017-05-12 01:59:22 +00:00
|
|
|
|
function changeCommandPlaceholder() {
|
|
|
|
|
var selectedId = $('#protocol').val();
|
|
|
|
|
switch (selectedId) {
|
|
|
|
|
case '1':
|
|
|
|
|
$('#command').attr('placeholder', '请输入URL地址');
|
|
|
|
|
break;
|
|
|
|
|
case '2':
|
|
|
|
|
$('#command').attr('placeholder', '请输入shell命令');
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-30 17:12:07 +00:00
|
|
|
|
function showNotify() {
|
2018-01-28 07:48:37 +00:00
|
|
|
|
var notifyStatus = {%.Task.NotifyStatus%};
|
2017-04-30 17:12:07 +00:00
|
|
|
|
if (notifyStatus > 0) {
|
|
|
|
|
$('#task-notify-type').show();
|
|
|
|
|
}
|
2018-01-28 07:48:37 +00:00
|
|
|
|
var notifyReceiverIds = '{%.Task.NotifyReceiverId%}'.split(',');
|
2017-04-30 17:12:07 +00:00
|
|
|
|
changeNotify(notifyReceiverIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function changeNotify(notifyReceiverIds) {
|
|
|
|
|
var selectedId = $('#task-notify-type').find('select').val();
|
|
|
|
|
if (selectedId == 1) {
|
|
|
|
|
$('#receiver-id').hide();
|
|
|
|
|
$('#receiver-id').html('');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (selectedId == 2) {
|
|
|
|
|
showMail(notifyReceiverIds);
|
|
|
|
|
} else if (selectedId == 3) {
|
|
|
|
|
showSlack(notifyReceiverIds);
|
|
|
|
|
}
|
|
|
|
|
$('#receiver-id').show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showMail(notifyReceiverIds) {
|
2017-04-30 23:12:39 +00:00
|
|
|
|
util.get("/manage/mail", function(code, message, data) {
|
2017-04-30 17:12:07 +00:00
|
|
|
|
renderReceiver(notifyReceiverIds, $('#mail-template'), data, 'MailUsers');
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showSlack(notifyReceiverIds) {
|
2017-04-30 23:12:39 +00:00
|
|
|
|
util.get("/manage/slack", function(code, message, data) {
|
2017-04-30 17:12:07 +00:00
|
|
|
|
renderReceiver(notifyReceiverIds, $('#slack-template'), data, 'Channels');
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderReceiver(notifyReceiverIds, $element, data, key) {
|
|
|
|
|
if (notifyReceiverIds !== undefined && notifyReceiverIds) {
|
|
|
|
|
console.log(data[key]);
|
|
|
|
|
for (i in data[key]) {
|
|
|
|
|
if ($.inArray(data[key][i].Id + '', notifyReceiverIds) != -1) {
|
|
|
|
|
data[key][i].checked = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var html = util.renderTemplate($($element), data);
|
|
|
|
|
$('#receiver-id').html(html);
|
|
|
|
|
$('.ui.checkbox').checkbox();
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-26 08:17:18 +00:00
|
|
|
|
function changeProtocol() {
|
|
|
|
|
var protocol = $('#protocol').val();
|
|
|
|
|
if (protocol == 2) {
|
|
|
|
|
$('#hostField').show();
|
2018-01-27 10:08:46 +00:00
|
|
|
|
$('#http-method').hide();
|
2017-04-26 08:17:18 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#hostField').hide();
|
2018-01-27 10:08:46 +00:00
|
|
|
|
$('#http-method').show();
|
2017-04-26 08:17:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-07 09:26:46 +00:00
|
|
|
|
$('.ui.checkbox')
|
|
|
|
|
.checkbox()
|
|
|
|
|
;
|
2017-04-30 17:12:07 +00:00
|
|
|
|
|
|
|
|
|
function validateNotify() {
|
|
|
|
|
var selectedId = $('#task-status').val();
|
|
|
|
|
if (selectedId == 1) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var checkedLength = $('#receiver-id input:checked').length;
|
|
|
|
|
if (checkedLength == 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseNotifyReceiver() {
|
|
|
|
|
var receivers = [];
|
|
|
|
|
$('#receiver-id input:checked').each(function() {
|
|
|
|
|
receivers.push($(this).val());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return receivers.join(",");
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-06 14:49:24 +00:00
|
|
|
|
function parseHostId() {
|
|
|
|
|
var hostIds = [];
|
|
|
|
|
$('#hostId input:checked').each(function () {
|
|
|
|
|
hostIds.push($(this).val());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return hostIds.join(",");
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-08 10:04:55 +00:00
|
|
|
|
function changeLevel() {
|
|
|
|
|
var selected = $('#level').val();
|
|
|
|
|
if (selected == 1) {
|
|
|
|
|
// 主任务
|
|
|
|
|
$('#parent-task').show();
|
|
|
|
|
$('#child-task').hide();
|
|
|
|
|
} else {
|
|
|
|
|
// 子任务
|
|
|
|
|
$('#parent-task').hide();
|
|
|
|
|
$('#child-task').show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-22 15:39:33 +00:00
|
|
|
|
var $uiForm = $('.ui.form');
|
|
|
|
|
registerSelectFormValidation("selectProtocol", $uiForm, $('#protocol'), 'protocol');
|
|
|
|
|
$($uiForm).form(
|
2017-04-07 09:26:46 +00:00
|
|
|
|
{
|
|
|
|
|
onSuccess: function(event, fields) {
|
2017-04-30 17:12:07 +00:00
|
|
|
|
if (!validateNotify()) {
|
|
|
|
|
swal('错误提示', '请至少选择一个接收者', 'error');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
fields.notify_receiver_id = parseNotifyReceiver();
|
2017-08-06 14:49:24 +00:00
|
|
|
|
fields.host_id = parseHostId();
|
|
|
|
|
if (fields.protocol == 2 && fields.host_id == "") {
|
|
|
|
|
swal('错误提示', '请选择任务节点');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-07 09:26:46 +00:00
|
|
|
|
util.post('/task/store', fields, function(code, message) {
|
2017-04-08 09:15:30 +00:00
|
|
|
|
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 : '请输入任务名称'
|
2017-05-05 08:31:24 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type : 'maxLength[32]',
|
|
|
|
|
prompt : '长度不能超过32'
|
2017-04-07 09:26:46 +00:00
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
command: {
|
|
|
|
|
identifier : 'command',
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
type : 'empty',
|
|
|
|
|
prompt : '请输入任务命令'
|
2017-05-05 08:31:24 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type : 'maxLength[256]',
|
|
|
|
|
prompt : '长度不能超过256'
|
2017-04-07 09:26:46 +00:00
|
|
|
|
}
|
|
|
|
|
]
|
2017-04-22 15:39:33 +00:00
|
|
|
|
},
|
|
|
|
|
hosts: {
|
|
|
|
|
identifier : 'host_id',
|
2017-04-07 09:26:46 +00:00
|
|
|
|
rules: [
|
|
|
|
|
{
|
2017-04-22 15:39:33 +00:00
|
|
|
|
type : 'selectProtocol',
|
2017-04-07 09:26:46 +00:00
|
|
|
|
prompt : '请选择主机'
|
|
|
|
|
}
|
|
|
|
|
]
|
2017-05-05 08:31:24 +00:00
|
|
|
|
},
|
2017-05-26 13:59:01 +00:00
|
|
|
|
timeout: {
|
|
|
|
|
identifier : 'timeout',
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
type : 'integer[0..86400]',
|
|
|
|
|
prompt : '超时范围0-86400'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
retryTimes: {
|
|
|
|
|
identifier : 'retry_times',
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
type : 'integer[0..10]',
|
|
|
|
|
prompt : '重试次数0-10'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
2017-12-09 03:01:48 +00:00
|
|
|
|
retryInterval: {
|
|
|
|
|
identifier : 'retry_interval',
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
type : 'integer[0..3600]',
|
|
|
|
|
prompt : '重试间隔时间0-3600'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
2017-05-05 08:31:24 +00:00
|
|
|
|
remark: {
|
|
|
|
|
identifier : 'remark',
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
type : 'maxLength[100]',
|
|
|
|
|
prompt : '长度不能超过100'
|
|
|
|
|
}
|
|
|
|
|
]
|
2017-04-07 09:26:46 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
inline : true
|
|
|
|
|
});
|
2017-04-07 01:13:36 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
2018-01-28 07:48:37 +00:00
|
|
|
|
{% template "common/footer" . %}
|