xuxueli преди 7 години
родител
ревизия
d24b7a308f
променени са 18 файла, в които са добавени 134 реда и са изтрити 41 реда
  1. 9 1
      xxl-job-admin/src/main/java/com/xxl/job/admin/controller/interceptor/CookieInterceptor.java
  2. 25 0
      xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/FtlUtil.java
  3. 7 1
      xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/I18nUtil.java
  4. 21 1
      xxl-job-admin/src/main/resources/i18n/message.properties
  5. 6 0
      xxl-job-admin/src/main/resources/i18n/message_en.properties
  6. 6 0
      xxl-job-admin/src/main/resources/i18n/message_zh.properties
  7. 14 4
      xxl-job-admin/src/main/webapp/WEB-INF/template/common/common.macro.ftl
  8. 2 2
      xxl-job-admin/src/main/webapp/WEB-INF/template/help.ftl
  9. 3 2
      xxl-job-admin/src/main/webapp/WEB-INF/template/index.ftl
  10. 1 1
      xxl-job-admin/src/main/webapp/WEB-INF/template/jobcode/jobcode.index.ftl
  11. 2 2
      xxl-job-admin/src/main/webapp/WEB-INF/template/jobgroup/jobgroup.index.ftl
  12. 2 2
      xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/jobinfo.index.ftl
  13. 1 1
      xxl-job-admin/src/main/webapp/WEB-INF/template/joblog/joblog.detail.ftl
  14. 2 2
      xxl-job-admin/src/main/webapp/WEB-INF/template/joblog/joblog.index.ftl
  15. 18 6
      xxl-job-admin/src/main/webapp/WEB-INF/template/login.ftl
  16. 5 4
      xxl-job-admin/src/main/webapp/static/js/common.1.js
  17. 0 2
      xxl-job-admin/src/main/webapp/static/js/index.js
  18. 10 10
      xxl-job-admin/src/main/webapp/static/js/login.1.js

+ 9 - 1
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/interceptor/CookieInterceptor.java Целия файл

@@ -1,5 +1,7 @@
1 1
 package com.xxl.job.admin.controller.interceptor;
2 2
 
3
+import com.xxl.job.admin.core.util.FtlUtil;
4
+import com.xxl.job.admin.core.util.I18nUtil;
3 5
 import org.apache.commons.lang3.ArrayUtils;
4 6
 import org.springframework.web.servlet.ModelAndView;
5 7
 import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
