Merge branch 'ent-9211-cambio-como-se-muestra-la-vista-de-stadisticas-de-nodos-en-los-eventos-de-meta' into 'develop'

minor fixed events

See merge request artica/pandorafms!4983
This commit is contained in:
Daniel Rodriguez 2022-06-23 16:21:04 +00:00
commit 85b1af94a4
4 changed files with 116 additions and 43 deletions

View File

@ -55,6 +55,7 @@ if (! check_acl($config['id_user'], 0, 'ER')
return;
}
$process_buffers = (bool) get_parameter('process_buffers', false);
$get_extended_event = (bool) get_parameter('get_extended_event');
$change_status = (bool) get_parameter('change_status');
$change_owner = (bool) get_parameter('change_owner');
@ -2138,6 +2139,92 @@ if ($get_table_response_command) {
return;
}
if ($process_buffers === true) {
$buffers = get_parameter('buffers', '');
$buffers = json_decode(io_safe_output($buffers), true);
$alert = false;
$content = '<ul>';
foreach ($buffers['data'] as $node => $data) {
$content .= '<li>';
$content .= '<span><b>';
$content .= __('Events').': ';
$content .= $node;
$content .= '</b></span>';
$class_total = 'info';
$str_total = '';
if ($buffers['settings']['total'] == $data) {
$alert = true;
$class_total .= ' danger';
$str_total = html_print_image(
'images/error_red.png',
true,
[
'title' => __('Total number of events in this node reached'),
'class' => 'forced-title',
]
);
}
if (isset($buffers['error'][$node]) === true) {
$alert = true;
$class_total .= ' danger';
$str_total = html_print_image(
'images/error_red.png',
true,
[
'title' => $buffers['error'][$node],
'class' => 'forced-title',
]
);
}
$content .= '<span class="'.$class_total.'">';
$content .= $data;
if (empty($str_total) === false) {
$content .= '<span class="text">';
$content .= ' '.$str_total;
$content .= '</span>';
}
$content .= '</span>';
$content .= '</li>';
}
$content .= '</ul>';
$title = __('Total Events per node').': (';
$title .= $buffers['settings']['total'].')';
if ($alert === true) {
$title .= html_print_image(
'images/error_red.png',
true,
[
'title' => __('Error'),
'class' => 'forced-title',
'style' => 'margin-top: -2px;',
]
);
}
$output = ui_toggle(
$content,
$title,
'',
'',
true,
true,
'white_box white_box_opened',
'no-border flex-row'
);
echo $output;
return;
}
if ($get_events_fired) {
global $config;
$id = get_parameter('id_row');

View File

@ -1582,13 +1582,7 @@ function events_get_all(
$data = [];
$buffers = [
'settings' => [
'total' => $config['max_number_of_events_per_node'],
'translate' => [
'tev' => __('Total Events'),
'nev' => __('Total Events per node'),
'ev' => __('Events'),
'tevn' => __('Total number of events in this node reached'),
],
'total' => $config['max_number_of_events_per_node'],
],
'data' => [],
'error' => [],

View File

@ -1011,43 +1011,20 @@ function event_widget_options() {
function process_buffers(buffers) {
$("#events_buffers_display").empty();
if (buffers != null && buffers.settings != undefined && buffers.data) {
var html = "<h3>" + buffers.settings.translate.nev;
html += ": (" + buffers.settings.total + ")</h3>";
html += "<ul>";
Object.entries(buffers.data).forEach(function(element) {
html += "<li>";
html += "<span><b>";
html += buffers.settings.translate.ev + " ";
html += element[0];
html += ": ";
html += "</b></span>";
var params = [];
params.push("page=include/ajax/events");
params.push("process_buffers=1");
params.push("buffers=" + JSON.stringify(buffers));
var class_total = "info";
var str_total = "";
if (buffers.settings.total == element[1]) {
class_total += " danger";
str_total = buffers.settings.translate.tevn;
jQuery.ajax({
data: params.join("&"),
type: "POST",
url: $("#hidden-ajax_file").val(),
async: true,
dataType: "html",
success: function(data) {
$("#events_buffers_display").html(data);
}
if (buffers.error[element[0]] !== undefined) {
class_total += " danger";
str_total = buffers.error[element[0]];
}
html += '<span class="' + class_total + '">';
html += element[1];
if (str_total != "") {
html += '<span class="text">';
html += " " + str_total;
html += "</span>";
}
html += "</span>";
html += "</li>";
});
html += "</ul>";
$("#events_buffers_display").html(html);
}
}

View File

@ -348,10 +348,11 @@ div.multi-response-buttons {
#events_buffers_display {
margin-bottom: 10px;
width: fit-content;
min-width: 300px;
}
#events_buffers_display ul {
min-width: 400px;
min-width: 300px;
}
#events_buffers_display li {
@ -359,6 +360,8 @@ div.multi-response-buttons {
flex-direction: row;
justify-content: flex-start;
align-items: center;
position: relative;
height: 20px;
}
#events_buffers_display ul li span.info {
@ -368,8 +371,20 @@ div.multi-response-buttons {
#events_buffers_display ul li span.danger {
color: red;
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
}
#events_buffers_display ul li span.danger img {
position: absolute;
top: -3px;
}
#events_buffers_display ul li span.text {
color: #3f3f3f;
}
.white_table_graph_header {
align-items: center;
}