metricConfigAdd.jsp
12.7 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<%@ 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"%>
<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>
<res:useJs value="${res.js.local['jquery.validate.min.js']}" target="head-js" />
<res:useJs value="${res.js.local['alarm_js']}" target="head-js" />
<res:useJs value="${res.js.local['dependencyConfig_js']}" target="head-js" />
<res:useCss value="${res.css.local['select2.css']}" target="head-css" />
<res:useJs value="${res.js.local['select2.min.js']}" target="head-js" />
<res:useCss value="${res.css.local['multiple-select.css']}" target="head-css" />
<res:useJs value="${res.js.local['jquery.multiple.select.js']}" target="head-js" />
<h4 class="text-success text-center">修改业务监控规则</h4>
<form name="metricConfigAddSubmit" id="form" method="post" action="${model.pageUri}?op=metricConfigAddSubmit">
<span class="text-center text-danger" id="state"> </span>
<input name="productLineName" value="${payload.productLineName}" type="hidden"/>
<table class="table table-striped table-condensed ">
<tr>
<td width="15%" style="text-align:right" class="text-success" width="50%">项目名称</td>
<td width="35%" >
<c:if test="${not empty model.metricItemConfig.domain}">
<input name="metricItemConfig.domain" value="${model.metricItemConfig.domain}" readonly required/>
</c:if>
<c:if test="${empty model.metricItemConfig.domain}">
<select style="width:200px;" name="metricItemConfig.domain" id="id">
<c:forEach var="item" items="${model.productLineToDomains}">
<option value="${item.key}">${item.key}</option>
</c:forEach>
</select>
</c:if>
</td>
<td width="20%" style="text-align:right" class="text-success">类型</td>
<td width="30%" >
<c:if test="${not empty model.metricItemConfig.domain}">
<input name="metricItemConfig.type" value="${model.metricItemConfig.type}" readonly required/>
</c:if>
<c:if test="${empty model.metricItemConfig.type}">
<select name="metricItemConfig.type">
<option value="URL">URL</option>
<option value="PigeonService">PigeonService</option>
</select>
</c:if>
</tr>
<tr>
<td style="text-align:right" class="text-success">MetricKey</td>
<td >
<c:if test="${not empty model.metricItemConfig.domain}">
<input name="metricItemConfig.metricKey" value="${model.metricItemConfig.metricKey}" readonly required/>
</c:if>
<c:if test="${empty model.metricItemConfig.type}">
<input name="metricItemConfig.metricKey" value="${model.metricItemConfig.metricKey}" required/>
</c:if>
</td>
<td style="text-align:right" class="text-success">产品线内显示顺序(数字)</td>
<td ><input name="metricItemConfig.viewOrder" value="${model.metricItemConfig.viewOrder}" required/></td>
</tr>
<tr>
<td style="text-align:right" class="text-success">显示标题</td>
<td ><input name="metricItemConfig.title" value="${model.metricItemConfig.title}" required/></td>
<td style="text-align:right" class="text-success">是否告警</td>
<td >
<c:choose>
<c:when test="${model.metricItemConfig.alarm}">
<input type="radio" name="metricItemConfig.alarm" value="true" checked />是
<input type="radio" name="metricItemConfig.alarm" value="false" />否
</c:when>
<c:otherwise>
<input type="radio" name="metricItemConfig.alarm" value="true" />是
<input type="radio" name="metricItemConfig.alarm" value="false" checked />否
</c:otherwise>
</c:choose>
</td>
</tr>
<tr>
<td style="text-align:right" class="text-success" >显示次数曲线</td>
<td colspan='3'>
<c:choose>
<c:when test="${model.metricItemConfig.showCount}">
<input type="radio" name="metricItemConfig.showCount" value="true" checked />是
<input type="radio" name="metricItemConfig.showCount" value="false" />否
</c:when>
<c:otherwise>
<input type="radio" name="metricItemConfig.showCount" value="true" />是
<input type="radio" name="metricItemConfig.showCount" value="false" checked />否
</c:otherwise>
</c:choose>
<select class="tags" id="countSelect" multiple="multiple">
<c:choose>
<c:when test="${empty model.tags}">
<option value="业务大盘">业务大盘</option>
</c:when>
<c:otherwise>
<c:forEach var="item" items="${model.tags}">
<option value="${item}">${item}</option>
</c:forEach>
</c:otherwise>
</c:choose>
</select>
<button class="btn btn-success btn-xs" id="addCountTag" type="button">
添加其他标签<i class="icon-plus icon-white"></i>
</button>
<button class="btn btn-danger btn-xs" id="deleteCountTag" type="button">
删除<i class="ace-icon fa fa-trash-o bigger-120"></i>
</button>
<span class="text-danger"><strong>【添加业务大盘标签会自动进行基线告警】</strong></span>
<input name="countTags" type="hidden"/>
</td>
</tr>
<tr>
<td style="text-align:right" class="text-success" >显示平均曲线</td>
<td colspan='3'>
<c:choose>
<c:when test="${model.metricItemConfig.showAvg}">
<input type="radio" name="metricItemConfig.showAvg" value="true" checked />是
<input type="radio" name="metricItemConfig.showAvg" value="false" />否
</c:when>
<c:otherwise>
<input type="radio" name="metricItemConfig.showAvg" value="true" />是
<input type="radio" name="metricItemConfig.showAvg" value="false" checked />否
</c:otherwise>
</c:choose>
<select class="tags" id="avgSelect" multiple="multiple">
<c:choose>
<c:when test="${empty model.tags}">
<option value="业务大盘">业务大盘</option>
</c:when>
<c:otherwise>
<c:forEach var="item" items="${model.tags}">
<option value="${item}">${item}</option>
</c:forEach>
</c:otherwise>
</c:choose>
</select>
<button class="btn btn-success btn-xs" id="addAvgTag" type="button">
添加其他标签<i class="icon-plus icon-white"></i>
</button>
<button class="btn btn-danger btn-xs" id="deleteAvgTag" type="button">
删除<i class="ace-icon fa fa-trash-o bigger-120"></i>
</button>
<input name="avgTags" type="hidden"/>
</td>
</tr>
<tr>
<td style="text-align:right" class="text-success">显示求和曲线</td>
<td colspan='3'>
<c:choose>
<c:when test="${model.metricItemConfig.showSum}">
<input type="radio" name="metricItemConfig.showSum" value="true" checked />是
<input type="radio" name="metricItemConfig.showSum" value="false" />否
</c:when>
<c:otherwise>
<input type="radio" name="metricItemConfig.showSum" value="true" />是
<input type="radio" name="metricItemConfig.showSum" value="false" checked />否
</c:otherwise>
</c:choose>
<select class="tags" id="sumSelect" multiple="multiple">
<c:choose>
<c:when test="${empty model.tags}">
<option value="业务大盘">业务大盘</option>
</c:when>
<c:otherwise>
<c:forEach var="item" items="${model.tags}">
<option value="${item}">${item}</option>
</c:forEach>
</c:otherwise>
</c:choose>
</select>
<button class="btn btn-success btn-xs" id="addSumTag" type="button">
添加其他标签<i class="icon-plus icon-white"></i>
</button>
<button class="btn btn-danger btn-xs" id="deleteSumTag" type="button">
删除<i class="ace-icon fa fa-trash-o bigger-120"></i>
</button>
<input name="sumTags" type="hidden"/>
</td>
</tr>
<tr>
<td style="text-align:right" class="text-success">业务大盘顺序(数字)</td>
<td colspan='3'><input name="metricItemConfig.showDashboardOrder" value="${model.metricItemConfig.showDashboardOrder}" required/></td>
</tr>
<tr>
<td style="text-align:center" colspan='4'><input class='btn btn-primary btn-xs' id="addOrUpdateNodeSubmit" type="submit" name="submit" value="提交" /></td>
</tr>
</table>
</form>
<script>
$(document).ready(function(){
$('#application_config').addClass('active open');
$('#metricConfigList').addClass('active');
var tagName, tagType;
<c:forEach var="tag" items="${model.metricItemConfig.tags}">
tagName = '${tag.name}';
tagType = '${tag.type}'.toLowerCase();
$("#"+tagType+"Select").children().each(function(){
if($(this).text() == tagName){
$(this).prop("selected","selected")
}
});
</c:forEach>
$('select').multipleSelect({
width: 300,
multiple: true,
multipleWidth: 300,
selectAll: false
});
$("#form").submit(function(){
var countTagStr;
var countSelect = $("#countSelect");
if(countSelect.length > 0){
countTagStr = countSelect.multipleSelect('getSelects', 'text');
}else{
countTagStr = $("#countInput").val();
}
$("input[name='countTags']").val(countTagStr);
var avgTagStr;
var avgSelect = $("#avgSelect");
if(avgSelect.length > 0){
avgTagStr = avgSelect.multipleSelect('getSelects', 'text');
}else{
avgTagStr = $("#avgInput").val();
}
$("input[name='avgTags']").val(avgTagStr);
var sumTagStr;
var sumSelect = $("#sumSelect");
if(sumSelect.length > 0){
sumTagStr = sumSelect.multipleSelect('getSelects', 'text');
}else{
sumTagStr = $("#sumInput").val();
}
$("input[name='sumTags']").val(sumTagStr);
return true;
})
$("#addCountTag").click(function(){
var existTags = $("#countSelect").multipleSelect('getSelects', 'text');
$(this).parent().find(".tags").remove();
if($(this).parent().find(".tagsInput").length == 0){
$(this).before($('<input class="tagsInput span4" id="countInput" type="text" value="'+existTags+'"></input>'));
}
$(this).addClass("disabled")
})
$("#addSumTag").click(function(){
var existTags = $("#sumSelect").multipleSelect('getSelects', 'text');
$(this).parent().find(".tags").remove();
if($(this).parent().find(".tagsInput").length == 0){
$(this).before($('<input class="tagsInput span4" id="sumInput" type="text" value="'+existTags+'"></input>'));
}
$(this).addClass("disabled")
})
$("#addAvgTag").click(function(){
var existTags = $("#avgSelect").multipleSelect('getSelects', 'text');
$(this).parent().find(".tags").remove();
if($(this).parent().find(".tagsInput").length == 0){
$(this).before($('<input class="tagsInput span4" id="avgInput" type="text" value="'+existTags+'"></input>'));
}
$(this).addClass("disabled")
})
$("#deleteCountTag").click(function(){
var addButton = $(this).prev();
$(this).parent().find(".tags").remove();
$(this).parent().find(".tagsInput").remove();
addButton.before($('<input class="tagsInput span4" id="countInput" type="text" disabled></input>'));
addButton.addClass("disabled");
$(this).addClass("disabled");
})
$("#deleteAvgTag").click(function(){
var addButton = $(this).prev();
$(this).parent().find(".tags").remove();
$(this).parent().find(".tagsInput").remove();
addButton.before($('<input class="tagsInput span4" id="avgInput" type="text" disabled></input>'));
addButton.addClass("disabled");
$(this).addClass("disabled");
})
$("#deleteSumTag").click(function(){
var addButton = $(this).prev();
$(this).parent().find(".tags").remove();
$(this).parent().find(".tagsInput").remove();
addButton.before($('<input class="tagsInput span4" id="sumInput" type="text" disabled></input>'));
addButton.addClass("disabled");
$(this).addClass("disabled");
})
})
</script>
</a:config>