storageRuleUpdate.jsp
4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib prefix="a" uri="/WEB-INF/app.tld"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="res" uri="http://www.unidal.org/webres"%>
<%@ taglib prefix="w" uri="http://www.unidal.org/web/core"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<jsp:useBean id="ctx" type="com.dianping.cat.system.page.config.Context" scope="request"/>
<jsp:useBean id="payload" type="com.dianping.cat.system.page.config.Payload" scope="request"/>
<jsp:useBean id="model" type="com.dianping.cat.system.page.config.Model" scope="request"/>
<a:config>
<c:if test="${payload.type eq 'SQL'}"><c:set var="name" value="数据库" /></c:if>
<c:if test="${payload.type eq 'Cache'}"><c:set var="name" value="缓存" /></c:if>
<h3 class="text-center text-success">编辑${name}监控规则</h3>
<form name="appRuleUpdate" id="form" method="post">
<table style='width:100%' class='table table-striped table-condensed '>
<c:set var="conditions" value="${fn:split(payload.ruleId, ';')}" />
<c:set var="name" value="${conditions[0]}" />
<c:set var="machine" value="${conditions[1]}" />
<c:set var="method" value="${conditions[2]}" />
<c:set var="target" value="${conditions[3]}" />
<c:set var="andStr" value="${conditions[4]}" />
<tr>
<td>名字 <input name="name" id="name" value="${name}"/></td>
<td>机器 <input name="machine" id="machine" value="${machine}"/></td>
<td>方法 <input name="method" id="method" value="${method}"/></td>
<td>监控项 <select name="target" id="target" style="width:200px;">
<option value="avg">响应时间</option>
<option value="errorPercent">错误率</option>
<option value="error">错误数</option>
</select></td>
<td> 与条件 <select name="and" id="and" style="width:200px;">
<option value="false">否</option>
<option value="true">是</option>
</select></td>
</tr>
<tr><th colspan="6">${model.content}</th></tr>
<tr>
<td style='text-align:center' colspan='6'><input class="btn btn-primary btn-sm" id="ruleSubmitButton" type="text" name="submit" value="提交"></button></td>
</tr>
</table>
</form>
</a:config>
<script type="text/javascript">
function update() {
var configStr = generateConfigsJsonString();
var name = $("#name").val().trim();
if(name == "undefined" || name == ""){
if($("#errorMessage").length == 0){
$("#name").after($("<span class=\"text-danger\" id=\"errorMessage\"> 该字段不能为空</span>"));
}
return;
}
var machine = $("#machine").val().trim();
if(machine == "undefined" || machine == ""){
if($("#errorMessage").length == 0){
$("#machine").after($("<span class=\"text-danger\" id=\"errorMessage\"> 该字段不能为空</span>"));
}
return;
}
var method = $("#method").val().trim();
if(method == "undefined" || method == ""){
if($("#errorMessage").length == 0){
$("#machine").after($("<span class=\"text-danger\" id=\"errorMessage\"> 该字段不能为空</span>"));
}
return;
}
var target = $("#target").val();
if(target == "undefined" || target == ""){
if($("#errorMessage").length == 0){
$("#target").after($("<span class=\"text-danger\" id=\"errorMessage\"> 该字段不能为空</span>"));
}
return;
}
var andStr = $("#and").val();
if(andStr == "undefined" || andStr == ""){
if($("#errorMessage").length == 0){
$("#andStr").after($("<span class=\"text-danger\" id=\"errorMessage\"> 该字段不能为空</span>"));
}
return;
}
var split = ";";
var id = name + split + machine + split + method + split + target + split + andStr;
window.location.href = "?op=storageRuleSubmit&configs=" + configStr + "&type=${payload.type}&ruleId=" + id;
}
$(document).ready(function() {
initRuleConfigs(["DescVal","DescPer","AscVal","AscPer"]);
var ruleId = "${payload.ruleId}";
if(ruleId.length > 0){
document.getElementById("name").disabled = true;
document.getElementById("machine").disabled = true;
document.getElementById("method").disabled = true;
document.getElementById("target").disabled = true;
document.getElementById("and").disabled = true;
var conditions = ruleId.split(';');
$('#target').val(conditions[3]);
$('#and').val(conditions[4]);
}
var name = $("#name").val().trim();
if(name == "" || name.length == 0){
$("#name").val("All");
}
$('#application_config').addClass('active open');
<c:if test="${empty payload.type or payload.type eq 'SQL'}">
$('#storageDatabaseRule').addClass('active');
</c:if>
<c:if test="${payload.type eq 'Cache'}">
$('#storageCacheRule').addClass('active');
</c:if>
$(document).delegate("#ruleSubmitButton","click",function(){
update();
})
});
</script>