wip event list

This commit is contained in:
fbsanchez 2019-06-07 17:35:13 +02:00
parent 23e6711f09
commit 419a90d69c
7 changed files with 808 additions and 86 deletions

View File

@ -902,6 +902,47 @@ function set_cookie($name, $value)
}
/**
* Returns database ORDER clause from datatables AJAX call.
*
* @param boolean $as_array Return as array or as string.
*
* @return string Order or empty.
*/
function get_datatable_order($as_array=false)
{
$order = get_parameter('order');
if (is_array($order)) {
$column = $order[0]['column'];
$direction = $order[0]['dir'];
}
if (!isset($column) || !isset($direction)) {
return '';
}
$columns = get_parameter('columns');
if (is_array($columns)) {
$column_name = $columns[$column]['data'];
}
if (!isset($column_name)) {
return '';
}
if ($as_array) {
return [
'direction' => $direction,
'field' => $column_name,
];
}
return $column_name.' '.$direction;
}
/**
* Get a parameter from a request.
*

View File

@ -69,6 +69,22 @@ function events_get_all_fields()
}
/**
* Creates SQL from filter (array) options.
*
* @param array $filter Filters.
*
* @return string DB sql filter for where clause.
*/
function events_sql_db_filter($filter)
{
if (!isset($filter) || is_array($filter)) {
return '';
}
}
/**
* Get all rows of events from the database, that
* pass the filter, and can get only some fields.
@ -251,7 +267,8 @@ function events_get_events_grouped(
(SELECT criticity FROM %s WHERE id_evento = MAX(te.id_evento)) AS criticity,
(SELECT ack_utimestamp FROM %s WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp,
(SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = te.id_agentmodule) AS module_name,
(SELECT alias FROM tagente WHERE id_agente = te.id_agente) agent_name
(SELECT alias FROM tagente WHERE id_agente = te.id_agente) agent_name,
te.id_agente
FROM %s te %s
WHERE 1=1 %s
GROUP BY estado, evento, id_agente, id_agentmodule %s ',
@ -5321,11 +5338,15 @@ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=
break;
default:
// Ignore.
$sort_field_translated = $sort_field;
break;
}
$dir = ($sort == 'up') ? 'ASC' : 'DESC';
if (strtolower($sort) != 'asc' && strtolower($sort) != 'desc') {
$dir = ($sort == 'up') ? 'ASC' : 'DESC';
} else {
$dir = $sort;
}
return 'ORDER BY '.$sort_field_translated.' '.$dir;
}

View File

@ -1241,7 +1241,9 @@ function html_print_input_text_extended($name, $value, $id, $alt, $size, $maxlen
$maxlength = 255;
}
if ($size == 0) {
if ($size === false) {
$size = '';
} else if ($size == 0) {
$size = 10;
}
@ -1441,7 +1443,9 @@ function html_print_input_password(
$maxlength = 255;
}
if ($size == 0) {
if ($size === false) {
$size = false;
} else if ($size == 0) {
$size = 10;
}
@ -1479,7 +1483,9 @@ function html_print_input_text($name, $value, $alt='', $size=50, $maxlength=255,
$maxlength = 255;
}
if ($size == 0) {
if ($size === false) {
$size = false;
} else if ($size == 0) {
$size = 10;
}
@ -2730,20 +2736,22 @@ function html_html2rgb($htmlcolor)
/**
* Print a magic-ajax control to select the module.
*
* @param string $name The name of ajax control, by default is "module".
* @param string $default The default value to show in the ajax control.
* @param array $id_agents The array list of id agents as array(1,2,3), by default is false and the function use all agents (if the ACL desactive).
* @param boolean $ACL Filter the agents by the ACL list of user.
* @param string $scriptResult The source code of script to call, by default is
* empty. And the example is:
* function (e, data, formatted) {
* ...
* }
* @param string $name The name of ajax control, by default is "module".
* @param string $default The default value to show in the ajax control.
* @param array $id_agents The array list of id agents as array(1,2,3), by default is false and the function use all agents (if the ACL desactive).
* @param boolean $ACL Filter the agents by the ACL list of user.
* @param string $scriptResult The source code of script to call, by default is
* empty. And the example is:
* function (e, data, formatted) {
* ...
* }
*
* And the formatted is the select item as string.
* And the formatted is the select item as string.
*
* @param array $filter Other filter of modules.
* @param boolean $return If it is true return a string with the output instead to echo the output.
* @param array $filter Other filter of modules.
* @param boolean $return If it is true return a string with the output instead to echo the output.
* @param integer $id_agent_module Id agent module.
* @param string $size Size.
*
* @return mixed If the $return is true, return the output as string.
*/
@ -2755,7 +2763,8 @@ function html_print_autocomplete_modules(
$scriptResult='',
$filter=[],
$return=false,
$id_agent_module=0
$id_agent_module=0,
$size='30'
) {
global $config;
@ -2796,7 +2805,7 @@ function html_print_autocomplete_modules(
$default,
'text-'.$name,
'',
30,
$size,
100,
false,
'',
@ -3055,4 +3064,4 @@ function html_print_link_with_params($text, $params=[], $type='text', $style='')
$html .= '</form>';
return $html;
}
}

