$(function() {
// jobGroup change, job list init and select
$("#jobGroup").on("change", function () {
var jobGroup = $(this).children('option:selected').val();
$.ajax({
type : 'POST',
async: false, // async, avoid js invoke pagelist before jobId data init
url : base_url + '/joblog/getJobsByGroup',
data : {"jobGroup":jobGroup},
dataType : "json",
success : function(data){
if (data.code == 200) {
$("#jobId").html( '' );
$.each(data.content, function (n, value) {
$("#jobId").append('');
});
if ($("#jobId").attr("paramVal")){
$("#jobId").find("option[value='" + $("#jobId").attr("paramVal") + "']").attr("selected",true);
}
} else {
layer.open({
title: I18n.system_tips ,
btn: [ I18n.system_ok ],
content: (data.msg || I18n.system_api_error ),
icon: '2'
});
}
},
});
});
if ($("#jobGroup").attr("paramVal")){
$("#jobGroup").find("option[value='" + $("#jobGroup").attr("paramVal") + "']").attr("selected",true);
$("#jobGroup").change();
}
// filter Time
var rangesConf = {};
rangesConf[I18n.daterangepicker_ranges_recent_hour] = [moment().subtract(1, 'hours'), moment()];
rangesConf[I18n.daterangepicker_ranges_today] = [moment().startOf('day'), moment().endOf('day')];
rangesConf[I18n.daterangepicker_ranges_yesterday] = [moment().subtract(1, 'days').startOf('day'), moment().subtract(1, 'days').endOf('day')];
rangesConf[I18n.daterangepicker_ranges_this_month] = [moment().startOf('month'), moment().endOf('month')];
rangesConf[I18n.daterangepicker_ranges_last_month] = [moment().subtract(1, 'months').startOf('month'), moment().subtract(1, 'months').endOf('month')];
rangesConf[I18n.daterangepicker_ranges_recent_week] = [moment().subtract(1, 'weeks').startOf('day'), moment().endOf('day')];
rangesConf[I18n.daterangepicker_ranges_recent_month] = [moment().subtract(1, 'months').startOf('day'), moment().endOf('day')];
$('#filterTime').daterangepicker({
autoApply:false,
singleDatePicker:false,
showDropdowns:false, // 是否显示年月选择条件
timePicker: true, // 是否显示小时和分钟选择条件
timePickerIncrement: 10, // 时间的增量,单位为分钟
timePicker24Hour : true,
opens : 'left', //日期选择框的弹出位置
ranges: rangesConf,
locale : {
format: 'YYYY-MM-DD HH:mm:ss',
separator : ' - ',
customRangeLabel : I18n.daterangepicker_custom_name ,
applyLabel : I18n.system_ok ,
cancelLabel : I18n.system_cancel ,
fromLabel : I18n.daterangepicker_custom_starttime ,
toLabel : I18n.daterangepicker_custom_endtime ,
daysOfWeek : I18n.daterangepicker_custom_daysofweek.split(',') , // '日', '一', '二', '三', '四', '五', '六'
monthNames : I18n.daterangepicker_custom_monthnames.split(',') , // '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'
firstDay : 1
},
startDate: rangesConf[I18n.daterangepicker_ranges_today][0],
endDate: rangesConf[I18n.daterangepicker_ranges_today][1]
});
// init date tables
var logTable = $("#joblog_list").dataTable({
"deferRender": true,
"processing" : true,
"serverSide": true,
"ajax": {
url: base_url + "/joblog/pageList" ,
type:"post",
data : function ( d ) {
var obj = {};
obj.jobGroup = $('#jobGroup').val();
obj.jobId = $('#jobId').val();
obj.logStatus = $('#logStatus').val();
obj.filterTime = $('#filterTime').val();
obj.start = d.start;
obj.length = d.length;
return obj;
}
},
"searching": false,
"ordering": false,
//"scrollX": false,
"columns": [
{
"data": 'jobId',
"visible" : true,
"width":'10%',
"render": function ( data, type, row ) {
var jobhandler = '';
if (row.executorHandler) {
jobhandler = "
JobHandler:" + row.executorHandler;
}
var temp = '';
temp += I18n.joblog_field_executorAddress + ':' + (row.executorAddress?row.executorAddress:'');
temp += jobhandler;
temp += '
'+ I18n.jobinfo_field_executorparam +':' + row.executorParam;
return ''+ row.jobId +'';
}
},
{ "data": 'jobGroup', "visible" : false},
{
"data": 'triggerTime',
"width":'20%',
"render": function ( data, type, row ) {
return data?moment(data).format("YYYY-MM-DD HH:mm:ss"):"";
}
},
{
"data": 'triggerCode',
"width":'10%',
"render": function ( data, type, row ) {
var html = data;
if (data == 200) {
html = ''+ I18n.system_success +'';
} else if (data == 500) {
html = ''+ I18n.system_fail +'';
} else if (data == 0) {
html = '';
}
return html;
}
},
{
"data": 'triggerMsg',
"width":'10%',
"render": function ( data, type, row ) {
return data?''+ I18n.system_show +'':I18n.system_empty;
}
},
{
"data": 'handleTime',
"width":'20%',
"render": function ( data, type, row ) {
return data?moment(data).format("YYYY-MM-DD HH:mm:ss"):"";
}
},
{
"data": 'handleCode',
"width":'10%',
"render": function ( data, type, row ) {
var html = data;
if (data == 200) {
html = ''+ I18n.joblog_handleCode_200 +'';
} else if (data == 500) {
html = ''+ I18n.joblog_handleCode_500 +'';
} else if (data == 502) {
html = ''+ I18n.joblog_handleCode_502 +'';
} else if (data == 0) {
html = '';
}
return html;
}
},
{
"data": 'handleMsg',
"width":'10%',
"render": function ( data, type, row ) {
return data?''+ I18n.system_show +'':I18n.system_empty;
}
},
{
"data": 'handleMsg' ,
"bSortable": false,
"width":'10%',
"render": function ( data, type, row ) {
// better support expression or string, not function
return function () {
if (row.triggerCode == 200 || row.handleCode != 0){
/*var temp = ''+ I18n.joblog_rolling_log +'';
if(row.handleCode == 0){
temp += '
'+ I18n.joblog_kill_log +'';
}*/
//return temp;
var logKillDiv = '';
if(row.handleCode == 0){
logKillDiv = '