Authored by FengRuwei

从数据库读取java服务类型

@@ -20,7 +20,7 @@ public class HttpUriContants { @@ -20,7 +20,7 @@ public class HttpUriContants {
20 public static String TYPE_DEL = "/type/delete"; 20 public static String TYPE_DEL = "/type/delete";
21 public static String TYPE_UPDATE = "/type/update"; 21 public static String TYPE_UPDATE = "/type/update";
22 public static String TYPE_QUERY_NODE = "/type/queryNode"; 22 public static String TYPE_QUERY_NODE = "/type/queryNode";
23 - 23 + public static String TYPE_QUERY_JAVAAPI = "/type/queryJavaApi";
24 24
25 /*** 主机信息 ****/ 25 /*** 主机信息 ****/
26 public static final String GET_HOST_INFOS = "/hostInfo/getHostInfos"; 26 public static final String GET_HOST_INFOS = "/hostInfo/getHostInfos";
@@ -97,6 +97,11 @@ public class TypeCtrl { @@ -97,6 +97,11 @@ public class TypeCtrl {
97 return response; 97 return response;
98 } 98 }
99 99
  100 + @RequestMapping("/queryJavaApiType")
  101 + @ResponseBody
  102 + public BaseResponse queryAllJavaApiType() throws Exception {
  103 + BaseResponse response=httpClient.defaultGet(HttpUriContants.TYPE_QUERY_JAVAAPI, BaseResponse.class);
  104 + return response;
  105 + }
100 106
101 -  
102 } 107 }
1 -<%@page language="java" contentType="text/html;charset=utf-8"%>  
2 -<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 1 +<%@page language="java" contentType="text/html;charset=utf-8" %>
  2 +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
3 3
4 <% 4 <%
5 - String path = request.getContextPath();  
6 - String basePath = request.getScheme() + "://"  
7 - + request.getServerName() + ":" + request.getServerPort()  
8 - + path + "/"; 5 + String path = request.getContextPath();
  6 + String basePath = request.getScheme() + "://"
  7 + + request.getServerName() + ":" + request.getServerPort()
  8 + + path + "/";
