use ajax() instead of getJSON so that we can specify no timeout. This prevents log queries from stacking up overloading the db

pull/3609/head
Isaac Connor 2022-08-31 23:38:50 +02:00
parent 00f2b325b0
commit 4e5278882d
2 changed files with 36 additions and 14 deletions

View File

@ -39,8 +39,11 @@ function ajaxRequest(params) {
params.data.advsearch = params.data.filter;
delete params.data.filter;
}
$j.getJSON(thisUrl + '?view=request&request=events&task=query'+filterQuery, params.data)
.done(function(data) {
$j.ajax({
url: thisUrl + '?view=request&request=events&task=query'+filterQuery,
data: params.data,
timeout: 0,
success: function(data) {
if (data.result == 'Error') {
alert(data.message);
return;
@ -48,11 +51,13 @@ function ajaxRequest(params) {
var rows = processRows(data.rows);
// rearrange the result into what bootstrap-table expects
params.success({total: data.total, totalNotFiltered: data.totalNotFiltered, rows: rows});
})
.fail(function(jqXHR) {
logAjaxFail(jqXHR);
$j('#eventTable').bootstrapTable('refresh');
});
},
error: function(jqXHR) {
console.log("error", jqXHR);
//logAjaxFail(jqXHR);
//$j('#eventTable').bootstrapTable('refresh');
}
});
}
function processRows(rows) {
@ -110,7 +115,10 @@ function getDelConfirmModal() {
insertModalHtml('deleteConfirm', data.html);
manageDelConfirmModalBtns();
})
.fail(logAjaxFail);
.fail(function(jqXHR) {
console.log("error getting delconfirm", jqXHR);
logAjaxFail(jqXHR);
});
}
// Manage the DELETE CONFIRMATION modal button
@ -152,6 +160,7 @@ function deleteEvents(event_ids) {
}
})
.fail( function(jqxhr) {
console.log("Fail delete");
logAjaxFail(jqxhr);
$j('#eventTable').bootstrapTable('refresh');
$j('#deleteConfirm').modal('hide');
@ -169,7 +178,10 @@ function getEventDetailModal(eid) {
$j('#eventDetailForm').submit();
});
})
.fail(logAjaxFail);
.fail(function(jqxhr){
console.log("Fail get event details");
logAjaxFail(jqxhr);
});
}
function getObjdetectModal(eid) {
@ -178,7 +190,10 @@ function getObjdetectModal(eid) {
insertModalHtml('objdetectModal', data.html);
$j('#objdetectModal').modal('show');
})
.fail(logAjaxFail);
.fail(function(jqxhr){
console.log("Fail get objdetect details");
logAjaxFail(jqxhr);
});
}
function initPage() {

View File

@ -27,8 +27,11 @@ var params =
// Called by bootstrap-table to retrieve zm log data
function ajaxRequest(params) {
$j.getJSON(thisUrl + '?view=request&request=log&task=query', params.data)
.done(function(data) {
$j.ajax({
url: thisUrl + '?view=request&request=log&task=query',
data: params.data,
timeout: 0,
success: function(data) {
//console.log('Ajax parameters: ' + JSON.stringify(params));
// rearrange the result into what bootstrap-table expects
params.success({
@ -37,9 +40,13 @@ function ajaxRequest(params) {
rows: processRows(data.rows)
});
updateHeaderStats(data);
})
.fail(logAjaxFail);
},
error: function(jqxhr) {
logAjaxFail(jqxhr);
}
});
}
function processRows(rows) {
$j.each(rows, function(ndx, row) {
try {