任务编辑界面交互调整

master
xueli.xue 8 years ago
parent f7ff804739
commit 23bd08bf36
  1. 19
      xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/jobinfo.index.ftl
  2. 32
      xxl-job-admin/src/main/webapp/static/js/jobinfo.index.1.js
  3. 17
      xxl-job-core/src/main/java/com/xxl/job/core/executor/jetty/XxlJobExecutor.java
  4. 48
      xxl-job-core/src/main/java/com/xxl/job/core/handler/HandlerRepository.java
  5. 4
      xxl-job-executor-example/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java

@ -193,14 +193,10 @@ public class DemoJobHandler extends IJobHandler {
<div class="form-group">
<label for="firstname" class="col-sm-2 control-label">分组<font color="red">*</font></label>
<div class="col-sm-4">
<select class="form-control" name="jobGroupTitle" disabled>
<#list JobGroupList as group>
<option value="${group}" >${group.desc}</option>
</#list>
</select>
<input type="text" class="form-control" name="jobGroupTitle" maxlength="50" readonly >
<input type="hidden" name="jobGroup" >
<input type="hidden" name="jobName" >
</div>
</div>
<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="jobDesc" placeholder="请输入“描述”" maxlength="50" ></div>
</div>
@ -226,13 +222,12 @@ public class DemoJobHandler extends IJobHandler {
<div class="form-group">
<label for="firstname" class="col-sm-2 control-label">任务模式<font color="red">*</font></label>
<div class="col-sm-4">
<select class="form-control" name="glueSwitch" disabled >
<option value="0" >BEAN模式</option>
<option value="1" >GLUE模式</option>
</select>
</div>
<input type="text" class="form-control" name="glueSwitchTitle" readonly >
</div>
<label for="lastname" class="col-sm-2 control-label">JobKey</label>
<div class="col-sm-4"><input type="text" class="form-control" name="jobKey" placeholder="请输入“jobHandler”" readonly ></div>
<div class="col-sm-4">
<input type="text" class="form-control" name="jobKey" placeholder="请输入“jobHandler”" readonly >
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-6">

@ -91,7 +91,7 @@ $(function() {
var codeUrl = base_url +'/jobcode?jobGroup='+ row.jobGroup +'&jobName='+ row.jobName;
codeBtn = '<button class="btn btn-warning btn-xs" type="button" onclick="javascript:window.open(\'' + codeUrl + '\')" >GLUE</button> '
}
var html = '<p id="'+ row.id +'" '+
' jobGroup="'+ row.jobGroup +'" '+
' jobName="'+ row.jobName +'" '+
@ -303,25 +303,23 @@ $(function() {
$("#updateModal .form input[name='alarmThreshold']").val($(this).parent('p').attr("alarmThreshold"));
// job group selected
$("#updateModal .form select[name='jobGroupTitle']").find("option[value='" + $(this).parent('p').attr("jobGroup") + "']").attr("selected",true);
// job group selected
$("#updateModal .form select[name='glueSwitch']").find("option[value='" + $(this).parent('p').attr("glueSwitch") + "']").attr("selected",true);
var jobGroupTitle = $("#addModal .form select[name='jobGroup']").find("option[value='" + $(this).parent('p').attr("jobGroup") + "']").text();
$("#updateModal .form input[name='jobGroupTitle']").val(jobGroupTitle);
// generate job key
$("#updateModal .form input[name='jobKey']").val( $(this).parent('p').attr("jobGroup") + "_" + $(this).parent('p').attr("jobName") );
// GLUE check
var $glueSwitch = $("#updateModal .form input[name='glueSwitch']");
var $executorHandler = $("#updateModal .form input[name='executorHandler']");
if ($glueSwitch.val() != 0) {
$executorHandler.attr("readonly","readonly");
$("#updateModal .form .ifGLUE").attr("checked", true);
// glueSwitch and jobKey
var glueSwitchTitle;
var jobKey;
if ($(this).parent('p').attr("glueSwitch") == 0) {
glueSwitchTitle = "BEAN模式";
jobKey = $(this).parent('p').attr("jobGroup") + "_" + $(this).parent('p').attr("jobName");
} else {
$executorHandler.removeAttr("readonly");
$("#updateModal .form .ifGLUE").attr("checked", false);
glueSwitchTitle = "GLUE模式";
jobKey = "无";
}
$("#updateModal .form input[name='glueSwitchTitle']").val(glueSwitchTitle);
$("#updateModal .form input[name='jobKey']").val(jobKey);
// show
$('#updateModal').modal({backdrop: false, keyboard: false}).modal('show');
});
var updateModalValidate = $("#updateModal .form").validate({

@ -1,6 +1,6 @@
package com.xxl.job.core.executor.jetty;
import java.util.Map;
import java.util.*;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Handler;
@ -88,11 +88,16 @@ public class XxlJobExecutor implements ApplicationContextAware {
Map<String, Object> serviceBeanMap = XxlJobExecutor.applicationContext.getBeansWithAnnotation(JobHander.class);
if (serviceBeanMap!=null && serviceBeanMap.size()>0) {
for (Object serviceBean : serviceBeanMap.values()) {
String jobName = serviceBean.getClass().getAnnotation(JobHander.class).value();
if (jobName!=null && jobName.trim().length()>0 && serviceBean instanceof IJobHandler) {
IJobHandler handler = (IJobHandler) serviceBean;
HandlerRepository.regist(jobName, handler);
}
if (serviceBean instanceof IJobHandler){
String jobKeys = serviceBean.getClass().getAnnotation(JobHander.class).value();
if (jobKeys!=null && jobKeys.trim().length()>0) {
Set<String> jobKeySet = new HashSet<String>(Arrays.asList(jobKeys.split(",")));
for (String jobKey : jobKeySet) {
IJobHandler handler = (IJobHandler) serviceBean;
HandlerRepository.regist(jobKey, handler);
}
}
}
}
}
}

@ -102,7 +102,6 @@ public class HandlerRepository {
callback.setMsg("JOB_GROUP or JOB_NAME is null.");
return JacksonUtil.writeValueAsString(callback);
}
String jobKey = job_group.concat("_").concat(job_name);
// glue switch
String handler_glue_switch = _param.get(HandlerParamEnum.GLUE_SWITCH.name());
@ -111,7 +110,8 @@ public class HandlerRepository {
return JacksonUtil.writeValueAsString(callback);
}
HandlerThread handlerThread = handlerTreadMap.get(jobKey);;
String jobKey = job_group.concat("_").concat(job_name);
HandlerThread handlerThread = handlerTreadMap.get(jobKey);
if ("0".equals(handler_glue_switch)) {
// bean model
if (handlerThread == null) {
@ -129,27 +129,6 @@ public class HandlerRepository {
// push data to queue
handlerThread.pushData(_param);
callback.setStatus(RemoteCallBack.SUCCESS);
} else if (namespace.equals(ActionEnum.LOG.name())) {
String log_id = _param.get(HandlerParamEnum.LOG_ID.name());
String log_date = _param.get(HandlerParamEnum.LOG_DATE.name());
if (log_id==null || log_date==null) {
callback.setMsg("LOG_ID | LOG_DATE can not be null.");
return JacksonUtil.writeValueAsString(callback);
}
int logId = -1;
Date triggerDate = null;
try {
logId = Integer.valueOf(log_id);
triggerDate = new Date(Long.valueOf(log_date));
} catch (Exception e) {
}
if (logId<=0 || triggerDate==null) {
callback.setMsg("LOG_ID | LOG_DATE parse error.");
return JacksonUtil.writeValueAsString(callback);
}
String logConteng = XxlJobFileAppender.readLog(triggerDate, log_id);
callback.setStatus(RemoteCallBack.SUCCESS);
callback.setMsg(logConteng);
} else if (namespace.equals(ActionEnum.KILL.name())) {
// generate jobKey
String job_group = _param.get(HandlerParamEnum.JOB_GROUP.name());
@ -171,7 +150,28 @@ public class HandlerRepository {
} else {
callback.setMsg("handler for jobKey=[" + jobKey + "] not found.");
}
} else if (namespace.equals(ActionEnum.LOG.name())) {
String log_id = _param.get(HandlerParamEnum.LOG_ID.name());
String log_date = _param.get(HandlerParamEnum.LOG_DATE.name());
if (log_id==null || log_date==null) {
callback.setMsg("LOG_ID | LOG_DATE can not be null.");
return JacksonUtil.writeValueAsString(callback);
}
int logId = -1;
Date triggerDate = null;
try {
logId = Integer.valueOf(log_id);
triggerDate = new Date(Long.valueOf(log_date));
} catch (Exception e) {
}
if (logId<=0 || triggerDate==null) {
callback.setMsg("LOG_ID | LOG_DATE parse error.");
return JacksonUtil.writeValueAsString(callback);
}
String logConteng = XxlJobFileAppender.readLog(triggerDate, log_id);
callback.setStatus(RemoteCallBack.SUCCESS);
callback.setMsg(logConteng);
} else if (namespace.equals(ActionEnum.BEAT.name())) {
callback.setStatus(RemoteCallBack.SUCCESS);
callback.setMsg(null);

@ -16,11 +16,11 @@ import com.xxl.job.core.handler.annotation.JobHander;
* 开发步骤
* 1继承 IJobHandler
* 2装配到Spring例如加 @Service 注解
* 3 @JobHander 注解自定义属性name的值name值在配置新任务是使用
* 3 @JobHander 注解注解value值为新增任务生成的JobKey的值;多个JobKey用逗号分割;
*
* @author xuxueli 2015-12-19 19:43:36
*/
@JobHander(value="defaults_201607192222270796")
@JobHander(value="defaults_201607192256270689,defaults_201607192256270689")
@Service
public class DemoJobHandler extends IJobHandler {
private static transient Logger logger = LoggerFactory.getLogger(DemoJobHandler.class);

Loading…
Cancel
Save