9 %> 9 %>
10 10
11 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 11 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
12 <html> 12 <html>
13 <head> 13 <head>
14 -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
15 -<link rel="stylesheet" href="<%=basePath %>css/bootstrap.min.css" />  
16 -<link href="<%=basePath %>js/bootstrap-plugin/css/bootstrap.table.css" rel="stylesheet" media="screen" />  
17 -<link rel="stylesheet" href="<%=basePath %>css/bootstrap-responsive.min.css" />  
18 -<link rel="stylesheet" href="<%=basePath %>css/fullcalendar.css" />  
19 -<link rel="stylesheet" href="<%=basePath %>css/unicorn.main.css" />  
20 -<link rel="stylesheet" href="<%=basePath %>css/unicorn.grey.css" class="skin-color" />  
21 -<link rel="stylesheet" href="<%=basePath %>css/jquery-ui.css" />  
22 -<link rel="stylesheet" href="<%=basePath %>css/uniform.css" />  
23 -<link rel="stylesheet" href="<%=basePath %>css/select2.css" />  
24 - <link rel="stylesheet" href="<%=basePath %>js/jstree/themes/proton/style.css"/>  
25 -<script src="<%=basePath %>js/jquery-1.12.0.min.js" charset="UTF-8" type="text/javascript"></script>  
26 -<script src="<%=basePath %>/js/bootstrap.min.js"></script>  
27 -<script src="<%=basePath %>js/global.js" charset="UTF-8" type="text/javascript"></script>  
28 -<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.pagination.js" charset="UTF-8" type="text/javascript"></script>  
29 -<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.table.js" charset="UTF-8" type="text/javascript"></script>  
30 -<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.dialog.js" charset="UTF-8" type="text/javascript"></script>  
31 -<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>  
32 -<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.panel.js" charset="UTF-8" type="text/javascript"></script>  
33 -<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.alerts.js" charset="UTF-8" type="text/javascript"></script>  
34 -<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.accordion.js" charset="UTF-8" type="text/javascript"></script>  
35 -<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.breadcrumb.js" charset="UTF-8" type="text/javascript"></script>  
36 -<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.validate.js" charset="UTF-8" type="text/javascript"></script>  
37 -<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>  
38 -<script src="<%=basePath %>js/layer/layer.js" charset="UTF-8" type="text/javascript"></script>  
39 -<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.select.js" charset="UTF-8" type="text/javascript"></script>  
40 - <script src="<%=basePath %>js/jstree/jstree.min.js"></script>  
41 - <script src="<%=basePath %>js/jquery.toaster.js"></script>  
42 -<script>  
43 - var contextPath='<%=basePath %>';  
44 -</script> 14 + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  15 + <link rel="stylesheet" href="<%=basePath %>css/bootstrap.min.css"/>
  16 + <link href="<%=basePath %>js/bootstrap-plugin/css/bootstrap.table.css" rel="stylesheet" media="screen"/>
  17 + <link rel="stylesheet" href="<%=basePath %>css/bootstrap-responsive.min.css"/>
  18 + <link rel="stylesheet" href="<%=basePath %>css/fullcalendar.css"/>
  19 + <link rel="stylesheet" href="<%=basePath %>css/unicorn.main.css"/>
  20 + <link rel="stylesheet" href="<%=basePath %>css/unicorn.grey.css" class="skin-color"/>
  21 + <link rel="stylesheet" href="<%=basePath %>css/jquery-ui.css"/>
  22 + <link rel="stylesheet" href="<%=basePath %>css/uniform.css"/>
  23 + <link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
  24 + <link rel="stylesheet" href="<%=basePath %>js/jstree/themes/proton/style.css"/>
  25 + <script src="<%=basePath %>js/jquery-1.12.0.min.js" charset="UTF-8" type="text/javascript"></script>
  26 + <script src="<%=basePath %>/js/bootstrap.min.js"></script>
  27 + <script src="<%=basePath %>js/global.js" charset="UTF-8" type="text/javascript"></script>
  28 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.pagination.js" charset="UTF-8"
  29 + type="text/javascript"></script>
  30 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.table.js" charset="UTF-8" type="text/javascript"></script>
  31 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.dialog.js" charset="UTF-8" type="text/javascript"></script>
  32 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
  33 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.panel.js" charset="UTF-8" type="text/javascript"></script>
  34 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.alerts.js" charset="UTF-8" type="text/javascript"></script>
  35 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.accordion.js" charset="UTF-8"
  36 + type="text/javascript"></script>
  37 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.breadcrumb.js" charset="UTF-8"
  38 + type="text/javascript"></script>
  39 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.validate.js" charset="UTF-8"
  40 + type="text/javascript"></script>
  41 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
  42 + <script src="<%=basePath %>js/layer/layer.js" charset="UTF-8" type="text/javascript"></script>
  43 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.select.js" charset="UTF-8" type="text/javascript"></script>
  44 + <script src="<%=basePath %>js/jstree/jstree.min.js"></script>
  45 + <script src="<%=basePath %>js/jquery.toaster.js"></script>
  46 + <script>
  47 + var contextPath = '<%=basePath %>';
  48 + </script>
45 49
46 -<title>YOHO!运维</title> 50 + <title>YOHO!运维</title>
47 </head> 51 </head>
48 <body> 52 <body>
49 53
50 - <!-- 头部 -->  
51 - <div id="head">  
52 - <h5 style="color: #E0EEE0;font-style:oblique;font-weight:900;font-size:200%;margin-left: 45px;margin-top: 40px;">YOHO</h5>  
53 - </div> 54 +<!-- 头部 -->
  55 +<div id="head">
  56 + <h5 style="color: #E0EEE0;font-style:oblique;font-weight:900;font-size:200%;margin-left: 45px;margin-top: 40px;">
  57 + YOHO</h5>
  58 +</div>