@@ -19,7 +21,8 @@ public class CookieInterceptor extends HandlerInterceptorAdapter {
19 21
 	@Override
20 22
 	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
21 23
 			ModelAndView modelAndView) throws Exception {
22
-		
24
+
25
+		// cookie
23 26
 		if (modelAndView!=null && ArrayUtils.isNotEmpty(request.getCookies())) {
24 27
 			HashMap<String, Cookie> cookieMap = new HashMap<String, Cookie>();
25 28
 			for (Cookie ck : request.getCookies()) {
@@ -27,6 +30,11 @@ public class CookieInterceptor extends HandlerInterceptorAdapter {
27 30
 			}
28 31
 			modelAndView.addObject("cookieMap", cookieMap);
29 32
 		}
33
+
34
+		// static method
35
+		if (modelAndView != null) {
36
+			modelAndView.addObject("I18nUtil", FtlUtil.generateStaticModel(I18nUtil.class.getName()));
37
+		}
30 38
 		
31 39
 		super.postHandle(request, response, handler, modelAndView);
32 40
 	}

+ 25 - 0
xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/FtlUtil.java Целия файл

@@ -0,0 +1,25 @@
1
+package com.xxl.job.admin.core.util;
2
+
3
+import freemarker.ext.beans.BeansWrapper;
4
+import freemarker.template.TemplateHashModel;
5
+
6
+/**
7
+ * ftl util
8
+ *
9
+ * @author xuxueli 2018-01-17 20:37:48
10
+ */
11
+public class FtlUtil {
12
+
13
+    public static TemplateHashModel generateStaticModel(String packageName) {
14
+        try {
15
+            BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
16
+            TemplateHashModel staticModels = wrapper.getStaticModels();
17
+            TemplateHashModel fileStatics = (TemplateHashModel) staticModels.get(packageName);
18
+            return fileStatics;
19
+        } catch (Exception e) {
20
+            e.printStackTrace();
21
+        }
22
+        return null;
23
+    }
24
+
25
+}

+ 7 - 1
xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/I18nUtil.java Целия файл

@@ -10,14 +10,20 @@ import org.springframework.core.io.support.PropertiesLoaderUtils;
10 10
 import java.io.IOException;
11 11
 import java.util.Properties;
12 12
 
13
+/**
14
+ * i18n util
15
+ *
16
+ * @author xuxueli 2018-01-17 20:39:06
17
+ */
13 18
 public class I18nUtil {
14 19
     private static Logger logger = LoggerFactory.getLogger(I18nUtil.class);
15 20
 
16 21
     private static final String i18n_file = "i18n/message.properties";
17 22
     private static Properties prop = null;
23
+    private static boolean prop_cache = false;
18 24
 
19 25
     public static Properties loadI18nProp(){
20
-        if (prop == null) {
26
+        if (prop_cache && prop == null) {
21 27
             try {
22 28
                 Resource resource = new ClassPathResource(i18n_file);
23 29
                 EncodedResource encodedResource = new EncodedResource(resource,"UTF-8");

+ 21 - 1
xxl-job-admin/src/main/resources/i18n/message.properties Целия файл

@@ -1 +1,21 @@
1
-admin_name=任务调度中心
1
+admin_name=任务调度中心
2
+
3
+login_btn=登录
4
+login_remember_me=记住密码
5
+login_username_placeholder=请输入登录账号
6
+login_password_placeholder=请输入登录密码
7
+login_username_empty=请输入登录账号
8
+login_username_lt_5=登录账号不应低于5位
9
+login_password_empty=请输入登录密码
10
+login_password_lt_5=登录密码不应低于5位
11
+login_success=登录成功
12
+login_fail=登录失败
13
+
14
+logout_btn=注销
15
+logout_confirm=确认注销登录?
16
+logout_success=注销成功
17
+logout_fail=注销失败
18
+
19
+system_tips=系统提示
20
+system_ok=确定2
21
+system_close=关闭2

+ 6 - 0
xxl-job-admin/src/main/resources/i18n/message_en.properties Целия файл

@@ -0,0 +1,6 @@
1
+admin_name=Job Scheduling Center 
2
+
3
+login_btn=Login
4
+login_remember_me=Remember Me
5
+login_username_placeholder=Please input username
6
+login_password_placeholder=Please input password

+ 6 - 0
xxl-job-admin/src/main/resources/i18n/message_zh.properties Целия файл

@@ -0,0 +1,6 @@
1
+admin_name=任务调度中心
2
+
3
+login_btn=登录
4
+login_remember_me=记住密码
5
+login_username_placeholder=请输入登录账号
6
+login_password_placeholder=请输入登录密码

+ 14 - 4
xxl-job-admin/src/main/webapp/WEB-INF/template/common/common.macro.ftl Целия файл

@@ -53,7 +53,17 @@
53 53
 
54 54
 	<#-- common -->
55 55
     <script src="${request.contextPath}/static/js/common.1.js"></script>
56
-    <script>var base_url = '${request.contextPath}';</script>
56
+    <script>
57
+		var base_url = '${request.contextPath}';
58
+
59
+		var system_tips = '${I18nUtil.getString("system_tips")}';
60
+        var system_ok = '${I18nUtil.getString("system_ok")}';
61
+        var system_close = '${I18nUtil.getString("system_close")}';
62
+
63
+        var logout_confirm = '${I18nUtil.getString("logout_confirm")}';
64
+        var logout_success = '${I18nUtil.getString("logout_success")}';
65
+        var logout_fail = '${I18nUtil.getString("logout_fail")}';
66
+	</script>
57 67
 
58 68
 </#macro>
59 69
 
@@ -61,7 +71,7 @@
61 71
 	<header class="main-header">
62 72
 		<a href="${request.contextPath}/" class="logo">
63 73
 			<span class="logo-mini"><b>XXL</b></span>
64
-			<span class="logo-lg"><b>任务调度中心</b></span>
74
+			<span class="logo-lg"><b>${I18nUtil.getString("admin_name")}</b></span>
65 75
 		</a>
66 76
 		<nav class="navbar navbar-static-top" role="navigation">
67 77
 			<a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button"><span class="sr-only">切换导航</span></a>
@@ -69,7 +79,7 @@
69 79
 				<ul class="nav navbar-nav">
70 80
 					<li class="dropdown user user-menu">
71 81
 	                    <a href=";" id="logoutBtn" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
72
-                      		<span class="hidden-xs">注销</span>
82
+                      		<span class="hidden-xs">${I18nUtil.getString("logout_btn")}</span>
73 83
 	                    </a>
74 84
 					</li>
75 85
 				</ul>
@@ -175,7 +185,7 @@
175 185
 
176 186
 <#macro commonFooter >
177 187
 	<footer class="main-footer">
178
-        Powered by <b>XXL-JOB</b> 1.9.1(快照版本
188
+        Powered by <b>XXL-JOB</b> 1.9.1(SNAPSHOT
179 189
 		<div class="pull-right hidden-xs">
180 190
             <strong>Copyright &copy; 2015-${.now?string('yyyy')} &nbsp;
181 191
                 <a href="http://www.xuxueli.com/" target="_blank" >xuxueli</a>

+ 2 - 2
xxl-job-admin/src/main/webapp/WEB-INF/template/help.ftl Целия файл

@@ -1,7 +1,7 @@
1 1
 <!DOCTYPE html>
2 2
 <html>
3 3
 <head>
4
-  	<title>任务调度中心</title>
4
+    <title>${I18nUtil.getString("admin_name")}</title>
5 5
   	<#import "/common/common.macro.ftl" as netCommon>
6 6
 	<@netCommon.commonStyle />
7 7
 </head>
@@ -16,7 +16,7 @@
16 16
 	<div class="content-wrapper">
17 17
 		<!-- Content Header (Page header) -->
18 18
 		<section class="content-header">
19
-			<h1>使用教程<small>任务调度中心</small></h1>
19
+			<h1>使用教程</h1>
20 20
 			<!--
21 21
 			<ol class="breadcrumb">
22 22
 				<li><a><i class="fa fa-dashboard"></i>调度中心</a></li>

+ 3 - 2
xxl-job-admin/src/main/webapp/WEB-INF/template/index.ftl Целия файл

@@ -1,7 +1,7 @@
1 1
 <!DOCTYPE html>
2 2
 <html>
3 3
 <head>
4
-  	<title>任务调度中心</title>
4
+    <title>${I18nUtil.getString("admin_name")}</title>
5 5
   	<#import "/common/common.macro.ftl" as netCommon>
6 6
 	<@netCommon.commonStyle />
7 7
     <!-- daterangepicker -->
@@ -18,8 +18,9 @@
18 18
 	<div class="content-wrapper">
19 19
 		<!-- Content Header (Page header) -->
20 20
 		<section class="content-header">
21
-			<h1>运行报表<small>任务调度中心</small></h1>
21
+			<h1>运行报表</h1>
22 22
 			<!--
23
+			<h1>运行报表<small>任务调度中心</small></h1>
23 24
 			<ol class="breadcrumb">
24 25
 				<li><a><i class="fa fa-dashboard"></i>调度中心</a></li>
25 26
 				<li class="active">使用教程</li>

+ 1 - 1
xxl-job-admin/src/main/webapp/WEB-INF/template/jobcode/jobcode.index.ftl Целия файл

@@ -1,7 +1,7 @@
1 1
 <!DOCTYPE html>
2 2
 <html>
3 3
 <head>
4
-  	<title>任务调度中心</title>
4
+    <title>${I18nUtil.getString("admin_name")}</title>
5 5
   	<#import "/common/common.macro.ftl" as netCommon>
6 6
 	<@netCommon.commonStyle />
7 7
 	<link rel="stylesheet" href="${request.contextPath}/static/plugins/codemirror/lib/codemirror.css">

+ 2 - 2
xxl-job-admin/src/main/webapp/WEB-INF/template/jobgroup/jobgroup.index.ftl Целия файл

@@ -1,7 +1,7 @@
1 1
 <!DOCTYPE html>
2 2
 <html>
3 3
 <head>
4
-  	<title>任务调度中心</title>
4
+    <title>${I18nUtil.getString("admin_name")}</title>
5 5
   	<#import "/common/common.macro.ftl" as netCommon>
6 6
 	<@netCommon.commonStyle />
7 7
 	<!-- DataTables -->
@@ -18,7 +18,7 @@
18 18
 	<div class="content-wrapper">
19 19
 		<!-- Content Header (Page header) -->
20 20
 		<section class="content-header">
21
-			<h1>执行器管理<small>任务调度中心</small></h1>
21
+			<h1>执行器管理</h1>
22 22
 		</section>
23 23
 
24 24
 		<!-- Main content -->

+ 2 - 2
xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/jobinfo.index.ftl Целия файл

@@ -1,7 +1,7 @@
1 1
 <!DOCTYPE html>
2 2
 <html>
3 3
 <head>
4
-  	<title>任务调度中心</title>
4
+    <title>${I18nUtil.getString("admin_name")}</title>
5 5
   	<#import "/common/common.macro.ftl" as netCommon>
6 6
 	<@netCommon.commonStyle />
7 7
 	<!-- DataTables -->
@@ -19,7 +19,7 @@
19 19
 	<div class="content-wrapper">
20 20
 		<!-- Content Header (Page header) -->
21 21
 		<section class="content-header">
22
-			<h1>任务管理<small>任务调度中心</small></h1>
22
+			<h1>任务管理</h1>
23 23
 			<!--
24 24
 			<ol class="breadcrumb">
25 25
 				<li><a><i class="fa fa-dashboard"></i>调度管理</a></li>

+ 1 - 1
xxl-job-admin/src/main/webapp/WEB-INF/template/joblog/joblog.detail.ftl Целия файл

@@ -1,7 +1,7 @@
1 1
 <!DOCTYPE html>
2 2
 <html>
3 3
 <head>
4
-    <title>任务调度中心</title>
4
+    <title>${I18nUtil.getString("admin_name")}</title>
5 5
 <#import "/common/common.macro.ftl" as netCommon>
6 6
 <@netCommon.commonStyle />
7 7
 </head>

+ 2 - 2
xxl-job-admin/src/main/webapp/WEB-INF/template/joblog/joblog.index.ftl Целия файл

@@ -1,7 +1,7 @@
1 1
 <!DOCTYPE html>
2 2
 <html>
3 3
 <head>
4
-  	<title>任务调度中心</title>
4
+    <title>${I18nUtil.getString("admin_name")}</title>
5 5
   	<#import "/common/common.macro.ftl" as netCommon>
6 6
 	<@netCommon.commonStyle />
7 7
 	<!-- DataTables -->
@@ -20,7 +20,7 @@
20 20
 	<div class="content-wrapper">
21 21
 		<!-- Content Header (Page header) -->
22 22
 		<section class="content-header">
23
-			<h1>调度日志<small>任务调度中心</small></h1>
23
+			<h1>调度日志</h1>
24 24
 			<!--
25 25
 			<ol class="breadcrumb">
26 26
 				<li><a><i class="fa fa-dashboard"></i>调度日志</a></li>

+ 18 - 6
xxl-job-admin/src/main/webapp/WEB-INF/template/login.ftl Целия файл

@@ -1,7 +1,7 @@
1 1
 <!DOCTYPE html>
2 2
 <html>
3 3
 <head>
4
-  	<title>调度中心</title>
4
+  	<title>${I18nUtil.getString("admin_name")}</title>
5 5
   	<#import "/common/common.macro.ftl" as netCommon>
6 6
 	<@netCommon.commonStyle />
7 7
     <link rel="stylesheet" href="${request.contextPath}/static/adminlte/plugins/iCheck/square/blue.css">
@@ -13,31 +13,43 @@
13 13
 		</div>
14 14
 		<form id="loginForm" method="post" >
15 15
 			<div class="login-box-body">
16
-				<p class="login-box-msg">任务调度中心</p>
16
+				<p class="login-box-msg">${I18nUtil.getString("admin_name")}</p>
17 17
 				<div class="form-group has-feedback">
18
-	            	<input type="text" name="userName" class="form-control" placeholder="请输入登录账号" value="admin" >
18
+	            	<input type="text" name="userName" class="form-control" placeholder="${I18nUtil.getString("login_username_placeholder")}" value="admin" maxlength="18" >
19 19
 	            	<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
20 20
 				</div>
21 21
 	          	<div class="form-group has-feedback">
22
-	            	<input type="password" name="password" class="form-control" placeholder="请输入登录密码" value="123456" >
22
+	            	<input type="password" name="password" class="form-control" placeholder="${I18nUtil.getString("login_password_placeholder")}" value="123456" maxlength="18" >
23 23
 	            	<span class="glyphicon glyphicon-lock form-control-feedback"></span>
24 24
 	          	</div>
25 25
 				<div class="row">
26 26
 					<div class="col-xs-8">
27 27
 		              	<div class="checkbox icheck">
28 28
 		                	<label>
29
-		                  		<input type="checkbox" name="ifRemember" > Remember Me
29
+		                  		<input type="checkbox" name="ifRemember" > ${I18nUtil.getString("login_remember_me")}
30 30
 		                	</label>
31 31
 						</div>
32 32
 		            </div><!-- /.col -->
33 33
 		            <div class="col-xs-4">
34
-						<button type="submit" class="btn btn-primary btn-block btn-flat">登录</button>
34
+						<button type="submit" class="btn btn-primary btn-block btn-flat">${I18nUtil.getString("login_btn")}</button>
35 35
 					</div>
36 36
 				</div>
37 37
 			</div>
38 38
 		</form>
39 39
 	</div>
40 40
 <@netCommon.commonScript />
41
+<script>
42
+var login_username_empty = '${I18nUtil.getString("login_username_empty")}';
43
+var login_username_lt_5 = '${I18nUtil.getString("login_username_lt_5")}';
44
+
45
+var login_password_empty = '${I18nUtil.getString("login_password_empty")}';
46
+var login_password_lt_5 = '${I18nUtil.getString("login_password_lt_5")}';
47
+
48
+var login_success = '${I18nUtil.getString("login_success")}';
49
+var login_fail = '${I18nUtil.getString("login_fail")}';
50
+var system_tips = '${I18nUtil.getString("system_tips")}';
51
+var system_ok = '${I18nUtil.getString("system_ok")}';
52
+</script>
41 53
 <script src="${request.contextPath}/static/plugins/jquery/jquery.validate.min.js"></script>
42 54
 <script src="${request.contextPath}/static/adminlte/plugins/iCheck/icheck.min.js"></script>
43 55
 <script src="${request.contextPath}/static/js/login.1.js"></script>

+ 5 - 4
xxl-job-admin/src/main/webapp/static/js/common.1.js Целия файл

@@ -2,12 +2,12 @@ $(function(){
2 2
 
3 3
 	// logout
4 4
 	$("#logoutBtn").click(function(){
5
-		layer.confirm('确认注销登录?', {icon: 3, title:'系统提示'}, function(index){
5
+		layer.confirm(logout_confirm, {icon: 3, title:system_tips}, function(index){
6 6
 			layer.close(index);
7 7
 
8 8
 			$.post(base_url + "/logout", function(data, status) {
9 9
 				if (data.code == "200") {
10
-                    layer.msg('注销成功');
10
+                    layer.msg(logout_success);
11 11
                     setTimeout(function(){
12 12
                         window.location.href = base_url + "/";
13 13
                     }, 500);
@@ -21,8 +21,9 @@ $(function(){
21 21
 					});*/
22 22
 				} else {
23 23
 					layer.open({
24
-						title: '系统提示',
25
-						content: (data.msg || "操作失败"),
24
+						title: system_tips,
25
+                        btn: [system_ok, system_close],
26
+						content: (data.msg || logout_fail),
26 27
 						icon: '2'
27 28
 					});
28 29
 				}

+ 0 - 2
xxl-job-admin/src/main/webapp/static/js/index.js Целия файл

@@ -1,8 +1,6 @@
1 1
 /**
2 2
  * Created by xuxueli on 17/4/24.
3 3
  */
4
-
5
-
6 4
 $(function () {
7 5
 
8 6
     // 过滤时间

+ 10 - 10
xxl-job-admin/src/main/webapp/static/js/login.1.js Целия файл

@@ -25,14 +25,13 @@ $(function(){
25 25
         }, 
26 26
         messages : {  
27 27
         	userName : {  
28
-                required :"请输入登录账号."  ,
29
-                minlength:"登录账号不应低于5位",
30
-                maxlength:"登录账号不应超过18位"
31
-            },  
28
+                required  : login_username_empty,
29
+                minlength : login_username_lt_5
30
+            },
32 31
             password : {
33
-            	required :"请输入登录密码."  ,
34
-                minlength:"登录密码不应低于5位",
35
-                maxlength:"登录密码不应超过18位"
32
+            	required  : login_password_empty  ,
33
+                minlength : login_password_lt_5
34
+                /*,maxlength:"登录密码不应超过18位"*/
36 35
             }
37 36
         }, 
38 37
 		highlight : function(element) {  
@@ -48,7 +47,7 @@ $(function(){
48 47
         submitHandler : function(form) {
49 48
 			$.post(base_url + "/login", $("#loginForm").serialize(), function(data, status) {
50 49
 				if (data.code == "200") {
51
-                    layer.msg('登录成功');
50
+                    layer.msg(login_success);
52 51
                     setTimeout(function(){
53 52
                         window.location.href = base_url;
54 53
                     }, 500);
@@ -62,8 +61,9 @@ $(function(){
62 61
                     });*/
63 62
 				} else {
64 63
                     layer.open({
65
-                        title: '系统提示',
66
-                        content: (data.msg || "登录失败"),
64
+                        title: system_tips,
65
+                        btn: [system_ok],
66
+                        content: (data.msg || login_fail),
67 67
                         icon: '2'
68 68
                     });
69 69
 				}