appRuleUpdate.jsp
6.4 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<%@ 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>
<h3 class="text-center text-success">编辑APP监控规则</h3>
<form name="appRuleUpdate" id="form" method="post">
<table style='width:100%' class='table table-striped table-condensed '>
<tr>
<c:set var="strs" value="${fn:split(payload.ruleId, ':')}" />
<c:set var="name" value="${strs[2]}" />
<th align=left>告警名<input id="name" value="${name}"/> 命令字 <select id="command" style="width: 350px;">
<c:forEach var="item" items="${model.commands}" varStatus="status">
<c:choose>
<c:when test="${empty item.title}">
<option value='${item.id}'>${item.name}</option>
</c:when>
<c:otherwise>
<option value='${item.id}'>${item.title}</option>
</c:otherwise>
</c:choose>
</c:forEach>
</select> 返回码 <select id="code" style="width: 120px;">
</select> 网络类型 <select id="network" style="width: 80px;">
<option value='-1'>All</option>
<c:forEach var="item" items="${model.networks}" varStatus="status">
<option value='${item.value.id}'>${item.value.name}</option>
</c:forEach>
</select>
</th>
</tr>
<tr>
<th align=left>版本 <select id="version" style="width: 100px;">
<option value='-1'>All</option>
<c:forEach var="item" items="${model.versions}" varStatus="status">
<option value='${item.value.id}'>${item.value.name}</option>
</c:forEach>
</select> 连接类型 <select id="connectionType" style="width: 100px;">
<option value='-1'>All</option>
<c:forEach var="item" items="${model.connectionTypes}"
varStatus="status">
<option value='${item.value.id}'>${item.value.name}</option>
</c:forEach>
</select> 平台 <select id="platform" style="width: 100px;">
<option value='-1'>All</option>
<c:forEach var="item" items="${model.platforms}"
varStatus="status">
<option value='${item.value.id}'>${item.value.name}</option>
</c:forEach>
</select> 地区 <select id="city" style="width: 100px;">
<option value='-1'>All</option>
<c:forEach var="item" items="${model.cities}" varStatus="status">
<option value='${item.value.id}'>${item.value.name}</option>
</c:forEach>
</select> 运营商 <select id="operator" style="width: 100px;">
<option value='-1'>All</option>
<c:forEach var="item" items="${model.operators}"
varStatus="status">
<option value='${item.value.id}'>${item.value.name}</option>
</c:forEach>
</select> 告警指标 <select id="metric" style="width: 100px;">
<option value='request'>请求数</option>
<option value='success'>成功率</option>
<option value='delay'>响应时间</option>
</select></th></tr>
<tr><th>${model.content}</th></tr>
<tr>
<td style='text-align:center' colspan='2'><input class="btn btn-primary btn-mini" id="ruleSubmitButton" type="text" name="submit" value="提交"></button></td>
</tr>
</table>
</form>
</a:config>
<script type="text/javascript">
var commandInfo = ${model.commandJson};
var commandChange = function commandChange() {
var key = $("#command").val();
var value = commandInfo[key];
var code = document.getElementById("code");
code.length = 0;
var opt = $('<option />');
opt.html("All");
opt.val("-1");
opt.appendTo(code);
for ( var prop in value) {
var opt = $('<option />');
opt.html(value[prop].name);
opt.val(value[prop].id);
opt.appendTo(code);
}
}
function update() {
var configStr = generateConfigsJsonString();
var name = $("#name").val();
var command = $("#command").val();
var code = $("#code").val();
var network = $("#network").val();
var version = $("#version").val();
var connectionType = $("#connectionType").val();
var platform = $("#platform").val();
var city = $("#city").val();
var operator = $("#operator").val();
var metric = $("#metric").val();
var split = ";";
var id = command + split + code + split + network + split + version + split + connectionType + split + platform + split + city + split + operator + ":" + metric + ":" + name;
window.location.href = "?op=appRuleSubmit&configs=" + configStr + "&ruleId=" + id;
}
$(document).ready(function() {
var commandSelector = $('#command');
commandSelector.on('change', commandChange);
var ruleId = "${payload.ruleId}";
if(ruleId.length > 0){
document.getElementById("name").disabled = true;
document.getElementById("command").disabled = true;
document.getElementById("code").disabled = true;
document.getElementById("network").disabled = true;
document.getElementById("version").disabled = true;
document.getElementById("connectionType").disabled = true;
document.getElementById("platform").disabled = true;
document.getElementById("city").disabled = true;
document.getElementById("operator").disabled = true;
document.getElementById("metric").disabled = true;
}
var words = ruleId.split(":")[0].split(";");
if(typeof words != "undefined" && words.length == 8){
var metric = ruleId.split(":")[1];
var command = words[0];
var code = words[1];
var network = words[2];
var version = words[3];
var connectionType = words[4];
var platform = words[5];
var city = words[6];
var operator = words[7];
$("#command").val(command);
commandChange();
$("#code").val(code);
$("#network").val(network);
$("#version").val(version);
$("#connectionType").val(connectionType);
$("#platform").val(platform);
$("#city").val(city);
$("#operator").val(operator);
$("#metric").val(metric);
}
commandChange();
$('#userMonitor_config').addClass('active open');
$('#appRule').addClass('active');
initRuleConfigs(["DescVal","DescPer","AscVal","AscPer"]);
$(document).delegate("#ruleSubmitButton","click",function(){
update();
})
});
</script>