54 59
55 - <!-- 左侧菜单项 -->  
56 - <div id="sidebar">  
57 - <ul>  
58 - <li class=""><a href="#"><i class="icon icon-home"></i> <span>Dashboard</span></a></li>  
59 - <li class="" id="jspmobjectmobjectInfojsp" onclick="clickMenuToPage('jsp/mobject/mobjectInfo.jsp')"><a href="#" ><i class="icon icon-th"></i> <span>监控对象</span></a></li>  
60 - <li class="" id="jsphosthostGroupListjsp" onclick="clickMenuToPage('jsp/host/hostGroupList.jsp')" ><a href="#" ><i class="icon icon-th"></i> <span>主机组</span></a></li>  
61 - <li class="" id="jsphosthostInfoListjsp" onclick="clickMenuToPage('jsp/host/hostInfoList.jsp')" ><a href="#" ><i class="icon icon-th"></i> <span>主机信息</span></a></li>  
62 - <li class="" id="javaApiListjsp" onclick="clickMenuToPage('jsp/javaapi/javaApiList.jsp')" ><a href="#" ><i class="icon icon-th"></i> <span>JAVA服务信息</span></a></li> 60 +<!-- 左侧菜单项 -->
  61 +<div id="sidebar">
  62 + <ul>
  63 + <li class=""><a href="#"><i class="icon icon-home"></i> <span>Dashboard</span></a></li>
  64 + <li class="" id="jspmobjectmobjectInfojsp" onclick="clickMenuToPage('jsp/mobject/mobjectInfo.jsp')"><a href="#"><i
  65 + class="icon icon-th"></i> <span>监控对象</span></a></li>
  66 + <li class="" id="jsphosthostGroupListjsp" onclick="clickMenuToPage('jsp/host/hostGroupList.jsp')"><a href="#"><i
  67 + class="icon icon-th"></i> <span>主机组</span></a></li>
  68 + <li class="" id="jsphosthostInfoListjsp" onclick="clickMenuToPage('jsp/host/hostInfoList.jsp')"><a href="#"><i
  69 + class="icon icon-th"></i> <span>主机信息</span></a></li>
  70 + <li class="" id="jspjavaapijavaApiListjsp" onclick="clickMenuToPage('jsp/javaapi/javaApiList.jsp')"><a
  71 + href="#"><i class="icon icon-th"></i> <span>JAVA服务信息</span></a></li>
63 72
64 - </ul>  
65 - </div>  
66 - <!-- 右侧具体内容 -->  
67 - <div id="content"> 73 + </ul>
  74 +</div>
  75 +<!-- 右侧具体内容 -->
  76 +<div id="content">
