提交 | 用户 | 时间
|
e7c126
|
1 |
$(function() { |
H |
2 |
|
|
3 |
// jobGroup change, job list init and select |
|
4 |
$("#jobGroup").on("change", function () { |
|
5 |
var jobGroup = $(this).children('option:selected').val(); |
|
6 |
$.ajax({ |
|
7 |
type : 'POST', |
|
8 |
async: false, // async, avoid js invoke pagelist before jobId data init |
|
9 |
url : base_url + '/joblog/getJobsByGroup', |
|
10 |
data : {"jobGroup":jobGroup}, |
|
11 |
dataType : "json", |
|
12 |
success : function(data){ |
|
13 |
if (data.code == 200) { |
|
14 |
$("#jobId").html( '<option value="0" >'+ I18n.system_all +'</option>' ); |
|
15 |
$.each(data.content, function (n, value) { |
|
16 |
$("#jobId").append('<option value="' + value.id + '" >' + value.jobDesc + '</option>'); |
|
17 |
}); |
|
18 |
if ($("#jobId").attr("paramVal")){ |
|
19 |
$("#jobId").find("option[value='" + $("#jobId").attr("paramVal") + "']").attr("selected",true); |
|
20 |
} |
|
21 |
} else { |
|
22 |
layer.open({ |
|
23 |
title: I18n.system_tips , |
|
24 |
btn: [ I18n.system_ok ], |
|
25 |
content: (data.msg || I18n.system_api_error ), |
|
26 |
icon: '2' |
|
27 |
}); |
|
28 |
} |
|
29 |
}, |
|
30 |
}); |
|
31 |
}); |
|
32 |
if ($("#jobGroup").attr("paramVal")){ |
|
33 |
$("#jobGroup").find("option[value='" + $("#jobGroup").attr("paramVal") + "']").attr("selected",true); |
|
34 |
$("#jobGroup").change(); |
|
35 |
} |
|
36 |
|
|
37 |
// filter Time |
|
38 |
var rangesConf = {}; |
|
39 |
rangesConf[I18n.daterangepicker_ranges_recent_hour] = [moment().subtract(1, 'hours'), moment()]; |
|
40 |
rangesConf[I18n.daterangepicker_ranges_today] = [moment().startOf('day'), moment().endOf('day')]; |
|
41 |
rangesConf[I18n.daterangepicker_ranges_yesterday] = [moment().subtract(1, 'days').startOf('day'), moment().subtract(1, 'days').endOf('day')]; |
|
42 |
rangesConf[I18n.daterangepicker_ranges_this_month] = [moment().startOf('month'), moment().endOf('month')]; |
|
43 |
rangesConf[I18n.daterangepicker_ranges_last_month] = [moment().subtract(1, 'months').startOf('month'), moment().subtract(1, 'months').endOf('month')]; |
|
44 |
rangesConf[I18n.daterangepicker_ranges_recent_week] = [moment().subtract(1, 'weeks').startOf('day'), moment().endOf('day')]; |
|
45 |
rangesConf[I18n.daterangepicker_ranges_recent_month] = [moment().subtract(1, 'months').startOf('day'), moment().endOf('day')]; |
|
46 |
|
|
47 |
$('#filterTime').daterangepicker({ |
|
48 |
autoApply:false, |
|
49 |
singleDatePicker:false, |
|
50 |
showDropdowns:false, // 是否显示年月选择条件 |
|
51 |
timePicker: true, // 是否显示小时和分钟选择条件 |
|
52 |
timePickerIncrement: 10, // 时间的增量,单位为分钟 |
|
53 |
timePicker24Hour : true, |
|
54 |
opens : 'left', //日期选择框的弹出位置 |
|
55 |
ranges: rangesConf, |
|
56 |
locale : { |
|
57 |
format: 'YYYY-MM-DD HH:mm:ss', |
|
58 |
separator : ' - ', |
|
59 |
customRangeLabel : I18n.daterangepicker_custom_name , |
|
60 |
applyLabel : I18n.system_ok , |
|
61 |
cancelLabel : I18n.system_cancel , |
|
62 |
fromLabel : I18n.daterangepicker_custom_starttime , |
|
63 |
toLabel : I18n.daterangepicker_custom_endtime , |
|
64 |
daysOfWeek : I18n.daterangepicker_custom_daysofweek.split(',') , // '日', '一', '二', '三', '四', '五', '六' |
|
65 |
monthNames : I18n.daterangepicker_custom_monthnames.split(',') , // '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月' |
|
66 |
firstDay : 1 |
|
67 |
}, |
|
68 |
startDate: rangesConf[I18n.daterangepicker_ranges_today][0], |
|
69 |
endDate: rangesConf[I18n.daterangepicker_ranges_today][1] |
|
70 |
}); |
|
71 |
|
|
72 |
// init date tables |
|
73 |
var logTable = $("#joblog_list").dataTable({ |
|
74 |
"deferRender": true, |
|
75 |
"processing" : true, |
|
76 |
"serverSide": true, |
|
77 |
"ajax": { |
|
78 |
url: base_url + "/joblog/pageList" , |
|
79 |
type:"post", |
|
80 |
data : function ( d ) { |
|
81 |
var obj = {}; |
|
82 |
obj.jobGroup = $('#jobGroup').val(); |
|
83 |
obj.jobId = $('#jobId').val(); |
|
84 |
obj.logStatus = $('#logStatus').val(); |
|
85 |
obj.filterTime = $('#filterTime').val(); |
|
86 |
obj.start = d.start; |
|
87 |
obj.length = d.length; |
|
88 |
return obj; |
|
89 |
} |
|
90 |
}, |
|
91 |
"searching": false, |
|
92 |
"ordering": false, |
|
93 |
//"scrollX": false, |
|
94 |
"columns": [ |
|
95 |
{ |
|
96 |
"data": 'jobId', |
|
97 |
"visible" : true, |
|
98 |
"width":'10%', |
|
99 |
"render": function ( data, type, row ) { |
|
100 |
|
|
101 |
var jobhandler = ''; |
|
102 |
if (row.executorHandler) { |
|
103 |
jobhandler = "<br>JobHandler:" + row.executorHandler; |
|
104 |
} |
|
105 |
|
|
106 |
var temp = ''; |
|
107 |
temp += I18n.joblog_field_executorAddress + ':' + (row.executorAddress?row.executorAddress:''); |
|
108 |
temp += jobhandler; |
|
109 |
temp += '<br>'+ I18n.jobinfo_field_executorparam +':' + row.executorParam; |
|
110 |
|
|
111 |
return '<a class="logTips" href="javascript:;" >'+ row.jobId +'<span style="display:none;">'+ temp +'</span></a>'; |
|
112 |
} |
|
113 |
}, |
|
114 |
{ "data": 'jobGroup', "visible" : false}, |
|
115 |
{ |
|
116 |
"data": 'triggerTime', |
|
117 |
"width":'20%', |
|
118 |
"render": function ( data, type, row ) { |
|
119 |
return data?moment(data).format("YYYY-MM-DD HH:mm:ss"):""; |
|
120 |
} |
|
121 |
}, |
|
122 |
{ |
|
123 |
"data": 'triggerCode', |
|
124 |
"width":'10%', |
|
125 |
"render": function ( data, type, row ) { |
|
126 |
var html = data; |
|
127 |
if (data == 200) { |
|
128 |
html = '<span style="color: green">'+ I18n.system_success +'</span>'; |
|
129 |
} else if (data == 500) { |
|
130 |
html = '<span style="color: red">'+ I18n.system_fail +'</span>'; |
|
131 |
} else if (data == 0) { |
|
132 |
html = ''; |
|
133 |
} |
|
134 |
return html; |
|
135 |
} |
|
136 |
}, |
|
137 |
{ |
|
138 |
"data": 'triggerMsg', |
|
139 |
"width":'10%', |
|
140 |
"render": function ( data, type, row ) { |
|
141 |
return data?'<a class="logTips" href="javascript:;" >'+ I18n.system_show +'<span style="display:none;">'+ data +'</span></a>':I18n.system_empty; |
|
142 |
} |
|
143 |
}, |
|
144 |
{ |
|
145 |
"data": 'handleTime', |
|
146 |
"width":'20%', |
|
147 |
"render": function ( data, type, row ) { |
|
148 |
return data?moment(data).format("YYYY-MM-DD HH:mm:ss"):""; |
|
149 |
} |
|
150 |
}, |
|
151 |
{ |
|
152 |
"data": 'handleCode', |
|
153 |
"width":'10%', |
|
154 |
"render": function ( data, type, row ) { |
|
155 |
var html = data; |
|
156 |
if (data == 200) { |
|
157 |
html = '<span style="color: green">'+ I18n.joblog_handleCode_200 +'</span>'; |
|
158 |
} else if (data == 500) { |
|
159 |
html = '<span style="color: red">'+ I18n.joblog_handleCode_500 +'</span>'; |
|
160 |
} else if (data == 502) { |
|
161 |
html = '<span style="color: red">'+ I18n.joblog_handleCode_502 +'</span>'; |
|
162 |
} else if (data == 0) { |
|
163 |
html = ''; |
|
164 |
} |
|
165 |
return html; |
|
166 |
} |
|
167 |
}, |
|
168 |
{ |
|
169 |
"data": 'handleMsg', |
|
170 |
"width":'10%', |
|
171 |
"render": function ( data, type, row ) { |
|
172 |
return data?'<a class="logTips" href="javascript:;" >'+ I18n.system_show +'<span style="display:none;">'+ data +'</span></a>':I18n.system_empty; |
|
173 |
} |
|
174 |
}, |
|
175 |
{ |
|
176 |
"data": 'handleMsg' , |
|
177 |
"bSortable": false, |
|
178 |
"width":'10%', |
|
179 |
"render": function ( data, type, row ) { |
|
180 |
// better support expression or string, not function |
|
181 |
return function () { |
|
182 |
if (row.triggerCode == 200 || row.handleCode != 0){ |
|
183 |
|
|
184 |
/*var temp = '<a href="javascript:;" class="logDetail" _id="'+ row.id +'">'+ I18n.joblog_rolling_log +'</a>'; |
|
185 |
if(row.handleCode == 0){ |
|
186 |
temp += '<br><a href="javascript:;" class="logKill" _id="'+ row.id +'" style="color: red;" >'+ I18n.joblog_kill_log +'</a>'; |
|
187 |
}*/ |
|
188 |
//return temp; |
|
189 |
|
|
190 |
var logKillDiv = ''; |
|
191 |
if(row.handleCode == 0){ |
|
192 |
logKillDiv = ' <li class="divider"></li>\n' + |
|
193 |
' <li><a href="javascript:void(0);" class="logKill" _id="'+ row.id +'" >'+ I18n.joblog_kill_log +'</a></li>\n'; |
|
194 |
} |
|
195 |
|
|
196 |
var html = '<div class="btn-group">\n' + |
|
197 |
' <button type="button" class="btn btn-primary btn-sm">'+ I18n.system_opt +'</button>\n' + |
|
198 |
' <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">\n' + |
|
199 |
' <span class="caret"></span>\n' + |
|
200 |
' <span class="sr-only">Toggle Dropdown</span>\n' + |
|
201 |
' </button>\n' + |
|
202 |
' <ul class="dropdown-menu" role="menu" _id="'+ row.id +'" >\n' + |
|
203 |
' <li><a href="javascript:void(0);" class="logDetail" _id="'+ row.id +'" >'+ I18n.joblog_rolling_log +'</a></li>\n' + |
|
204 |
logKillDiv + |
|
205 |
' </ul>\n' + |
|
206 |
' </div>'; |
|
207 |
|
|
208 |
return html; |
|
209 |
} |
|
210 |
return null; |
|
211 |
} |
|
212 |
} |
|
213 |
} |
|
214 |
], |
|
215 |
"language" : { |
|
216 |
"sProcessing" : I18n.dataTable_sProcessing , |
|
217 |
"sLengthMenu" : I18n.dataTable_sLengthMenu , |
|
218 |
"sZeroRecords" : I18n.dataTable_sZeroRecords , |
|
219 |
"sInfo" : I18n.dataTable_sInfo , |
|
220 |
"sInfoEmpty" : I18n.dataTable_sInfoEmpty , |
|
221 |
"sInfoFiltered" : I18n.dataTable_sInfoFiltered , |
|
222 |
"sInfoPostFix" : "", |
|
223 |
"sSearch" : I18n.dataTable_sSearch , |
|
224 |
"sUrl" : "", |
|
225 |
"sEmptyTable" : I18n.dataTable_sEmptyTable , |
|
226 |
"sLoadingRecords" : I18n.dataTable_sLoadingRecords , |
|
227 |
"sInfoThousands" : ",", |
|
228 |
"oPaginate" : { |
|
229 |
"sFirst" : I18n.dataTable_sFirst , |
|
230 |
"sPrevious" : I18n.dataTable_sPrevious , |
|
231 |
"sNext" : I18n.dataTable_sNext , |
|
232 |
"sLast" : I18n.dataTable_sLast |
|
233 |
}, |
|
234 |
"oAria" : { |
|
235 |
"sSortAscending" : I18n.dataTable_sSortAscending , |
|
236 |
"sSortDescending" : I18n.dataTable_sSortDescending |
|
237 |
} |
|
238 |
} |
|
239 |
}); |
|
240 |
logTable.on('xhr.dt',function(e, settings, json, xhr) { |
|
241 |
if (json.code && json.code != 200) { |
|
242 |
layer.msg( json.msg || I18n.system_api_error ); |
|
243 |
} |
|
244 |
}); |
|
245 |
|
|
246 |
// logTips alert |
|
247 |
$('#joblog_list').on('click', '.logTips', function(){ |
|
248 |
var msg = $(this).find('span').html(); |
|
249 |
ComAlertTec.show(msg); |
|
250 |
}); |
|
251 |
|
|
252 |
// search Btn |
|
253 |
$('#searchBtn').on('click', function(){ |
|
254 |
logTable.fnDraw(); |
|
255 |
}); |
|
256 |
|
|
257 |
// logDetail look |
|
258 |
$('#joblog_list').on('click', '.logDetail', function(){ |
|
259 |
var _id = $(this).attr('_id'); |
|
260 |
|
|
261 |
window.open(base_url + '/joblog/logDetailPage?id=' + _id); |
|
262 |
return; |
|
263 |
}); |
|
264 |
|
|
265 |
/** |
|
266 |
* log Kill |
|
267 |
*/ |
|
268 |
$('#joblog_list').on('click', '.logKill', function(){ |
|
269 |
var _id = $(this).attr('_id'); |
|
270 |
|
|
271 |
layer.confirm( (I18n.system_ok + I18n.joblog_kill_log + '?'), { |
|
272 |
icon: 3, |
|
273 |
title: I18n.system_tips , |
|
274 |
btn: [ I18n.system_ok, I18n.system_cancel ] |
|
275 |
}, function(index){ |
|
276 |
layer.close(index); |
|
277 |
|
|
278 |
$.ajax({ |
|
279 |
type : 'POST', |
|
280 |
url : base_url + '/joblog/logKill', |
|
281 |
data : {"id":_id}, |
|
282 |
dataType : "json", |
|
283 |
success : function(data){ |
|
284 |
if (data.code == 200) { |
|
285 |
layer.open({ |
|
286 |
title: I18n.system_tips, |
|
287 |
btn: [ I18n.system_ok ], |
|
288 |
content: I18n.system_opt_suc , |
|
289 |
icon: '1', |
|
290 |
end: function(layero, index){ |
|
291 |
logTable.fnDraw(); |
|
292 |
} |
|
293 |
}); |
|
294 |
} else { |
|
295 |
layer.open({ |
|
296 |
title: I18n.system_tips, |
|
297 |
btn: [ I18n.system_ok ], |
|
298 |
content: (data.msg || I18n.system_opt_fail ), |
|
299 |
icon: '2' |
|
300 |
}); |
|
301 |
} |
|
302 |
}, |
|
303 |
}); |
|
304 |
}); |
|
305 |
|
|
306 |
}); |
|
307 |
|
|
308 |
/** |
|
309 |
* clear Log |
|
310 |
*/ |
|
311 |
$('#clearLog').on('click', function(){ |
|
312 |
|
|
313 |
var jobGroup = $('#jobGroup').val(); |
|
314 |
var jobId = $('#jobId').val(); |
|
315 |
|
|
316 |
var jobGroupText = $("#jobGroup").find("option:selected").text(); |
|
317 |
var jobIdText = $("#jobId").find("option:selected").text(); |
|
318 |
|
|
319 |
$('#clearLogModal input[name=jobGroup]').val(jobGroup); |
|
320 |
$('#clearLogModal input[name=jobId]').val(jobId); |
|
321 |
|
|
322 |
$('#clearLogModal .jobGroupText').val(jobGroupText); |
|
323 |
$('#clearLogModal .jobIdText').val(jobIdText); |
|
324 |
|
|
325 |
$('#clearLogModal').modal('show'); |
|
326 |
|
|
327 |
}); |
|
328 |
$("#clearLogModal .ok").on('click', function(){ |
|
329 |
$.post(base_url + "/joblog/clearLog", $("#clearLogModal .form").serialize(), function(data, status) { |
|
330 |
if (data.code == "200") { |
|
331 |
$('#clearLogModal').modal('hide'); |
|
332 |
layer.open({ |
|
333 |
title: I18n.system_tips , |
|
334 |
btn: [ I18n.system_ok ], |
|
335 |
content: (I18n.joblog_clean_log + I18n.system_success) , |
|
336 |
icon: '1', |
|
337 |
end: function(layero, index){ |
|
338 |
logTable.fnDraw(); |
|
339 |
} |
|
340 |
}); |
|
341 |
} else { |
|
342 |
layer.open({ |
|
343 |
title: I18n.system_tips , |
|
344 |
btn: [ I18n.system_ok ], |
|
345 |
content: (data.msg || (I18n.joblog_clean_log + I18n.system_fail) ), |
|
346 |
icon: '2' |
|
347 |
}); |
|
348 |
} |
|
349 |
}); |
|
350 |
}); |
|
351 |
$("#clearLogModal").on('hide.bs.modal', function () { |
|
352 |
$("#clearLogModal .form")[0].reset(); |
|
353 |
}); |
|
354 |
|
|
355 |
}); |
|
356 |
|
|
357 |
|
|
358 |
// Com Alert by Tec theme |
|
359 |
var ComAlertTec = { |
|
360 |
html:function(){ |
|
361 |
var html = |
|
362 |
'<div class="modal fade" id="ComAlertTec" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' + |
|
363 |
' <div class="modal-dialog modal-lg-">' + |
|
364 |
' <div class="modal-content-tec">' + |
|
365 |
' <div class="modal-body">' + |
|
366 |
' <div class="alert" style="color:#fff;word-wrap: break-word;">' + |
|
367 |
' </div>' + |
|
368 |
' </div>' + |
|
369 |
' <div class="modal-footer">' + |
|
370 |
' <div class="text-center" >' + |
|
371 |
' <button type="button" class="btn btn-info ok" data-dismiss="modal" >'+ I18n.system_ok +'</button>' + |
|
372 |
' </div>' + |
|
373 |
' </div>' + |
|
374 |
' </div>' + |
|
375 |
' </div>' + |
|
376 |
'</div>'; |
|
377 |
return html; |
|
378 |
}, |
|
379 |
show:function(msg, callback){ |
|
380 |
// dom init |
|
381 |
if ($('#ComAlertTec').length == 0){ |
|
382 |
$('body').append(ComAlertTec.html()); |
|
383 |
} |
|
384 |
|
|
385 |
// init com alert |
|
386 |
$('#ComAlertTec .alert').html(msg); |
|
387 |
$('#ComAlertTec').modal('show'); |
|
388 |
|
|
389 |
$('#ComAlertTec .ok').click(function(){ |
|
390 |
$('#ComAlertTec').modal('hide'); |
|
391 |
if(typeof callback == 'function') { |
|
392 |
callback(); |
|
393 |
} |
|
394 |
}); |
|
395 |
} |
|
396 |
}; |