Event list agent view

This commit is contained in:
fbsanchez 2019-05-28 18:03:01 +02:00
parent 99e485e96e
commit 70469c4909
8 changed files with 194 additions and 34 deletions

View File

@ -959,6 +959,8 @@ function events_print_event_table(
) { ) {
global $config; global $config;
ui_require_css_file('events');
if ($agent_id == 0) { if ($agent_id == 0) {
$agent_condition = ''; $agent_condition = '';
} else { } else {
@ -1011,7 +1013,7 @@ function events_print_event_table(
$table->data = []; $table->data = [];
$table->align = []; $table->align = [];
$table->style[0] = 'width:25px;'; $table->style[0] = 'width:25px;';
$table->style[1] = 'width:25px;'; $table->style[1] = 'width:25px;padding: 0;';
$table->style[2] = 'width:25px;'; $table->style[2] = 'width:25px;';
if ($agent_id == 0) { if ($agent_id == 0) {
$table->style[3] = 'word-break: break-all;'; $table->style[3] = 'word-break: break-all;';
@ -1041,6 +1043,11 @@ function events_print_event_table(
$table->align[5] = 'left'; $table->align[5] = 'left';
$table->size[5] = '15%'; $table->size[5] = '15%';
$table->head[6] = __('Status');
$table->headclass[6] = 'datos3 f9';
$table->align[6] = 'left';
$table->size[6] = '13%';
$all_groups = []; $all_groups = [];
if ($agent_id != 0) { if ($agent_id != 0) {
$all_groups = agents_get_all_groups_agent($agent_id); $all_groups = agents_get_all_groups_agent($agent_id);
@ -1109,16 +1116,7 @@ function events_print_event_table(
break; break;
} }
$data[1] = html_print_image( $data[1] = ui_print_event_priority($event['criticity'], true, true);
$img,
true,
[
'class' => 'image_status',
'width' => 12,
'height' => 12,
'title' => get_priority_name($event['criticity']),
]
);
// Event type. // Event type.
$data[2] = events_print_type_img($event['event_type'], true); $data[2] = events_print_type_img($event['event_type'], true);
@ -1135,9 +1133,7 @@ function events_print_event_table(
if ($event['id_agente'] > 0) { if ($event['id_agente'] > 0) {
// Agent name. // Agent name.
// Get class name, for the link color, etc. // Get class name, for the link color, etc.
$myclass = get_priority_class($event['criticity']); $data[4] = "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$event['id_agente']."'>".agents_get_alias($event['id_agente']).'</A>';
$data[4] = "<a class='".$myclass."' href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$event['id_agente']."'>".agents_get_alias($event['id_agente']).'</A>';
// For System or SNMP generated alerts. // For System or SNMP generated alerts.
} else if ($event['event_type'] == 'system') { } else if ($event['event_type'] == 'system') {
$data[4] = __('System'); $data[4] = __('System');
@ -1149,12 +1145,17 @@ function events_print_event_table(
// Timestamp. // Timestamp.
$data[5] = ui_print_timestamp($event['timestamp'], true, ['style' => 'font-size: 7.5pt; letter-spacing: 0.3pt;']); $data[5] = ui_print_timestamp($event['timestamp'], true, ['style' => 'font-size: 7.5pt; letter-spacing: 0.3pt;']);
// Status.
$data[6] = ui_print_event_priority($event['criticity'], true);
/*
$class = get_priority_class($event['criticity']); $class = get_priority_class($event['criticity']);
$cell_classes[3] = $class; $cell_classes[3] = $class;
$cell_classes[4] = $class; $cell_classes[4] = $class;
$cell_classes[5] = $class; $cell_classes[5] = $class;
array_push($table->cellclass, $cell_classes); array_push($table->cellclass, $cell_classes);
*/
/* /*
Commented out (old). Commented out (old).

View File

@ -2748,6 +2748,80 @@ function ui_progress(
} }
/**
* Returns a div wich represents the priority received.
*
* Requires ui_require_css_file('events');.
*
* @param integer $priority priority level.
* @param boolean $return Or print.
* @param boolean $min Show mini div.
*
* @return string HTML.
*/
function ui_print_event_priority(
$priority,
$return=false,
$mini=false
) {
global $config;
$output = '';
switch ($priority) {
case EVENT_CRIT_MAINTENANCE:
$color = COL_MAINTENANCE;
$criticity = __('MAINTENANCE');
break;
case EVENT_CRIT_INFORMATIONAL:
$color = COL_INFORMATIONAL;
$criticity = __('INFORMATIONAL');
break;
case EVENT_CRIT_NORMAL:
$color = COL_NORMAL;
$criticity = __('NORMAL');
break;
case EVENT_CRIT_WARNING:
$color = COL_WARNING;
$criticity = __('WARNING');
break;
case EVENT_CRIT_CRITICAL:
$color = COL_CRITICAL;
$criticity = __('CRITICAL');
break;
case EVENT_CRIT_MINOR:
$color = COL_MINOR;
$criticity = __('MINOR');
break;
case EVENT_CRIT_MAJOR:
$color = COL_MAJOR;
$criticity = __('MAJOR');
break;
default:
$color = COL_UNKNOWN;
$criticity = __('UNKNOWN');
break;
}
if ($mini === false) {
$output = '<div class="criticity" style="background: '.$color.'">';
$output .= $criticity;
$output .= '</div>';
} else {
$output = '<div class="mini-criticity" style="background: '.$color.'">';
$output .= '</div>';
}
return $output;
}
/** /**
* Print a code into a DIV and enable a toggle to show and hide it. * Print a code into a DIV and enable a toggle to show and hide it.
* *

View File

@ -0,0 +1,20 @@
div.criticity {
width: 150px;
height: 2em;
color: #fff;
text-align: center;
border-radius: 5px;
font-size: 1.4em;
padding: 0;
margin: 0;
display: table-cell;
vertical-align: middle;
}
div.mini-criticity {
width: 5px;
height: 4em;
padding: 0;
margin: 0;
display: inline-block;
}

View File

@ -453,6 +453,16 @@ select:-internal-list-box {
max-width: 100%; max-width: 100%;
} }
.no-padding {
padding: 0;
}
.no-padding-imp {
padding: 0 !important;
}
.no-margin {
margin: 0;
}
div#page { div#page {
background: #fbfbfb; background: #fbfbfb;
background-image: none; background-image: none;
@ -5985,16 +5995,38 @@ div#bullets_modules div {
.agent_details_col_left { .agent_details_col_left {
width: 35%; width: 35%;
min-width: 470px; min-width: 300px;
} }
.agent_details_col_right { .agent_details_col_right {
width: 64%; width: 64%;
min-width: 455px; min-width: 480px;
} }
@media screen and (max-width: 1600px) {
.agent_access_rate_events {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
}
.white_table_graph#table_access_rate {
flex: 1 1 auto;
min-width: 450px;
margin-right: 1%;
}
.white_table_graph#table_events {
flex: 1 1 auto;
min-width: 450px;
}
@media screen and (max-width: 1150px) {
.agent_details_col { .agent_details_col {
flex: 1 1 auto; flex: 1 1 auto;
} }
.white_table_graph#table_access_rate {
margin-right: 0;
}
} }
.buttons_agent_view { .buttons_agent_view {
@ -6083,8 +6115,6 @@ div#status_pie {
/* White tables to show graphs */ /* White tables to show graphs */
.white_table_graph { .white_table_graph {
margin-bottom: 20px; margin-bottom: 20px;
display: grid;
grid-template-rows: max-content;
} }
.white_table_graph_header { .white_table_graph_header {
@ -6121,10 +6151,13 @@ div#status_pie {
flex-wrap: wrap; flex-wrap: wrap;
} }
div.white_table_graph_content div.pagination { .white_table_graph_content div.pagination {
width: 100%; width: 100%;
padding: 0 1em; padding: 0 1em;
} }
.white_table_graph_content div.action-buttons {
padding: 10px;
}
/* White tables */ /* White tables */
.white_table, .white_table,

View File

@ -140,8 +140,10 @@ if ($idAgent != 0) {
$tab = get_parameter('tab', 'main'); $tab = get_parameter('tab', 'main');
ob_start();
if ($tab == 'main') { if ($tab == 'main') {
echo "<h4 style='padding-top:0px !important;'>".__('Full list of alerts').'</h4>'; $agent_view_page = true;
} }
} else { } else {
$agent_a = check_acl($config['id_user'], 0, 'AR'); $agent_a = check_acl($config['id_user'], 0, 'AR');
@ -610,7 +612,12 @@ foreach ($alerts['alerts_simple'] as $alert) {
} }
if (!empty($table->data)) { if (!empty($table->data)) {
echo '<form method="post" action="'.$url.'">'; $class = '';
if ($agent_view_page === true) {
$class = 'white_table_graph_content w100p no-padding-imp';
}
echo '<form class="'.$class.'" method="post" action="'.$url.'">';
ui_pagination( ui_pagination(
$countAlertsSimple, $countAlertsSimple,
@ -647,6 +654,22 @@ if (!empty($table->data)) {
ui_print_info_message(['no_close' => true, 'message' => __('No alerts found') ]); ui_print_info_message(['no_close' => true, 'message' => __('No alerts found') ]);
} }
$html_content = ob_get_clean();
if ($agent_view_page === true) {
// Create controlled toggle content.
ui_toggle(
$html_content,
__('Full list of alerts'),
'status_monitor_agent',
false
);
} else {
// Dump entire content.
echo $html_content;
}
// strict user hidden // strict user hidden
echo '<div id="strict_hidden" style="display:none;">'; echo '<div id="strict_hidden" style="display:none;">';
html_print_input_text('strict_user_hidden', $strict_user); html_print_input_text('strict_user_hidden', $strict_user);

View File

@ -817,7 +817,7 @@ echo '<div id="agent_details_first_row">
// Show both graphs, events and access rate. // Show both graphs, events and access rate.
if ($table_access_rate) { if ($table_access_rate) {
echo '<div style="display:grid; grid-template-columns: 1fr 1fr; grid-column-gap: 20px;">'.$table_access_rate.$table_events.'</div>'; echo '<div class="agent_access_rate_events">'.$table_access_rate.$table_events.'</div>';
} else { } else {
echo '<div style="width: 100%">'.$table_events.'</div>'; echo '<div style="width: 100%">'.$table_events.'</div>';
} }

View File

@ -492,11 +492,13 @@ function print_form_filter_monitors(
$form_text = ''; $form_text = '';
$table = new stdClass(); $table = new stdClass();
$table->class = 'info_table'; $table->class = 'info_table';
$table->styleTable = 'width: 100%;border-radius: 0;padding: 0;margin: 0;margin-top: -1px;'; $table->styleTable = 'border-radius: 0;padding: 0;margin: 0;margin-top: -1px;';
$table->width = '100%'; $table->width = '100%';
$table->style[0] = 'font-weight: bold;'; $table->style[0] = 'font-weight: bold;';
$table->style[2] = 'font-weight: bold;'; $table->style[2] = 'font-weight: bold;';
$table->style[4] = 'font-weight: bold;'; $table->style[4] = 'font-weight: bold;';
$table->style[6] = 'font-weight: bold;';
$table->style[6] = 'min-width: 150px;';
$table->data[0][0] = html_print_input_hidden('filter_monitors', 1, true); $table->data[0][0] = html_print_input_hidden('filter_monitors', 1, true);
$table->data[0][0] .= html_print_input_hidden('monitors_change_filter', 1, true); $table->data[0][0] .= html_print_input_hidden('monitors_change_filter', 1, true);
$table->data[0][0] .= __('Status:'); $table->data[0][0] .= __('Status:');
@ -525,7 +527,14 @@ function print_form_filter_monitors(
true true
); );
$table->data[0][3] = html_print_input_text('status_text_monitor', $status_text_monitor, '', 30, 100, true); $table->data[0][3] = html_print_input_text(
'status_text_monitor',
$status_text_monitor,
'',
'',
100,
true
);
$table->data[0][4] = __('Module group'); $table->data[0][4] = __('Module group');
$rows = db_get_all_rows_sql( $rows = db_get_all_rows_sql(
sprintf( sprintf(
@ -575,7 +584,7 @@ function print_form_filter_monitors(
'class="sub search"', 'class="sub search"',
true true
); );
$table->data[0][8] = '&nbsp;'.html_print_button( $table->data[0][8] = html_print_button(
__('Reset'), __('Reset'),
'filter', 'filter',
false, false,

View File

@ -20,9 +20,9 @@ if (!isset($id_agente)) {
} }
require_once 'include/functions_events.php'; require_once 'include/functions_events.php';
ui_require_css_file('events');
ui_toggle( ui_toggle(
"<div id='event_list'>".html_print_image('images/spinner.gif', true).'</div>', "<div class='white_table_graph_content' id='event_list'>".html_print_image('images/spinner.gif', true).'</div>',
__('Latest events for this agent'), __('Latest events for this agent'),
__('Latest events for this agent'), __('Latest events for this agent'),
false false