68 77
69 - </div> 78 +</div>
70 79
71 - <script type="text/javascript">  
72 - function clickMenuToPage(page){  
73 - var g = page.replace(/\//g,"").replace(".","");  
74 - $("#"+g).addClass("active").siblings().removeClass("active");  
75 - //加载左侧内容  
76 - $("#content").load(contextPath+page);  
77 - } 80 +<script type="text/javascript">
  81 + function clickMenuToPage(page) {
  82 + var g = page.replace(/\//g, "").replace(".", "");
  83 + $("#" + g).addClass("active").siblings().removeClass("active");
  84 + //加载左侧内容
  85 + $("#content").load(contextPath + page);
  86 + }
78 87
79 - function localAlert(title,message){  
80 - var dialog = $("<div>").appendTo($("body"));  
81 - dialog.dialog({  
82 - title : title,  
83 - backdrop : "static",  
84 - content : message,  
85 - buttons : [{  
86 - text : "确定",  
87 - className : "btn-danger",  
88 - onclick : function() {  
89 - $(dialog).dialog("hide");  
90 - }  
91 - }]  
92 - });  
93 - }  
94 - </script>  
95 - </body> 88 + function localAlert(title, message) {
  89 + var dialog = $("<div>").appendTo($("body"));
  90 + dialog.dialog({
  91 + title: title,
  92 + backdrop: "static",
  93 + content: message,
  94 + buttons: [{
  95 + text: "确定",
  96 + className: "btn-danger",
  97 + onclick: function () {
  98 + $(dialog).dialog("hide");
  99 + }
  100 + }]
  101 + });
  102 + }
  103 +</script>
  104 +</body>
96 </html> 105 </html>
1 <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 1 <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
2 <%@page language="java" contentType="text/html;charset=utf-8" %> 2 <%@page language="java" contentType="text/html;charset=utf-8" %>
3 -<form method="post" class="form-horizontal" id="javaInfoForm" name="javaInfoForm"> 3 +<form class="form-horizontal" id="javaInfoForm" name="javaInfoForm">
4 4
5 <div class="form-group"> 5 <div class="form-group">
6 <label class="col-sm-2 control-label"> <span style="color:red">*</span>服务名:</label> 6 <label class="col-sm-2 control-label"> <span style="color:red">*</span>服务名:</label>
@@ -24,17 +24,14 @@ @@ -24,17 +24,14 @@
24 <label class="col-sm-2 control-label"> <span style="color:red">*</span>类型:</label> 24 <label class="col-sm-2 control-label"> <span style="color:red">*</span>类型:</label>
25 25
26 <div class="col-sm-2"> 26 <div class="col-sm-2">
27 - <select id="apiType" name="cloudType" class="form-control">  
28 - <option value="1">gateway</option>  
29 - <option value="2">order</option>  
30 - <option value="3">product</option> 27 + <select id="serviceType" name="serviceType" class="form-control">
31 </select> 28 </select>
32 </div> 29 </div>
33 30
34 <label class="col-sm-2 control-label"> <span style="color:red">*</span>请求类型:</label> 31 <label class="col-sm-2 control-label"> <span style="color:red">*</span>请求类型:</label>
35 32
36 <div class="col-sm-2"> 33 <div class="col-sm-2">
37 - <select id="requestType" name="cloudType" class="form-control"> 34 + <select id="apiReqMethod" name="apiReqMethod" class="form-control">
38 <option value="0">GET</option> 35 <option value="0">GET</option>
39 <option value="1">POST</option> 36 <option value="1">POST</option>
40 </select> 37 </select>
@@ -43,26 +40,26 @@ @@ -43,26 +40,26 @@
43 40
44 41
45 <div class="form-group"> 42 <div class="form-group">
46 - <label class="col-sm-2 control-label"> <span style="color:red">*</span>是否启用:</label> 43 + <label class="col-sm-2 control-label">是否启用:</label>
47 44
48 <div class="col-sm-2"> 45 <div class="col-sm-2">
49 - <input type="checkbox" id="apiIsUse" name="apiIsUse"> 46 + <input type="checkbox" id="apiToggle" name="apiToggle">
50 </div> 47 </div>
51 48
52 <label class="col-sm-2 control-label"> <span style="color:red">*</span>告警阈值:</label> 49 <label class="col-sm-2 control-label"> <span style="color:red">*</span>告警阈值:</label>
53 50
54 <div class="col-sm-2"> 51 <div class="col-sm-2">
55 - <input type="text" class="form-control" id="apiTrigger" name="apiTrigger" placeholder="输入告警阈值" 52 + <input type="text" class="form-control" id="apiWarnTrigger" name="apiWarnTrigger" placeholder="输入告警阈值"
56 maxlength="30" size="40"/> 53 maxlength="30" size="40"/>
57 </div> 54 </div>
58 </div> 55 </div>
59 56
60 57
61 <div class="form-group"> 58 <div class="form-group">
62 - <label class="col-sm-2 control-label"> <span style="color:red">*</span>请求参数:</label> 59 + <label class="col-sm-2 control-label">请求参数:</label>
63 60
64 <div class="col-sm-8"> 61 <div class="col-sm-8">
65 - <textarea class="form-control" rows="3"></textarea> 62 + <textarea id="apiData" name="apiData" class="form-control" rows="3"></textarea>
66 </div> 63 </div>
67 </div> 64 </div>
68 <div class="form-group"> 65 <div class="form-group">
@@ -75,39 +72,35 @@ @@ -75,39 +72,35 @@
75 72
76 <script> 73 <script>
77 74
  75 +
78 $(function () { 76 $(function () {
79 -// $("#javaInfoForm #groupId").select({  
80 -// valueField: "id",  
81 -// textField: "groupName",  
82 -// firstText: "请选择主机组类型",  
83 -// firstValue: 0,  
84 -// className: "form-control",  
85 -// url: contextPath + "/hostGroup/getAllGroups", 77 +
  78 + $.each(java_api_type, function (idx, val) {
  79 + var selObj = $("#javaInfoForm #serviceType");
  80 + var value = val.value;
  81 + var text = val.text;
  82 + selObj.append("<option value='" + value + "'>" + text + "</option>");
  83 + });
  84 +
  85 +
  86 +// //加载form
  87 +// $("#javaInfoForm").form({
  88 +// loadUrl: contextPath + "/hostInfo/getHostInfoById.do",
  89 +// loadParams: {
  90 +// id: paramObj.hoseInfoId
  91 +// },
86 // loadFilter: function (data) { 92 // loadFilter: function (data) {
87 // return defaultLoadFilter(data); 93 // return defaultLoadFilter(data);
88 // }, 94 // },
89 -// value: 0 95 +// onBeforeLoad: function (loadParams) {
  96 +// if (loadParams.hoseInfoId == 0) {
  97 +// return false;
  98 +// }
  99 +// },
  100 +// onLoadSuccess: function (data) {
  101 +// $("#javaInfoForm #hostIp").prop("readonly", true);
  102 +// }
90 // }); 103 // });
91 104
92 -  
93 - //加载form  
94 - $("#javaInfoForm").form({  
95 - loadUrl: contextPath + "/hostInfo/getHostInfoById.do",  
96 - loadParams: {  
97 - id: paramObj.hoseInfoId  
98 - },  
99 - loadFilter: function (data) {  
100 - return defaultLoadFilter(data);  
101 - },  
102 - onBeforeLoad: function (loadParams) {  
103 - if (loadParams.hoseInfoId == 0) {  
104 - return false;  
105 - }  
106 - },  
107 - onLoadSuccess: function (data) {  
108 - $("#javaInfoForm #hostIp").prop("readonly", true);  
109 - }  
110 - });  
111 -  
112 }); 105 });
113 </script> 106 </script>
@@ -23,12 +23,14 @@ @@ -23,12 +23,14 @@
23 </div> 23 </div>
24 <div class="input-group" style="float: left;"> 24 <div class="input-group" style="float: left;">
25 <span class="input-group-addon">服务类型:</span> 25 <span class="input-group-addon">服务类型:</span>
26 - <input type="text" id="searchapiType" name="apiType" class="form-control" placeholder=""/> 26 + <select id="searchApiType" name="searchApiType" class="form-control" placeholder=""/>
27 </div> 27 </div>
28 <div class="input-group" style="float: left;"> 28 <div class="input-group" style="float: left;">
29 <span class="input-group-addon">请求类型:</span> 29 <span class="input-group-addon">请求类型:</span>
30 - <input type="text" id="searchapiMethod" name="apiMethod" class="form-control"  
31 - placeholder=""/> 30 + <select id="searchApiReqMethod" name="searchApiReqMethod" class="form-control">
  31 + <option value="0">GET</option>
  32 + <option value="1">POST</option>
  33 + </select>
32 </div> 34 </div>
33 <div class="input-group" style="float: left;"> 35 <div class="input-group" style="float: left;">
34 <span class="input-group-addon">url:</span> 36 <span class="input-group-addon">url:</span>
@@ -39,6 +41,9 @@ @@ -39,6 +41,9 @@
39 <button id="addInfoBtn" class="btn btn-primary" style="margin-top: 12px;margin-left: 100px;"> 41 <button id="addInfoBtn" class="btn btn-primary" style="margin-top: 12px;margin-left: 100px;">
40 新增 42 新增
41 </button> 43 </button>
  44 + <button id="modeoBtn" class="btn btn-primary" style="margin-top: 12px;margin-left: 100px;">
  45 + 编辑模式
  46 + </button>
42 </div> 47 </div>
43 </div> 48 </div>
44 <div id="infoTable"> 49 <div id="infoTable">
@@ -48,8 +53,49 @@ @@ -48,8 +53,49 @@
48 </div> 53 </div>
49 </div> 54 </div>
50 <script> 55 <script>
  56 + var java_api_type=[];
  57 + var refreshTypeSelected=function(){
  58 + $.each(java_api_type,function(idx,val){
  59 + var selObj = $("#searchApiType");
  60 + var value=val.value;
  61 + var text=val.text;
  62 + selObj.append("<option value='"+value+"'>"+text+"</option>");
  63 + });
  64 +
  65 + };
  66 + var getTypeName=function(typeId){
  67 + for(var i=0;i<java_api_type.length;i++){
  68 + if(java_api_type[i].value==typeId){
  69 + return java_api_type[i].text;
  70 + }
  71 + }
  72 + return "unkown"
  73 +
  74 + };
51 $(function () { 75 $(function () {
52 76
  77 + $.ajax({
  78 + url: contextPath + "/type/queryJavaApiType",
  79 + type: 'get',
  80 + success: function (data) {
  81 + if (!data || data.code != 200) {
  82 + $.toaster('获取java服务类型失败', '警告', 'warn');
  83 + return;
  84 + }
  85 + $.each(data.data,function(idx,val){
  86 + java_api_type.push({
  87 + "value":val.typeId,
  88 + "text":val.typeName
  89 + });
  90 + })
  91 + refreshTypeSelected();
  92 + },
  93 + error: function (data) {
  94 + $.toaster('获取java服务类型失败', '警告', 'warn');
  95 +
  96 + }
  97 + });
  98 +
53 //加载表格 99 //加载表格
54 $("#infoTable").table({ 100 $("#infoTable").table({
55 columnAutoWidth: false, 101 columnAutoWidth: false,
@@ -65,7 +111,7 @@ @@ -65,7 +111,7 @@
65 columns: [{ 111 columns: [{
66 title: "ID", 112 title: "ID",
67 field: "serviceId", 113 field: "serviceId",
68 - width: "5%" 114 + width: "2%"
69 }, { 115 }, {
70 title: "服务名", 116 title: "服务名",
71 field: "apiName", 117 field: "apiName",
@@ -77,16 +123,48 @@ @@ -77,16 +123,48 @@
77 }, { 123 }, {
78 title: "服务类型", 124 title: "服务类型",
79 field: "serviceType", 125 field: "serviceType",
  126 + formatter:function(value,rowData,rowIndex) {
  127 + return getTypeName(rowData.serviceType);
  128 + },
80 width: "5%" 129 width: "5%"
81 130
82 }, { 131 }, {
  132 + title: "请求类型",
  133 + field: "apiMethod",
  134 + formatter: function (value, rowData, rowIndex) {
  135 + if (rowData.apiReqMethod == 0)
  136 + return "GET";
  137 + else
  138 + return "POST";
  139 + },
  140 + width: "4%"
  141 +
  142 + }, {
  143 + title: "告警阈值",
  144 + field: "apiTrigger",
  145 + width: "3%"
  146 +
  147 + }, {
  148 + title: "是否启用",
  149 + field: "apiIsUse",
  150 + width: "4%"
  151 +
  152 + }, {
  153 + title: "运行状态",
  154 + field: "apiStatus",
  155 + formatter: function (value, rowData, rowIndex) {
  156 + return "<span style='height: 200px' id='status_'+rowData.serviceId>192.168.0.1,192.168.0.1,192.168.0.1,192.168.0.1,192.168.0.1,192.168.0.1,192.168.0.1,192.168.0.1,192.168.0.1,192.168.0.1</span>"
  157 + },
  158 + width: "40%"
  159 +
  160 + },{
83 title: "操作", 161 title: "操作",
84 field: "op", 162 field: "op",
85 formatter: function (value, rowData, rowIndex) { 163 formatter: function (value, rowData, rowIndex) {
86 var div = $("<div>"); 164 var div = $("<div>");
87 var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("修改").appendTo(div); 165 var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("修改").appendTo(div);
88 editBtn.click(function () { 166 editBtn.click(function () {
89 - editJavaInfo(rowData.id); 167 + editJavaInfo(rowData);
90 }); 168 });
91 div.append("&nbsp;"); 169 div.append("&nbsp;");
92 var delBtn = $("<button>").addClass("btn btn-xs btn-danger").html("删除").appendTo(div); 170 var delBtn = $("<button>").addClass("btn btn-xs btn-danger").html("删除").appendTo(div);
@@ -110,7 +188,6 @@ @@ -110,7 +188,6 @@
110 $.ajax({ 188 $.ajax({
111 url: contextPath + "/javaApi/del?id=" + rowData.serviceId, 189 url: contextPath + "/javaApi/del?id=" + rowData.serviceId,
112 type: 'get', 190 type: 'get',
113 - async: false,  
114 dataType: "json", 191 dataType: "json",
115 success: function (data) { 192 success: function (data) {
116 if (!data || data.code != 200) { 193 if (!data || data.code != 200) {
@@ -128,11 +205,11 @@ @@ -128,11 +205,11 @@
128 }); 205 });
129 return div; 206 return div;
130 }, 207 },
131 - width: "15%" 208 + width: "7%"
132 }] 209 }]
133 }); 210 });
134 $("#addInfoBtn").click(function () { 211 $("#addInfoBtn").click(function () {
135 - editJavaInfo(0); 212 + editJavaInfo(null);
136 }); 213 });
137 }); 214 });
138 215
@@ -151,28 +228,45 @@ @@ -151,28 +228,45 @@
151 }); 228 });
152 }); 229 });
153 230
154 -  
155 //打开新增或修改页面 231 //打开新增或修改页面
156 - function editJavaInfo(javaInfoId) {  
157 - paramObj.hoseInfoId = javaInfoId; 232 + function editJavaInfo(rowData) {
  233 + console.log(rowData);
158 var dialog = $("<div>").appendTo($("body")); 234 var dialog = $("<div>").appendTo($("body"));
159 -  
160 var dialogTitle; 235 var dialogTitle;
161 - if(javaInfoId==0){  
162 - title="新增JAVA服务信息";  
163 - $("#javaInfoForm #serviceType").  
164 - }else{  
165 - title="修改JAVA服务信息";  
166 - $("#javaInfoForm #serviceType") 236 + var serviceId;
  237 + if (rowData == null || rowData == undefined || rowData.serviceId == 0) {
  238 + dialogTitle = "新增JAVA服务信息";
  239 + serviceId = 0;
  240 + } else {
  241 + dialogTitle = "修改JAVA服务信息";
  242 + serviceId = rowData.serviceId;
167 } 243 }
168 244
169 245
170 -  
171 dialog.dialog({ 246 dialog.dialog({
172 size: "modal-lg", 247 size: "modal-lg",
173 title: dialogTitle, 248 title: dialogTitle,
174 backdrop: "static", 249 backdrop: "static",
175 href: contextPath + "jsp/javaapi/editJavaInfo.jsp", 250 href: contextPath + "jsp/javaapi/editJavaInfo.jsp",
  251 + onLoadSuccess: function (data) {
  252 + if (serviceId == 0) {
  253 + $("#javaInfoForm #apiName").val("");
  254 + $("#javaInfoForm #apiUrl").val("");
  255 + $("#javaInfoForm #apiData").val("");
  256 + $("#javaInfoForm #apiToggle").prop("checked", true)
  257 + $("#javaInfoForm #apiWarnTrigger").val(0);
  258 + $("#javaInfoForm #apiReqMethod").val(0);
  259 + $("#javaInfoForm #serviceType").val(1);
  260 + } else {
  261 + $("#javaInfoForm #serviceType").val(rowData.serviceType);
  262 + $("#javaInfoForm #apiName").val(rowData.apiName);
  263 + $("#javaInfoForm #apiUrl").val(rowData.apiUrl);
  264 + $("#javaInfoForm #apiData").val(rowData.apiData);
  265 + $("#javaInfoForm #apiToggle").prop("checked", (rowData.apiToggle == 1) ? true : false);
  266 + $("#javaInfoForm #apiWarnTrigger").val(rowData.apiWarnTrigger);
  267 + $("#javaInfoForm #apiReqMethod").val(rowData.apiReqMethod);
  268 + }
  269 + },
176 buttons: [{ 270 buttons: [{
177 text: "关闭", 271 text: "关闭",
178 className: "btn-danger", 272 className: "btn-danger",
@@ -185,23 +279,23 @@ @@ -185,23 +279,23 @@
185 onclick: function () { 279 onclick: function () {
186 var btn = $(this); 280 var btn = $(this);
187 this.prop("disabled", "disabled"); 281 this.prop("disabled", "disabled");
188 - var serviceType = $("#javaInfoForm #serviceType").val();  
189 - var apiName = $("#javaInfoForm #apiName").val();  
190 - var apiUrl = $("#javaInfoForm #apiUrl").val();  
191 -  
192 -  
193 - $("#javaInfoForm").form("submit", {  
194 - submitUrl: contextPath + "javaApi/save",  
195 - submitData: {  
196 - 'serviceId': javaInfoId  
197 - },  
198 - onBeforeSubmit: function () {  
199 - if (!$(this).form("validate")) {  
200 - btn.removeAttr("disabled");  
201 - return false;  
202 - } 282 + $.ajax({
  283 + url: contextPath + "/javaApi/save",
  284 + type: 'post',
  285 + dataType: "json",
  286 + sync: false,
  287 + data: {
  288 + 'serviceId':serviceId,
  289 + 'serviceType': $("#javaInfoForm #serviceType").val(),
  290 + 'apiName': $("#javaInfoForm #apiName").val(),
  291 + 'apiUrl': $("#javaInfoForm #apiUrl").val(),
  292 + 'apiData': $("#javaInfoForm #apiData").val(),
  293 + 'apiToggle': $("#javaInfoForm #apiToggle").prop("checked") == true ? 1 : 0,
  294 + 'apiWarnTrigger': $("#javaInfoForm #apiWarnTrigger").val(),
  295 + 'apiReqMethod': $("#javaInfoForm #apiReqMethod").val(),
203 }, 296 },
204 success: function (data) { 297 success: function (data) {
  298 + console.log("fffuck 1");
205 if (!data || data.code != 200) { 299 if (!data || data.code != 200) {
206 btn.removeAttr("disabled"); 300 btn.removeAttr("disabled");
207 $("#javaInfoForm #messageAlert").alerts({ 301 $("#javaInfoForm #messageAlert").alerts({
@@ -212,6 +306,12 @@ @@ -212,6 +306,12 @@
212 } 306 }
213 $("#infoTable").table("load"); 307 $("#infoTable").table("load");
214 $(dialog).dialog("hide"); 308 $(dialog).dialog("hide");
  309 + },
  310 + error: function (data) {
  311 + $("#javaInfoForm #messageAlert").alerts({
  312 + content: data,
  313 + type: "danger"
  314 + });
215 } 315 }
216 }); 316 });
217 } 317 }