设计 "注册模式" 交互

v1.5
xueli.xue 8 years ago
parent 8e84a428b9
commit 662e129afc

@ -41,20 +41,22 @@ public class JobInfoController {
@RequestMapping("/add")
@ResponseBody
public ReturnT<String> add(String jobGroup, String jobCron, String jobDesc, String author, String alarmEmail,
String executorAddress, String executorHandler, String executorParam, int glueSwitch, String glueSource, String glueRemark,
String childJobKey) {
String executorAppname, String executorAddress, String executorHandler, String executorParam,
int glueSwitch, String glueSource, String glueRemark, String childJobKey) {
return xxlJobService.add(jobGroup, jobCron, jobDesc, author, alarmEmail,
executorAddress, executorHandler, executorParam, glueSwitch, glueSource, glueRemark, childJobKey);
executorAppname, executorAddress, executorHandler, executorParam,
glueSwitch, glueSource, glueRemark, childJobKey);
}
@RequestMapping("/reschedule")
@ResponseBody
public ReturnT<String> reschedule(String jobGroup, String jobName, String jobCron, String jobDesc, String author, String alarmEmail,
String executorAddress, String executorHandler, String executorParam, int glueSwitch, String childJobKey) {
String executorAppname, String executorAddress, String executorHandler, String executorParam,
int glueSwitch, String childJobKey) {
return xxlJobService.reschedule(jobGroup, jobName, jobCron, jobDesc, author, alarmEmail,
executorAddress, executorHandler, executorParam, glueSwitch, childJobKey);
executorAppname, executorAddress, executorHandler, executorParam, glueSwitch, childJobKey);
}
@RequestMapping("/remove")

