Merge branch 'ent-10190-agregar-funcionalidad-de-visualizar-los-eventos-desde-consola-audible-de-eventos' into 'develop'

Ent 10190 agregar funcionalidad de visualizar los eventos desde consola audible de eventos

See merge request artica/pandorafms!5518
This commit is contained in:
Rafael Ameijeiras 2023-02-10 07:59:42 +00:00
commit 413511ba8d
2 changed files with 91 additions and 43 deletions

View File

@ -2407,6 +2407,18 @@ if ($drawConsoleSound === true) {
$output .= '</span>'; $output .= '</span>';
$output .= '</div>'; $output .= '</div>';
$output .= '<div class="elements-discovered-alerts"><ul></ul></div>'; $output .= '<div class="elements-discovered-alerts"><ul></ul></div>';
$output .= html_print_input_hidden(
'ajax_file_sound_console',
ui_get_full_url('ajax.php', false, false, false),
true
);
$output .= html_print_input_hidden(
'meta',
is_metaconsole(),
true
);
$output .= '<div id="sound_event_details_window"></div>';
$output .= '<div id="sound_event_response_window"></div>';
$output .= '</div>'; $output .= '</div>';
$output .= '</div>'; $output .= '</div>';
@ -2511,29 +2523,32 @@ if ($get_events_fired) {
$return = []; $return = [];
if (empty($data) === false) { if (empty($data) === false) {
foreach ($data as $event) { foreach ($data as $event) {
$return[] = [ $return[] = array_merge(
'fired' => $event['id_evento'], $event,
'message' => ui_print_string_substr( [
strip_tags(io_safe_output($event['evento'])), 'fired' => $event['id_evento'],
75, 'message' => ui_print_string_substr(
true, strip_tags(io_safe_output($event['evento'])),
'9' 75,
), true,
'priority' => ui_print_event_priority($event['criticity'], true, true), '9'
'type' => events_print_type_img( ),
$event['event_type'], 'priority' => ui_print_event_priority($event['criticity'], true, true),
true 'type' => events_print_type_img(
), $event['event_type'],
'timestamp' => ui_print_timestamp( true
$event['timestamp'], ),
true, 'timestamp' => ui_print_timestamp(
['style' => 'font-size: 9pt; letter-spacing: 0.3pt;'] $event['timestamp'],
), true,
]; ['style' => 'font-size: 9pt; letter-spacing: 0.3pt;']
),
]
);
} }
} }
echo io_json_mb_encode($return); echo io_safe_output(io_json_mb_encode($return));
return; return;
} }

View File

