Showing
6 changed files
with
495 additions
and
3 deletions
@@ -71,6 +71,11 @@ public class HttpUriContants { | @@ -71,6 +71,11 @@ public class HttpUriContants { | ||
71 | public static final String EDIT_ZK_ROOT = "/zkMonitor/editZkMonitorRoot"; | 71 | public static final String EDIT_ZK_ROOT = "/zkMonitor/editZkMonitorRoot"; |
72 | 72 | ||
73 | /*** | 73 | /*** |
74 | + * ZK监控信息查询 log4j | ||
75 | + ****/ | ||
76 | + public static final String GET_ZK_TREE_LOG4J = "/zkMonitor/getZkMonitorTree4Log4j"; | ||
77 | + | ||
78 | + /*** | ||
74 | * ZK 服务监控查询 | 79 | * ZK 服务监控查询 |
75 | ****/ | 80 | ****/ |
76 | public static final String GET_ZK_SVC_LIST = "/zkSvcLookup/getAllSvc"; | 81 | public static final String GET_ZK_SVC_LIST = "/zkSvcLookup/getAllSvc"; |
@@ -33,7 +33,12 @@ public class ZkMonitorTreeCtrl { | @@ -33,7 +33,12 @@ public class ZkMonitorTreeCtrl { | ||
33 | public ModelAndView tozkMonitorList() { | 33 | public ModelAndView tozkMonitorList() { |
34 | return new ModelAndView("zkMonitor/zkMonitorList"); | 34 | return new ModelAndView("zkMonitor/zkMonitorList"); |
35 | } | 35 | } |
36 | - | 36 | + |
37 | + @RequestMapping("/tozkMonitorList4Log4j") | ||
38 | + public ModelAndView tozkMonitorList4Log4j() { | ||
39 | + return new ModelAndView("zkMonitor/zkMonitorList4Log4j"); | ||
40 | + } | ||
41 | + | ||
37 | @RequestMapping("/getRoot") | 42 | @RequestMapping("/getRoot") |
38 | @ResponseBody | 43 | @ResponseBody |
39 | public BaseResponse getRoot(ZkTreeReq req){ | 44 | public BaseResponse getRoot(ZkTreeReq req){ |
@@ -41,6 +46,14 @@ public class ZkMonitorTreeCtrl { | @@ -41,6 +46,14 @@ public class ZkMonitorTreeCtrl { | ||
41 | BaseResponse response=httpClient.defaultPost(HttpUriContants.GET_ZK_TREE, req, BaseResponse.class); | 46 | BaseResponse response=httpClient.defaultPost(HttpUriContants.GET_ZK_TREE, req, BaseResponse.class); |
42 | return response; | 47 | return response; |
43 | } | 48 | } |
49 | + | ||
50 | + @RequestMapping("/getRoot4Log4j") | ||
51 | + @ResponseBody | ||
52 | + public BaseResponse getRoot4Log4j(ZkTreeReq req){ | ||
53 | + log.info("getRoot4Log4j with req is {}",req); | ||
54 | + BaseResponse response=httpClient.defaultPost(HttpUriContants.GET_ZK_TREE_LOG4J, req, BaseResponse.class); | ||
55 | + return response; | ||
56 | + } | ||
44 | 57 | ||
45 | @RequestMapping("/getAll") | 58 | @RequestMapping("/getAll") |
46 | @ResponseBody | 59 | @ResponseBody |
@@ -236,7 +236,7 @@ | @@ -236,7 +236,7 @@ | ||
236 | </div> | 236 | </div> |
237 | </div> | 237 | </div> |
238 | </body> | 238 | </body> |
239 | -<script src="<%=basePath %>script/common/genarate_left_panel.js?v=20171016-1"></script> | 239 | +<script src="<%=basePath %>script/common/genarate_left_panel.js?v=20171023-1"></script> |
240 | <script type="text/javascript"> | 240 | <script type="text/javascript"> |
241 | $("#li_dashboard").addClass("active"); | 241 | $("#li_dashboard").addClass("active"); |
242 | </script> | 242 | </script> |
1 | +<%@page language="java" contentType="text/html;charset=utf-8" %> | ||
2 | +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> | ||
3 | +<% | ||
4 | + String path = request.getContextPath(); | ||
5 | + String basePath = request.getScheme() + "://" | ||
6 | + + request.getServerName() + ":" + request.getServerPort() | ||
7 | + + path + "/"; | ||
8 | +%> | ||
9 | +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | ||
10 | +<html> | ||
11 | +<head> | ||
12 | + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
13 | + <link rel="stylesheet" href="<%=basePath %>css/bootstrap.min.css"/> | ||
14 | + <link rel="stylesheet" href="<%=basePath %>css/bootstrap-datetimepicker.css"/> | ||
15 | + <link href="<%=basePath %>js/bootstrap-plugin/css/bootstrap.table.css" rel="stylesheet" media="screen"/> | ||
16 | + <link rel="stylesheet" href="<%=basePath %>css/bootstrap-responsive.min.css"/> | ||
17 | + <link rel="stylesheet" href="<%=basePath %>css/fullcalendar.css"/> | ||
18 | + <link rel="stylesheet" href="<%=basePath %>css/unicorn.main.css"/> | ||
19 | + <link rel="stylesheet" href="<%=basePath %>css/unicorn.grey.css"/> | ||
20 | + <link rel="stylesheet" href="<%=basePath %>css/jquery-ui.css"/> | ||
21 | + <link rel="stylesheet" href="<%=basePath %>css/uniform.css"/> | ||
22 | + <link rel="stylesheet" href="<%=basePath %>css/select2.css"/> | ||
23 | + <link rel="stylesheet" href="<%=basePath %>js/jstree/themes/proton/style.css"/> | ||
24 | + <link rel="stylesheet" href="<%=basePath %>css/select2.css"/> | ||
25 | + <link rel="stylesheet" href="<%=basePath %>css/yoho.css"/> | ||
26 | + <script src="<%=basePath %>js/excanvas.min.js" charset="UTF-8" type="text/javascript"></script> | ||
27 | + <script src="<%=basePath %>js/jquery-1.12.0.min.js" charset="UTF-8" type="text/javascript"></script> | ||
28 | + <script src="<%=basePath %>js/jquery-ui.custom.js" charset="UTF-8" type="text/javascript"></script> | ||
29 | + <script src="<%=basePath %>/js/bootstrap.min.js"></script> | ||
30 | + <script src="<%=basePath %>/js/unicorn.js"></script> | ||
31 | + <script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/moment-with-locales.js" charset="UTF-8" | ||
32 | + type="text/javascript"></script> | ||
33 | + <script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/bootstrap-datetimepicker.js" charset="UTF-8" | ||
34 | + type="text/javascript"></script> | ||
35 | + <script src="<%=basePath %>js/global.js" charset="UTF-8" type="text/javascript"></script> | ||
36 | + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.pagination.js" charset="UTF-8" | ||
37 | + type="text/javascript"></script> | ||
38 | + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.table.js" charset="UTF-8" type="text/javascript"></script> | ||
39 | + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.dialog.js" charset="UTF-8" type="text/javascript"></script> | ||
40 | + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script> | ||
41 | + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.panel.js" charset="UTF-8" type="text/javascript"></script> | ||
42 | + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.alerts.js" charset="UTF-8" type="text/javascript"></script> | ||
43 | + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.accordion.js" charset="UTF-8" | ||
44 | + type="text/javascript"></script> | ||
45 | + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.breadcrumb.js" charset="UTF-8" | ||
46 | + type="text/javascript"></script> | ||
47 | + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.validate.js" charset="UTF-8" | ||
48 | + type="text/javascript"></script> | ||
49 | + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script> | ||
50 | + <script src="<%=basePath %>js/layer/layer.js" charset="UTF-8" type="text/javascript"></script> | ||
51 | + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.select.js" charset="UTF-8" type="text/javascript"></script> | ||
52 | + <script src="<%=basePath %>js/jstree/jstree.js"></script> | ||
53 | + <script src="<%=basePath %>js/jquery.toaster.js"></script> | ||
54 | + <link href="<%=basePath %>css/jquery.tagsinput.css" rel="stylesheet"/> | ||
55 | + <script src="<%=basePath %>js/jquery.tagsinput.min.js" type="text/javascript"></script> | ||
56 | + <script> | ||
57 | + var contextPath = '<%=basePath %>'; | ||
58 | + | ||
59 | + </script> | ||
60 | + <title>YOHO!运维</title> | ||
61 | +</head> | ||
62 | +<body> | ||
63 | + | ||
64 | +<!-- 头部 --> | ||
65 | +<div id="head"> | ||
66 | + | ||
67 | +</div> | ||
68 | +<!-- 右侧具体内容 --> | ||
69 | +<div id="content"> | ||
70 | + | ||
71 | +<div id="breadcrumb"> | ||
72 | + <a href="#" title="Go to Home" class="tip-bottom"><i | ||
73 | + class="icon-home"></i> Home</a> <a href="#" class="current">监控对象</a> | ||
74 | +</div> | ||
75 | + | ||
76 | +<div class="container-fluid"> | ||
77 | + <div class="widget-box"> | ||
78 | + <div class="widget-title"> | ||
79 | + | ||
80 | + <h5>ZK配置</h5> | ||
81 | + | ||
82 | + </div> | ||
83 | + <!-- 树 --> | ||
84 | + <div style="float: left;width: 250px;color: #D3D3D3;height: 600px;"> | ||
85 | + <div class="widget-title" style="height: 50px;"> | ||
86 | + <h5>节点展示</h5> | ||
87 | + </div> | ||
88 | + <div class="tree_container" style="height: 540px;color: black;overflow:auto;"> | ||
89 | + <div id="jstree" class="jstree jstree-default" role="tree" aria-multiselectable="true" | ||
90 | + tabindex="0"></div> | ||
91 | + </div> | ||
92 | + </div> | ||
93 | + <!-- 列表 --> | ||
94 | + <div class="widget-content nopadding" style="border-left: 1px solid #E5E5E5;width: 450px;float: left;"> | ||
95 | + <div class="widget-title" style="height: 50px;"> | ||
96 | + <h5>根路径</h5> | ||
97 | + </div> | ||
98 | + <div class="widget-content nopadding"> | ||
99 | + <div class="tree_container" style="height: 540px;color: black;overflow:auto;"> | ||
100 | + <div id="rootTable"></div> | ||
101 | + </div> | ||
102 | + </div> | ||
103 | + </div> | ||
104 | + <div class="widget-content nopadding" style="margin-left: 700px;border-left: 1px solid #E5E5E5;"> | ||
105 | + <div class="widget-title" style="height: 50px;"> | ||
106 | + <h5>节点详情</h5> | ||
107 | + </div> | ||
108 | + <div class="widget-content nopadding"> | ||
109 | + <div class="tree_container" style="height: 540px;color: black;overflow:auto;"> | ||
110 | + <div id="detailTable"></div> | ||
111 | + </div> | ||
112 | + </div> | ||
113 | + </div> | ||
114 | + </div> | ||
115 | +</div> | ||
116 | +</div> | ||
117 | +</body> | ||
118 | +<script type="text/javascript" src="<%=basePath %>/script/yoho.type.zktree.log4j.js"></script> | ||
119 | +<script> | ||
120 | +function toDetail(rowData,ip){ | ||
121 | + $("#detailTable").show(); | ||
122 | + $(function () { | ||
123 | + $("#detailTable").table({ | ||
124 | + url: contextPath + "/zkTree/getAll?ip="+ip+"&zkPath="+rowData.root, | ||
125 | + striped : true, | ||
126 | + pagination : false, | ||
127 | + loadFilter: function (data) { | ||
128 | + return defaultLoadFilter(data); | ||
129 | + }, | ||
130 | + columns: [{ | ||
131 | + title: "名称", | ||
132 | + width:"60%", | ||
133 | + align:"left", | ||
134 | + field: "zkName" | ||
135 | + }/*, { | ||
136 | + title: "值", | ||
137 | + width:"20%", | ||
138 | + field: "zkValue" | ||
139 | + }*/, { | ||
140 | + title: "操作", | ||
141 | + width:"20%", | ||
142 | + formatter: function (value, rowData, rowIndex) { | ||
143 | + var div = $("<div>"); | ||
144 | + //修改 | ||
145 | + var editBtn = $("<button data-target='#updateModal' data-toggle='modal'>").addClass("btn btn-xs btn-success").html("修改").appendTo(div); | ||
146 | + /* editBtn.click(function () { | ||
147 | + updateMObject(rowData); | ||
148 | + });*/ | ||
149 | + return div; | ||
150 | + } | ||
151 | + }], | ||
152 | + }); | ||
153 | + | ||
154 | + }); | ||
155 | +} | ||
156 | + | ||
157 | +function updateMObject(rowData){ | ||
158 | + paramObj.zkPath = rowData.zkPath; | ||
159 | + paramObj.zkValue = rowData.zkValue; | ||
160 | + paramObj.zkName = rowData.zkName; | ||
161 | + var dialog0 = $("<div>").appendTo($("body")); | ||
162 | + dialog0.dialog({ | ||
163 | + size : "modal-lg", | ||
164 | + title : "修改路径", | ||
165 | + backdrop : "static", | ||
166 | + href : contextPath +"/jsp/zkMonitor/zkMonitorEdit.jsp", | ||
167 | + buttons : [{ | ||
168 | + text : "关闭", | ||
169 | + className : "btn-danger", | ||
170 | + onclick : function() { | ||
171 | + $(dialog0).dialog("hide"); | ||
172 | + } | ||
173 | + }, { | ||
174 | + text : "提交", | ||
175 | + className : "btn-success", | ||
176 | + onclick : function() { | ||
177 | + | ||
178 | + var btn = $(this); | ||
179 | + $(dialog0).dialog("hide"); | ||
180 | + $("#zkInfoForm").form("submit", { | ||
181 | + submitUrl : contextPath + "/zkTree/editDetail.do", | ||
182 | + submitData : { | ||
183 | + ip : rowData.ip, | ||
184 | + zkPath : rowData.zkPath | ||
185 | + }, | ||
186 | + onBeforeSubmit : function() { | ||
187 | + | ||
188 | + if (!$(this).form("validate")) { | ||
189 | + btn.removeAttr("disabled"); | ||
190 | + return false; | ||
191 | + } | ||
192 | + }, | ||
193 | + success : function(data) { | ||
194 | + var mes=""; | ||
195 | + if(data.data==1){ | ||
196 | + mes="修改成功"; | ||
197 | + }else{ | ||
198 | + mes="修改失败"; | ||
199 | + } | ||
200 | + if(data.data==1){ | ||
201 | + | ||
202 | + var dialog = $("<div>").appendTo($("body")); | ||
203 | + dialog.dialog({ | ||
204 | + title :mes, | ||
205 | + backdrop : "static", | ||
206 | + content : mes, | ||
207 | + buttons : [{ | ||
208 | + text : "确定", | ||
209 | + className : "btn-success", | ||
210 | + onclick : function() { | ||
211 | + $(dialog).dialog("hide"); | ||
212 | + $("#detailTable").table("load"); | ||
213 | + } | ||
214 | + }] | ||
215 | + }); | ||
216 | + } | ||
217 | + $(dialog0).dialog("hide"); | ||
218 | + } | ||
219 | + }); | ||
220 | + } | ||
221 | + }] | ||
222 | + }); | ||
223 | +} | ||
224 | + | ||
225 | +</script> | ||
226 | +<script src="<%=basePath %>script/common/genarate_left_panel.js"></script> | ||
227 | +<script type="text/javascript"> | ||
228 | + $("#li_config").addClass("active open"); | ||
229 | + $("#li_zkMonitor_log4j").addClass("active"); | ||
230 | +</script> | ||
231 | +</html> |
@@ -66,8 +66,9 @@ innerHTML += "</ul></li>"; | @@ -66,8 +66,9 @@ innerHTML += "</ul></li>"; | ||
66 | innerHTML += "</ul></li>";*/ | 66 | innerHTML += "</ul></li>";*/ |
67 | 67 | ||
68 | /*配置管理*/ | 68 | /*配置管理*/ |
69 | -innerHTML += "<li class='submenu' id='li_config'><a id='li_config_a' href='#'><i class='icon icon-th-list'></i> <span>配置管理</span><span class='label'>8</span></a><ul>"; | 69 | +innerHTML += "<li class='submenu' id='li_config'><a id='li_config_a' href='#'><i class='icon icon-th-list'></i> <span>配置管理</span><span class='label'>9</span></a><ul>"; |
70 | innerHTML += "<li id='li_zkMonitor'><a id='li_zkMonitor_a' href=''><i class='icon icon-th'></i> <span>ZK配置管理</span></a></li>"; | 70 | innerHTML += "<li id='li_zkMonitor'><a id='li_zkMonitor_a' href=''><i class='icon icon-th'></i> <span>ZK配置管理</span></a></li>"; |
71 | +innerHTML += "<li id='li_zkMonitor_log4j'><a id='li_zkMonitor_log4j_a' href=''><i class='icon icon-th'></i> <span>ZK_log4j配置管理</span></a></li>"; | ||
71 | innerHTML += "<li id='li_nginxSync'><a id='li_nginxSync_a' href=''><i class='icon icon-th'></i> <span>Nginx配置同步</span></a></li>"; | 72 | innerHTML += "<li id='li_nginxSync'><a id='li_nginxSync_a' href=''><i class='icon icon-th'></i> <span>Nginx配置同步</span></a></li>"; |
72 | innerHTML += "<li id='li_degrade_info'><a id='li_degrade_info_a' href=''><i class='icon icon-th'></i> <span>降级服务配置</span></a></li>"; | 73 | innerHTML += "<li id='li_degrade_info'><a id='li_degrade_info_a' href=''><i class='icon icon-th'></i> <span>降级服务配置</span></a></li>"; |
73 | innerHTML += "<li id='li_app_degrade'><a id='li_app_degrade_a' href=''><i class='icon icon-th'></i> <span>APP降级管理</span></a></li>"; | 74 | innerHTML += "<li id='li_app_degrade'><a id='li_app_degrade_a' href=''><i class='icon icon-th'></i> <span>APP降级管理</span></a></li>"; |
@@ -157,6 +158,7 @@ document.getElementById("changepwd_a").setAttribute("href", path + "/user/toupda | @@ -157,6 +158,7 @@ document.getElementById("changepwd_a").setAttribute("href", path + "/user/toupda | ||
157 | document.getElementById("li_sms_a").setAttribute("href", path + "/sms/toSmsLog"); | 158 | document.getElementById("li_sms_a").setAttribute("href", path + "/sms/toSmsLog"); |
158 | document.getElementById("li_search_compare_a").setAttribute("href", path + "/searchCompare/getComparePage"); | 159 | document.getElementById("li_search_compare_a").setAttribute("href", path + "/searchCompare/getComparePage"); |
159 | document.getElementById("li_zkMonitor_a").setAttribute("href", path + "/zkTree/tozkMonitorList"); | 160 | document.getElementById("li_zkMonitor_a").setAttribute("href", path + "/zkTree/tozkMonitorList"); |
161 | +document.getElementById("li_zkMonitor_log4j_a").setAttribute("href", path + "/zkTree/tozkMonitorList4Log4j"); | ||
160 | document.getElementById("li_user_a").setAttribute("href", path + "/manage/toUser"); | 162 | document.getElementById("li_user_a").setAttribute("href", path + "/manage/toUser"); |
161 | document.getElementById("li_module_a").setAttribute("href", path + "/manage/toModule"); | 163 | document.getElementById("li_module_a").setAttribute("href", path + "/manage/toModule"); |
162 | document.getElementById("li_taskConfigure_a").setAttribute("href", path + "/taskConfigure/toTaskConfigure"); | 164 | document.getElementById("li_taskConfigure_a").setAttribute("href", path + "/taskConfigure/toTaskConfigure"); |
1 | +/** | ||
2 | + * Created by frw on 2016/6/17. | ||
3 | + */ | ||
4 | + | ||
5 | +var selectedNodeId = null; | ||
6 | + | ||
7 | +var treeData = []; | ||
8 | +var nodeId2id = function (nodeid) { | ||
9 | + if (nodeid == "#") { | ||
10 | + return 0; | ||
11 | + } else { | ||
12 | + return nodeid.split("_")[1]; | ||
13 | + } | ||
14 | +}; | ||
15 | + | ||
16 | +var getPath = function (nodeid) { | ||
17 | + var paths = []; | ||
18 | + var num = 0; | ||
19 | + var currentId = nodeid; | ||
20 | + while (currentId != "#") { | ||
21 | + var node = $("#jstree").jstree().get_node(currentId); | ||
22 | + paths.push(node.text); | ||
23 | + num++; | ||
24 | + currentId = node.parent; | ||
25 | + } | ||
26 | + | ||
27 | + var strPath = ""; | ||
28 | + for (var i = 0; i < num; i++) { | ||
29 | + strPath += paths.pop() + "/"; | ||
30 | + } | ||
31 | + return strPath; | ||
32 | +} | ||
33 | + | ||
34 | +var openTree = function (node_id, level) { | ||
35 | +// console.log("open tree" + node_id); | ||
36 | + try { | ||
37 | + var node = $("#jstree").jstree().get_node(node_id); | ||
38 | + $("#jstree").jstree("open_node", node); | ||
39 | + var children = node.children; | ||
40 | + } catch (e) { | ||
41 | + console.warn(e); | ||
42 | + return; | ||
43 | + } | ||
44 | +// console.log("open children" +children); | ||
45 | + if (level <= 1) | ||
46 | + return; | ||
47 | + level--; | ||
48 | + $.each(children, function (n, data) { | ||
49 | + openTree(data, level); | ||
50 | + }); | ||
51 | +} | ||
52 | + | ||
53 | +var addType = function (node) { | ||
54 | + var rel = 0; | ||
55 | + var pid; | ||
56 | + var name; | ||
57 | + var isleaf; | ||
58 | + $('#modal_type_update').hide(); | ||
59 | + $('#modal_type_del').hide(); | ||
60 | + $('#modal_type_add').show(); | ||
61 | + $('#myModalLabel').html("添加类型"); | ||
62 | + $('#cb_new_type_isleaf').prop("checked", true);// 默认为子节点 | ||
63 | + $('#tx_new_type_name').val(""); | ||
64 | + $('#tx_type_id').val(nodeId2id(node.id)); | ||
65 | + $('#tx_type_action').val("add"); | ||
66 | + $('#tx_new_type_isleaf').val(1); | ||
67 | + $('#tx_new_type_parent').val(getPath(node.id)); | ||
68 | + $('#myModal').modal({keyboard: true}); | ||
69 | + | ||
70 | + return rel; | ||
71 | +}; | ||
72 | + | ||
73 | +var doAddType = function () { | ||
74 | + var pid = $('#tx_type_id').val(); | ||
75 | + var name = $('#tx_new_type_name').val(); | ||
76 | + if (name == null || $('#tx_new_type_name').val() == "") { | ||
77 | + $.toaster('输入类型名', '提示', 'warning'); | ||
78 | + return; | ||
79 | + } | ||
80 | + var isleaf = $('#cb_new_type_isleaf').prop("checked") == true ? 1 : 0; | ||
81 | + $.get("type/add", {"pid": pid, "name": name, "isleaf": isleaf}, | ||
82 | + function (data, state) { | ||
83 | + var repjson = JSON.parse(data); | ||
84 | + if (state == "success" && repjson.code == 200) { | ||
85 | + $.toaster('添加成功', '提示', 'info'); | ||
86 | + console.log(repjson.data); | ||
87 | + var newNode = repjson.data; | ||
88 | + $('#jstree').jstree().create_node("#node_" + newNode.typeParentId, | ||
89 | + { | ||
90 | + 'id': "node_" + newNode.typeId, | ||
91 | + 'text': newNode.typeName, | ||
92 | + 'parent': "#node_" + newNode.typeParentId, | ||
93 | + 'data': newNode.typeIsLeaf | ||
94 | + }, 'last'); | ||
95 | + $('#jstree').jstree().get_node("node_" + newNode.typeId).data = newNode.typeIsLeaf; | ||
96 | + } else | ||
97 | + $.toaster('添加失败' + repjson.code + " " + repjson.message, '提示', 'warning'); | ||
98 | + } | ||
99 | + ).fail(function () { | ||
100 | + $.toaster('添加失败:', '提示', 'warning'); | ||
101 | + }); | ||
102 | + $('#myModal').dialog('hide'); | ||
103 | +} | ||
104 | + | ||
105 | +/** | ||
106 | + * 获取所有选择节点 | ||
107 | + * @param isleaf true:仅获取叶子节点;false:所有节点 | ||
108 | + * @returns {Array} | ||
109 | + */ | ||
110 | +var getSelectType = function (isleaf) { | ||
111 | + var seltypes = []; | ||
112 | + $.each($("#jstree").jstree('get_selected'), function (idx, nodeid) { | ||
113 | + var node = $('#jstree').jstree().get_node(nodeid); | ||
114 | + if (isleaf == true && node.data != 1) | ||
115 | + return; | ||
116 | + seltypes.push(nodeId2id(nodeid)); | ||
117 | + }); | ||
118 | + | ||
119 | + return seltypes; | ||
120 | + | ||
121 | +} | ||
122 | + | ||
123 | + | ||
124 | +/** | ||
125 | + * 检查节点是否子节点 | ||
126 | + * @param nodeid | ||
127 | + * @returns {boolean} | ||
128 | + */ | ||
129 | +var checkIsLeaf = function (nodeid) { | ||
130 | + var node = $('#jstree').jstree().get_node(nodeid); | ||
131 | + var isLeaf = node.data == 1 ? true : false; | ||
132 | + return isLeaf; | ||
133 | +} | ||
134 | + | ||
135 | + | ||
136 | +$("#btn4type").click(function () { | ||
137 | + console.log("frw"); | ||
138 | + if ($("#tx_type_action").val() == "add") { | ||
139 | + doAddType(); | ||
140 | + } | ||
141 | +}); | ||
142 | + | ||
143 | + | ||
144 | +/** | ||
145 | + * 根据选中的节点获取信息 | ||
146 | + */ | ||
147 | +function searchType(ip, children, nodeId){ | ||
148 | + | ||
149 | + //非叶子节点不处理 | ||
150 | + if(children.length != 0) { | ||
151 | + return; | ||
152 | + } | ||
153 | + | ||
154 | + //将原来选中的节点的背景颜色去掉 | ||
155 | + if(selectedNodeId != null) { | ||
156 | + var nodeStyle = document.getElementById(selectedNodeId).style; | ||
157 | + nodeStyle.backgroundColor=""; | ||
158 | + nodeStyle.color="black"; | ||
159 | + //document.getElementById(selectedNodeId).style.backgroundColor=""; | ||
160 | + } | ||
161 | + | ||
162 | + //给选中的节点添加背景颜色 | ||
163 | + var nodeStyle = document.getElementById(nodeId).style; | ||
164 | + nodeStyle.backgroundColor = "#3392e3"; | ||
165 | + nodeStyle.color = "#ffffff"; | ||
166 | + selectedNodeId = nodeId; | ||
167 | + | ||
168 | + $("#detailTable").hide(); | ||
169 | + $("#rootTable").table({ | ||
170 | + url: contextPath + "/zkTree/getRoot4Log4j?ip="+ip, | ||
171 | + striped: true, | ||
172 | + panelClass: "panel-success", | ||
173 | + pagination: false, | ||
174 | + loadFilter: function (data) { | ||
175 | + return defaultLoadFilter(data); | ||
176 | + }, | ||
177 | + columns: [{ | ||
178 | + title: "名称", | ||
179 | + field: "name", | ||
180 | + formatter: function (value, rowData, rowIndex) { | ||
181 | + var div = $("<div>"); | ||
182 | + var input = $("<input type=\"button\">").addClass("form-control").attr({ | ||
183 | + id :"name", | ||
184 | + name : "name", | ||
185 | + style : "border: none;", | ||
186 | + value : value | ||
187 | + }).appendTo(div); | ||
188 | + input.click(function () { | ||
189 | + toDetail(rowData,ip); | ||
190 | + }); | ||
191 | + return div; | ||
192 | + } | ||
193 | + }, { | ||
194 | + title: "路径", | ||
195 | + field: "root" | ||
196 | + }], | ||
197 | + }); | ||
198 | +} | ||
199 | + | ||
200 | + | ||
201 | + | ||
202 | +var refreshTypeTree = function () { | ||
203 | + console.log("refresh tree"); | ||
204 | + treeData = []; //重置 | ||
205 | + $.get(contextPath+"type/zkTree", function (data, state) { | ||
206 | + console.log(state) | ||
207 | + var jsonData = JSON.parse(data); | ||
208 | + $.each(jsonData.data, function (n, val) { | ||
209 | + var treeNode = {}; | ||
210 | + treeNode.id = "node_" + val.typeId; | ||
211 | + treeNode.parent = (val.typeParentId == 0 ? "#" : "node_" + val.typeParentId); | ||
212 | + treeNode.text = val.typeName; | ||
213 | + treeNode.data = val.typeIsLeaf; | ||
214 | + treeData.push(treeNode) | ||
215 | + }); | ||
216 | + $('#jstree').jstree(true).settings.core.data = treeData; | ||
217 | + $('#jstree').jstree().refresh(true, true); | ||
218 | + | ||
219 | + setTimeout("openTree('#', 3)", 300); //展开三层 | ||
220 | + }); | ||
221 | +} | ||
222 | + | ||
223 | + | ||
224 | +$('#jstree').jstree({ | ||
225 | + "plugins": ["themes", "contextmenu", "ui", "types", "crrm", "core", "status"], | ||
226 | + 'core': { | ||
227 | + "themes": { | ||
228 | + name: 'proton', | ||
229 | + dots: false, | ||
230 | + icons: false | ||
231 | + }, | ||
232 | + 'data': treeData, | ||
233 | + 'check_callback': true | ||
234 | + } | ||
235 | +}).bind("changed.jstree", | ||
236 | + function (e, data) { | ||
237 | + console.log(data); | ||
238 | + console.log("Checked: " + data.node.text); | ||
239 | + searchType(data.node.text, data.node.children, data.node.a_attr.id); | ||
240 | + }); | ||
241 | +refreshTypeTree(); |
-
Please register or login to post a comment