@ -21,6 +21,7 @@ public class XxlJobInfo {
private String author; // 负责人
private String alarmEmail; // 报警邮件
private String executorAppname; // 执行器对应的AppName
private String executorAddress; // 执行器地址,有多个则逗号分隔
private String executorHandler; // 执行器任务Handler名称
private String executorParam; // 执行器,任务参数
@ -106,6 +107,14 @@ public class XxlJobInfo {
this.alarmEmail = alarmEmail;
}
public String getExecutorAppname() {
return executorAppname;
}
public void setExecutorAppname(String executorAppname) {
this.executorAppname = executorAppname;
}
public String getExecutorAddress() {
return executorAddress;
}

@ -1,9 +1,9 @@
package com.xxl.job.admin.service;
import java.util.Map;
import com.xxl.job.admin.core.model.ReturnT;
import java.util.Map;
/**
* core job action for xxl-job
*
@ -14,11 +14,11 @@ public interface IXxlJobService {
public Map<String, Object> pageList(int start, int length, String jobGroup, String executorHandler, String filterTime);
public ReturnT<String> add(String jobGroup, String jobCron, String jobDesc,String author, String alarmEmail,
String executorAddress, String executorHandler, String executorParam, int glueSwitch, String glueSource, String glueRemark,
String childJobKey);
String executorAppname, String executorAddress, String executorHandler, String executorParam,
int glueSwitch, String glueSource, String glueRemark, String childJobKey);
public ReturnT<String> reschedule(String jobGroup, String jobName, String jobCron, String jobDesc, String author, String alarmEmail,
String executorAddress, String executorHandler, String executorParam, int glueSwitch, String childJobKey);
String executorAppname, String executorAddress, String executorHandler, String executorParam, int glueSwitch, String childJobKey);
public ReturnT<String> remove(String jobGroup, String jobName);

@ -62,8 +62,8 @@ public class XxlJobServiceImpl implements IXxlJobService {
@Override
public ReturnT<String> add(String jobGroup, String jobCron, String jobDesc,String author, String alarmEmail,
String executorAddress, String executorHandler, String executorParam, int glueSwitch, String glueSource, String glueRemark,
String childJobKey) {
String executorAppname, String executorAddress, String executorHandler, String executorParam,
int glueSwitch, String glueSource, String glueRemark, String childJobKey) {
// valid
if (JobGroupEnum.match(jobGroup) == null) {
return new ReturnT<String>(500, "请选择“任务组”");
@ -80,8 +80,11 @@ public class XxlJobServiceImpl implements IXxlJobService {
if (StringUtils.isBlank(alarmEmail)) {
return new ReturnT<String>(500, "请输入“报警邮件”");
}
if (StringUtils.isBlank(executorAddress)) {
return new ReturnT<String>(500, "请输入“执行器地址”");
if (StringUtils.isBlank(executorAppname) && StringUtils.isBlank(executorAddress)) {
return new ReturnT<String>(500, "“执行器AppName”和“执行器地址”不可同时为空");
}
if (StringUtils.isNotBlank(executorAppname) && StringUtils.isNotBlank(executorAddress)) {
return new ReturnT<String>(500, "“执行器AppName”和“执行器地址” 不可同时使用");
}
if (glueSwitch==0 && StringUtils.isBlank(executorHandler)) {
return new ReturnT<String>(500, "请输入“JobHandler”");
@ -121,6 +124,7 @@ public class XxlJobServiceImpl implements IXxlJobService {
jobInfo.setJobDesc(jobDesc);
jobInfo.setAuthor(author);
jobInfo.setAlarmEmail(alarmEmail);
jobInfo.setExecutorAppname(executorAppname);
jobInfo.setExecutorAddress(executorAddress);
jobInfo.setExecutorHandler(executorHandler);
jobInfo.setExecutorParam(executorParam);
@ -146,7 +150,7 @@ public class XxlJobServiceImpl implements IXxlJobService {
@Override
public ReturnT<String> reschedule(String jobGroup, String jobName, String jobCron, String jobDesc, String author, String alarmEmail,
String executorAddress, String executorHandler, String executorParam, int glueSwitch, String childJobKey) {
String executorAppname, String executorAddress, String executorHandler, String executorParam, int glueSwitch, String childJobKey) {
// valid
if (JobGroupEnum.match(jobGroup) == null) {
@ -167,8 +171,11 @@ public class XxlJobServiceImpl implements IXxlJobService {
if (StringUtils.isBlank(alarmEmail)) {
return new ReturnT<String>(500, "请输入“报警邮件”");
}
if (StringUtils.isBlank(executorAddress)) {
return new ReturnT<String>(500, "请输入“执行器地址”");
if (StringUtils.isBlank(executorAppname) && StringUtils.isBlank(executorAddress)) {
return new ReturnT<String>(500, "“执行器AppName”和“执行器地址”不可同时为空");
}
if (StringUtils.isNotBlank(executorAppname) && StringUtils.isNotBlank(executorAddress)) {
return new ReturnT<String>(500, "“执行器AppName”和“执行器地址” 不可同时使用");
}
if (glueSwitch==0 && StringUtils.isBlank(executorHandler)) {
return new ReturnT<String>(500, "请输入“JobHandler”");
@ -195,6 +202,7 @@ public class XxlJobServiceImpl implements IXxlJobService {
jobInfo.setJobDesc(jobDesc);
jobInfo.setAuthor(author);
jobInfo.setAlarmEmail(alarmEmail);
jobInfo.setExecutorAppname(executorAppname);
jobInfo.setExecutorAddress(executorAddress);
jobInfo.setExecutorHandler(executorHandler);
jobInfo.setExecutorParam(executorParam);

@ -17,6 +17,7 @@
<result column="author" property="author" />
<result column="alarm_email" property="alarmEmail" />
<result column="executor_appname" property="executorAppname" />
<result column="executor_address" property="executorAddress" />
<result column="executor_handler" property="executorHandler" />
<result column="executor_param" property="executorParam" />
@ -38,6 +39,7 @@
t.update_time,
t.author,
t.alarm_email,
t.executor_appname,
t.executor_address,
t.executor_handler,
t.executor_param,
@ -85,6 +87,7 @@
update_time,
author,
alarm_email,
executor_appname,
executor_address,
executor_handler,
executor_param,
@ -101,6 +104,7 @@
NOW(),
#{author},
#{alarmEmail},
#{executorAppname},
#{executorAddress},
#{executorHandler},
#{executorParam},
@ -129,6 +133,7 @@
update_time = NOW(),
author = #{author},
alarm_email = #{alarmEmail},
executor_appname = #{executorAppname},
executor_address = #{executorAddress},
executor_handler = #{executorHandler},
executor_param = #{executorParam},

@ -78,6 +78,7 @@
<th name="childJobKey" >任务Key</th>
<th name="jobDesc" >描述</th>
<th name="jobCron" >Cron</th>
<th name="executorAppname" >执行器Appname</th>
<th name="executorAddress" >执行器地址</th>
<th name="executorHandler" >JobJandler</th>
<th name="executorParam" >任务参数</th>
@ -126,8 +127,14 @@
<div class="col-sm-4"><input type="text" class="form-control" name="jobDesc" placeholder="请输入“描述”" maxlength="50" ></div>
</div>
<div class="form-group">
<div class="executorAddress">
<label for="lastname" class="col-sm-2 control-label">执行器地址<font color="red">*</font></label>
<div class="col-sm-4"><input type="text" class="form-control" name="executorAddress" placeholder="请输入“执行器地址”,多个地址逗号分隔" maxlength="50" ></div>
</div>
<div class="executorAppname" style="display:none;">
<label for="lastname" class="col-sm-2 control-label">AppName<font color="red">*</font></label>
<div class="col-sm-4"><input type="text" class="form-control" name="executorAppname" placeholder="请输入执行器对应Appname, 自动发现注册的人任务" maxlength="100" ></div>
</div>
<label for="lastname" class="col-sm-2 control-label">Cron<font color="red">*</font></label>
<div class="col-sm-4"><input type="text" class="form-control" name="jobCron" placeholder="请输入“Cron”" maxlength="20" ></div>
</div>
@ -159,6 +166,9 @@
<button type="submit" class="btn btn-primary" >保存</button>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
</div>
<div class="col-sm-offset-0 col-sm-3">
启动注册&nbsp;<input type="checkbox" class="ifAppName" >
</div>
</div>
<input type="hidden" name="glueRemark" value="GLUE代码初始化" >
@ -205,8 +215,14 @@ public class DemoGlueJobHandler extends IJobHandler {
<div class="col-sm-4"><input type="text" class="form-control" name="jobDesc" placeholder="请输入“描述”" maxlength="50" ></div>
</div>
<div class="form-group">
<div class="executorAddress">
<label for="lastname" class="col-sm-2 control-label">执行器地址<font color="red">*</font></label>
<div class="col-sm-4"><input type="text" class="form-control" name="executorAddress" placeholder="请输入“执行器地址”,多个地址逗号分隔" maxlength="50" ></div>
</div>
<div class="executorAppname" style="display:none;">
<label for="lastname" class="col-sm-2 control-label">AppName<font color="red">*</font></label>
<div class="col-sm-4"><input type="text" class="form-control" name="executorAppname" placeholder="请输入执行器对应Appname, 自动发现注册的人任务" maxlength="100" ></div>
</div>
<label for="lastname" class="col-sm-2 control-label">Cron<font color="red">*</font></label>
<div class="col-sm-4"><input type="text" class="form-control" name="jobCron" placeholder="请输入“Cron”" maxlength="20" ></div>
</div>
@ -240,6 +256,9 @@ public class DemoGlueJobHandler extends IJobHandler {
<input type="hidden" name="jobGroup" >
<input type="hidden" name="jobName" >
</div>
<div class="col-sm-offset-0 col-sm-3">
启动注册&nbsp;<input type="checkbox" class="ifAppName" >
</div>
</div>
</form>
</div>

@ -45,6 +45,7 @@ $(function() {
},
{ "data": 'jobDesc', "visible" : true},
{ "data": 'jobCron', "visible" : true},
{ "data": 'executorAppname', "visible" : false},
{ "data": 'executorAddress', "visible" : false},
{
"data": 'executorHandler',
@ -113,6 +114,7 @@ $(function() {
' jobDesc="'+ row.jobDesc +'" '+
' author="'+ row.author +'" '+
' alarmEmail="'+ row.alarmEmail +'" '+
' executorAppname="'+row.executorAppname +'" '+
' executorAddress="'+row.executorAddress +'" '+
' executorHandler="'+row.executorHandler +'" '+
' executorParam="'+ row.executorParam +'" '+
@ -312,6 +314,26 @@ $(function() {
$("#addModal .form input[name='executorHandler']").removeAttr("readonly");
});
// 注册模式
$(".ifAppName").click(function(){
var ifAppName = $(this).is(':checked');
var $executorAddress = $(this).parents("form").find("input[name='executorAddress']");
var $executorAppname = $(this).parents("form").find("input[name='executorAppname']");
$($executorAddress).val("");
$($executorAppname).val("");
var $executorAddressDiv = $(this).parents("form").find(".executorAddress");
var $executorAppnameDiv = $(this).parents("form").find(".executorAppname");
if (ifAppName) {
$($executorAddressDiv).hide();
$($executorAppnameDiv).show();
} else {
$($executorAddressDiv).show();
$($executorAppnameDiv).hide();
}
});
// GLUE模式开启
$(".ifGLUE").click(function(){
var ifGLUE = $(this).is(':checked');
@ -337,6 +359,7 @@ $(function() {
$("#updateModal .form input[name='jobCron']").val($(this).parent('p').attr("jobCron"));
$("#updateModal .form input[name='author']").val($(this).parent('p').attr("author"));
$("#updateModal .form input[name='alarmEmail']").val($(this).parent('p').attr("alarmEmail"));
$("#updateModal .form input[name='executorAppname']").val($(this).parent('p').attr("executorAppname"));
$("#updateModal .form input[name='executorAddress']").val($(this).parent('p').attr("executorAddress"));
$("#updateModal .form input[name='executorHandler']").val($(this).parent('p').attr("executorHandler"));
$("#updateModal .form input[name='executorParam']").val($(this).parent('p').attr("executorParam"));
@ -346,6 +369,18 @@ $(function() {
var jobGroupTitle = $("#addModal .form select[name='jobGroup']").find("option[value='" + $(this).parent('p').attr("jobGroup") + "']").text();
$("#updateModal .form .jobGroupTitle").val(jobGroupTitle);
// appname / address, switch
var $executorAppname = $(this).parent('p').attr("executorAppname");
if ($executorAppname) {
$("#updateModal .form .ifAppName").attr("checked", true);
$("#updateModal .form .executorAppname").show();
$("#updateModal .form .executorAddress").hide();
} else {
$("#updateModal .form .ifAppName").attr("checked", false);
$("#updateModal .form .executorAppname").hide();
$("#updateModal .form .executorAddress").show();
}
// glueSwitch
var glueSwitch = $(this).parent('p').attr("glueSwitch");
$("#updateModal .form input[name='glueSwitch']").val(glueSwitch);
@ -377,7 +412,7 @@ $(function() {
required : true
},
executorAddress : {
required : true
required : false
},
executorHandler : {
required : false

Loading…
Cancel
Save