View File

@ -2769,8 +2769,13 @@ function ui_progress(
* 'id' => datatable id.
* 'class' => datatable class.
* 'style' => datatable style.
* 'order' => '9, "desc"'. Column index (starting by 1) and sort direction.
* 'order' => [
* 'field' => column name
* 'direction' => asc or desc
* ],
* 'default_pagination' => integer, default pagination is set to block_size
* 'ajax_url' => 'include/ajax.php' ajax_url.
* 'ajax_data' => [ operation => 1 ] extra info to be sent.
* 'ajax_postprocess' => a javscript function to postprocess data received
* by ajax call. It is applied foreach row and must
* use following format:
@ -2781,7 +2786,7 @@ function ui_progress(
* * item.name = tmp;
* * }
* * [/code]
* 'columns' => [
* 'columns_names' => [
* 'column1' :: Used as th text. Direct text entry. It could be array:
* OR
* [
@ -2791,7 +2796,7 @@ function ui_progress(
* 'text' => 'column1'.
* ]
* ],
* 'datacolumns' => [
* 'columns' => [
* 'column1',
* 'column2',
* ...
@ -2824,18 +2829,43 @@ function ui_progress(
*/
function ui_print_datatable(array $parameters)
{
global $config;
if (isset($parameters['id'])) {
$table_id = $parameters['id'];
} else {
$table_id = uniqid('datatable_');
}
if (!isset($parameters['order'])) {
$parameters['order'] = '0, "asc"';
if (!isset($parameters['columns']) || !is_array($parameters['columns'])) {
throw new Exception('[ui_print_datatable]: You must define columns for datatable');
}
if (!isset($parameters['ajax_url'])) {
throw new Exception('Parameter ajax_url is required');
throw new Exception('[ui_print_datatable]: Parameter ajax_url is required');
}
if (!isset($parameters['default_pagination'])) {
$parameters['default_pagination'] = $config['block_size'];
}
if (!is_array($parameters['order'])) {
$order = '0, "asc"';
} else {
if (!isset($parameters['order']['direction'])) {
$direction = 'asc';
}
if (!isset($parameters['order']['field'])) {
$order = 1;
} else {
$order = array_search(
$parameters['order']['field'],
$parameters['columns']
);
}
$order .= ', "'.$parameters['order']['direction'].'"';
}
if (!isset($parameters['ajax_data'])) {
@ -2852,6 +2882,7 @@ function ui_print_datatable(array $parameters)
} else {
$pagination_options = [
[
$parameters['default_pagination'],
10,
25,
100,
@ -2861,6 +2892,7 @@ function ui_print_datatable(array $parameters)
-1,
],
[
$parameters['default_pagination'],
10,
25,
100,
@ -2970,20 +3002,21 @@ function ui_print_datatable(array $parameters)
);
}
if (!isset($parameters['columns']) || !is_array($parameters['columns'])) {
throw new Exception('[ui_print_datatable]: You must define columns for datatable');
}
// Base table.
$table = '<table id="'.$table_id.'" ';
$table .= 'class="'.$parameters['class'].'"';
$table .= 'style="'.$parameters['style'].'">';
$table .= '<thead><tr>';
if (!is_array($parameters['columns'])) {
throw new Exception('[ui_print_datatable]: Parameter columns is required.');
if (isset($parameters['column_names'])
&& is_array($parameters['column_names'])
) {
$names = $parameters['column_names'];
} else {
$names = $parameters['columns'];
}
foreach ($parameters['columns'] as $column) {
foreach ($names as $column) {
if (is_array($column)) {
$table .= '<th id="'.$column['id'].'" class="'.$column['class'].'" ';
$table .= ' style="'.$column['style'].'">'.__($column['text']);
@ -3004,7 +3037,7 @@ function ui_print_datatable(array $parameters)
processing: true,
serverSide: true,
paging: true,
pageLength: 10,
pageLength: '.$parameters['default_pagination'].',
searching: false,
responsive: true,
dom: "lBfrtip",
@ -3071,7 +3104,7 @@ function ui_print_datatable(array $parameters)
$js .= '
],
order: [[ '.$parameters['order'].' ]]
order: [[ '.$order.' ]]
});
$("#'.$form_id.'_search_bt").click(function (){

View File

@ -19,8 +19,16 @@ div.mini-criticity {
display: inline-block;
}
form.flex-row > div.filter_input,
form.flex-row > ul {
div.mini-criticity.h100p {
height: 100%;
}
.flex-row.event {
align-items: center;
}
form.flex-row div.filter_input,
form.flex-row ul {
width: 30%;
min-width: 300px;
display: flex;
@ -28,16 +36,40 @@ form.flex-row > ul {
align-items: baseline;
flex-wrap: wrap;
align-content: center;
justify-content: space-between;
flex: 1;
margin: 1em 0.3em;
margin: 0.5em 3em 0.5em 0;
}
div.filter_input_little {
flex: 1;
display: flex;
flex-direction: row;
align-items: baseline;
flex-wrap: nowrap;
margin: 0.5em 0 0.5em 1em;
}
form.flex-row div.filter_input.large {
flex: 1;
min-width: 650px;
}
div.filter_input > label,
div.filter_input_little > label {
width: 10em;
}
form.flex-row > ul,
form.flex-row > ul > li,
form.flex-row > .box-shadow.white_table_graph {
width: 100%;
}
form.flex-row > .box-shadow.white_table_graph {
margin-top: 2em;
}
form.flex-row > ul input[type="submit"] {
float: right;
}
@ -45,3 +77,67 @@ form.flex-row > ul input[type="submit"] {
form.flex-row > div > label {
margin-right: 1em;
}
table.dataTable tbody th,
table.dataTable tbody td {
padding: 8px 10px;
}
.info_table.events tr > th {
padding-left: 1em;
font-size: 1.3em;
font-weight: 400;
border-bottom: 2px solid #878787;
cursor: pointer;
}
.info_table.events tr > td {
height: 2.5em;
}
.sorting_desc {
background: url(http://localhost/pandora_console/images/sort_down_green.png)
no-repeat;
background-position-x: left;
background-position-y: center;
}
.sorting_asc {
background: url(http://localhost/pandora_console/images/sort_up_green.png)
no-repeat;
background-position-x: left;
background-position-y: center;
}
.info_table.events > tbody > tr > td {
-moz-border-radius: 0px;
-webkit-border-radius: 0px;
border-radius: 0px;
border: none;
padding-left: 0px;
padding-right: 9px;
padding-top: 7px;
padding-bottom: 7px;
border-bottom: 2px solid #dedede;
}
.info_table.events tr > td:first-child {
padding-left: 5px;
padding-top: 0;
vertical-align: middle;
padding-bottom: 0;
}
.filter_input {
align-items: center;
}
.filter_input_little > select,
.filter_input_little > input,
.filter_input > select,
.filter_input > input {
flex: 1;
}
fieldset {
margin: 0 auto;
}

View File

@ -504,6 +504,10 @@ select:-internal-list-box {
align-content: center;
}
.nowrap {
flex-wrap: nowrap;
}
.padding-2 {
padding: 2em;
}

View File

@ -80,10 +80,7 @@ $event_view_hr = get_parameter('filter[event_view_hr]', 8);
$id_user_ack = get_parameter('filter[id_user_ack]');
$group_rep = get_parameter('filter[group_rep]');
$tag_with = get_parameter('filter[tag_with]', io_json_mb_encode([]));
$tag_without = get_parameter(
'filter[tag_without]',
io_json_mb_encode([])
);
$tag_without = get_parameter('filter[tag_without]', io_json_mb_encode([]));
$filter_only_alert = get_parameter('filter[filter_only_alert]');
$id_group_filter = get_parameter('filter[id_group_filter]');
$date_from = get_parameter('filter[date_from]');
@ -92,6 +89,182 @@ $source = get_parameter('filter[source]');
$id_extra = get_parameter('filter[id_extra]');
$user_comment = get_parameter('filter[user_comment]');
// TAGS.
$tags_select_with = [];
$tags_select_without = [];
$tag_with_temp = [];
$tag_without_temp = [];
foreach ($tags as $id_tag => $tag) {
if ((array_search($id_tag, $tag_with) === false)
|| (array_search($id_tag, $tag_with) === null)
) {
$tags_select_with[$id_tag] = ui_print_truncate_text($tag, 50, true);
} else {
$tag_with_temp[$id_tag] = ui_print_truncate_text($tag, 50, true);
}
if ((array_search($id_tag, $tag_without) === false)
|| (array_search($id_tag, $tag_without) === null)
) {
$tags_select_without[$id_tag] = ui_print_truncate_text($tag, 50, true);
} else {
$tag_without_temp[$id_tag] = ui_print_truncate_text($tag, 50, true);
}
}
$add_with_tag_disabled = empty($tags_select_with);
$remove_with_tag_disabled = empty($tag_with_temp);
$add_without_tag_disabled = empty($tags_select_without);
$remove_without_tag_disabled = empty($tag_without_temp);
$tabletags_with = html_get_predefined_table('transparent', 2);
$tabletags_with->id = 'filter_events_tags_with';
$tabletags_with->width = '100%';
$tabletags_with->cellspacing = 4;
$tabletags_with->cellpadding = 4;
$tabletags_with->class = 'noshadow';
$tabletags_with->styleTable = 'border: 0px;';
if (defined('METACONSOLE')) {
$tabletags_with->class = 'nobady';
$tabletags_with->cellspacing = 0;
$tabletags_with->cellpadding = 0;
}
$data = [];
$data[0] = html_print_select(
$tags_select_with,
'select_with',
'',
'',
'',
0,
true,
true,
true,
'',
false,
'width: 200px;'
);
$data[1] = html_print_image(
'images/darrowright.png',
true,
[
'id' => 'button-add_with',
'style' => 'cursor: pointer;',
'title' => __('Add'),
]
);
$data[1] .= html_print_input_hidden(
'tag_with',
$tag_with_base64,
true
);
$data[1] .= '<br><br>'.html_print_image(
'images/darrowleft.png',
true,
[
'id' => 'button-remove_with',
'style' => 'cursor: pointer;',
'title' => __('Remove'),
]
);
$data[2] = html_print_select(
$tag_with_temp,
'tag_with_temp',
[],
'',
'',
0,
true,
true,
true,
'',
false,
'width: 200px;'
);
$tabletags_with->data[] = $data;
$tabletags_with->rowclass[] = '';
$tabletags_without = html_get_predefined_table('transparent', 2);
$tabletags_without->id = 'filter_events_tags_without';
$tabletags_without->width = '100%';
$tabletags_without->cellspacing = 4;
$tabletags_without->cellpadding = 4;
$tabletags_without->class = 'noshadow';
if (defined('METACONSOLE')) {
$tabletags_without->class = 'nobady';
$tabletags_without->cellspacing = 0;
$tabletags_without->cellpadding = 0;
}
$tabletags_without->styleTable = 'border: 0px;';
$data = [];
$data[0] = html_print_select(
$tags_select_without,
'select_without',
'',
'',
'',
0,
true,
true,
true,
'',
false,
'width: 200px;'
);
$data[1] = html_print_image(
'images/darrowright.png',
true,
[
'id' => 'button-add_without',
'style' => 'cursor: pointer;',
'title' => __('Add'),
]
);
$data[1] .= html_print_input_hidden(
'tag_without',
$tag_without_base64,
true
);
$data[1] .= '<br><br>'.html_print_image(
'images/darrowleft.png',
true,
[
'id' => 'button-remove_without',
'style' => 'cursor: pointer;',
'title' => __('Remove'),
]
);
$data[2] = html_print_select(
$tag_without_temp,
'tag_without_temp',
[],
'',
'',
0,
true,
true,
true,
'',
false,
'width: 200px;'
);
$tabletags_without->data[] = $data;
$tabletags_without->rowclass[] = '';
// END OF TAGS.
// Datatables offset, limit.
$start = get_parameter('start', 0);
$length = get_parameter('length', $config['block_size']);
@ -111,8 +284,11 @@ if (is_ajax()) {
$update_event_filter = get_parameter('update_event_filter', 0);
$get_event_filters = get_parameter('get_event_filters', 0);
$get_events = get_parameter('get_events', 0);
$filter = get_parameter('filter', []);
if ($get_events) {
$order = get_datatable_order(true);
$sql_post = ' AND te.utimestamp > UNIX_TIMESTAMP(now() - INTERVAL '.$event_view_hr.' hour)';
$events = events_get_events_grouped(
// Sql_post.
@ -126,7 +302,13 @@ if (is_ajax()) {
// History.
false,
// Total.
false
false,
// History db.
false,
// Order.
$order['direction'],
// Sort field.
$order['field']
);
if ($events) {
@ -380,7 +562,10 @@ if (is_metaconsole() !== true) {
}
}
// Load filter form.
/*
* Load filter form.
*/
// Group.
$user_groups_array = users_get_groups_for_select(
$config['id_user'],
@ -483,7 +668,7 @@ $in .= $data.'</div>';
$inputs[] = $in;
// Source.
$data = html_print_input_text('source', $source, '', 35, 255, true);
$data = html_print_input_text('source', $source, '', '', 255, true);
$in = '<div class="filter_input"><label>'.__('Source').'</label>';
$in .= $data.'</div>';
$inputs[] = $in;
@ -500,7 +685,7 @@ $data = html_print_input_text(
'user_comment',
$user_comment,
'',
35,
'',
255,
true
);
@ -509,10 +694,229 @@ $in .= $data.'</div>';
$inputs[] = $in;
// Advanced filter.
$adv_filter = '';
/*
* Advanced filter.
*/
$adv_inputs = [];
// Free search.
$data = html_print_input_text('search', $search, '', '', 255, true);
$in = '<div class="filter_input"><label>'.__('Free search').'</label>';
$in .= $data.'</div>';
$adv_inputs[] = $in;
// Agent search.
$params = [];
$params['show_helptip'] = true;
$params['input_name'] = 'text_agent';
$params['value'] = $text_agent;
$params['return'] = true;
if ($meta) {
$params['javascript_page'] = 'enterprise/meta/include/ajax/events.ajax';
}
$params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_name'] = 'id_agent';
$params['hidden_input_idagent_value'] = $id_agent;
$params['size'] = '';
$data = ui_print_agent_autocomplete_input($params);
$in = '<div class="filter_input"><label>'.__('Agent search').'</label>';
$in .= $data.'</div>';
$adv_inputs[] = $in;
// Mixed. Metaconsole => server, Console => module.
if (is_metaconsole()) {
$title = __('Server');
$data = html_print_select_from_sql(
'SELECT id, server_name FROM tmetaconsole_setup',
'server_id',
$server_id,
'script',
__('All'),
'0',
true
);
} else {
$title = __('Module search');
$data = html_print_autocomplete_modules(
'module_search',
$text_module,
false,
true,
'',
[],
true,
$id_agent_module,
''
);
}
$in = '<div class="filter_input"><label>'.$title.'</label>';
$in .= $data.'</div>';
$adv_inputs[] = $in;
// User ack.
$user_users = users_get_user_users(
$config['id_user'],
$access,
users_can_manage_group_all()
);
$data = html_print_select(
$user_users,
'id_user_ack',
$id_user_ack,
'',
__('Any'),
0,
true
);
$in = '<div class="filter_input"><label>'.__('User ack.').'</label>';
$in .= $data.'</div>';
$adv_inputs[] = $in;
// Only alert events.
$data = html_print_select(
[
'-1' => __('All'),
'0' => __('Filter alert events'),
'1' => __('Only alert events'),
],
'filter_only_alert',
$filter_only_alert,
'',
'',
'',
true
);
$in = '<div class="filter_input"><label>'.__('Alert events').'</label>';
$in .= $data.'</div>';
$adv_inputs[] = $in;
// Gap.
$adv_inputs[] = '<div class="filter_input"></div>';
// Date from.
$data = html_print_input_text(
'date_from',
$date_from,
'',
false,
10,
true,
// Disabled.
false,
// Required.
false,
// Function.
'',
// Class.
'',
// OnChange.
'',
// Autocomplete.
'off'
);
$in = '<div class="filter_input">';
$in .= '<div class="filter_input_little"><label>'.__('Date from').'</label>';
$in .= $data.'</div>';
// Time from.
$data = html_print_input_text(
'time_from',
$time_from,
'',
false,
10,
true,
// Disabled.
false,
// Required.
false,
// Function.
'',
// Class.
'',
// OnChange.
'',
// Autocomplete.
'off'
);
$in .= '<div class="filter_input_little"><label>'.__('Time from').'</label>';
$in .= $data.'</div>';
$in .= '</div>';
$adv_inputs[] = $in;
// Date to.
$data = html_print_input_text(
'date_to',
$date_to,
'',
false,
10,
true,
// Disabled.
false,
// Required.
false,
// Function.
'',
// Class.
'',
// OnChange.
'',
// Autocomplete.
'off'
);
$in = '<div class="filter_input">';
$in .= '<div class="filter_input_little"><label>'.__('Date to').'</label>';
$in .= $data.'</div>';
// Time to.
$data = html_print_input_text(
'time_to',
$time_to,
'',
false,
10,
true,
// Disabled.
false,
// Required.
false,
// Function.
'',
// Class.
'',
// OnChange.
'',
// Autocomplete.
'off'
);
$in .= '<div class="filter_input_little"><label>'.__('Time to').'</label>';
$in .= $data.'</div>';
$in .= '</div>';
$adv_inputs[] = $in;
// Tags.
if (is_metaconsole()) {
$data = '<fieldset><legend style="padding:0px;">'.__('Events with following tags').'</legend>'.html_print_table($tabletags_with, true).'</fieldset>';
$data .= '<fieldset><legend style="padding:0px;">'.__('Events without following tags').'</legend>'.html_print_table($tabletags_without, true).'</fieldset>';
} else {
$data = '<fieldset><legend>'.__('Events with following tags').'</legend>'.html_print_table($tabletags_with, true).'</fieldset>';
$data .= '<fieldset><legend>'.__('Events without following tags').'</legend>'.html_print_table($tabletags_without, true).'</fieldset>';
}
$in = '<div class="filter_input large">';
$in .= $data.'</div>';
$adv_inputs[] = $in;
// Load view.
$adv_filter = join('', $adv_inputs);
$filter = join('', $inputs);
$filter .= ui_toggle(
$adv_filter,
@ -522,14 +926,55 @@ $filter .= ui_toggle(
true,
true,
'white_box white_box_opened',
'no-border'
'no-border flex-row'
);
try {
$column_names = [
__('Event'),
__('Event ID'),
__('Agent name'),
__('Timestamp'),
__('Severity'),
__('Options'),
];
$fields = [
'evento',
'id_evento',
// 'id_agente',
// 'id_usuario',
// 'id_grupo',
// 'estado',
'agent_name',
'timestamp',
// 'utimestamp',
// 'event_type',
// 'id_agentmodule',
// 'id_alert_am',
'event_type',
// 'user_comment',
// 'tags',
// 'source',
// 'id_extra',
// 'critical_instructions',
// 'warning_instructions',
// 'unknown_instructions',
// 'owner_user',
// 'ack_utimestamp',
// 'custom_data',
// 'data',
// 'module_status',
// 'similar_ids',
// 'event_rep',
// 'timestamp_rep',
// 'timestamp_rep_min',
// 'module_name',
'options',
];
ui_print_datatable(
[
'id' => 'events',
'class' => 'info_table',
'class' => 'info_table events',
'style' => 'width: 100%;',
'ajax_url' => 'operation/events/events',
'ajax_data' => ['get_events' => 1],
@ -560,38 +1005,12 @@ try {
'html' => $filter,
'inputs' => [],
],
'columns' => [
'id_evento',
'id_agente',
// 'id_usuario',
// 'id_grupo',
// 'estado',
'evento',
'agent_name',
'timestamp',
// 'utimestamp',
// 'event_type',
// 'id_agentmodule',
// 'id_alert_am',
'criticity',
'user_comment',
'tags',
// 'source',
// 'id_extra',
// 'critical_instructions',
// 'warning_instructions',
// 'unknown_instructions',
// 'owner_user',
// 'ack_utimestamp',
// 'custom_data',
// 'data',
// 'module_status',
// 'similar_ids',
// 'event_rep',
// 'timestamp_rep',
// 'timestamp_rep_min',
// 'module_name',
'order' => [
'field' => 'timestamp',
'direction' => 'desc',
],
'column_names' => $column_names,
'columns' => $fields,
'ajax_postprocess' => '
function (item) {
item.id_evento = "#"+item.id_evento;
@ -632,10 +1051,78 @@ try {
text = "WARNING";
color = "'.COL_WARNING.'";
break;
}
item.criticity = \'<div class="criticity" style="background: \';
item.criticity += color + \'">\' + text + "</div>";
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>\';
evn = \'<div class="event flex-row h100p nowrap">\';
evn += \'<div>\'+item.evento+\'</div>\';
evn += output;
evn += \'</div>\'
item.evento = evn;
// Event type.
switch (item.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.'":
$tex = "'.__('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;
}
item.event_type = \'<div class="criticity" style="background: \';
item.event_type += color + \'">\' + text + "</div>";
console.log(item);
if (item.id_agente > 0) {
item.agent_name = \'<a href="'.ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=').'\'+item.id_agente+\'">\' + item.agent_name + \'</a>\';
}
item.options = \'<a href="#">button</a>\';
}',
]
);
@ -645,3 +1132,34 @@ try {
// Close viewer.
enterprise_hook('close_meta_frame');
// Datepicker requirements.
ui_require_css_file('datepicker');
ui_include_time_picker();
ui_require_jquery_file(
'ui.datepicker-'.get_user_language(),
'include/javascript/i18n/'
);
?>
<script type="text/javascript">
function datetime_picker_callback() {
$("#text-time_from, #text-time_to").timepicker({
showSecond: true,
timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
timeOnlyTitle: '<?php echo __('Choose time'); ?>',
timeText: '<?php echo __('Time'); ?>',
hourText: '<?php echo __('Hour'); ?>',
minuteText: '<?php echo __('Minute'); ?>',
secondText: '<?php echo __('Second'); ?>',
currentText: '<?php echo __('Now'); ?>',
closeText: '<?php echo __('Close'); ?>'});
$("#text-date_from, #text-date_to").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
};
datetime_picker_callback();
</script>