Authored by unknown

配置中心

... ... @@ -70,6 +70,13 @@ public class HttpUriContants {
public static final String EDIT_ZK_DETAIL = "/zkMonitor/editZkMonitorDetail";
public static final String EDIT_ZK_ROOT = "/zkMonitor/editZkMonitorRoot";
/**
* 配置中心
*/
public static final String GET_ZK_TREE_CONFIGCENTER = "/zkMonitor/getZkConfigCenterTree";
public static final String BATCHIMPORT_ZK_ROOT_CONFIGCENTER = "/zkMonitor/batchImport";
public static final String ADD_ZK_ROOT = "/zkMonitor/addZkConfigCenterRoot";
/***
* ZK监控信息查询 log4j
****/
... ...
... ... @@ -2,6 +2,8 @@ package com.ui.model.req;
import lombok.Data;
import java.util.Properties;
@Data
public class ZkTreeReq extends PageRequest{
... ... @@ -13,4 +15,6 @@ public class ZkTreeReq extends PageRequest{
private String root;
private String oldRoot;
private Properties properties;
}
... ...
... ... @@ -32,5 +32,9 @@
<version>1.0-rc2</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
... ...
... ... @@ -5,7 +5,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import com.ui.contants.HttpUriContants;
... ... @@ -14,6 +16,9 @@ import com.ui.model.BaseResponse;
import com.ui.model.req.ZkDetailReq;
import com.ui.model.req.ZkTreeReq;
import javax.servlet.http.HttpSession;
import java.util.Properties;
/**
*
* @author yoho
... ... @@ -34,6 +39,11 @@ public class ZkMonitorTreeCtrl {
return new ModelAndView("zkMonitor/zkMonitorList");
}
@RequestMapping("/tozkConfigCenterList")
public ModelAndView tozkConfigCenter() {
return new ModelAndView("zkConfigCenter/zkConfigCenterList");
}
@RequestMapping("/tozkMonitorList4Log4j")
public ModelAndView tozkMonitorList4Log4j() {
return new ModelAndView("zkMonitor/zkMonitorList4Log4j");
... ... @@ -47,6 +57,14 @@ public class ZkMonitorTreeCtrl {
return response;
}
@RequestMapping("/getRootConfigCenter")
@ResponseBody
public BaseResponse getRootConfigCenter(ZkTreeReq req){
log.info("getRootConfigCenter with req is {}",req);
BaseResponse response=httpClient.defaultPost(HttpUriContants.GET_ZK_TREE_CONFIGCENTER, req, BaseResponse.class);
return response;
}
@RequestMapping("/getRoot4Log4j")
@ResponseBody
public BaseResponse getRoot4Log4j(ZkTreeReq req){
... ... @@ -78,4 +96,28 @@ public class ZkMonitorTreeCtrl {
BaseResponse response=httpClient.defaultPost(HttpUriContants.EDIT_ZK_ROOT, req, BaseResponse.class);
return response;
}
@RequestMapping("/addRoot")
@ResponseBody
public BaseResponse addRoot(ZkTreeReq req){
log.info("addRoot with req is {}",req);
BaseResponse response=httpClient.defaultPost(HttpUriContants.ADD_ZK_ROOT, req, BaseResponse.class);
return response;
}
@RequestMapping("/batchImport")
@ResponseBody
public BaseResponse batchImport(ZkTreeReq req, @RequestParam("file") MultipartFile file){
log.info("batchImport with req is {}", req);
Properties properties = new Properties();
try {
properties.load(file.getInputStream());
req.setProperties(properties);
} catch (Exception e) {
log.error("get zk batchImport file info failed", e);
}
BaseResponse response=httpClient.defaultPost(HttpUriContants.BATCHIMPORT_ZK_ROOT_CONFIGCENTER, req, BaseResponse.class);
return response;
}
}
... ...
... ... @@ -48,6 +48,14 @@
</property>
</bean>
<!-- 配置MultipartResolver 用于文件上传 使用spring的CommosMultipartResolver -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="defaultEncoding" value="UTF-8"></property>
<property name="maxUploadSize" value="1048576"></property>
<!-- <property name="uploadTempDir" value="${file.uploadTempDir}"></property>-->
<property name="resolveLazily" value="true"></property>
</bean>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
... ...
<%@page language="java" contentType="text/html;charset=utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<form method="post" class="form-horizontal" id="zkImportForm" name="zkImportForm" enctype="multipart/form-data">
<input type="hidden" name="ip" id="ip">
<div class="form-group">
<label class="col-sm-2 control-label">名称:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="name" name="name" maxlength="30" size="40" readonly="readonly"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">路径:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="root" name="root" readonly="readonly"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">文件:</label>
<div class="col-sm-8">
<input id="file" name="file" type="file" style="display:none">
<div class="input-append">
<input id="filepath" class="input-large" type="text" style="height:30px;" readonly="readonly">
<a class="btn" onclick="$('input[id=file]').click();">选择</a>
</div>
</div>
</div>
<div id="tip" style="color:red;font-size: 16px; text-align: center;">上传文件格式必须为.properties</div>
</form>
<script>
$(function(){
$("#zkImportForm #name").val(paramObj.name);
$("#zkImportForm #root").val(paramObj.root);
$('input[id=file]').change(function() {
$('#filepath').val($(this).val());
});
})
</script>
\ No newline at end of file
... ...
<%@page language="java" contentType="text/html;charset=utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=basePath %>css/bootstrap.min.css"/>
<link rel="stylesheet" href="<%=basePath %>css/bootstrap-datetimepicker.css"/>
<link href="<%=basePath %>js/bootstrap-plugin/css/bootstrap.table.css" rel="stylesheet" media="screen"/>
<link rel="stylesheet" href="<%=basePath %>css/bootstrap-responsive.min.css"/>
<link rel="stylesheet" href="<%=basePath %>css/fullcalendar.css"/>
<link rel="stylesheet" href="<%=basePath %>css/unicorn.main.css"/>
<link rel="stylesheet" href="<%=basePath %>css/unicorn.grey.css"/>
<link rel="stylesheet" href="<%=basePath %>css/jquery-ui.css"/>
<link rel="stylesheet" href="<%=basePath %>css/uniform.css"/>
<link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
<link rel="stylesheet" href="<%=basePath %>js/jstree/themes/proton/style.css"/>
<link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
<link rel="stylesheet" href="<%=basePath %>css/yoho.css"/>
<script src="<%=basePath %>js/excanvas.min.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jquery-1.12.0.min.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jquery-ui.custom.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>/js/bootstrap.min.js"></script>
<script src="<%=basePath %>/js/unicorn.js"></script>
<script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/moment-with-locales.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/bootstrap-datetimepicker.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/global.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.pagination.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.table.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.dialog.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.panel.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.alerts.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.accordion.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.breadcrumb.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.validate.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/layer/layer.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.select.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jstree/jstree.js"></script>
<script src="<%=basePath %>js/jquery.toaster.js"></script>
<link href="<%=basePath %>css/jquery.tagsinput.css" rel="stylesheet"/>
<script src="<%=basePath %>js/jquery.tagsinput.min.js" type="text/javascript"></script>
<script>
var contextPath = '<%=basePath %>';
</script>
<title>YOHO!运维</title>
</head>
<body>
<!-- 头部 -->
<div id="head">
</div>
<!-- 右侧具体内容 -->
<div id="content">
<div id="breadcrumb">
<a href="#" title="Go to Home" class="tip-bottom"><i
class="icon-home"></i> Home</a> <a href="#" class="current">监控对象</a>
</div>
<div class="container-fluid">
<div class="widget-box">
<div class="widget-title">
<h5>ZK配置</h5>
</div>
<!-- 树 -->
<div style="float: left;width: 250px;color: #D3D3D3;height: 600px;">
<div class="widget-title" style="height: 50px;">
<h5>节点展示</h5>
</div>
<div class="tree_container" style="height: 540px;color: black;overflow:auto;">
<div id="jstree" class="jstree jstree-default" role="tree" aria-multiselectable="true"
tabindex="0"></div>
</div>
</div>
<!-- 列表 -->
<div class="widget-content nopadding" style="border-left: 1px solid #E5E5E5;width: 450px;float: left;">
<div class="widget-title" style="height: 50px;">
<h5>根路径</h5>
</div>
<div class="widget-content nopadding">
<div class="tree_container" style="height: 540px;color: black;overflow:auto;">
<button id="add_btn" class="btn btn-success btn-rounded" onclick="addRoot()" style="margin: 15px;display: none;">新增</button>
<div id="rootTable"></div>
</div>
</div>
</div>
<div class="widget-content nopadding" style="margin-left: 700px;border-left: 1px solid #E5E5E5;">
<div class="widget-title" style="height: 50px;">
<h5>节点详情</h5>
</div>
<div class="widget-content nopadding">
<div class="tree_container" style="height: 540px;color: black;overflow:auto;">
<div id="detailTable"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script type="text/javascript" src="<%=basePath %>/script/yoho.type.zktree.configcenter.js"></script>
<script>
function toDetail(rowData,ip){
$("#detailTable").show();
$(function () {
$("#detailTable").table({
url: contextPath + "/zkTree/getAll?ip="+ip+"&zkPath="+rowData.root,
striped : true,
pagination : false,
loadFilter: function (data) {
return defaultLoadFilter(data);
},
columns: [{
title: "名称",
width:"60%",
align:"left",
field: "zkName"
}, {
title: "值",
width:"20%",
field: "zkValue"
}, {
title: "操作",
width:"20%",
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
//修改
var editBtn = $("<button data-target='#updateModal' data-toggle='modal'>").addClass("btn btn-xs btn-success").html("修改").appendTo(div);
editBtn.click(function () {
updateMObject(rowData);
});
return div;
}
}],
});
});
}
function updateMObject(rowData){
paramObj.zkPath = rowData.zkPath;
paramObj.zkValue = rowData.zkValue;
paramObj.zkName = rowData.zkName;
var dialog0 = $("<div>").appendTo($("body"));
dialog0.dialog({
size : "modal-lg",
title : "修改路径",
backdrop : "static",
href : contextPath +"/jsp/zkMonitor/zkMonitorEdit.jsp",
buttons : [{
text : "关闭",
className : "btn-danger",
onclick : function() {
$(dialog0).dialog("hide");
}
}, {
text : "提交",
className : "btn-success",
onclick : function() {
var btn = $(this);
$(dialog0).dialog("hide");
$("#zkInfoForm").form("submit", {
submitUrl : contextPath + "/zkTree/editDetail.do",
submitData : {
ip : rowData.ip,
zkPath : rowData.zkPath
},
onBeforeSubmit : function() {
if (!$(this).form("validate")) {
btn.removeAttr("disabled");
return false;
}
},
success : function(data) {
var mes="";
if(data.data==1){
mes="修改成功";
}else{
mes="修改失败";
}
if(data.data==1){
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
title :mes,
backdrop : "static",
content : mes,
buttons : [{
text : "确定",
className : "btn-success",
onclick : function() {
$(dialog).dialog("hide");
$("#detailTable").table("load");
}
}]
});
}
$(dialog0).dialog("hide");
}
});
}
}]
});
}
</script>
<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
<script type="text/javascript">
$("#li_config").addClass("active open");
$("#li_zkConfigCenter").addClass("active");
</script>
</html>
\ No newline at end of file
... ...
<%@page language="java" contentType="text/html;charset=utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<form class="form-horizontal" id="zkRootInfoForm" name="zkRootInfoForm">
<div class="form-group">
<label class="col-sm-2 control-label">路径:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="zkRoot" name="zkRoot" value="/yh/config/"/>
</div>
</div>
<div id="oldRoot"></div>
</form>
... ...
... ... @@ -68,6 +68,7 @@ innerHTML += "</ul></li>";
/*配置管理*/
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>";
innerHTML += "<li id='li_zkMonitor'><a id='li_zkMonitor_a' href=''><i class='icon icon-th'></i> <span>ZK配置管理</span></a></li>";
innerHTML += "<li id='li_zkConfigCenter'><a id='li_zkConfigCenter_a' href=''><i class='icon icon-th'></i> <span>配置中心</span></a></li>";
innerHTML += "<li id='li_zkMonitor_log4j'><a id='li_zkMonitor_log4j_a' href=''><i class='icon icon-th'></i> <span>Log4j配置管理</span></a></li>";
innerHTML += "<li id='li_nginxSync'><a id='li_nginxSync_a' href=''><i class='icon icon-th'></i> <span>Nginx配置同步</span></a></li>";
innerHTML += "<li id='li_degrade_info'><a id='li_degrade_info_a' href=''><i class='icon icon-th'></i> <span>降级服务配置</span></a></li>";
... ... @@ -161,6 +162,7 @@ document.getElementById("changepwd_a").setAttribute("href", path + "/user/toupda
document.getElementById("li_sms_a").setAttribute("href", path + "/sms/toSmsLog");
document.getElementById("li_search_compare_a").setAttribute("href", path + "/searchCompare/getComparePage");
document.getElementById("li_zkMonitor_a").setAttribute("href", path + "/zkTree/tozkMonitorList");
document.getElementById("li_zkConfigCenter_a").setAttribute("href", path + "/zkTree/tozkConfigCenterList");
document.getElementById("li_zkMonitor_log4j_a").setAttribute("href", path + "/zkTree/tozkMonitorList4Log4j");
document.getElementById("li_user_a").setAttribute("href", path + "/manage/toUser");
document.getElementById("li_module_a").setAttribute("href", path + "/manage/toModule");
... ...
/**
* Created by frw on 2016/6/17.
*/
var selectedNodeId = null;
var treeData = [];
var nodeId2id = function (nodeid) {
if (nodeid == "#") {
return 0;
} else {
return nodeid.split("_")[1];
}
};
var getPath = function (nodeid) {
var paths = [];
var num = 0;
var currentId = nodeid;
while (currentId != "#") {
var node = $("#jstree").jstree().get_node(currentId);
paths.push(node.text);
num++;
currentId = node.parent;
}
var strPath = "";
for (var i = 0; i < num; i++) {
strPath += paths.pop() + "/";
}
return strPath;
}
var openTree = function (node_id, level) {
// console.log("open tree" + node_id);
try {
var node = $("#jstree").jstree().get_node(node_id);
$("#jstree").jstree("open_node", node);
var children = node.children;
} catch (e) {
console.warn(e);
return;
}
// console.log("open children" +children);
if (level <= 1)
return;
level--;
$.each(children, function (n, data) {
openTree(data, level);
});
}
var addType = function (node) {
var rel = 0;
var pid;
var name;
var isleaf;
$('#modal_type_update').hide();
$('#modal_type_del').hide();
$('#modal_type_add').show();
$('#myModalLabel').html("添加类型");
$('#cb_new_type_isleaf').prop("checked", true);// 默认为子节点
$('#tx_new_type_name').val("");
$('#tx_type_id').val(nodeId2id(node.id));
$('#tx_type_action').val("add");
$('#tx_new_type_isleaf').val(1);
$('#tx_new_type_parent').val(getPath(node.id));
$('#myModal').modal({keyboard: true});
return rel;
};
var doAddType = function () {
var pid = $('#tx_type_id').val();
var name = $('#tx_new_type_name').val();
if (name == null || $('#tx_new_type_name').val() == "") {
$.toaster('输入类型名', '提示', 'warning');
return;
}
var isleaf = $('#cb_new_type_isleaf').prop("checked") == true ? 1 : 0;
$.get("type/add", {"pid": pid, "name": name, "isleaf": isleaf},
function (data, state) {
var repjson = JSON.parse(data);
if (state == "success" && repjson.code == 200) {
$.toaster('添加成功', '提示', 'info');
console.log(repjson.data);
var newNode = repjson.data;
$('#jstree').jstree().create_node("#node_" + newNode.typeParentId,
{
'id': "node_" + newNode.typeId,
'text': newNode.typeName,
'parent': "#node_" + newNode.typeParentId,
'data': newNode.typeIsLeaf
}, 'last');
$('#jstree').jstree().get_node("node_" + newNode.typeId).data = newNode.typeIsLeaf;
} else
$.toaster('添加失败' + repjson.code + " " + repjson.message, '提示', 'warning');
}
).fail(function () {
$.toaster('添加失败:', '提示', 'warning');
});
$('#myModal').dialog('hide');
}
/**
* 获取所有选择节点
* @param isleaf true:仅获取叶子节点;false:所有节点
* @returns {Array}
*/
var getSelectType = function (isleaf) {
var seltypes = [];
$.each($("#jstree").jstree('get_selected'), function (idx, nodeid) {
var node = $('#jstree').jstree().get_node(nodeid);
if (isleaf == true && node.data != 1)
return;
seltypes.push(nodeId2id(nodeid));
});
return seltypes;
}
/**
* 检查节点是否子节点
* @param nodeid
* @returns {boolean}
*/
var checkIsLeaf = function (nodeid) {
var node = $('#jstree').jstree().get_node(nodeid);
var isLeaf = node.data == 1 ? true : false;
return isLeaf;
}
$("#btn4type").click(function () {
console.log("frw");
if ($("#tx_type_action").val() == "add") {
doAddType();
}
});
var curIp;
/**
* 根据选中的节点获取信息
*/
function searchType(ip, children, nodeId){
//非叶子节点不处理
if(children.length != 0) {
return;
}
//将原来选中的节点的背景颜色去掉
if(selectedNodeId != null) {
var nodeStyle = document.getElementById(selectedNodeId).style;
nodeStyle.backgroundColor="";
nodeStyle.color="black";
//document.getElementById(selectedNodeId).style.backgroundColor="";
}
//给选中的节点添加背景颜色
var nodeStyle = document.getElementById(nodeId).style;
nodeStyle.backgroundColor = "#3392e3";
nodeStyle.color = "#ffffff";
selectedNodeId = nodeId;
//新增按钮
curIp = ip;
$("#add_btn").css("display", "block");
$("#detailTable").hide();
$("#rootTable").table({
url: contextPath + "/zkTree/getRootConfigCenter?ip="+ip,
striped: true,
panelClass: "panel-success",
pagination: false,
loadFilter: function (data) {
return defaultLoadFilter(data);
},
columns: [{
title: "名称",
field: "name",
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
var input = $("<input type=\"button\">").addClass("form-control").attr({
id :"name",
name : "name",
style : "border: none;",
value : value
}).appendTo(div);
input.click(function () {
toDetail(rowData,ip);
});
return div;
}
}, {
title: "路径",
field: "root",
width: 200,
}, {
title: "操作",
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
//修改
var editBtn = $("<button data-target='#updateModal' data-toggle='modal'>").addClass("btn btn-xs btn-success").html("修改").appendTo(div);
editBtn.click(function () {
updateRoot(rowData,ip);
});
//导入
var importBtn = $("<button data-target='#importModal' data-toggle='modal' style='margin-left: 10px;'>").addClass("btn btn-xs btn-warning").html("导入").appendTo(div);
importBtn.click(function () {
importFile(rowData,ip);
});
return div;
}
}],
});
}
function addRoot(){
var dialog0 = $("<div>").appendTo($("body"));
dialog0.dialog({
size : "modal-lg",
title : "新增根路径",
backdrop : "static",
href : contextPath +"/jsp/zkConfigCenter/zkRootAdd.jsp",
buttons : [{
text : "关闭",
className : "btn-danger",
onclick : function() {
$(dialog0).dialog("hide");
}
}, {
text : "提交",
className : "btn-success",
onclick : function() {
var btn = $(this);
$(dialog0).dialog("hide");
$("#zkRootInfoForm").form("submit", {
submitUrl : contextPath + "/zkTree/addRoot",
submitData : {
ip : curIp,
root : $("#zkRootInfoForm #zkRoot").val()
},
onBeforeSubmit : function() {
if (!$(this).form("validate")) {
btn.removeAttr("disabled");
return false;
}
},
success : function(data) {
var mes="";
if (data.data==1) {
mes="新增成功";
} else {
mes="新增失败!确认节点是否已存在!";
}
if(data.data==1){
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
title :mes,
backdrop : "static",
content : mes,
buttons : [{
text : "确定",
className : "btn-success",
onclick : function() {
$(dialog).dialog("hide");
$("#rootTable").table("load");
}
}]
});
}
}
});
}
}]
});
}
function importFile(rowData,ip){
paramObj.name = rowData.name;
paramObj.root = rowData.root;
var dialog0 = $("<div>").appendTo($("body"));
dialog0.dialog({
size : "modal-lg",
title : "批量导入",
backdrop : "static",
href : contextPath +"/jsp/zkConfigCenter/zkConfigCenterImport.jsp",
buttons : [{
text : "关闭",
className : "btn-danger",
onclick : function() {
$(dialog0).dialog("hide");
}
}, {
text : "提交",
className : "btn-success",
onclick : function() {
var filepath = $("#zkImportForm #filepath").val();
if (filepath == "") {
alert("请选择文件!");
return;
}
if (filepath.indexOf(".properties") == -1) {
alert("文件格式不对!");
return;
}
$("#ip").val(ip);
var formData = new FormData($("#zkImportForm")[0]);
$(dialog0).dialog("hide");
$.ajax({
url: contextPath + "/zkTree/batchImport",
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
success: function (data) {
var mes="";
if (data.data > 0) {
mes="修改成功";
} else {
mes="修改失败";
}
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
title :mes,
backdrop : "static",
content : mes,
buttons : [{
text : "确定",
className : "btn-success",
onclick : function() {
$(dialog).dialog("hide");
$("#rootTable").table("load");
}
}]
});
},
error: function (returndata) {
alert(returndata);
}
});
}
}]
});
}
function updateRoot(rowData,ip){
paramObj.name = rowData.name;
paramObj.root = rowData.root;
var dialog0 = $("<div>").appendTo($("body"));
dialog0.dialog({
size : "modal-lg",
title : "修改路径",
backdrop : "static",
href : contextPath +"/jsp/zkMonitor/zkRootEdit.jsp",
buttons : [{
text : "关闭",
className : "btn-danger",
onclick : function() {
$(dialog0).dialog("hide");
}
}, {
text : "提交",
className : "btn-success",
onclick : function() {
var btn = $(this);
$(dialog0).dialog("hide");
$("#zkRootInfoForm").form("submit", {
submitUrl : contextPath + "/zkTree/editRoot",
submitData : {
ip : ip,
name : $("#zkRootInfoForm #zkName").val(),
root : $("#zkRootInfoForm #zkRoot").val(),
oldRoot : rowData.root
},
onBeforeSubmit : function() {
if (!$(this).form("validate")) {
btn.removeAttr("disabled");
return false;
}
},
success : function(data) {
var mes="";
if(data.data==1){
mes="修改成功";
}else{
mes="修改失败";
}
if(data.data==1){
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
title :mes,
backdrop : "static",
content : mes,
buttons : [{
text : "确定",
className : "btn-success",
onclick : function() {
$(dialog).dialog("hide");
$("#rootTable").table("load");
}
}]
});
}
}
});
}
}]
});
}
var refreshTypeTree = function () {
console.log("refresh tree");
treeData = []; //重置
$.get(contextPath+"type/zkTree", function (data, state) {
console.log(state)
var jsonData = JSON.parse(data);
$.each(jsonData.data, function (n, val) {
var treeNode = {};
treeNode.id = "node_" + val.typeId;
treeNode.parent = (val.typeParentId == 0 ? "#" : "node_" + val.typeParentId);
treeNode.text = val.typeName;
treeNode.data = val.typeIsLeaf;
treeData.push(treeNode)
});
$('#jstree').jstree(true).settings.core.data = treeData;
$('#jstree').jstree().refresh(true, true);
setTimeout("openTree('#', 3)", 300); //展开三层
});
}
$('#jstree').jstree({
"plugins": ["themes", "contextmenu", "ui", "types", "crrm", "core", "status"],
'core': {
"themes": {
name: 'proton',
dots: false,
icons: false
},
'data': treeData,
'check_callback': true
}
}).bind("changed.jstree",
function (e, data) {
console.log(data);
console.log("Checked: " + data.node.text);
searchType(data.node.text, data.node.children, data.node.a_attr.id);
});
refreshTypeTree();
... ...