Parcourir la source

GLUE远程任务init

xueli.xue il y a 9 ans
Parent
révision
4b2b6d8256

+ 11 - 0
xxl-job-admin/src/main/java/com/xxl/job/controller/JobCodeController.java Voir le fichier

@@ -5,6 +5,10 @@ import javax.servlet.http.HttpServletRequest;
5 5
 import org.springframework.stereotype.Controller;
6 6
 import org.springframework.ui.Model;
7 7
 import org.springframework.web.bind.annotation.RequestMapping;
8
+import org.springframework.web.bind.annotation.ResponseBody;
9
+
10
+import com.xxl.job.core.model.ReturnT;
11
+import com.xxl.job.core.model.XxlJobInfo;
8 12
 
9 13
 /**
10 14
  * job code controller
@@ -19,4 +23,11 @@ public class JobCodeController {
19 23
 		return "jobcode/index";
20 24
 	}
21 25
 	
26
+	@RequestMapping("/save")
27
+	@ResponseBody
28
+	public ReturnT<String> save(Model model, XxlJobInfo jobInfo, HttpServletRequest request) {
29
+		
30
+		return ReturnT.SUCCESS;
31
+	}
32
+	
22 33
 }

+ 21 - 18
xxl-job-admin/src/main/webapp/WEB-INF/template/jobcode/index.ftl Voir le fichier

@@ -15,7 +15,7 @@
15 15
 		}
16 16
     </style>
17 17
 </head>
18
-<body>
18
+<body class=" layout-top-nav">
19 19
 
20 20
 <div class="wrapper">
21 21
 	
@@ -27,12 +27,11 @@
27 27
 		
28 28
 		<!-- Main content -->
29 29
 	    <section class="content">
30
-	    
31 30
 	    	<div class="row">
32 31
 	    		<div class="col-xs-4">
33 32
 					<div class="input-group margin">
34 33
                     	<div class="input-group-btn">
35
-                      		<button type="button" class="btn btn-default">版本回溯</button>
34
+                      		<button type="button" class="btn btn-info">版本回溯</button>
36 35
                     	</div>
37 36
                     	<select class="form-control" id="jobGroup" >
38 37
             				<option value="999" >逻辑调整版本C</option>
@@ -45,15 +44,15 @@
45 44
 	            <div class="col-xs-4">
46 45
 	            	<div class="input-group margin">
47 46
                     	<div class="input-group-btn">
48
-                      		<button type="button" class="btn btn-default">Action</button>
47
+                      		<button type="button" class="btn btn-info">备注</button>
49 48
                     	</div>
50
-                    	<input type="text" class="form-control" id="jobName" value="${jobName}" autocomplete="on" >
49
+                    	<input type="text" class="form-control" id="codeRemark" value="${jobName}" autocomplete="on" >
51 50
                   	</div>
52 51
 	            </div>
53 52
 	            <div class="col-xs-2">
54 53
 	            	<div class="input-group margin">
55 54
                     	<div class="input-group-btn">
56
-                      		<button type="button" class="btn btn-info">保存</button>
55
+                      		<button type="button" class="btn btn-primary" id="save" >保存</button>
57 56
                     	</div>
58 57
                   	</div>
59 58
 	            </div>
@@ -61,8 +60,18 @@
61 60
 	    	
62 61
 			<div class="row">
63 62
 				<div class="col-xs-12">
64
-					<div class="box">
65
-						<textarea id="editor" >
63
+					<div class="box callout callout-info">
64
+						<textarea id="codeSource" ></textarea>
65
+					</div>
66
+				</div>
67
+			</div>
68
+	    </section>
69
+	</div>
70
+	<!-- footer -->
71
+	<@netCommon.commonFooter />
72
+</div>
73
+
74
+<textarea id="demoCode" >
66 75
 package com.xxl.job.service.handler;
67 76
 
68 77
 import org.slf4j.Logger;
@@ -83,16 +92,7 @@ public class DemoJobHandler extends IJobHandler {
83 92
 		return JobHandleStatus.SUCCESS;
84 93
 	}
85 94
 }
86
-						</textarea>
87
-					</div>
88
-				</div>
89
-			</div>
90
-	    </section>
91
-	</div>
92
-	
93
-	<!-- footer -->
94
-	<@netCommon.commonFooter />
95
-</div>
95
+</textarea>
96 96
 	
97 97
 <@netCommon.comAlert />
98 98
 <@netCommon.commonScript />
@@ -100,6 +100,9 @@ public class DemoJobHandler extends IJobHandler {
100 100
 <script src="${request.contextPath}/static/plugins/codemirror/mode/clike/clike.js"></script>
101 101
 <script src="${request.contextPath}/static/plugins/codemirror/addon/hint/show-hint.js"></script>
102 102
 <script src="${request.contextPath}/static/plugins/codemirror/addon/hint/anyword-hint.js"></script>
103
+<script>
104
+var id = ${id!-1};
105
+</script>
103 106
 <script src="${request.contextPath}/static/js/jobcode.index.1.js"></script>
104 107
 </body>
105 108
 </html>

+ 48 - 9
xxl-job-admin/src/main/webapp/static/js/jobcode.index.1.js Voir le fichier

@@ -1,16 +1,55 @@
1 1
 $(function() {
2 2
 
3
-	var javaEditor = CodeMirror.fromTextArea(document.getElementById("editor"), {
3
+	// init code editor
4
+	var codeEditor = CodeMirror.fromTextArea(document.getElementById("codeSource"), {
4 5
 		mode : "text/x-java",
5 6
 		lineNumbers : true,
6
-		matchBrackets : true,
7
-		extraKeys: {
8
-			"F11": function(cm) {
9
-				cm.setOption("fullScreen", !cm.getOption("fullScreen"));
10
-			},
11
-	        "Esc": function(cm) {
12
-	        	if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
13
-	        }
7
+		matchBrackets : true
8
+	});
9
+	codeEditor.setValue( $("#demoCode").val() );
10
+	
11
+	
12
+	$("#save").click(function() {
13
+		var codeSource = codeEditor.getValue();
14
+		var codeRemark = $("#codeRemark").val();
15
+		
16
+		if (!codeRemark) {
17
+			ComAlert.show(1, "请输入备注");
18
+			return;
19
+		}
20
+		if (codeRemark.length < 6|| codeRemark.length > 100) {
21
+			ComAlert.show(1, "备注长度应该在6至100之间");
22
+			return;
14 23
 		}
24
+		
25
+		ComConfirm.show("是否执行保存操作?", function(){
26
+			$.ajax({
27
+				type : 'POST',
28
+				url : base_url + '/jobcode/save',
29
+				data : {
30
+					'jobInfo.id' : id,
31
+					'jobInfo.codeSource' : codeSource,
32
+					'jobInfo.codeRemark' : codeRemark
33
+				},
34
+				dataType : "json",
35
+				success : function(data){
36
+					if (data.code == 200) {
37
+						ComAlert.show(1, '提交成功', function(){
38
+							//$(window).unbind('beforeunload');
39
+							window.location.reload();
40
+						});
41
+					} else {
42
+						ComAlert.alert(data.msg);
43
+					}
44
+				}
45
+			});
46
+		});
47
+		
15 48
 	});
49
+	
50
+	// before upload
51
+	/*$(window).bind('beforeunload',function(){
52
+		return 'Glue尚未保存,确定离开Glue编辑器?';
53
+	});*/
54
+	
16 55
 });

+ 1 - 1
xxl-job-admin/src/main/webapp/static/js/jobinfo.index.1.js Voir le fichier

@@ -111,7 +111,7 @@ $(function() {
111 111
 										pause_resume +
112 112
 										'<button class="btn btn-primary btn-xs" type="job_del" type="button" onclick="javascript:window.open(\'' + logUrl + '\')" >日志</button><br>  '+
113 113
 										'<button class="btn btn-warning btn-xs update" type="button">编辑</button>  '+
114
-										'<button class="btn btn-warning btn-xs" type="button" onclick="javascript:window.open(\'' + codeUrl + '\')" >CODE</button>  '+
114
+										'<button class="btn btn-warning btn-xs" type="button" onclick="javascript:window.open(\'' + codeUrl + '\')" >GLUE</button>  '+
115 115
 								  		'<button class="btn btn-danger btn-xs job_operate" type="job_del" type="button">删除</button>  '+
116 116
 									'</p>';
117 117