@ -2,7 +2,15 @@
// Show the modal window of an event // Show the modal window of an event
function show_event_dialog(event, dialog_page) { function show_event_dialog(event, dialog_page) {
var ajax_file = $("#hidden-ajax_file").val(); 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";
}
if (dialog_page == undefined) { if (dialog_page == undefined) {
dialog_page = "general"; dialog_page = "general";
@ -39,7 +47,7 @@ function show_event_dialog(event, dialog_page) {
filter: values filter: values
}, },
function(data) { function(data) {
$("#event_details_window") $(view)
.hide() .hide()
.empty() .empty()
.append(data) .append(data)
@ -122,7 +130,7 @@ function execute_response(event_id, server_id) {
jQuery.ajax({ jQuery.ajax({
data: params, data: params,
type: "POST", type: "POST",
url: $("#hidden-ajax_file").val(), url: getUrlAjax(),
dataType: "json", dataType: "json",
success: function(response) { success: function(response) {
// If cannot get response abort it // If cannot get response abort it
@ -153,7 +161,7 @@ function execute_response_massive(events, response_id, response_parameters) {
jQuery.ajax({ jQuery.ajax({
data: params, data: params,
type: "POST", type: "POST",
url: $("#hidden-ajax_file").val(), url: getUrlAjax(),
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
// If cannot get response abort it // If cannot get response abort it
@ -203,7 +211,7 @@ function execute_response_massive(events, response_id, response_parameters) {
jQuery.ajax({ jQuery.ajax({
data: params, data: params,
type: "POST", type: "POST",
url: $("#hidden-ajax_file").val(), url: getUrlAjax(),
dataType: "html", dataType: "html",
success: function(data) { success: function(data) {
$(".container-massive-events-response").append(data); $(".container-massive-events-response").append(data);
@ -240,13 +248,21 @@ function show_response_dialog(response_id, response) {
params.push({ name: "server_id", value: response.server_id }); params.push({ name: "server_id", value: response.server_id });
params.push({ name: "response", value: JSON.stringify(response) }); params.push({ name: "response", value: JSON.stringify(response) });
var view = ``;
if ($("#event_response_window").length) {
view = "#event_response_window";
} else if ($("#sound_event_response_window").length) {
view = "#sound_event_response_window";
}
jQuery.ajax({ jQuery.ajax({
data: params, data: params,
type: "POST", type: "POST",
url: $("#hidden-ajax_file").val(), url: getUrlAjax(),
dataType: "html", dataType: "html",
success: function(data) { success: function(data) {
$("#event_response_window") $(view)
.hide() .hide()
.empty() .empty()
.append(data) .append(data)
@ -292,7 +308,7 @@ function perform_response(response, response_id, index) {
jQuery.ajax({ jQuery.ajax({
data: params, data: params,
type: "POST", type: "POST",
url: $("#hidden-ajax_file").val(), url: getUrlAjax(),
dataType: "html", dataType: "html",
success: function(data) { success: function(data) {
var out = data.replace(/[\n|\r]/g, "<br>"); var out = data.replace(/[\n|\r]/g, "<br>");
@ -321,7 +337,7 @@ function event_change_status(event_ids, server_id) {
server_id: server_id server_id: server_id
}, },
type: "POST", type: "POST",
url: $("#hidden-ajax_file").val(), url: getUrlAjax(),
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
$("#button-status_button").removeAttr("disabled"); $("#button-status_button").removeAttr("disabled");
@ -350,9 +366,12 @@ function event_change_status(event_ids, server_id) {
} }
}); });
$("#table_events") if ($("#table_events").length) {
.DataTable() $("#table_events")
.draw(false); .DataTable()
.draw(false);
}
$("#notification_status_success").show(); $("#notification_status_success").show();
$("#general_status") $("#general_status")
@ -385,7 +404,7 @@ function event_change_owner(event_id, server_id) {
new_owner: new_owner new_owner: new_owner
}, },
type: "POST", type: "POST",
url: $("#hidden-ajax_file").val(), url: getUrlAjax(),
async: true, async: true,
dataType: "html", dataType: "html",
success: function(data) { success: function(data) {
@ -404,9 +423,12 @@ function event_change_owner(event_id, server_id) {
// if (typeof dt_events !== "undefined") { // if (typeof dt_events !== "undefined") {
// dt_events.draw(false); // dt_events.draw(false);
// } // }
$("#table_events")
.DataTable() if ($("#table_events").length) {
.draw(false); $("#table_events")
.DataTable()
.draw(false);
}
$("#notification_owner_success").show(); $("#notification_owner_success").show();
if (new_owner == -1) { if (new_owner == -1) {
$("#extended_event_general_page table td.general_owner").html( $("#extended_event_general_page table td.general_owner").html(
@ -460,7 +482,7 @@ function event_comment(current_event) {
jQuery.ajax({ jQuery.ajax({
data: params.join("&"), data: params.join("&"),
type: "POST", type: "POST",
url: $("#hidden-ajax_file").val(), url: getUrlAjax(),
dataType: "html", dataType: "html",
success: function() { success: function() {
$("#button-comment_button").removeAttr("disabled"); $("#button-comment_button").removeAttr("disabled");
@ -485,7 +507,7 @@ function update_event(table, id_evento, type, event_rep, row, server_id) {
$.ajax({ $.ajax({
async: true, async: true,
type: "POST", type: "POST",
url: $("#hidden-ajax_file").val(), url: getUrlAjax(),
data: { data: {
page: "include/ajax/events", page: "include/ajax/events",
validate_event: type.validate_event, validate_event: type.validate_event,
@ -776,7 +798,7 @@ function show_response_dialog_massive(response_id, response_parameters) {
jQuery.ajax({ jQuery.ajax({
data: params, data: params,
type: "POST", type: "POST",
url: $("#hidden-ajax_file").val(), url: getUrlAjax(),
dataType: "json", dataType: "json",
success: function(response) { success: function(response) {
// If cannot get response abort it // If cannot get response abort it
@ -914,7 +936,7 @@ function process_buffers(buffers) {
jQuery.ajax({ jQuery.ajax({
data: params.join("&"), data: params.join("&"),
type: "POST", type: "POST",
url: $("#hidden-ajax_file").val(), url: getUrlAjax(),
async: true, async: true,
dataType: "html", dataType: "html",
success: function(data) { success: function(data) {
@ -1147,6 +1169,7 @@ function check_event_sound(settings) {
// Add elements. // Add elements.
data.forEach(function(element) { data.forEach(function(element) {
var li = document.createElement("li"); var li = document.createElement("li");
var b64 = btoa(JSON.stringify(element));
li.insertAdjacentHTML( li.insertAdjacentHTML(
"beforeend", "beforeend",
'<div class="li-priority">' + element.priority + "</div>" '<div class="li-priority">' + element.priority + "</div>"
@ -1157,7 +1180,7 @@ function check_event_sound(settings) {
); );
li.insertAdjacentHTML( li.insertAdjacentHTML(
"beforeend", "beforeend",
'<div class="li-title">' + element.message + "</div>" `<div class="li-title"><a href="javascript:" onclick="show_event_dialog('${b64}')">${element.message}</a></div>`
); );
li.insertAdjacentHTML( li.insertAdjacentHTML(
"beforeend", "beforeend",
@ -1185,10 +1208,12 @@ function table_info_response_event(response_id, event_id, server_id, massive) {
params.push({ name: "server_id", value: server_id }); params.push({ name: "server_id", value: server_id });
params.push({ name: "event_id", value: event_id }); params.push({ name: "event_id", value: event_id });
var url = getUrlAjax();
jQuery.ajax({ jQuery.ajax({
data: params, data: params,
type: "POST", type: "POST",
url: $("#hidden-ajax_file").val(), url: url,
dataType: "json", dataType: "json",
success: function(response) { success: function(response) {
if (response) { if (response) {
@ -1201,7 +1226,7 @@ function table_info_response_event(response_id, event_id, server_id, massive) {
jQuery.ajax({ jQuery.ajax({
data: params, data: params,
type: "POST", type: "POST",
url: $("#hidden-ajax_file").val(), url: url,
dataType: "html", dataType: "html",
success: function(output) { success: function(output) {
if (massive === true) { if (massive === true) {
@ -1216,3 +1241,11 @@ function table_info_response_event(response_id, event_id, server_id, massive) {
} }
}); });
} }
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();
}
}