refactor events meta pandora_enterprise#9086

This commit is contained in:
Daniel Barbero Martin 2022-06-21 11:17:18 +02:00
parent 3e59093b0e
commit 9d23b9af4a
9 changed files with 765 additions and 771 deletions

View File

@ -94,6 +94,7 @@ if ($get_comments === true) {
$eventsGrouped = [];
// Consider if the event is grouped.
$whereGrouped = '1=1';
if (isset($event['event_rep']) === true && $event['event_rep'] > 0) {
// Default grouped message filtering (evento and estado).
$whereGrouped = sprintf(
@ -117,6 +118,7 @@ if ($get_comments === true) {
(int) $event['id_agentmodule']
);
}
}
try {
if (is_metaconsole() === true
@ -151,7 +153,6 @@ if ($get_comments === true) {
$node->disconnect();
}
}
}
// End of get_comments.
echo events_page_comments($event, true, $eventsGrouped);

View File

@ -17395,7 +17395,7 @@ function util_api_check_agent_and_print_error($id_agent, $returnType, $access='A
* Function for get event id and node id, then we get in return the Metaconsole event ID.
*
* @param [string] $server_id id server (Node)
* @param [string] $console_event_id console Id node event in tmetaconsole_event
* @param [string] $console_event_id console Id node event in tevent
* @param [string] $trash2 don't use
* @param [string] $returnType
*
@ -17406,19 +17406,54 @@ function util_api_check_agent_and_print_error($id_agent, $returnType, $access='A
*/
function api_get_event_mcid($server_id, $console_event_id, $trash2, $returnType)
{
global $config;
try {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node = new Node($server_id);
$node->connect();
}
// Get grouped comments.
$mc_event_id = db_get_all_rows_sql(
sprintf(
'SELECT id_evento
FROM tevento
WHERE id_evento = %d
',
$console_event_id
)
);
if (is_metaconsole()) {
$mc_event_id = db_get_all_rows_sql("SELECT id_evento FROM tmetaconsole_event WHERE id_source_event = $console_event_id AND server_id = $server_id ");
if ($mc_event_id !== false) {
returnData($returnType, ['type' => 'string', 'data' => $mc_event_id]);
returnData(
$returnType,
[
'type' => 'string',
'data' => $mc_event_id,
]
);
} else {
returnError('id_not_found', 'string');
}
} else {
returnError('forbidden', 'string');
return;
} catch (\Exception $e) {
// Unexistent agent.
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
returnError('forbidden', 'string');
} finally {
if (is_metaconsole() === true
&& $server_id > 0
) {
$node->disconnect();
}
}
return;
}

View File

@ -1336,7 +1336,6 @@ function events_get_all(
if (is_metaconsole() === true
&& empty($id_server) === true
&& isset($filter['csv_all']) === false
&& $filter['csv_all'] !== 1
) {
// TODO: XXX TIP. captura el error.
$pagination = sprintf(
@ -1350,6 +1349,10 @@ function events_get_all(
// Group by.
$group_by = 'GROUP BY ';
$tagente_join = 'LEFT';
if (isset($filter['group_rep']) === false) {
$filter['group_rep'] = 0;
}
switch ($filter['group_rep']) {
case '0':
default:
@ -1639,7 +1642,6 @@ function events_get_all(
if (isset($limit, $offset) === true
&& $limit !== 0
&& isset($filter['csv_all']) === false
&& $filter['csv_all'] !== 1
) {
$count = count($data);
$end = ((int) $offset !== 0) ? ($offset + $limit) : $limit;

View File

@ -3254,7 +3254,7 @@ function ui_print_datatable(array $parameters)
$parameters['paging'] = true;
}
$no_sortable_columns = [];
$no_sortable_columns = json_encode([]);
if (isset($parameters['no_sortable_columns'])) {
$no_sortable_columns = json_encode($parameters['no_sortable_columns']);
}
@ -3326,6 +3326,11 @@ function ui_print_datatable(array $parameters)
$parameters['datacolumns'] = $parameters['columns'];
}
if (isset($parameters['csv']) === false) {
$parameters['csv'] = 1;
}
$filter = '';
// Datatable filter.
if (isset($parameters['form']) && is_array($parameters['form'])) {
if (isset($parameters['form']['id'])) {
@ -3496,7 +3501,7 @@ function ui_print_datatable(array $parameters)
language: {
processing:"'.$processing.'"
},
buttons: [
buttons: '.$parameters['csv'].'== 1 ? [
{
extend: "csv",
text : "'.__('Export current page to CSV').'",
@ -3512,7 +3517,7 @@ function ui_print_datatable(array $parameters)
}'.$export_columns.'
}
}
],
] : [],
lengthMenu: '.json_encode($pagination_options).',
ajax: {
url: "'.ui_get_full_url('ajax.php', false, false, false).'",

View File

@ -1387,131 +1387,6 @@ function dashboardLoadVC(settings) {
});
}
// eslint-disable-next-line no-unused-vars
function dashboardShowEventDialog(settings) {
settings = JSON.parse(atob(settings));
var dialog_exist = $("div[aria-describedby='event_details_window']");
if (dialog_exist.length == 1) {
$("div[aria-describedby='event_details_window']").remove();
}
$.ajax({
method: "post",
url: settings.ajaxUrl,
data: {
page: settings.page,
get_extended_event: 1,
event: settings.event,
dialog_page: "",
meta: 0,
history: 0,
filter: [],
node_id: settings.node_id
},
dataType: "html",
success: function(data) {
$("#event_details_window")
.hide()
.empty()
.append(data)
.dialog({
title: settings.event.evento,
resizable: true,
draggable: true,
modal: true,
create: function() {
$("#button-delete_button").removeAttr("onclick");
$("#button-delete_button").click(function() {
var confirm_message = $("#hidden-delete_confirm_message").val();
if (confirm(confirm_message) == false) {
return false;
}
$.ajax({
method: "post",
url: settings.ajaxUrl,
data: {
page: "include/ajax/events",
delete_event: 1,
node_id: settings.node_id,
id_evento: settings.event.id_evento,
filter: []
},
success: function() {
$("#notification_delete_error").show();
$("#event_details_window").dialog("close");
},
error: function(error) {
console.error(error);
}
});
});
},
close: function() {
//$("#refrcounter").countdown("resume");
//$("div.vc-countdown").countdown("resume");
$.ajax({
method: "post",
url: settings.ajaxUrl,
data: {
page: "operation/dashboard/dashboard",
method: "drawWidget",
dashboardId: settings.dashboardId,
cellId: settings.cellId,
widgetId: settings.widgetId,
redraw: 1
},
success: function(dataWidget) {
// Widget empty and reload.
$("#widget-" + settings.cellId + " .content-widget").empty();
$("#widget-" + settings.cellId + " .content-widget").append(
dataWidget
);
},
error: function(error) {
console.error(error);
}
});
},
overlay: {
opacity: 0.5,
background: "black"
},
width: 710,
height: 600
})
.show();
//$("#refrcounter").countdown("pause");
//$("div.vc-countdown").countdown("pause");
switch (settings.result) {
case "comment_ok":
$("#notification_comment_success").show();
break;
case "comment_error":
$("#notification_comment_error").show();
break;
case "status_ok":
$("#notification_status_success").show();
break;
case "status_error":
$("#notification_status_error").show();
break;
case "owner_ok":
$("#notification_owner_success").show();
break;
case "owner_error":
$("#notification_owner_error").show();
break;
}
forced_title_callback();
},
error: function(error) {
console.error(error);
}
});
}
// eslint-disable-next-line no-unused-vars
function dashboardInitTinyMce(url) {
// Initialice.

View File

@ -1,7 +1,7 @@
/*global jQuery, $, forced_title_callback, dt_events, confirmDialog*/
/*global jQuery, $, forced_title_callback, confirmDialog*/
// Show the modal window of an event
function show_event_dialog(event, dialog_page, result) {
function show_event_dialog(event, dialog_page) {
var ajax_file = $("#hidden-ajax_file").val();
if (dialog_page == undefined) {
@ -85,6 +85,7 @@ function show_event_dialog(event, dialog_page, result) {
$("#refrcounter").countdown("pause");
$("div.vc-countdown").countdown("pause");
/*
switch (result) {
case "comment_ok":
$("#notification_comment_success").show();
@ -105,6 +106,7 @@ function show_event_dialog(event, dialog_page, result) {
$("#notification_owner_error").show();
break;
}
*/
forced_title_callback();
},
@ -675,7 +677,9 @@ function update_event(table, id_evento, type, event_rep, row, server_id) {
redraw = true;
}
if (redraw) {
table.draw(false);
$("#" + table)
.DataTable()
.draw(false);
} else {
$(row)
.closest("tr")
@ -692,6 +696,11 @@ function update_event(table, id_evento, type, event_rep, row, server_id) {
function validate_event(table, id_evento, event_rep, row, server_id) {
var button = document.getElementById("val-" + id_evento);
var meta = $("#hidden-meta").val();
if (meta) {
button = document.getElementById("val-" + id_evento + "-" + server_id);
}
if (!button) {
// Button does not exist. Ignore.
processed += 1;
@ -712,6 +721,11 @@ function validate_event(table, id_evento, event_rep, row, server_id) {
function in_process_event(table, id_evento, event_rep, row, server_id) {
var button = document.getElementById("proc-" + id_evento);
var meta = $("#hidden-meta").val();
if (meta) {
button = document.getElementById("proc-" + id_evento + "-" + server_id);
}
if (!button) {
// Button does not exist. Ignore.
processed += 1;
@ -732,6 +746,11 @@ function in_process_event(table, id_evento, event_rep, row, server_id) {
function delete_event(table, id_evento, event_rep, row, server_id) {
var button = document.getElementById("del-" + id_evento);
var meta = $("#hidden-meta").val();
if (meta) {
button = document.getElementById("del-" + id_evento + "-" + server_id);
}
if (!button) {
// Button does not exist. Ignore.
processed += 1;
@ -771,6 +790,11 @@ function execute_delete_event_reponse(
server_id
) {
var button = document.getElementById("del-" + id_evento);
var meta = $("#hidden-meta").val();
if (meta) {
button = document.getElementById("del-" + id_evento + "-" + server_id);
}
if (!button) {
// Button does not exist. Ignore.
processed += 1;
@ -868,17 +892,22 @@ function execute_event_response(event_list_btn) {
});
}
} else {
var event_id = $(this).val();
var server_id = $("#hidden-server_id_" + event_id).val();
// It is not a custom response
switch (response_id) {
case "in_progress_selected":
$(".chk_val:checked").each(function() {
// Parent: TD. GrandParent: TR.
var event_id = $(this).val();
var meta = $("#hidden-meta").val();
var server_id = 0;
if (meta) {
var split_id = event_id.split("|");
event_id = split_id[0];
server_id = split_id[1];
}
in_process_event(
dt_events,
$(this).val(),
"events",
event_id,
$(this).attr("event_rep"),
this.parentElement.parentElement,
server_id
@ -887,8 +916,17 @@ function execute_event_response(event_list_btn) {
break;
case "validate_selected":
$(".chk_val:checked").each(function() {
var event_id = $(this).val();
var meta = $("#hidden-meta").val();
var server_id = 0;
if (meta) {
var split_id = event_id.split("|");
event_id = split_id[0];
server_id = split_id[1];
}
validate_event(
dt_events,
"events",
event_id,
$(this).attr("event_rep"),
this.parentElement.parentElement,
@ -898,8 +936,17 @@ function execute_event_response(event_list_btn) {
break;
case "delete_selected":
$(".chk_val:checked").each(function() {
var event_id = $(this).val();
var meta = $("#hidden-meta").val();
var server_id = 0;
if (meta) {
var split_id = event_id.split("|");
event_id = split_id[0];
server_id = split_id[1];
}
execute_delete_event_reponse(
dt_events,
"events",
event_id,
$(this).attr("event_rep"),
this.parentElement.parentElement,
@ -931,7 +978,9 @@ function check_massive_response_event(
var meta = $("#hidden-meta").val();
var server_id = 0;
if (meta) {
server_id = $("#hidden-server_id_" + event_id).val();
var split_id = event_id.split("|");
event_id = split_id[0];
server_id = split_id[1];
}
response["target"] = get_response_target(
@ -958,3 +1007,41 @@ function event_widget_options() {
$(".event-widget-input").enable();
}
}
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 class_total = "info";
var str_total = "";
if (buffers.settings.total == element[1]) {
class_total += " danger";
str_total = buffers.settings.translate.tevn;
}
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

@ -501,8 +501,6 @@ class EventsListWidget extends Widget
$output = '';
\ui_require_css_file('events', 'include/styles/', true);
\ui_require_css_file('tables', 'include/styles/', true);
\ui_require_javascript_file('pandora_events');
\ui_require_javascript_file('pandora_events', 'include/javascript/', true);
$this->values['groupId'] = explode(',', $this->values['groupId'][0]);
@ -536,7 +534,7 @@ class EventsListWidget extends Widget
io_safe_output($filter['tag_without'])
);
if (!empty($filter['id_agent_module'])) {
if (empty($filter['id_agent_module']) === false) {
$name = \modules_get_modules_name(
' FROM tagente_modulo',
' WHERE id_agente_modulo = '.$filter['id_agent_module'],
@ -581,87 +579,38 @@ class EventsListWidget extends Widget
}
}
// Order.
$order['field'] = 'timestamp';
$order['direction'] = 'DESC';
$fields = [
'te.id_evento',
'te.id_agente',
'te.id_usuario',
'te.id_grupo',
'te.estado',
'te.timestamp',
'te.evento',
'te.utimestamp',
'te.event_type',
'te.id_alert_am',
'te.criticity',
'te.user_comment',
'te.tags',
'te.source',
'te.id_extra',
'te.critical_instructions',
'te.warning_instructions',
'te.unknown_instructions',
'te.owner_user',
'if(te.ack_utimestamp > 0, from_unixtime(te.ack_utimestamp),"") as ack_utimestamp',
'te.custom_data',
'te.data',
'te.module_status',
'ta.alias as agent_name',
'tg.nombre as group_name',
$default_fields = [
[
'text' => 'evento',
'class' => 'mw120px',
],
[
'text' => 'mini_severity',
'class' => 'no-padding',
],
'id_evento',
'agent_name',
'timestamp',
'event_type',
[
'text' => 'options',
'class' => 'action_buttons w120px',
],
];
$fields = explode(',', $config['event_fields']);
$home_url = $config['homeurl'];
$fields[] = 'am.nombre as module_name';
$fields[] = 'am.id_agente_modulo as id_agentmodule';
$fields[] = 'am.custom_id as module_custom_id';
$fields[] = 'ta.server_name as server_name';
$events = \events_get_all(
// Fields.
$fields,
// Filter.
$filter,
// Offset.
0,
// Limit.
$this->values['limit'],
// Order.
$order['direction'],
// Sort field.
$order['field'],
// History.
false,
// SQL.
false,
// Having.
'',
// ValidatedEvents.
false,
// Recursive Groups.
(bool) $this->values['groupRecursion'],
// Already connected.
// ($this->nodeId > 0)
);
if (is_metaconsole() === true
&& empty($filter['server_id']) !== false
) {
$events = $events['data'];
// Always check something is shown.
if (empty($fields) === true) {
$fields = $default_fields;
}
if ($events === false) {
$events = [];
}
// Get column names.
$column_names = events_get_column_names($fields, true);
$i = 0;
if (isset($events) === true
&& is_array($events) === true
&& empty($events) === false
) {
// AJAX call options responses.
$output .= '<div id="event_details_window" style="display:none"></div>';
$output .= '<div id="event_response_window" style="display:none"></div>';
$output .= '<div id="event_response_command_window" title="'.__('Parameters').'" style="display:none"></div>';
$output .= \html_print_input_hidden(
'ajax_file',
\ui_get_full_url('ajax.php', false, false, false),
@ -680,123 +629,51 @@ class EventsListWidget extends Widget
true
);
$table = new \StdClass;
$table->class = 'widget_groups_status databox';
$table->cellspacing = '1';
$table->width = '100%';
$table->data = [];
$table->size = [];
$table->rowclass = [];
$table_id = 'dashboard_list_events_'.$this->cellId;
// If its node, get direccion value and construct rute.
if ($this->nodeId !== null && $this->nodeId > 0) {
metaconsole_restore_db();
$result = db_get_all_rows_sql('SELECT server_url FROM tmetaconsole_setup WHERE id = '.$this->nodeId.'');
$home_url = $result[0]['server_url'];
metaconsole_connect(null, $this->nodeId);
}
hd($events, true);
foreach ($events as $event) {
$data = [];
$event['evento'] = \io_safe_output($event['evento']);
$data[0] = \events_print_type_img($event['event_type'], true);
$agent_alias = \agents_get_alias($event['id_agente']);
if ($agent_alias !== '') {
$data[1] = '<a href="'.$home_url;
$data[1] .= '/index.php?sec=estado';
$data[1] .= '&sec2=operation/agentes/ver_agente';
$data[1] .= '&id_agente='.$event['id_agente'];
$data[1] .= '" title="'.$event['evento'].'">';
$data[1] .= $agent_alias;
$data[1] .= '</a>';
} else {
$data[1] = '&nbsp;';
}
if (isset($event['event_rep']) === true
&& $event['event_rep'] > 1
) {
$data[1] .= ' ('.$event['event_rep'].')';
}
// Group.
$data[2] = $event['group_name'];
// Tags.
$data[3] = $event['tags'];
$settings = json_encode(
// Print datatable.
$output .= ui_print_datatable(
[
'event' => $event,
'page' => 'include/ajax/events',
'cellId' => $this->cellId,
'ajaxUrl' => \ui_get_full_url(
'ajax.php',
false,
false,
false
),
'result' => false,
'dashboardId' => $this->dashboardId,
'widgetId' => $this->widgetId,
'cellId' => $this->cellId,
'node_id' => $this->nodeId,
'id' => $table_id,
'class' => 'info_table events',
'style' => 'width: 100%;',
'ajax_url' => 'operation/events/events',
'ajax_data' => [
'get_events' => 1,
'table_id' => $table_id,
'filter' => $filter,
'length' => $this->values['limit'],
'groupRecursion' => (bool) $this->values['groupRecursion'],
],
'default_pagination' => $this->values['limit'],
'pagination_options' => [
[
$this->values['limit'],
10,
25,
100,
],
[
$this->values['limit'],
10,
25,
100,
],
],
'order' => [
'field' => 'timestamp',
'direction' => 'desc',
],
'column_names' => $column_names,
'columns' => $fields,
'ajax_return_operation' => 'buffers',
'ajax_return_operation_function' => 'process_buffers',
// 'drawCallback' => 'process_datatables_callback(this, settings)',
'return' => true,
'csv' => 0,
]
);
if ($this->publicLink === false) {
$data[4] = '<a href="javascript:"onclick="';
$data[4] .= 'dashboardShowEventDialog(\'';
$data[4] .= base64_encode($settings).'\');">';
}
$data[4] .= substr(\io_safe_output($event['evento']), 0, 150);
if (strlen($event['evento']) > 150) {
$data[4] .= '...';
}
if ($this->publicLink === false) {
$data[4] .= '<a>';
}
$data[5] = \ui_print_timestamp($event['timestamp'], true);
$table->data[$i] = $data;
$bg_color = 'background: #E8E8E8;';
if ($config['style'] === 'pandora_black' && !is_metaconsole()) {
$bg_color = 'background: #222;';
}
$table->cellstyle[$i][0] = $bg_color;
$rowclass = \events_get_criticity_class($event['criticity']);
$table->cellclass[$i][1] = $rowclass;
$table->cellclass[$i][2] = $rowclass;
$table->cellclass[$i][3] = $rowclass;
$table->cellclass[$i][4] = $rowclass;
$table->cellclass[$i][5] = $rowclass;
$i++;
}
$output .= \html_print_table($table, true);
$output .= "<div id='event_details_window'></div>";
$output .= "<div id='event_response_window'></div>";
$output .= "<div id='event_response_command_window' title='";
$output .= \__('Parameters')."'></div>";
} else {
$output .= '<div class="container-center">';
$output .= \ui_print_info_message(
\__('There are no events matching selected search filters'),
'',
true
);
$output .= '</div>';
}
return $output;
}

View File

@ -572,3 +572,8 @@ div#main_pure {
#main_page > .ui-content div.label > p {
margin: 0;
}
.content-widget .dataTables_wrapper {
width: 98%;
margin-top: 5px;
}

View File

@ -267,6 +267,9 @@ if (is_metaconsole() === true) {
// Ajax responses.
if (is_ajax() === true) {
$get_events = (int) get_parameter('get_events', 0);
$table_id = get_parameter('table_id', '');
$groupRecursion = (bool) get_parameter('groupRecursion', false);
// Datatables offset, limit.
$start = get_parameter('start', 0);
$length = get_parameter(
@ -349,7 +352,11 @@ if (is_ajax() === true) {
// Sort field.
$order['field'],
// History.
$history
$history,
false,
'',
false,
$groupRecursion
);
$buffers = [];
@ -364,7 +371,11 @@ if (is_ajax() === true) {
null,
null,
null,
$history
$history,
false,
'',
false,
$groupRecursion
);
if ($count !== false) {
@ -379,12 +390,13 @@ if (is_ajax() === true) {
if (empty($events) === false) {
$data = array_reduce(
$events,
function ($carry, $item) {
function ($carry, $item) use ($table_id) {
global $config;
$tmp = (object) $item;
$tmp->meta = is_metaconsole();
//// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
if ($tmp->meta === true) {
if ($tmp->server_name !== null) {
$tmp->data_server = metaconsole_get_servers(
@ -463,6 +475,479 @@ if (is_ajax() === true) {
$tmp->b64 = base64_encode(json_encode($tmp));
// Show comments events.
$tmp->user_comment = $tmp->comments;
if ($tmp->comments !== 'undefined' && strlen($tmp->comments) > 80) {
$tmp->user_comment .= '&nbsp;&nbsp;';
$tmp->user_comment .= '<a id="show_comments" href="javascript:" onclick="show_event_dialog(\'';
$tmp->user_comment .= $tmp->b64;
$tmp->user_comment .= '\',\'comments\')>;';
$tmp->user_comment .= html_print_image(
'images/operation.png',
true,
[
'title' => __('Show more'),
'class' => 'invert_filter',
]
);
$tmp->user_comment .= '</a>';
}
// Grouped events.
if (isset($tmp->max_id_evento) === true
&& empty($tmp->max_id_evento) === false
) {
$tmp->id_evento = $tmp->max_id_evento;
}
// Event severity prepared.
switch ($tmp->criticity) {
case EVENT_CRIT_CRITICAL;
$text = __('CRITICAL');
$color = COL_CRITICAL;
break;
case EVENT_CRIT_MAINTENANCE;
$text = __('MAINTENANCE');
$color = COL_MAINTENANCE;
break;
case EVENT_CRIT_INFORMATIONAL;
$text = __('INFORMATIONAL');
$color = COL_INFORMATIONAL;
break;
case EVENT_CRIT_MAJOR;
$text = __('MAJOR');
$color = COL_MAJOR;
break;
case EVENT_CRIT_MINOR;
$text = __('MINOR');
$color = COL_MINOR;
break;
case EVENT_CRIT_NORMAL;
$text = __('NORMAL');
$color = COL_NORMAL;
break;
case EVENT_CRIT_WARNING;
$text = __('WARNING');
$color = COL_WARNING;
break;
default:
$color = COL_UNKNOWN;
$text = __('UNKNOWN');
break;
}
$output = '<div data-title="';
$output .= $text;
$output .= '" data-use_title_for_force_title="1" ';
$output .= 'class="forced_title mini-criticity h100p" ';
$output .= ('style="background: '.$color.'">');
$output .= '</div>';
$tmp->mini_severity = '<div class="event flex-row h100p nowrap">';
$tmp->mini_severity .= $output;
$tmp->mini_severity .= '</div>';
$criticity = '<div class="criticity" style="background: ';
$criticity .= $color.'">'.$text.'</div>';
$tmp->criticity = $criticity;
// Add event severity to end of text.
$evn = '<a href="javascript:" onclick="show_event_dialog(\''.$tmp->b64.'\')">';
// Grouped events.
if (isset($tmp->event_rep) === true && $tmp->event_rep > 1) {
$evn .= '('.$tmp->event_rep.') ';
}
$evn .= $tmp->evento.'</a>';
// Add event severity format to itself.
$tmp->evento = $evn;
// Grouped events.
if (isset($item->max_timestamp) === true
&& ($item->max_timestamp) === false
) {
$item->timestamp = $item->max_timestamp;
}
// Event type prepared.
switch ($tmp->event_type) {
case EVENTS_ALERT_FIRED;
case EVENTS_ALERT_RECOVERED;
case EVENTS_ALERT_CEASED;
case EVENTS_ALERT_MANUAL_VALIDATION;
$text = __('ALERT');
$color = COL_ALERTFIRED;
break;
case EVENTS_RECON_HOST_DETECTED;
case EVENTS_SYSTEM;
case EVENTS_ERROR;
case EVENTS_NEW_AGENT;
case EVENTS_CONFIGURATION_CHANGE;
$text = __('SYSTEM');
$color = COL_MAINTENANCE;
break;
case EVENTS_GOING_UP_WARNING;
case EVENTS_GOING_DOWN_WARNING;
$text = __('WARNING');
$color = COL_WARNING;
break;
case EVENTS_GOING_DOWN_NORMAL;
case EVENTS_GOING_UP_NORMAL;
$text = __('NORMAL');
$color = COL_NORMAL;
break;
case EVENTS_GOING_DOWN_CRITICAL;
case EVENTS_GOING_UP_CRITICAL;
$text = __('CRITICAL');
$color = COL_CRITICAL;
break;
case EVENTS_UNKNOWN;
case EVENTS_GOING_UNKNOWN;
default:
$text = __('UNKNOWN');
$color = COL_UNKNOWN;
break;
}
$event_type = '<div class="criticity" style="background: ';
$event_type .= $color.'">'.$text.'</div>';
$tmp->event_type = $event_type;
// Module status.
// Event severity prepared.
switch ($tmp->module_status) {
case AGENT_MODULE_STATUS_NORMAL;
$text = __('NORMAL');
$color = COL_NORMAL;
break;
case AGENT_MODULE_STATUS_CRITICAL_BAD;
$text = __('CRITICAL');
$color = COL_CRITICAL;
break;
case AGENT_MODULE_STATUS_NO_DATA;
$text = __('NOT INIT');
$color = COL_NOTINIT;
break;
case AGENT_MODULE_STATUS_CRITICAL_ALERT;
case AGENT_MODULE_STATUS_NORMAL_ALERT;
case AGENT_MODULE_STATUS_WARNING_ALERT;
$text = __('ALERT');
$color = COL_ALERTFIRED;
break;
case AGENT_MODULE_STATUS_WARNING;
$text = __('WARNING');
$color = COL_WARNING;
break;
default:
$text = __('UNKNOWN');
$color = COL_UNKNOWN;
break;
}
$module_status = '<div class="criticity" style="background: ';
$module_status .= $color.'">'.$text.'</div>';
$tmp->module_status = $module_status;
// Status.
switch ($tmp->estado) {
case EVENT_STATUS_NEW:
$img = html_print_image(
'images/star.png',
true,
[
'title' => __('New event'),
'class' => 'forced-title',
]
);
$state = 0;
break;
case EVENT_STATUS_VALIDATED:
$state = 1;
$img = html_print_image(
'images/tick.png',
true,
[
'title' => __('Event validated'),
'class' => 'forced-title invert_filter',
]
);
break;
case EVENT_STATUS_INPROCESS:
$state = 2;
$img = html_print_image(
'images/hourglass.png',
true,
[
'title' => __('Event in process'),
'class' => 'forced-title invert_filter',
]
);
break;
default:
$img = html_print_image(
'images/star.png',
true,
[
'title' => __('Unknown'),
'class' => 'forced-title',
]
);
$state = 0;
break;
}
$draw_state = '<div>';
$draw_state .= '<span class="invisible">';
$draw_state .= $state;
$draw_state .= '</span>';
$draw_state .= $img;
$draw_state .= '</div>';
$tmp->estado = $draw_state;
// Owner.
if (empty($tmp->owner_user) === true) {
$tmp->owner_user = __('System');
}
// Group name.
if (empty($tmp->id_grupo) === true) {
$tmp->id_grupo = __('All');
} else {
$tmp->id_grupo = $tmp->group_name;
}
// Module name.
$tmp->id_agentmodule = $tmp->module_name;
// Options.
// Show more.
$tmp->options = '<a href="javascript:" onclick="show_event_dialog(\''.$tmp->b64.'\')">';
$tmp->options .= html_print_image(
'images/operation.png',
true,
[
'title' => __('Show more'),
'class' => 'invert_filter',
]
);
$tmp->options .= '</a>';
if ((int) $tmp->user_can_write === 1) {
if ((int) $tmp->estado !== 1) {
// Validate.
$tmp->options .= '<a href="javascript:" onclick="validate_event(\''.$table_id.'\',';
if (isset($tmp->max_id_evento) === true
&& empty($tmp->max_id_evento) === false
) {
$id_val = $tmp->max_id_evento;
if (is_metaconsole() === true) {
$id_val .= '-'.$tmp->server_id;
}
$tmp->options .= $tmp->max_id_evento.', ';
$tmp->options .= $tmp->event_rep.', this, '.$tmp->server_id.')"';
$tmp->options .= ' id="val-'.$id_val.'">';
$tmp->options .= html_print_image(
'images/tick.png',
true,
[
'title' => __('Validate events'),
'class' => 'invert_filter',
]
);
$tmp->options .= '</a>';
} else {
$id_val = $tmp->id_evento;
if (is_metaconsole() === true) {
$id_val .= '-'.$tmp->server_id;
}
$tmp->options .= $tmp->id_evento.', 0, this, ';
$tmp->options .= $tmp->server_id.')" id="val-'.$id_val.'">';
$tmp->options .= html_print_image(
'images/tick.png',
true,
[
'title' => __('Validate event'),
'class' => 'invert_filter',
]
);
$tmp->options .= '</a>';
}
}
if ((int) $tmp->estado !== 2) {
// In process.
$tmp->options .= '<a href="javascript:" onclick="in_process_event(\''.$table_id.'\',';
if (isset($tmp->max_id_evento) === true
&& empty($tmp->max_id_evento) === false
) {
$id_proc = $tmp->max_id_evento;
if (is_metaconsole() === true) {
$id_proc .= '-'.$tmp->server_id;
}
$tmp->options .= $tmp->max_id_evento.', '.$tmp->event_rep.', this, ';
$tmp->options .= $tmp->server_id.')" id="proc-'.$id_proc.'">';
} else {
$id_proc = $tmp->id_evento;
if (is_metaconsole() === true) {
$id_proc .= '-'.$tmp->server_id;
}
$tmp->options .= $tmp->id_evento.', 0, this, ';
$tmp->options .= $tmp->server_id.')" id="proc-'.$id_proc.'">';
}
$tmp->options .= html_print_image(
'images/hourglass.png',
true,
[
'title' => __('Change to in progress status'),
'class' => 'invert_filter',
]
);
$tmp->options .= '</a>';
}
}
if ((int) $tmp->user_can_manage === 1) {
// Delete.
$tmp->options .= '<a href="javascript:" onclick="delete_event(\''.$table_id.'\',';
if (isset($tmp->max_id_evento) === true
&& empty($tmp->max_id_evento) === false
) {
$id_del = $tmp->max_id_evento;
if (is_metaconsole() === true) {
$id_del .= '-'.$tmp->server_id;
}
$tmp->options .= $tmp->max_id_evento.', '.$tmp->event_rep;
$tmp->options .= ', this, '.$tmp->server_id.')" id="del-'.$id_del.'">';
$tmp->options .= html_print_image(
'images/cross.png',
true,
[
'title' => __('Delete events'),
'class' => 'invert_filter',
]
);
$tmp->options .= '</a>';
} else {
$id_del = $tmp->id_evento;
if (is_metaconsole() === true) {
$id_del .= '-'.$tmp->server_id;
}
$tmp->options .= $tmp->id_evento.', 0, this, ';
$tmp->options .= $tmp->server_id.')" id="del-'.$id_del.'">';
$tmp->options .= html_print_image(
'images/cross.png',
true,
[
'title' => __('Delete event'),
'class' => 'invert_filter',
]
);
$tmp->options .= '</a>';
}
}
// Multi select.
$value_checkbox = $tmp->id_evento;
if (is_metaconsole() === true) {
$value_checkbox .= '|'.$tmp->server_id;
}
$tmp->m = '<input name="checkbox-multi[]" type="checkbox" value="';
$tmp->m .= $value_checkbox.'" id="checkbox-multi-'.$tmp->id_evento.'" ';
if (isset($tmp->max_id_evento) === true
&& empty($tmp->max_id_evento) === false
) {
$tmp->m .= ' event_rep="'.$tmp->event_rep.'" ';
} else {
$tmp->m .= ' event_rep="0" ';
}
$tmp->m .= 'class="candeleted chk_val">';
// Url to go to node from meta.
$server_url = '';
$hashdata = '';
if ($tmp->meta === true) {
if (isset($tmp->data_server) === true
&& isset($tmp->server_url_hash) === true
) {
$server_url = $tmp->data_server['server_url'];
$hashdata = $tmp->server_url_hash;
}
}
// Url to agent view.
$url_link = ui_get_full_url(
'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='
);
$url_link_hash = '';
if ($tmp->meta === true) {
$url_link = $server_url;
$url_link .= '/index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=';
$url_link_hash = $hashdata;
}
// Agent name link.
if ($tmp->id_agente > 0) {
$draw_agent_name = '<a href="'.$url_link.$tmp->id_agente.$url_link_hash.'">';
$draw_agent_name .= $tmp->agent_name;
$draw_agent_name .= '</a>';
$tmp->agent_name = $draw_agent_name;
} else {
$tmp->agent_name = '';
}
// Agent ID link.
if ($tmp->id_agente > 0) {
$draw_agent_id = '<a href="'.$url_link.$tmp->id_agente.$url_link_hash.'">';
$draw_agent_id .= $tmp->id_agente;
$draw_agent_id .= '</a>';
$tmp->id_agente = $draw_agent_id;
} else {
$tmp->id_agente = '';
}
if (empty($tmp->custom_data) === false) {
$custom_data = json_decode(io_safe_output($tmp->custom_data), true);
$custom_data_str = '';
if (isset($custom_data) === true && empty($custom_data) === false) {
foreach ($custom_data as $key => $value) {
$custom_data_str .= $value['attr_name'].' = '.$value['val'].'<br>';
}
}
$tmp->custom_data = $custom_data_str;
}
$carry[] = $tmp;
return $carry;
}
@ -1748,6 +2233,8 @@ try {
$table_id = 'events';
$form_id = 'events_form';
// Print datatable.
ui_print_datatable(
[
@ -1758,6 +2245,7 @@ try {
'ajax_data' => [
'get_events' => 1,
'history' => (int) $history,
'table_id' => $table_id,
],
'form' => [
'id' => $form_id,
@ -1800,7 +2288,6 @@ try {
-2,
'column-instructions',
],
'ajax_postprocess' => 'process_datatables_item(item)',
'ajax_return_operation' => 'buffers',
'ajax_return_operation_function' => 'process_buffers',
'drawCallback' => 'process_datatables_callback(this, settings)',
@ -2018,386 +2505,6 @@ function process_datatables_callback(table, settings) {
$('#checkbox-all_validate_box').uncheck();
}
}
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 class_total = 'info';
var str_total = '';
if(buffers.settings.total == element[1]) {
class_total += ' danger';
str_total = buffers.settings.translate.tevn;
}
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);
}
}
function process_datatables_item(item) {
// Url to go to node from meta.
var server_url = '';
var hashdata = '';
if(item.meta === true){
if(typeof item.data_server !== 'undefined' && typeof item.server_url_hash !== 'undefined'){
server_url = item.data_server.server_url;
hashdata = item.server_url_hash;
}
}
// Show comments events.
item.user_comment = item.comments
if(typeof item.comments !== 'undefined' && item.comments.length > 80) {
item.user_comment += '&nbsp;&nbsp;<a id="show_comments" href="javascript:" onclick="show_event_dialog(\'';
item.user_comment += item.b64+"','comments'," + $("#group_rep").val()+');">';
item.user_comment += '<?php echo html_print_image('images/operation.png', true, ['title' => __('Show more'), 'class' => 'invert_filter']); ?></a>';
}
// Grouped events.
if(item.max_id_evento) {
item.id_evento = item.max_id_evento
}
/* Event severity prepared */
var color = "<?php echo COL_UNKNOWN; ?>";
var text = "<?php echo __('UNKNOWN'); ?>";
switch (item.criticity) {
case "<?php echo EVENT_CRIT_CRITICAL; ?>":
text = "<?php echo __('CRITICAL'); ?>";
color = "<?php echo COL_CRITICAL; ?>";
break;
case "<?php echo EVENT_CRIT_MAINTENANCE; ?>":
text = "<?php echo __('MAINTENANCE'); ?>";
color = "<?php echo COL_MAINTENANCE; ?>";
break;
case "<?php echo EVENT_CRIT_INFORMATIONAL; ?>":
text = "<?php echo __('INFORMATIONAL'); ?>";
color = "<?php echo COL_INFORMATIONAL; ?>";
break;
case "<?php echo EVENT_CRIT_MAJOR; ?>":
text = "<?php echo __('MAJOR'); ?>";
color = "<?php echo COL_MAJOR; ?>";
break;
case "<?php echo EVENT_CRIT_MINOR; ?>":
text = "<?php echo __('MINOR'); ?>";
color = "<?php echo COL_MINOR; ?>";
break;
case "<?php echo EVENT_CRIT_NORMAL; ?>":
text = "<?php echo __('NORMAL'); ?>";
color = "<?php echo COL_NORMAL; ?>";
break;
case "<?php echo EVENT_CRIT_WARNING; ?>":
text = "<?php echo __('WARNING'); ?>";
color = "<?php echo COL_WARNING; ?>";
break;
}
output = '<div data-title="';
output += text;
output += '" data-use_title_for_force_title="1" ';
output += 'class="forced_title mini-criticity h100p" ';
output += 'style="background: ' + color + '">';
output += '</div>';
// Add event severity to end of text.
evn = '<a href="javascript:" onclick="show_event_dialog(\'';
evn += item.b64+'\','+$("#group_rep").val()+');">';
// Grouped events.
if(item.event_rep && item.event_rep > 1) {
evn += '('+item.event_rep+') ';
}
evn += item.evento+'</a>';
if(item.meta === true) {
evn += '<input id="hidden-server_id_'+item.id_evento+'" type="hidden" value="'+item.server_id+'">';
}
item.mini_severity = '<div class="event flex-row h100p nowrap">';
item.mini_severity += output;
item.mini_severity += '</div>';
criticity = '<div class="criticity" style="background: ';
criticity += color + '">' + text + "</div>";
// Grouped events.
if(item.max_timestamp) {
item.timestamp = item.max_timestamp;
}
/* Event type prepared. */
switch (item.event_type) {
case "<?php echo EVENTS_ALERT_FIRED; ?>":
case "<?php echo EVENTS_ALERT_RECOVERED; ?>":
case "<?php echo EVENTS_ALERT_CEASED; ?>":
case "<?php echo EVENTS_ALERT_MANUAL_VALIDATION; ?>":
text = "<?php echo __('ALERT'); ?>";
color = "<?php echo COL_ALERTFIRED; ?>";
break;
case "<?php echo EVENTS_RECON_HOST_DETECTED; ?>":
case "<?php echo EVENTS_SYSTEM; ?>":
case "<?php echo EVENTS_ERROR; ?>":
case "<?php echo EVENTS_NEW_AGENT; ?>":
case "<?php echo EVENTS_CONFIGURATION_CHANGE; ?>":
text = "<?php echo __('SYSTEM'); ?>";
color = "<?php echo COL_MAINTENANCE; ?>";
break;
case "<?php echo EVENTS_GOING_UP_WARNING; ?>":
case "<?php echo EVENTS_GOING_DOWN_WARNING; ?>":
text = "<?php echo __('WARNING'); ?>";
color = "<?php echo COL_WARNING; ?>";
break;
case "<?php echo EVENTS_GOING_DOWN_NORMAL; ?>":
case "<?php echo EVENTS_GOING_UP_NORMAL; ?>":
text = "<?php echo __('NORMAL'); ?>";
color = "<?php echo COL_NORMAL; ?>";
break;
case "<?php echo EVENTS_GOING_DOWN_CRITICAL; ?>":
case "<?php echo EVENTS_GOING_UP_CRITICAL; ?>":
text = "<?php echo __('CRITICAL'); ?>";
color = "<?php echo COL_CRITICAL; ?>";
break;
case "<?php echo EVENTS_UNKNOWN; ?>":
case "<?php echo EVENTS_GOING_UNKNOWN; ?>":
default:
text = "<?php echo __('UNKNOWN'); ?>";
color = "<?php echo COL_UNKNOWN; ?>";
break;
}
event_type = '<div class="criticity" style="background: ';
event_type += color + '">' + text + "</div>";
/* Module status */
/* Event severity prepared */
var color = "<?php echo COL_UNKNOWN; ?>";
var text = "<?php echo __('UNKNOWN'); ?>";
switch (item.module_status) {
case "<?php echo AGENT_MODULE_STATUS_NORMAL; ?>":
text = "<?php echo __('NORMAL'); ?>";
color = "<?php echo COL_NORMAL; ?>";
break;
case "<?php echo AGENT_MODULE_STATUS_CRITICAL_BAD; ?>":
text = "<?php echo __('CRITICAL'); ?>";
color = "<?php echo COL_CRITICAL; ?>";
break;
case "<?php echo AGENT_MODULE_STATUS_NO_DATA; ?>":
text = "<?php echo __('NOT INIT'); ?>";
color = "<?php echo COL_NOTINIT; ?>";
break;
case "<?php echo AGENT_MODULE_STATUS_CRITICAL_ALERT; ?>":
case "<?php echo AGENT_MODULE_STATUS_NORMAL_ALERT; ?>":
case "<?php echo AGENT_MODULE_STATUS_WARNING_ALERT; ?>":
text = "<?php echo __('ALERT'); ?>";
color = "<?php echo COL_ALERTFIRED; ?>";
break;
case "<?php echo AGENT_MODULE_STATUS_WARNING; ?>":
text = "<?php echo __('WARNING'); ?>";
color = "<?php echo COL_WARNING; ?>";
break;
}
module_status = '<div class="criticity" style="background: ';
module_status += color + '">' + text + "</div>";
/* Options */
// Show more.
item.options = '<a href="javascript:" onclick="show_event_dialog(\'';
item.options += item.b64+'\','+$("#group_rep").val();
item.options += ')" ><?php echo html_print_image('images/operation.png', true, ['title' => __('Show more'), 'class' => 'invert_filter']); ?></a>';
<?php
if (!$readonly) {
?>
if (item.user_can_write == '1') {
if (item.estado != '1') {
// Validate.
item.options += '<a href="javascript:" onclick="validate_event(dt_<?php echo $table_id; ?>,';
if (item.max_id_evento) {
item.options += item.max_id_evento+', '+ item.event_rep +', this, '+item.server_id+')" id="val-'+item.max_id_evento+'">';
item.options += '<?php echo html_print_image('images/tick.png', true, ['title' => __('Validate events'), 'class' => 'invert_filter']); ?></a>';
} else {
item.options += item.id_evento+', 0, this, '+item.server_id+')" id="val-'+item.id_evento+'">';
item.options += '<?php echo html_print_image('images/tick.png', true, ['title' => __('Validate event'), 'class' => 'invert_filter']); ?></a>';
}
}
if (item.estado != '2') {
// In process.
item.options += '<a href="javascript:" onclick="in_process_event(dt_<?php echo $table_id; ?>,';
if (item.max_id_evento) {
item.options += item.max_id_evento+', '+ item.event_rep +', this, '+item.server_id+')" id="proc-'+item.max_id_evento+'">';
} else {
item.options += item.id_evento+', 0, this, '+item.server_id+')" id="proc-'+item.id_evento+'">';
}
item.options += '<?php echo html_print_image('images/hourglass.png', true, ['title' => __('Change to in progress status'), 'class' => 'invert_filter']); ?></a>';
}
}
if (item.user_can_manage == '1') {
// Delete.
item.options += '<a href="javascript:" onclick="delete_event(dt_<?php echo $table_id; ?>,';
if (item.max_id_evento) {
item.options += item.max_id_evento+', '+ item.event_rep +', this, '+item.server_id+')" id="del-'+item.max_id_evento+'">';
item.options += '<?php echo html_print_image('images/cross.png', true, ['title' => __('Delete events'), 'class' => 'invert_filter']); ?></a>';
} else {
item.options += item.id_evento+', 0, this, '+item.server_id+')" id="del-'+item.id_evento+'">';
item.options += '<?php echo html_print_image('images/cross.png', true, ['title' => __('Delete event'), 'class' => 'invert_filter']); ?></a>';
}
}
<?php
}
?>
// Multi select.
item.m = '<input name="checkbox-multi[]" type="checkbox" value="';
item.m += item.id_evento+'" id="checkbox-multi-'+item.id_evento+'" ';
if (item.max_id_evento) {
item.m += ' event_rep="' + item.event_rep +'" ';
} else {
item.m += ' event_rep="0" ';
}
item.m += 'class="candeleted chk_val">';
/* Status */
img = '<?php echo html_print_image('images/star.png', true, ['title' => __('Unknown'), 'class' => 'forced-title']); ?>';
state = '0';
switch (item.estado) {
case "<?php echo EVENT_STATUS_NEW; ?>":
img = '<?php echo html_print_image('images/star.png', true, ['title' => __('New event'), 'class' => 'forced-title']); ?>';
break;
case "<?php echo EVENT_STATUS_VALIDATED; ?>":
state = '1';
img = '<?php echo html_print_image('images/tick.png', true, [ 'title' => __('Event validated'), 'class' => 'forced-title invert_filter']); ?>';
break;
case "<?php echo EVENT_STATUS_INPROCESS; ?>":
state = '2';
img = '<?php echo html_print_image('images/hourglass.png', true, [ 'title' => __('Event in process'), 'class' => 'forced-title invert_filter']); ?>';
break;
}
/* Update column content now to avoid json poisoning. */
// Url to agent view.
var url_link = '<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>';
var url_link_hash = '';
if(item.meta === true){
url_link = server_url+'/index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=';
url_link_hash = hashdata;
}
/* Agent name link */
if (item.id_agente > 0) {
item.agent_name = '<a href="'+url_link+item.id_agente+url_link_hash+'">' + item.agent_name + '</a>';
} else {
item.agent_name = '';
}
/* Agent ID link */
if (item.id_agente > 0) {
item.id_agente = '<a href="'+url_link+item.id_agente+url_link_hash+'">' + item.id_agente + '</a>';
} else {
item.id_agente = '';
}
item.estado = '<div>';
item.estado += '<span class="invisible">';
item.estado += state;
item.estado += '</span>';
item.estado += img;
item.estado += '</div>';
item.criticity = criticity;
item.event_type = event_type;
item.module_status = module_status;
/* Event ID dash */
item.id_evento = "#"+item.id_evento;
/* Owner */
if (item.owner_user == "0") {
item.owner_user = '<?php echo __('System'); ?>';
}
// Add event severity format to itself.
item.evento = evn;
/* Group name */
if (item.id_grupo == "0") {
item.id_grupo = "<?php echo __('All'); ?>";
} else {
item.id_grupo = item.group_name;
}
/* Module name */
item.id_agentmodule = item.module_name;
if (item.custom_data !== '') {
var custom_data_str = '';
var item_custom_data_obj = (function(json_str) {
try {
return JSON.parse(json_str);
} catch (err) {
return false;
}
})(item.custom_data);
if (item_custom_data_obj !== false) {
for (const [attr_name, val] of Object.entries(item_custom_data_obj)) {
custom_data_str += attr_name + ' = ' + val + '<br>';
}
item.custom_data = custom_data_str;
} else {
item.custom_data = '';
}
}
}
/* Datatables auxiliary functions ends */
/* Tag management starts */