From 4b2b6d8256a5b9b448973ec9e329a5964fe53c88 Mon Sep 17 00:00:00 2001 From: "xueli.xue" Date: Wed, 18 May 2016 23:25:29 +0800 Subject: [PATCH] =?UTF-8?q?GLUE=E8=BF=9C=E7=A8=8B=E4=BB=BB=E5=8A=A1init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xxl/job/controller/JobCodeController.java | 11 ++++ .../webapp/WEB-INF/template/jobcode/index.ftl | 39 +++++++------ .../main/webapp/static/js/jobcode.index.1.js | 57 ++++++++++++++++--- .../main/webapp/static/js/jobinfo.index.1.js | 2 +- 4 files changed, 81 insertions(+), 28 deletions(-) diff --git a/xxl-job-admin/src/main/java/com/xxl/job/controller/JobCodeController.java b/xxl-job-admin/src/main/java/com/xxl/job/controller/JobCodeController.java index 53171a17..90590974 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/controller/JobCodeController.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/controller/JobCodeController.java @@ -5,6 +5,10 @@ import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.xxl.job.core.model.ReturnT; +import com.xxl.job.core.model.XxlJobInfo; /** * job code controller @@ -19,4 +23,11 @@ public class JobCodeController { return "jobcode/index"; } + @RequestMapping("/save") + @ResponseBody + public ReturnT save(Model model, XxlJobInfo jobInfo, HttpServletRequest request) { + + return ReturnT.SUCCESS; + } + } diff --git a/xxl-job-admin/src/main/webapp/WEB-INF/template/jobcode/index.ftl b/xxl-job-admin/src/main/webapp/WEB-INF/template/jobcode/index.ftl index 6bddc624..6e064dc5 100644 --- a/xxl-job-admin/src/main/webapp/WEB-INF/template/jobcode/index.ftl +++ b/xxl-job-admin/src/main/webapp/WEB-INF/template/jobcode/index.ftl @@ -15,7 +15,7 @@ } - +
@@ -27,12 +27,11 @@
-
- +
+
- +
@@ -61,8 +60,18 @@
-
- +
+
+
+
+
+ + <@netCommon.commonFooter /> + + + - - - - - - - - <@netCommon.commonFooter /> - + <@netCommon.comAlert /> <@netCommon.commonScript /> @@ -100,6 +100,9 @@ public class DemoJobHandler extends IJobHandler { + diff --git a/xxl-job-admin/src/main/webapp/static/js/jobcode.index.1.js b/xxl-job-admin/src/main/webapp/static/js/jobcode.index.1.js index e300e41c..697366cf 100644 --- a/xxl-job-admin/src/main/webapp/static/js/jobcode.index.1.js +++ b/xxl-job-admin/src/main/webapp/static/js/jobcode.index.1.js @@ -1,16 +1,55 @@ $(function() { - var javaEditor = CodeMirror.fromTextArea(document.getElementById("editor"), { + // init code editor + var codeEditor = CodeMirror.fromTextArea(document.getElementById("codeSource"), { mode : "text/x-java", lineNumbers : true, - matchBrackets : true, - extraKeys: { - "F11": function(cm) { - cm.setOption("fullScreen", !cm.getOption("fullScreen")); - }, - "Esc": function(cm) { - if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false); - } + matchBrackets : true + }); + codeEditor.setValue( $("#demoCode").val() ); + + + $("#save").click(function() { + var codeSource = codeEditor.getValue(); + var codeRemark = $("#codeRemark").val(); + + if (!codeRemark) { + ComAlert.show(1, "请输入备注"); + return; + } + if (codeRemark.length < 6|| codeRemark.length > 100) { + ComAlert.show(1, "备注长度应该在6至100之间"); + return; } + + ComConfirm.show("是否执行保存操作?", function(){ + $.ajax({ + type : 'POST', + url : base_url + '/jobcode/save', + data : { + 'jobInfo.id' : id, + 'jobInfo.codeSource' : codeSource, + 'jobInfo.codeRemark' : codeRemark + }, + dataType : "json", + success : function(data){ + if (data.code == 200) { + ComAlert.show(1, '提交成功', function(){ + //$(window).unbind('beforeunload'); + window.location.reload(); + }); + } else { + ComAlert.alert(data.msg); + } + } + }); + }); + }); + + // before upload + /*$(window).bind('beforeunload',function(){ + return 'Glue尚未保存,确定离开Glue编辑器?'; + });*/ + }); diff --git a/xxl-job-admin/src/main/webapp/static/js/jobinfo.index.1.js b/xxl-job-admin/src/main/webapp/static/js/jobinfo.index.1.js index 86613e90..f0727ff4 100644 --- a/xxl-job-admin/src/main/webapp/static/js/jobinfo.index.1.js +++ b/xxl-job-admin/src/main/webapp/static/js/jobinfo.index.1.js @@ -111,7 +111,7 @@ $(function() { pause_resume + '
'+ ' '+ - ' '+ + ' '+ ' '+ '

';