2022-07-04 17:09:30 +02:00
|
|
|
/*global jQuery, $, forced_title_callback, confirmDialog, progressTimeBar*/
|
2019-06-12 13:17:18 +02:00
|
|
|
|
2012-10-09 18:05:32 +02:00
|
|
|
// Show the modal window of an event
|
2022-06-21 11:17:18 +02:00
|
|
|
function show_event_dialog(event, dialog_page) {
|
2023-02-07 16:48:23 +01:00
|
|
|
var ajax_file = getUrlAjax();
|
|
|
|
|
|
|
|
var view = ``;
|
|
|
|
|
|
|
|
if ($("#event_details_window").length) {
|
|
|
|
view = "#event_details_window";
|
|
|
|
} else if ($("#sound_event_details_window").length) {
|
|
|
|
view = "#sound_event_details_window";
|
|
|
|
}
|
2019-01-30 12:27:18 +01:00
|
|
|
|
|
|
|
if (dialog_page == undefined) {
|
|
|
|
dialog_page = "general";
|
|
|
|
}
|
|
|
|
|
2019-06-17 17:02:33 +02:00
|
|
|
try {
|
|
|
|
event = JSON.parse(atob(event));
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
return;
|
|
|
|
}
|
2019-01-30 12:27:18 +01:00
|
|
|
|
2019-06-14 19:23:04 +02:00
|
|
|
var inputs = $("#events_form :input");
|
|
|
|
var values = {};
|
|
|
|
inputs.each(function() {
|
|
|
|
values[this.name] = $(this).val();
|
|
|
|
});
|
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
// Metaconsole mode flag
|
|
|
|
var meta = $("#hidden-meta").val();
|
|
|
|
|
|
|
|
// History mode flag
|
|
|
|
var history = $("#hidden-history").val();
|
|
|
|
|
|
|
|
jQuery.post(
|
|
|
|
ajax_file,
|
|
|
|
{
|
|
|
|
page: "include/ajax/events",
|
|
|
|
get_extended_event: 1,
|
|
|
|
dialog_page: dialog_page,
|
2019-06-17 17:02:33 +02:00
|
|
|
event: event,
|
2019-01-30 12:27:18 +01:00
|
|
|
meta: meta,
|
2019-06-14 19:23:04 +02:00
|
|
|
history: history,
|
|
|
|
filter: values
|
2019-01-30 12:27:18 +01:00
|
|
|
},
|
2019-06-12 13:17:18 +02:00
|
|
|
function(data) {
|
2023-02-07 16:48:23 +01:00
|
|
|
$(view)
|
2019-01-30 12:27:18 +01:00
|
|
|
.hide()
|
|
|
|
.empty()
|
|
|
|
.append(data)
|
|
|
|
.dialog({
|
2019-06-17 17:02:33 +02:00
|
|
|
title: event.evento,
|
2019-01-30 12:27:18 +01:00
|
|
|
resizable: true,
|
|
|
|
draggable: true,
|
|
|
|
modal: true,
|
2021-10-15 09:36:22 +02:00
|
|
|
minWidth: 875,
|
2021-05-11 15:49:40 +02:00
|
|
|
minHeight: 600,
|
2019-01-30 12:27:18 +01:00
|
|
|
close: function() {
|
|
|
|
$("#refrcounter").countdown("resume");
|
|
|
|
$("div.vc-countdown").countdown("resume");
|
|
|
|
},
|
|
|
|
overlay: {
|
|
|
|
opacity: 0.5,
|
|
|
|
background: "black"
|
|
|
|
},
|
2019-06-17 19:12:45 +02:00
|
|
|
width: 710,
|
2023-03-10 08:40:38 +01:00
|
|
|
height: 650,
|
2022-03-03 18:37:33 +01:00
|
|
|
autoOpen: true,
|
|
|
|
open: function() {
|
|
|
|
if (
|
|
|
|
$.ui &&
|
|
|
|
$.ui.dialog &&
|
|
|
|
$.ui.dialog.prototype._allowInteraction
|
|
|
|
) {
|
|
|
|
var ui_dialog_interaction =
|
|
|
|
$.ui.dialog.prototype._allowInteraction;
|
|
|
|
$.ui.dialog.prototype._allowInteraction = function(e) {
|
|
|
|
if ($(e.target).closest(".select2-dropdown").length)
|
|
|
|
return true;
|
|
|
|
return ui_dialog_interaction.apply(this, arguments);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
_allowInteraction: function(event) {
|
|
|
|
return !!$(event.target).is(".select2-input") || this._super(event);
|
|
|
|
}
|
2019-01-30 12:27:18 +01:00
|
|
|
})
|
|
|
|
.show();
|
|
|
|
|
|
|
|
$("#refrcounter").countdown("pause");
|
|
|
|
$("div.vc-countdown").countdown("pause");
|
|
|
|
|
|
|
|
forced_title_callback();
|
|
|
|
},
|
|
|
|
"html"
|
|
|
|
);
|
|
|
|
return false;
|
2012-10-01 13:15:31 +02:00
|
|
|
}
|
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
// Check the response type and open it in a modal dialog or new window
|
2012-12-20 16:33:23 +01:00
|
|
|
function execute_response(event_id, server_id) {
|
2019-01-30 12:27:18 +01:00
|
|
|
var response_id = $("#select_custom_response option:selected").val();
|
|
|
|
|
2022-09-27 09:51:37 +02:00
|
|
|
var response_parameters_list = $('input[name^="values_params_"]');
|
|
|
|
var response_parameters = [];
|
|
|
|
if (response_parameters_list.length > 0) {
|
|
|
|
response_parameters_list.each(function() {
|
|
|
|
var acum = {
|
|
|
|
name: $(this).attr("name"),
|
|
|
|
value: $(this).val()
|
|
|
|
};
|
|
|
|
response_parameters.push(acum);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
var params = [];
|
|
|
|
params.push({ name: "page", value: "include/ajax/events" });
|
|
|
|
params.push({ name: "get_response", value: 1 });
|
|
|
|
params.push({ name: "response_id", value: response_id });
|
|
|
|
params.push({ name: "server_id", value: server_id });
|
|
|
|
params.push({ name: "event_id", value: event_id });
|
2022-09-27 09:51:37 +02:00
|
|
|
params.push({
|
|
|
|
name: "response_parameters",
|
|
|
|
value: JSON.stringify(response_parameters)
|
|
|
|
});
|
2019-01-30 12:27:18 +01:00
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
jQuery.ajax({
|
|
|
|
data: params,
|
|
|
|
type: "POST",
|
2023-02-07 17:41:27 +01:00
|
|
|
url: getUrlAjax(),
|
2022-09-23 13:55:01 +02:00
|
|
|
dataType: "json",
|
|
|
|
success: function(response) {
|
|
|
|
// If cannot get response abort it
|
|
|
|
if (response == null) {
|
|
|
|
return [];
|
|
|
|
}
|
2019-01-30 12:27:18 +01:00
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
response["event_id"] = event_id;
|
|
|
|
response["server_id"] = server_id;
|
|
|
|
if (response["type"] == "url" && response["new_window"] == 1) {
|
|
|
|
window.open(response["target"], "_blank");
|
|
|
|
} else {
|
|
|
|
show_response_dialog(response_id, response);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2012-10-09 18:05:32 +02:00
|
|
|
}
|
2012-10-01 13:15:31 +02:00
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
// Check the response type and open it in a modal dialog or new window
|
2022-09-27 09:51:37 +02:00
|
|
|
function execute_response_massive(events, response_id, response_parameters) {
|
2019-01-30 12:27:18 +01:00
|
|
|
var params = [];
|
2022-09-23 13:55:01 +02:00
|
|
|
params.push({ name: "page", value: "include/ajax/events" });
|
|
|
|
params.push({ name: "get_response_massive", value: 1 });
|
|
|
|
params.push({ name: "response_id", value: response_id });
|
|
|
|
params.push({ name: "events", value: JSON.stringify(events) });
|
2022-09-27 09:51:37 +02:00
|
|
|
params.push({ name: "response_parameters", value: response_parameters });
|
2019-01-30 12:27:18 +01:00
|
|
|
|
|
|
|
jQuery.ajax({
|
2022-09-23 13:55:01 +02:00
|
|
|
data: params,
|
2019-01-30 12:27:18 +01:00
|
|
|
type: "POST",
|
2023-02-07 17:41:27 +01:00
|
|
|
url: getUrlAjax(),
|
2022-09-23 13:55:01 +02:00
|
|
|
dataType: "json",
|
2019-01-30 12:27:18 +01:00
|
|
|
success: function(data) {
|
2022-09-23 13:55:01 +02:00
|
|
|
// If cannot get response abort it
|
|
|
|
if (data == null) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
$(".container-massive-events-response").empty();
|
|
|
|
|
|
|
|
// Convert to array.
|
|
|
|
var array_data = Object.entries(data.event_response_targets);
|
|
|
|
var total_count = array_data.length;
|
|
|
|
|
|
|
|
// Each input checkeds.
|
|
|
|
array_data.forEach(function(element, index) {
|
|
|
|
var id = element[0];
|
|
|
|
var target = element[1].target;
|
|
|
|
var meta = $("#hidden-meta").val();
|
|
|
|
var event_id = id;
|
|
|
|
var server_id = 0;
|
|
|
|
if (meta != 0) {
|
|
|
|
var split_id = id.split("|");
|
|
|
|
event_id = split_id[0];
|
|
|
|
server_id = split_id[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
var end = 0;
|
|
|
|
if (total_count - 1 === index) {
|
|
|
|
end = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
var response = data.event_response;
|
|
|
|
response["event_id"] = event_id;
|
|
|
|
response["server_id"] = server_id;
|
|
|
|
response["target"] = target;
|
|
|
|
if (response["type"] == "url" && response["new_window"] == 1) {
|
|
|
|
window.open(response["target"], "_blank");
|
|
|
|
} else {
|
|
|
|
var params = [];
|
|
|
|
params.push({ name: "page", value: "include/ajax/events" });
|
|
|
|
params.push({ name: "get_row_response_action", value: 1 });
|
|
|
|
params.push({ name: "response_id", value: response_id });
|
|
|
|
params.push({ name: "server_id", value: response.server_id });
|
|
|
|
params.push({ name: "end", value: end });
|
|
|
|
params.push({ name: "response", value: JSON.stringify(response) });
|
|
|
|
|
|
|
|
jQuery.ajax({
|
|
|
|
data: params,
|
|
|
|
type: "POST",
|
2023-02-07 17:41:27 +01:00
|
|
|
url: getUrlAjax(),
|
2022-09-23 13:55:01 +02:00
|
|
|
dataType: "html",
|
|
|
|
success: function(data) {
|
|
|
|
$(".container-massive-events-response").append(data);
|
|
|
|
response["event_id"] = event_id;
|
|
|
|
response["server_id"] = server_id;
|
|
|
|
response["target"] = target;
|
2022-09-27 09:51:37 +02:00
|
|
|
|
|
|
|
var indexstr = event_id;
|
|
|
|
if (meta != 0) {
|
|
|
|
indexstr += "-" + server_id;
|
|
|
|
}
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
perform_response(
|
|
|
|
btoa(JSON.stringify(response)),
|
|
|
|
response_id,
|
2022-09-27 09:51:37 +02:00
|
|
|
indexstr
|
2022-09-23 13:55:01 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2019-01-30 12:27:18 +01:00
|
|
|
}
|
|
|
|
});
|
2012-10-09 18:05:32 +02:00
|
|
|
}
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
//Show the modal window of an event response
|
|
|
|
function show_response_dialog(response_id, response) {
|
2019-01-30 12:27:18 +01:00
|
|
|
var params = [];
|
2022-09-23 13:55:01 +02:00
|
|
|
params.push({ name: "page", value: "include/ajax/events" });
|
|
|
|
params.push({ name: "dialogue_event_response", value: 1 });
|
|
|
|
params.push({ name: "event_id", value: response.event_id });
|
|
|
|
params.push({ name: "target", value: response.target });
|
|
|
|
params.push({ name: "response_id", value: response_id });
|
|
|
|
params.push({ name: "server_id", value: response.server_id });
|
|
|
|
params.push({ name: "response", value: JSON.stringify(response) });
|
2019-01-30 12:27:18 +01:00
|
|
|
|
2023-02-07 17:41:27 +01:00
|
|
|
var view = ``;
|
|
|
|
|
|
|
|
if ($("#event_response_window").length) {
|
|
|
|
view = "#event_response_window";
|
|
|
|
} else if ($("#sound_event_response_window").length) {
|
|
|
|
view = "#sound_event_response_window";
|
|
|
|
}
|
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
jQuery.ajax({
|
2022-09-23 13:55:01 +02:00
|
|
|
data: params,
|
2019-01-30 12:27:18 +01:00
|
|
|
type: "POST",
|
2023-02-07 17:41:27 +01:00
|
|
|
url: getUrlAjax(),
|
2019-01-30 12:27:18 +01:00
|
|
|
dataType: "html",
|
|
|
|
success: function(data) {
|
2023-02-07 17:41:27 +01:00
|
|
|
$(view)
|
2019-01-30 12:27:18 +01:00
|
|
|
.hide()
|
2022-09-23 13:55:01 +02:00
|
|
|
.empty()
|
2019-01-30 12:27:18 +01:00
|
|
|
.append(data)
|
|
|
|
.dialog({
|
|
|
|
title: $("#select_custom_response option:selected").html(),
|
|
|
|
resizable: true,
|
|
|
|
draggable: true,
|
|
|
|
modal: false,
|
2019-06-12 13:17:18 +02:00
|
|
|
open: function() {
|
2022-09-23 13:55:01 +02:00
|
|
|
perform_response(btoa(JSON.stringify(response)), response_id, "");
|
2019-01-30 12:27:18 +01:00
|
|
|
},
|
|
|
|
width: response["modal_width"],
|
2022-09-27 09:51:37 +02:00
|
|
|
height: response["modal_height"],
|
|
|
|
buttons: []
|
2019-01-30 12:27:18 +01:00
|
|
|
})
|
|
|
|
.show();
|
|
|
|
}
|
|
|
|
});
|
2019-01-14 12:10:43 +01:00
|
|
|
}
|
|
|
|
|
2012-10-09 18:05:32 +02:00
|
|
|
// Perform a response and put the output into a div
|
2022-09-23 13:55:01 +02:00
|
|
|
function perform_response(response, response_id, index) {
|
|
|
|
$("#re_exec_command" + index).hide();
|
|
|
|
$("#response_loading_command" + index).show();
|
|
|
|
$("#response_out" + index).html("");
|
2019-01-30 12:27:18 +01:00
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
try {
|
|
|
|
response = JSON.parse(atob(response));
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
return;
|
|
|
|
}
|
2019-01-30 12:27:18 +01:00
|
|
|
|
|
|
|
var params = [];
|
2022-09-23 13:55:01 +02:00
|
|
|
params.push({ name: "page", value: "include/ajax/events" });
|
|
|
|
params.push({ name: "perform_event_response", value: 1 });
|
|
|
|
params.push({ name: "target", value: response["target"] });
|
|
|
|
params.push({ name: "response_id", value: response_id });
|
|
|
|
params.push({ name: "event_id", value: response["event_id"] });
|
|
|
|
params.push({ name: "server_id", value: response["server_id"] });
|
|
|
|
params.push({ name: "response", value: JSON.stringify(response) });
|
2019-01-30 12:27:18 +01:00
|
|
|
|
|
|
|
jQuery.ajax({
|
2022-09-23 13:55:01 +02:00
|
|
|
data: params,
|
2019-01-30 12:27:18 +01:00
|
|
|
type: "POST",
|
2023-02-07 17:41:27 +01:00
|
|
|
url: getUrlAjax(),
|
2019-01-30 12:27:18 +01:00
|
|
|
dataType: "html",
|
|
|
|
success: function(data) {
|
|
|
|
var out = data.replace(/[\n|\r]/g, "<br>");
|
2022-09-23 13:55:01 +02:00
|
|
|
$("#response_out" + index).html(out);
|
|
|
|
$("#response_loading_command" + index).hide();
|
|
|
|
$("#re_exec_command" + index).show();
|
2019-01-30 12:27:18 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
2019-01-14 12:10:43 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 10:59:44 +01:00
|
|
|
// Change the status of an event to new, in process or validated.
|
2022-06-15 13:06:10 +02:00
|
|
|
function event_change_status(event_ids, server_id) {
|
2019-01-30 12:27:18 +01:00
|
|
|
var new_status = $("#estado").val();
|
|
|
|
|
|
|
|
$("#button-status_button").attr("disabled", "disabled");
|
|
|
|
$("#response_loading").show();
|
|
|
|
|
|
|
|
jQuery.ajax({
|
2019-07-10 12:15:41 +02:00
|
|
|
data: {
|
|
|
|
page: "include/ajax/events",
|
|
|
|
change_status: 1,
|
|
|
|
event_ids: event_ids,
|
|
|
|
new_status: new_status,
|
2022-06-15 13:06:10 +02:00
|
|
|
server_id: server_id
|
2019-07-10 12:15:41 +02:00
|
|
|
},
|
2019-01-30 12:27:18 +01:00
|
|
|
type: "POST",
|
2023-02-07 17:41:27 +01:00
|
|
|
url: getUrlAjax(),
|
2020-10-30 14:42:10 +01:00
|
|
|
dataType: "json",
|
2019-01-30 12:27:18 +01:00
|
|
|
success: function(data) {
|
|
|
|
$("#button-status_button").removeAttr("disabled");
|
|
|
|
$("#response_loading").hide();
|
2019-07-10 12:15:41 +02:00
|
|
|
|
|
|
|
if ($("#notification_status_success").length) {
|
|
|
|
$("#notification_status_success").hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($("#notification_status_error").length) {
|
|
|
|
$("#notification_status_error").hide();
|
|
|
|
}
|
2022-03-22 18:02:53 +01:00
|
|
|
|
2020-10-30 14:42:10 +01:00
|
|
|
if (data.status == "status_ok") {
|
2023-01-05 10:36:14 +01:00
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: "ajax.php",
|
|
|
|
data: {
|
|
|
|
page: "include/ajax/events",
|
|
|
|
get_Acknowledged: 1,
|
2023-01-25 11:25:20 +01:00
|
|
|
event_id: event_ids,
|
|
|
|
server_id: server_id
|
2023-01-05 10:36:14 +01:00
|
|
|
},
|
|
|
|
success: function(response) {
|
2023-01-25 11:25:20 +01:00
|
|
|
$(".general_acknowleded").html(response);
|
2023-01-05 10:36:14 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-02-07 16:48:23 +01:00
|
|
|
if ($("#table_events").length) {
|
|
|
|
$("#table_events")
|
|
|
|
.DataTable()
|
|
|
|
.draw(false);
|
|
|
|
}
|
|
|
|
|
2019-07-10 12:15:41 +02:00
|
|
|
$("#notification_status_success").show();
|
2022-03-21 18:15:58 +01:00
|
|
|
|
|
|
|
$("#general_status")
|
|
|
|
.find(".general_status")
|
|
|
|
.text(data.status_title);
|
|
|
|
$("#general_status")
|
|
|
|
.find("img")
|
|
|
|
.attr("src", data.status_img);
|
2019-07-10 12:15:41 +02:00
|
|
|
} else {
|
|
|
|
$("#notification_status_error").show();
|
|
|
|
}
|
2019-01-30 12:27:18 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
2012-10-01 13:15:31 +02:00
|
|
|
}
|
|
|
|
|
2012-10-09 18:05:32 +02:00
|
|
|
// Change te owner of an event to one user of empty
|
2022-06-15 13:06:10 +02:00
|
|
|
function event_change_owner(event_id, server_id) {
|
2019-01-30 12:27:18 +01:00
|
|
|
var new_owner = $("#id_owner").val();
|
|
|
|
|
|
|
|
$("#button-owner_button").attr("disabled", "disabled");
|
|
|
|
$("#response_loading").show();
|
|
|
|
|
|
|
|
jQuery.ajax({
|
2019-07-09 16:41:00 +02:00
|
|
|
data: {
|
|
|
|
page: "include/ajax/events",
|
|
|
|
change_owner: 1,
|
|
|
|
event_id: event_id,
|
2022-06-15 13:06:10 +02:00
|
|
|
server_id: server_id,
|
|
|
|
new_owner: new_owner
|
2019-07-09 16:41:00 +02:00
|
|
|
},
|
2019-01-30 12:27:18 +01:00
|
|
|
type: "POST",
|
2023-02-07 17:41:27 +01:00
|
|
|
url: getUrlAjax(),
|
2019-01-30 12:27:18 +01:00
|
|
|
async: true,
|
|
|
|
dataType: "html",
|
|
|
|
success: function(data) {
|
|
|
|
$("#button-owner_button").removeAttr("disabled");
|
|
|
|
$("#response_loading").hide();
|
|
|
|
|
2019-07-10 11:05:06 +02:00
|
|
|
if ($("#notification_owner_success").length) {
|
|
|
|
$("#notification_owner_success").hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($("#notification_owner_error").length) {
|
|
|
|
$("#notification_owner_error").hide();
|
|
|
|
}
|
|
|
|
|
2019-07-09 16:41:00 +02:00
|
|
|
if (data == "owner_ok") {
|
2022-09-16 11:04:01 +02:00
|
|
|
// if (typeof dt_events !== "undefined") {
|
|
|
|
// dt_events.draw(false);
|
|
|
|
// }
|
2023-02-07 16:48:23 +01:00
|
|
|
|
|
|
|
if ($("#table_events").length) {
|
|
|
|
$("#table_events")
|
|
|
|
.DataTable()
|
|
|
|
.draw(false);
|
|
|
|
}
|
2019-07-09 16:41:00 +02:00
|
|
|
$("#notification_owner_success").show();
|
|
|
|
if (new_owner == -1) {
|
2019-07-10 12:15:41 +02:00
|
|
|
$("#extended_event_general_page table td.general_owner").html(
|
|
|
|
"<i>N/A</i>"
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$("#extended_event_general_page table td.general_owner").text(
|
|
|
|
new_owner
|
|
|
|
);
|
2019-07-09 16:41:00 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$("#notification_owner_error").show();
|
|
|
|
}
|
2019-01-30 12:27:18 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
2012-10-01 13:15:31 +02:00
|
|
|
}
|
|
|
|
|
2012-10-09 18:05:32 +02:00
|
|
|
// Save a comment into an event
|
2020-03-26 12:29:38 +01:00
|
|
|
function event_comment(current_event) {
|
2019-06-17 19:12:45 +02:00
|
|
|
var event;
|
|
|
|
try {
|
|
|
|
event = JSON.parse(atob(current_event));
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
var comment = $("#textarea_comment").val();
|
2020-03-26 12:29:38 +01:00
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
if (comment == "") {
|
2019-06-17 19:12:45 +02:00
|
|
|
show_event_dialog(current_event, "comments", "comment_error");
|
2019-01-30 12:27:18 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
var params = [];
|
|
|
|
params.push("page=include/ajax/events");
|
|
|
|
params.push("add_comment=1");
|
2021-11-29 16:12:15 +01:00
|
|
|
if (event.event_rep > 0) {
|
|
|
|
params.push("event_id=" + event.max_id_evento);
|
|
|
|
} else {
|
|
|
|
params.push("event_id=" + event.id_evento);
|
|
|
|
}
|
2019-01-30 12:27:18 +01:00
|
|
|
params.push("comment=" + comment);
|
2022-06-14 18:47:09 +02:00
|
|
|
params.push("server_id=" + event.server_id);
|
2019-01-30 12:27:18 +01:00
|
|
|
|
|
|
|
$("#button-comment_button").attr("disabled", "disabled");
|
|
|
|
$("#response_loading").show();
|
2023-02-07 17:41:27 +01:00
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
jQuery.ajax({
|
|
|
|
data: params.join("&"),
|
|
|
|
type: "POST",
|
2023-02-07 17:41:27 +01:00
|
|
|
url: getUrlAjax(),
|
2019-01-30 12:27:18 +01:00
|
|
|
dataType: "html",
|
2022-06-15 13:06:10 +02:00
|
|
|
success: function() {
|
2019-01-30 12:27:18 +01:00
|
|
|
$("#button-comment_button").removeAttr("disabled");
|
2019-06-20 21:11:56 +02:00
|
|
|
$("#response_loading").hide();
|
|
|
|
$("#link_comments").click();
|
2019-01-30 12:27:18 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
2012-10-01 13:15:31 +02:00
|
|
|
}
|
2016-07-22 16:08:45 +02:00
|
|
|
|
2019-06-18 10:32:04 +02:00
|
|
|
var processed = 0;
|
2022-06-15 13:06:10 +02:00
|
|
|
function update_event(table, id_evento, type, event_rep, row, server_id) {
|
2019-06-13 12:30:09 +02:00
|
|
|
var inputs = $("#events_form :input");
|
|
|
|
var values = {};
|
2019-06-13 13:07:11 +02:00
|
|
|
var redraw = false;
|
2019-06-13 12:30:09 +02:00
|
|
|
inputs.each(function() {
|
|
|
|
values[this.name] = $(this).val();
|
|
|
|
});
|
2019-06-13 13:07:11 +02:00
|
|
|
var t1 = new Date();
|
2023-02-07 17:41:27 +01:00
|
|
|
|
2019-06-13 12:30:09 +02:00
|
|
|
$.ajax({
|
2019-06-18 11:00:48 +02:00
|
|
|
async: true,
|
2019-06-13 12:30:09 +02:00
|
|
|
type: "POST",
|
2023-02-07 17:41:27 +01:00
|
|
|
url: getUrlAjax(),
|
2019-06-13 12:30:09 +02:00
|
|
|
data: {
|
|
|
|
page: "include/ajax/events",
|
|
|
|
validate_event: type.validate_event,
|
|
|
|
in_process_event: type.in_process_event,
|
2019-06-13 16:28:26 +02:00
|
|
|
delete_event: type.delete_event,
|
2019-06-13 12:30:09 +02:00
|
|
|
id_evento: id_evento,
|
2022-06-15 13:06:10 +02:00
|
|
|
server_id: server_id,
|
2019-06-18 18:35:34 +02:00
|
|
|
event_rep: event_rep,
|
2019-06-13 12:30:09 +02:00
|
|
|
filter: values
|
|
|
|
},
|
2019-06-18 10:32:04 +02:00
|
|
|
success: function(d) {
|
|
|
|
processed += 1;
|
2019-06-13 13:07:11 +02:00
|
|
|
var t2 = new Date();
|
2019-06-13 13:35:02 +02:00
|
|
|
var diff_g = t2.getTime() - t1.getTime();
|
2019-06-13 13:07:11 +02:00
|
|
|
var diff_s = diff_g / 1000;
|
2019-06-18 10:32:04 +02:00
|
|
|
if (processed >= $(".chk_val:checked").length) {
|
|
|
|
// If operation takes less than 2 seconds, redraw.
|
2019-06-25 17:24:16 +02:00
|
|
|
if (diff_s < 2 || $(".chk_val:checked").length > 1) {
|
2019-06-18 10:32:04 +02:00
|
|
|
redraw = true;
|
|
|
|
}
|
|
|
|
if (redraw) {
|
2022-06-21 11:17:18 +02:00
|
|
|
$("#" + table)
|
|
|
|
.DataTable()
|
|
|
|
.draw(false);
|
2019-06-18 10:32:04 +02:00
|
|
|
} else {
|
|
|
|
$(row)
|
|
|
|
.closest("tr")
|
|
|
|
.remove();
|
2019-06-13 20:09:55 +02:00
|
|
|
}
|
2019-06-13 12:36:31 +02:00
|
|
|
}
|
2019-06-18 14:26:55 +02:00
|
|
|
},
|
|
|
|
error: function() {
|
|
|
|
processed += 1;
|
2019-06-13 12:30:09 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-06-04 13:50:36 +02:00
|
|
|
// Update events matching current filters and id_evento selected.
|
2019-06-13 12:30:09 +02:00
|
|
|
|
2022-06-15 13:06:10 +02:00
|
|
|
function validate_event(table, id_evento, event_rep, row, server_id) {
|
2019-06-18 15:03:49 +02:00
|
|
|
var button = document.getElementById("val-" + id_evento);
|
2022-06-21 11:17:18 +02:00
|
|
|
var meta = $("#hidden-meta").val();
|
2022-06-22 10:29:19 +02:00
|
|
|
if (meta != 0) {
|
2022-06-21 11:17:18 +02:00
|
|
|
button = document.getElementById("val-" + id_evento + "-" + server_id);
|
|
|
|
}
|
|
|
|
|
2019-06-18 15:03:49 +02:00
|
|
|
if (!button) {
|
|
|
|
// Button does not exist. Ignore.
|
2019-06-25 16:05:56 +02:00
|
|
|
processed += 1;
|
2019-06-18 15:03:49 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
button.children[0];
|
|
|
|
button.children[0].src = "images/spinner.gif";
|
2022-06-15 13:06:10 +02:00
|
|
|
return update_event(
|
|
|
|
table,
|
|
|
|
id_evento,
|
|
|
|
{ validate_event: 1 },
|
|
|
|
event_rep,
|
|
|
|
row,
|
|
|
|
server_id
|
|
|
|
);
|
2019-06-13 12:30:09 +02:00
|
|
|
}
|
|
|
|
|
2022-06-15 13:06:10 +02:00
|
|
|
function in_process_event(table, id_evento, event_rep, row, server_id) {
|
2019-06-18 15:03:49 +02:00
|
|
|
var button = document.getElementById("proc-" + id_evento);
|
2022-06-21 11:17:18 +02:00
|
|
|
var meta = $("#hidden-meta").val();
|
2022-06-22 10:29:19 +02:00
|
|
|
if (meta != 0) {
|
2022-06-21 11:17:18 +02:00
|
|
|
button = document.getElementById("proc-" + id_evento + "-" + server_id);
|
|
|
|
}
|
|
|
|
|
2019-06-18 15:03:49 +02:00
|
|
|
if (!button) {
|
|
|
|
// Button does not exist. Ignore.
|
2019-06-25 16:05:56 +02:00
|
|
|
processed += 1;
|
2019-06-18 15:03:49 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
button.children[0];
|
|
|
|
button.children[0].src = "images/spinner.gif";
|
2019-06-18 18:35:34 +02:00
|
|
|
return update_event(
|
|
|
|
table,
|
|
|
|
id_evento,
|
|
|
|
{ in_process_event: 1 },
|
|
|
|
event_rep,
|
2022-06-15 13:06:10 +02:00
|
|
|
row,
|
|
|
|
server_id
|
2019-06-18 18:35:34 +02:00
|
|
|
);
|
2019-06-12 18:19:39 +02:00
|
|
|
}
|
|
|
|
|
2022-06-15 13:06:10 +02:00
|
|
|
function delete_event(table, id_evento, event_rep, row, server_id) {
|
2019-06-18 15:03:49 +02:00
|
|
|
var button = document.getElementById("del-" + id_evento);
|
2022-06-21 11:17:18 +02:00
|
|
|
var meta = $("#hidden-meta").val();
|
2022-06-22 10:29:19 +02:00
|
|
|
if (meta != 0) {
|
2022-06-21 11:17:18 +02:00
|
|
|
button = document.getElementById("del-" + id_evento + "-" + server_id);
|
|
|
|
}
|
|
|
|
|
2019-06-18 15:03:49 +02:00
|
|
|
if (!button) {
|
|
|
|
// Button does not exist. Ignore.
|
2019-06-25 16:05:56 +02:00
|
|
|
processed += 1;
|
2019-06-18 15:03:49 +02:00
|
|
|
return;
|
|
|
|
}
|
2022-06-16 11:31:07 +02:00
|
|
|
var message = "<h3 style = 'text-align: center;' > Are you sure?</h3> ";
|
2020-06-04 11:08:51 +02:00
|
|
|
confirmDialog({
|
|
|
|
title: "ATTENTION",
|
2020-06-04 13:50:36 +02:00
|
|
|
message: message,
|
2020-06-04 11:08:51 +02:00
|
|
|
cancel: "Cancel",
|
|
|
|
ok: "Ok",
|
|
|
|
onAccept: function() {
|
|
|
|
button.children[0];
|
|
|
|
button.children[0].src = "images/spinner.gif";
|
|
|
|
return update_event(
|
|
|
|
table,
|
|
|
|
id_evento,
|
|
|
|
{ delete_event: 1 },
|
|
|
|
event_rep,
|
2022-06-15 13:06:10 +02:00
|
|
|
row,
|
|
|
|
server_id
|
2020-06-04 11:08:51 +02:00
|
|
|
);
|
2020-06-04 13:50:36 +02:00
|
|
|
},
|
|
|
|
onDeny: function() {
|
|
|
|
button.children[0];
|
2023-03-10 12:40:21 +01:00
|
|
|
button.children[0].src = "images/delete.svg";
|
2020-06-04 13:50:36 +02:00
|
|
|
return;
|
2020-06-04 11:08:51 +02:00
|
|
|
}
|
|
|
|
});
|
2019-06-12 18:19:39 +02:00
|
|
|
}
|
2019-06-13 19:41:21 +02:00
|
|
|
|
2022-06-20 12:29:00 +02:00
|
|
|
function execute_delete_event_reponse(
|
|
|
|
table,
|
|
|
|
id_evento,
|
|
|
|
event_rep,
|
|
|
|
row,
|
|
|
|
server_id
|
|
|
|
) {
|
2020-06-04 13:50:36 +02:00
|
|
|
var button = document.getElementById("del-" + id_evento);
|
2022-06-21 11:17:18 +02:00
|
|
|
var meta = $("#hidden-meta").val();
|
2022-06-22 10:29:19 +02:00
|
|
|
if (meta != 0) {
|
2022-06-21 11:17:18 +02:00
|
|
|
button = document.getElementById("del-" + id_evento + "-" + server_id);
|
|
|
|
}
|
|
|
|
|
2020-06-04 13:50:36 +02:00
|
|
|
if (!button) {
|
|
|
|
// Button does not exist. Ignore.
|
|
|
|
processed += 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
button.children[0];
|
|
|
|
button.children[0].src = "images/spinner.gif";
|
2022-06-20 12:29:00 +02:00
|
|
|
return update_event(
|
|
|
|
table,
|
|
|
|
id_evento,
|
|
|
|
{ delete_event: 1 },
|
|
|
|
event_rep,
|
|
|
|
row,
|
|
|
|
server_id
|
|
|
|
);
|
2020-06-04 13:50:36 +02:00
|
|
|
}
|
|
|
|
|
2019-06-13 19:41:21 +02:00
|
|
|
// Imported from old files.
|
|
|
|
function execute_event_response(event_list_btn) {
|
2022-09-27 09:51:37 +02:00
|
|
|
var response_id = $("select[name=response_id]").val();
|
|
|
|
if (!isNaN(response_id)) {
|
|
|
|
table_info_response_event(response_id, 0, 0, true);
|
|
|
|
}
|
|
|
|
|
2021-03-29 09:23:03 +02:00
|
|
|
var message =
|
2022-09-27 09:51:37 +02:00
|
|
|
"<h4 style = 'text-align: center; color:black' > Are you sure?</h4> <div id='massive-parameters-response'></div> ";
|
2020-06-04 13:50:36 +02:00
|
|
|
confirmDialog({
|
|
|
|
title: "ATTENTION",
|
|
|
|
message: message,
|
|
|
|
cancel: "Cancel",
|
|
|
|
ok: "Ok",
|
|
|
|
onAccept: function() {
|
|
|
|
// Continue execution.
|
|
|
|
processed = 0;
|
|
|
|
$("#max_custom_event_resp_msg").hide();
|
|
|
|
$("#max_custom_selected").hide();
|
2019-06-13 19:41:21 +02:00
|
|
|
|
2020-06-04 13:50:36 +02:00
|
|
|
var total_checked = $(".chk_val:checked").length;
|
2019-06-18 10:32:04 +02:00
|
|
|
|
2020-06-04 13:50:36 +02:00
|
|
|
// Check select an event.
|
|
|
|
if (total_checked == 0) {
|
|
|
|
$("#max_custom_selected").show();
|
|
|
|
return;
|
|
|
|
}
|
2019-06-18 10:32:04 +02:00
|
|
|
|
2020-06-04 13:50:36 +02:00
|
|
|
if (!isNaN(response_id)) {
|
2022-09-27 09:51:37 +02:00
|
|
|
var response_parameters_list = $('input[name^="values_params_"]');
|
|
|
|
var response_parameters = [];
|
|
|
|
if (response_parameters_list.length > 0) {
|
|
|
|
response_parameters_list.each(function() {
|
|
|
|
var acum = {
|
|
|
|
name: $(this).attr("name"),
|
|
|
|
value: $(this).val()
|
|
|
|
};
|
|
|
|
response_parameters.push(acum);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
response_parameters = JSON.stringify(response_parameters);
|
|
|
|
|
2020-06-04 13:50:36 +02:00
|
|
|
if (event_list_btn) {
|
|
|
|
$("#button-submit_event_response").hide(function() {
|
|
|
|
$("#response_loading_dialog").show(function() {
|
2022-09-27 09:51:37 +02:00
|
|
|
show_response_dialog_massive(response_id, response_parameters);
|
2020-06-04 13:50:36 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
2022-09-27 09:51:37 +02:00
|
|
|
check_execute_response_massive(response_id, response_parameters);
|
2020-06-04 13:50:36 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// It is not a custom response
|
|
|
|
switch (response_id) {
|
|
|
|
case "in_progress_selected":
|
|
|
|
$(".chk_val:checked").each(function() {
|
2022-06-21 11:17:18 +02:00
|
|
|
var event_id = $(this).val();
|
|
|
|
var meta = $("#hidden-meta").val();
|
|
|
|
var server_id = 0;
|
2022-06-22 10:29:19 +02:00
|
|
|
if (meta != 0) {
|
2022-06-21 11:17:18 +02:00
|
|
|
var split_id = event_id.split("|");
|
|
|
|
event_id = split_id[0];
|
|
|
|
server_id = split_id[1];
|
|
|
|
}
|
|
|
|
|
2020-06-04 13:50:36 +02:00
|
|
|
in_process_event(
|
2022-10-19 16:20:49 +02:00
|
|
|
"table_events",
|
2022-06-21 11:17:18 +02:00
|
|
|
event_id,
|
2020-06-04 13:50:36 +02:00
|
|
|
$(this).attr("event_rep"),
|
2022-06-20 12:29:00 +02:00
|
|
|
this.parentElement.parentElement,
|
|
|
|
server_id
|
2020-06-04 13:50:36 +02:00
|
|
|
);
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case "validate_selected":
|
|
|
|
$(".chk_val:checked").each(function() {
|
2022-06-21 11:17:18 +02:00
|
|
|
var event_id = $(this).val();
|
|
|
|
var meta = $("#hidden-meta").val();
|
|
|
|
var server_id = 0;
|
2022-06-22 10:29:19 +02:00
|
|
|
if (meta != 0) {
|
2022-06-21 11:17:18 +02:00
|
|
|
var split_id = event_id.split("|");
|
|
|
|
event_id = split_id[0];
|
|
|
|
server_id = split_id[1];
|
|
|
|
}
|
|
|
|
|
2020-06-04 13:50:36 +02:00
|
|
|
validate_event(
|
2022-10-19 16:20:49 +02:00
|
|
|
"table_events",
|
2022-06-20 12:29:00 +02:00
|
|
|
event_id,
|
2020-06-04 13:50:36 +02:00
|
|
|
$(this).attr("event_rep"),
|
2022-06-20 12:29:00 +02:00
|
|
|
this.parentElement.parentElement,
|
|
|
|
server_id
|
2020-06-04 13:50:36 +02:00
|
|
|
);
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case "delete_selected":
|
|
|
|
$(".chk_val:checked").each(function() {
|
2022-06-21 11:17:18 +02:00
|
|
|
var event_id = $(this).val();
|
|
|
|
var meta = $("#hidden-meta").val();
|
|
|
|
var server_id = 0;
|
2022-06-22 10:29:19 +02:00
|
|
|
if (meta != 0) {
|
2022-06-21 11:17:18 +02:00
|
|
|
var split_id = event_id.split("|");
|
|
|
|
event_id = split_id[0];
|
|
|
|
server_id = split_id[1];
|
|
|
|
}
|
|
|
|
|
2020-06-04 13:50:36 +02:00
|
|
|
execute_delete_event_reponse(
|
2022-10-19 16:20:49 +02:00
|
|
|
"table_events",
|
2022-06-20 12:29:00 +02:00
|
|
|
event_id,
|
2020-06-04 13:50:36 +02:00
|
|
|
$(this).attr("event_rep"),
|
2022-06-20 12:29:00 +02:00
|
|
|
this.parentElement.parentElement,
|
|
|
|
server_id
|
2020-06-04 13:50:36 +02:00
|
|
|
);
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onDeny: function() {
|
|
|
|
processed += 1;
|
|
|
|
return;
|
2019-06-13 19:41:21 +02:00
|
|
|
}
|
2020-06-04 13:50:36 +02:00
|
|
|
});
|
2019-06-13 19:41:21 +02:00
|
|
|
}
|
|
|
|
|
2022-09-27 09:51:37 +02:00
|
|
|
function show_response_dialog_massive(response_id, response_parameters) {
|
2022-09-23 13:55:01 +02:00
|
|
|
var params = [];
|
|
|
|
params.push({ name: "page", value: "include/ajax/events" });
|
|
|
|
params.push({ name: "get_response", value: 1 });
|
|
|
|
params.push({ name: "response_id", value: response_id });
|
|
|
|
|
|
|
|
jQuery.ajax({
|
|
|
|
data: params,
|
|
|
|
type: "POST",
|
2023-02-07 17:41:27 +01:00
|
|
|
url: getUrlAjax(),
|
2022-09-23 13:55:01 +02:00
|
|
|
dataType: "json",
|
|
|
|
success: function(response) {
|
|
|
|
// If cannot get response abort it
|
|
|
|
if (response == null) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#event_response_window")
|
|
|
|
.hide()
|
|
|
|
.empty()
|
|
|
|
.append('<div class="container-massive-events-response"></div>')
|
|
|
|
.dialog({
|
|
|
|
title: $("#response_id option:selected").html(),
|
|
|
|
resizable: true,
|
|
|
|
draggable: true,
|
|
|
|
modal: false,
|
|
|
|
open: function() {
|
2022-09-27 09:51:37 +02:00
|
|
|
check_execute_response_massive(response_id, response_parameters);
|
2022-09-23 13:55:01 +02:00
|
|
|
},
|
|
|
|
close: function() {
|
|
|
|
$("#checkbox-all_validate_box").prop("checked", false);
|
|
|
|
$(".chk_val").prop("checked", false);
|
|
|
|
$("#response_loading_dialog").hide();
|
|
|
|
$("#button-submit_event_response").show();
|
|
|
|
},
|
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
text: "Execute All",
|
|
|
|
id: "execute-again-all",
|
|
|
|
class:
|
|
|
|
"ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
|
|
|
|
click: function() {
|
|
|
|
execute_event_response(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
width: response["modal_width"],
|
|
|
|
height: response["modal_height"]
|
|
|
|
})
|
|
|
|
.show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-06-13 19:41:21 +02:00
|
|
|
|
2022-09-27 09:51:37 +02:00
|
|
|
function check_execute_response_massive(response_id, response_parameters) {
|
2022-09-23 13:55:01 +02:00
|
|
|
var events = [];
|
|
|
|
$(".container-massive-events-response").empty();
|
2019-06-18 10:32:04 +02:00
|
|
|
$(".chk_val:checked").each(function() {
|
|
|
|
var event_id = $(this).val();
|
2020-04-15 15:50:08 +02:00
|
|
|
var meta = $("#hidden-meta").val();
|
|
|
|
var server_id = 0;
|
2022-06-22 10:29:19 +02:00
|
|
|
if (meta != 0) {
|
2022-06-21 11:17:18 +02:00
|
|
|
var split_id = event_id.split("|");
|
|
|
|
event_id = split_id[0];
|
|
|
|
server_id = split_id[1];
|
2019-06-13 19:41:21 +02:00
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
if (events[server_id] === undefined) {
|
|
|
|
events[server_id] = [];
|
|
|
|
}
|
2019-06-13 19:41:21 +02:00
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
events[server_id].push(event_id);
|
|
|
|
} else {
|
|
|
|
events.push(event_id);
|
|
|
|
}
|
2019-06-13 19:41:21 +02:00
|
|
|
});
|
2022-09-23 13:55:01 +02:00
|
|
|
|
2022-09-27 09:51:37 +02:00
|
|
|
execute_response_massive(events, response_id, response_parameters);
|
2019-06-13 19:41:21 +02:00
|
|
|
}
|
2021-02-10 18:41:53 +01:00
|
|
|
|
|
|
|
function event_widget_options() {
|
|
|
|
if ($("#customFilter").val() != "-1") {
|
2022-11-30 14:40:41 +01:00
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: "ajax.php",
|
|
|
|
dataType: "json",
|
|
|
|
data: {
|
|
|
|
page: "include/ajax/events",
|
|
|
|
get_filter_values: 1,
|
|
|
|
id: $("#customFilter").val()
|
|
|
|
},
|
|
|
|
success: function(data) {
|
|
|
|
if (data["event_type"] === "") {
|
|
|
|
$("#eventType").val("0");
|
|
|
|
$("#eventType").trigger("change");
|
|
|
|
} else {
|
|
|
|
$("#eventType").val(data["event_type"]);
|
|
|
|
$("#eventType").trigger("change");
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#limit").val(data["pagination"]);
|
|
|
|
$("#limit").trigger("change");
|
|
|
|
|
|
|
|
$("input[name='maxHours']").val(data["event_view_hr"]);
|
|
|
|
|
|
|
|
$("#eventStatus").val(data["status"]);
|
|
|
|
$("#eventStatus").trigger("change");
|
|
|
|
|
|
|
|
let posicion = data["severity"].indexOf(-1);
|
|
|
|
if (posicion !== -1) {
|
|
|
|
$("#severity").val(-1);
|
|
|
|
$("#severity").trigger("change");
|
|
|
|
} else {
|
|
|
|
const severity_array = data["severity"].split(",");
|
|
|
|
$("#severity").val(severity_array[0]);
|
|
|
|
$("#severity").trigger("change");
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#tagsId option").attr("selected", false);
|
|
|
|
$.each(
|
|
|
|
atob(data["tag_with"])
|
|
|
|
.slice(0, -1)
|
|
|
|
.slice(1)
|
|
|
|
.split(","),
|
|
|
|
function(i, e) {
|
|
|
|
$(`#tagsId option[value=${e}]`).prop("selected", true);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$(".event-widget-input").disable();
|
|
|
|
}
|
|
|
|
});
|
2021-02-10 18:41:53 +01:00
|
|
|
} else {
|
|
|
|
$(".event-widget-input").enable();
|
|
|
|
}
|
|
|
|
}
|
2022-06-21 11:17:18 +02:00
|
|
|
|
|
|
|
function process_buffers(buffers) {
|
|
|
|
$("#events_buffers_display").empty();
|
|
|
|
if (buffers != null && buffers.settings != undefined && buffers.data) {
|
2022-06-23 18:06:25 +02:00
|
|
|
var params = [];
|
|
|
|
params.push("page=include/ajax/events");
|
|
|
|
params.push("process_buffers=1");
|
|
|
|
params.push("buffers=" + JSON.stringify(buffers));
|
|
|
|
|
|
|
|
jQuery.ajax({
|
|
|
|
data: params.join("&"),
|
|
|
|
type: "POST",
|
2023-02-07 17:41:27 +01:00
|
|
|
url: getUrlAjax(),
|
2022-06-23 18:06:25 +02:00
|
|
|
async: true,
|
|
|
|
dataType: "html",
|
|
|
|
success: function(data) {
|
|
|
|
$("#events_buffers_display").html(data);
|
2022-06-21 11:17:18 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2022-06-30 17:17:05 +02:00
|
|
|
|
|
|
|
function openSoundEventModal(settings) {
|
|
|
|
settings = JSON.parse(atob(settings));
|
|
|
|
|
|
|
|
// Check modal exists and is open.
|
|
|
|
if (
|
|
|
|
$("#modal-sound").hasClass("ui-dialog-content") &&
|
|
|
|
$("#modal-sound").dialog("isOpen")
|
|
|
|
) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize modal.
|
|
|
|
$("#modal-sound")
|
2022-07-04 17:09:30 +02:00
|
|
|
.empty()
|
2022-06-30 17:17:05 +02:00
|
|
|
.dialog({
|
|
|
|
title: settings.title,
|
|
|
|
resizable: false,
|
|
|
|
modal: true,
|
|
|
|
position: { my: "right top", at: "right bottom", of: window },
|
|
|
|
overlay: {
|
|
|
|
opacity: 0.5,
|
|
|
|
background: "black"
|
|
|
|
},
|
|
|
|
width: 600,
|
|
|
|
height: 600,
|
|
|
|
open: function() {
|
|
|
|
$.ajax({
|
|
|
|
method: "post",
|
|
|
|
url: settings.url,
|
|
|
|
data: {
|
|
|
|
page: settings.page,
|
|
|
|
drawConsoleSound: 1
|
|
|
|
},
|
|
|
|
dataType: "html",
|
|
|
|
success: function(data) {
|
2022-07-01 13:08:39 +02:00
|
|
|
$("#modal-sound").append(data);
|
2022-07-04 17:09:30 +02:00
|
|
|
$("#tabs-sound-modal").tabs({
|
|
|
|
disabled: [1]
|
|
|
|
});
|
|
|
|
|
|
|
|
// Test sound.
|
|
|
|
$("#button-melody_sound").click(function() {
|
|
|
|
var sound = false;
|
|
|
|
if ($("#id_sound_event").length == 0) {
|
|
|
|
sound = true;
|
|
|
|
}
|
|
|
|
|
2022-11-03 15:12:50 +01:00
|
|
|
test_sound_button(sound, settings.urlSound);
|
2022-07-04 17:09:30 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
// Play Stop.
|
|
|
|
$("#button-start-search").click(function() {
|
|
|
|
var mode = $("#hidden-mode_alert").val();
|
|
|
|
var action = false;
|
|
|
|
if (mode == 0) {
|
|
|
|
action = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
action_events_sound(action, settings);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Silence Alert.
|
|
|
|
$("#button-no-alerts").click(function() {
|
|
|
|
if ($("#button-no-alerts").hasClass("silence-alerts") === true) {
|
|
|
|
// Remove audio.
|
|
|
|
remove_audio();
|
|
|
|
|
|
|
|
// Clean events.
|
|
|
|
$("#tabs-sound-modal .elements-discovered-alerts ul").empty();
|
|
|
|
$("#tabs-sound-modal .empty-discovered-alerts").removeClass(
|
|
|
|
"invisible_important"
|
|
|
|
);
|
|
|
|
|
|
|
|
// Clean progress.
|
|
|
|
$("#progressbar_time").empty();
|
|
|
|
|
|
|
|
// Change img button.
|
|
|
|
$("#button-no-alerts")
|
|
|
|
.removeClass("silence-alerts")
|
|
|
|
.addClass("alerts");
|
|
|
|
// Change value button.
|
|
|
|
$("#button-no-alerts").val(settings.noAlert);
|
2023-03-06 08:21:04 +01:00
|
|
|
$("#button-no-alerts > span").text(settings.noAlert);
|
2022-07-04 17:09:30 +02:00
|
|
|
|
|
|
|
// Background button.
|
|
|
|
$(".container-button-alert").removeClass("fired");
|
|
|
|
|
|
|
|
// New progress.
|
|
|
|
listen_event_sound(settings);
|
|
|
|
}
|
|
|
|
});
|
2022-06-30 17:17:05 +02:00
|
|
|
},
|
|
|
|
error: function(error) {
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
close: function() {
|
2022-07-04 17:09:30 +02:00
|
|
|
remove_audio();
|
2022-06-30 17:17:05 +02:00
|
|
|
$(this).dialog("destroy");
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.show();
|
|
|
|
}
|
2022-07-04 17:09:30 +02:00
|
|
|
|
2022-11-03 15:12:50 +01:00
|
|
|
function test_sound_button(test_sound, urlSound) {
|
2022-07-04 17:09:30 +02:00
|
|
|
if (test_sound === true) {
|
2023-01-27 12:44:15 +01:00
|
|
|
$("#button-melody_sound").addClass("blink-image");
|
2022-11-03 15:12:50 +01:00
|
|
|
add_audio(urlSound);
|
2022-07-04 17:09:30 +02:00
|
|
|
} else {
|
2023-01-27 12:44:15 +01:00
|
|
|
$("#button-melody_sound").removeClass("blink-image");
|
2022-07-04 17:09:30 +02:00
|
|
|
remove_audio();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function action_events_sound(mode, settings) {
|
|
|
|
if (mode === true) {
|
|
|
|
// Enable tabs.
|
|
|
|
$("#tabs-sound-modal").tabs("option", "disabled", [0]);
|
|
|
|
// Active tabs.
|
|
|
|
$("#tabs-sound-modal").tabs("option", "active", 1);
|
|
|
|
// Change mode.
|
|
|
|
$("#hidden-mode_alert").val(1);
|
|
|
|
// Change img button.
|
|
|
|
$("#button-start-search")
|
|
|
|
.removeClass("play")
|
|
|
|
.addClass("stop");
|
|
|
|
// Change value button.
|
|
|
|
$("#button-start-search").val(settings.stop);
|
2023-03-06 08:21:04 +01:00
|
|
|
$("#button-start-search > span").text(settings.stop);
|
2022-07-04 17:09:30 +02:00
|
|
|
// Add Progress bar.
|
|
|
|
listen_event_sound(settings);
|
|
|
|
} else {
|
|
|
|
// Enable tabs.
|
|
|
|
$("#tabs-sound-modal").tabs("option", "disabled", [1]);
|
|
|
|
// Active tabs.
|
|
|
|
$("#tabs-sound-modal").tabs("option", "active", 0);
|
|
|
|
// Change mode.
|
|
|
|
$("#hidden-mode_alert").val(0);
|
|
|
|
// Change img button.
|
|
|
|
$("#button-start-search")
|
|
|
|
.removeClass("stop")
|
|
|
|
.addClass("play");
|
|
|
|
// Change value button.
|
|
|
|
$("#button-start-search").val(settings.start);
|
2023-03-06 08:21:04 +01:00
|
|
|
$("#button-start-search > span").text(settings.start);
|
2022-07-04 17:09:30 +02:00
|
|
|
// Remove progress bar.
|
|
|
|
$("#progressbar_time").empty();
|
|
|
|
// Remove audio.
|
|
|
|
remove_audio();
|
|
|
|
// Clean events.
|
|
|
|
$("#tabs-sound-modal .elements-discovered-alerts ul").empty();
|
|
|
|
$("#tabs-sound-modal .empty-discovered-alerts").removeClass(
|
|
|
|
"invisible_important"
|
|
|
|
);
|
|
|
|
// Change img button.
|
|
|
|
$("#button-no-alerts")
|
|
|
|
.removeClass("silence-alerts")
|
|
|
|
.addClass("alerts");
|
|
|
|
// Change value button.
|
|
|
|
$("#button-no-alerts").val(settings.noAlert);
|
2023-03-06 08:21:04 +01:00
|
|
|
$("#button-no-alerts > span").text(settings.noAlert);
|
2022-07-04 17:09:30 +02:00
|
|
|
|
|
|
|
// Background button.
|
|
|
|
$(".container-button-alert").removeClass("fired");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-03 15:12:50 +01:00
|
|
|
function add_audio(urlSound) {
|
|
|
|
var sound = urlSound + $("#tabs-sound-modal #sound_id").val();
|
2022-07-04 17:09:30 +02:00
|
|
|
$(".actions-sound-modal").append(
|
|
|
|
"<audio id='id_sound_event' src='" +
|
|
|
|
sound +
|
|
|
|
"' autoplay='true' hidden='true' loop='false'>"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function remove_audio() {
|
|
|
|
$(".actions-sound-modal audio").remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
function listen_event_sound(settings) {
|
|
|
|
progressTimeBar(
|
|
|
|
"progressbar_time",
|
|
|
|
$("#interval").val(),
|
|
|
|
"infinite",
|
|
|
|
function() {
|
|
|
|
// Search events.
|
|
|
|
check_event_sound(settings);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_event_sound(settings) {
|
|
|
|
jQuery.post(
|
2022-11-03 15:12:50 +01:00
|
|
|
settings.url,
|
2022-07-04 17:09:30 +02:00
|
|
|
{
|
|
|
|
page: "include/ajax/events",
|
|
|
|
get_events_fired: 1,
|
|
|
|
filter_id: $("#tabs-sound-modal #filter_id").val(),
|
|
|
|
interval: $("#tabs-sound-modal #interval").val(),
|
|
|
|
time_sound: $("#tabs-sound-modal #time_sound").val()
|
|
|
|
},
|
|
|
|
function(data) {
|
|
|
|
if (data != false) {
|
|
|
|
// Hide empty.
|
|
|
|
$("#tabs-sound-modal .empty-discovered-alerts").addClass(
|
|
|
|
"invisible_important"
|
|
|
|
);
|
|
|
|
|
|
|
|
// Change img button.
|
|
|
|
$("#button-no-alerts")
|
|
|
|
.removeClass("alerts")
|
|
|
|
.addClass("silence-alerts");
|
|
|
|
// Change value button.
|
|
|
|
$("#button-no-alerts").val(settings.silenceAlarm);
|
2023-03-06 08:21:04 +01:00
|
|
|
$("#button-no-alerts > span").text(settings.silenceAlarm);
|
2022-07-04 17:09:30 +02:00
|
|
|
|
|
|
|
// Background button.
|
|
|
|
$(".container-button-alert").addClass("fired");
|
|
|
|
|
|
|
|
// Remove audio.
|
|
|
|
remove_audio();
|
|
|
|
|
|
|
|
// Apend audio.
|
2022-11-03 15:12:50 +01:00
|
|
|
add_audio(settings.urlSound);
|
2022-07-04 17:09:30 +02:00
|
|
|
|
|
|
|
// Add elements.
|
|
|
|
data.forEach(function(element) {
|
|
|
|
var li = document.createElement("li");
|
2023-02-07 16:48:23 +01:00
|
|
|
var b64 = btoa(JSON.stringify(element));
|
2022-07-04 17:09:30 +02:00
|
|
|
li.insertAdjacentHTML(
|
|
|
|
"beforeend",
|
|
|
|
'<div class="li-priority">' + element.priority + "</div>"
|
|
|
|
);
|
|
|
|
li.insertAdjacentHTML(
|
|
|
|
"beforeend",
|
|
|
|
'<div class="li-type">' + element.type + "</div>"
|
|
|
|
);
|
|
|
|
li.insertAdjacentHTML(
|
|
|
|
"beforeend",
|
2023-02-07 16:48:23 +01:00
|
|
|
`<div class="li-title"><a href="javascript:" onclick="show_event_dialog('${b64}')">${element.message}</a></div>`
|
2022-07-04 17:09:30 +02:00
|
|
|
);
|
|
|
|
li.insertAdjacentHTML(
|
|
|
|
"beforeend",
|
|
|
|
'<div class="li-time">' + element.timestamp + "</div>"
|
|
|
|
);
|
|
|
|
$("#tabs-sound-modal .elements-discovered-alerts ul").append(li);
|
|
|
|
});
|
|
|
|
|
|
|
|
// -100 delay sound.
|
|
|
|
setTimeout(
|
|
|
|
remove_audio,
|
|
|
|
parseInt($("#tabs-sound-modal #time_sound").val()) * 1000 - 100
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
|
|
|
}
|
2022-09-27 09:51:37 +02:00
|
|
|
|
|
|
|
function table_info_response_event(response_id, event_id, server_id, massive) {
|
|
|
|
var params = [];
|
|
|
|
params.push({ name: "page", value: "include/ajax/events" });
|
|
|
|
params.push({ name: "get_response", value: 1 });
|
|
|
|
params.push({ name: "response_id", value: response_id });
|
|
|
|
params.push({ name: "server_id", value: server_id });
|
|
|
|
params.push({ name: "event_id", value: event_id });
|
|
|
|
|
2023-02-07 17:41:27 +01:00
|
|
|
var url = getUrlAjax();
|
|
|
|
|
2022-09-27 09:51:37 +02:00
|
|
|
jQuery.ajax({
|
|
|
|
data: params,
|
|
|
|
type: "POST",
|
2023-02-07 17:41:27 +01:00
|
|
|
url: url,
|
2022-09-27 09:51:37 +02:00
|
|
|
dataType: "json",
|
|
|
|
success: function(response) {
|
|
|
|
if (response) {
|
|
|
|
var params = [];
|
|
|
|
params.push({ name: "page", value: "include/ajax/events" });
|
|
|
|
params.push({ name: "draw_row_response_info", value: 1 });
|
|
|
|
params.push({ name: "massive", value: massive === true ? 1 : 0 });
|
|
|
|
params.push({ name: "response", value: JSON.stringify(response) });
|
|
|
|
|
|
|
|
jQuery.ajax({
|
|
|
|
data: params,
|
|
|
|
type: "POST",
|
2023-02-07 17:41:27 +01:00
|
|
|
url: url,
|
2022-09-27 09:51:37 +02:00
|
|
|
dataType: "html",
|
|
|
|
success: function(output) {
|
|
|
|
if (massive === true) {
|
|
|
|
$("#massive-parameters-response").append(output);
|
|
|
|
} else {
|
|
|
|
$(".params_rows").remove();
|
|
|
|
$("#responses_table").append(output);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2023-02-07 16:48:23 +01:00
|
|
|
|
|
|
|
function getUrlAjax() {
|
|
|
|
if ($("#hidden-ajax_file").length) {
|
|
|
|
return $("#hidden-ajax_file").val();
|
|
|
|
} else if ($("#hidden-ajax_file_sound_console").length) {
|
|
|
|
return $("#hidden-ajax_file_sound_console").val();
|
|
|
|
}
|
|
|
|
}
|