Merge branch 'ent-12137-propuesta-de-refactoring-visual-de-vista-ppal-de-agente' into 'develop'

Ent 12137 propuesta de refactoring visual de vista ppal de agente

See merge request artica/pandorafms!6520
This commit is contained in:
Rafael Ameijeiras 2023-11-29 14:26:53 +00:00
commit 60d9fffe22
5 changed files with 215 additions and 100 deletions

View File

@ -4752,7 +4752,7 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
$secondary_groups = enterprise_hook('agents_get_secondary_groups', [$id_agente]); $secondary_groups = enterprise_hook('agents_get_secondary_groups', [$id_agente]);
$secondaryLinks = []; $secondaryLinks = [];
if (empty($secondary_groups['for_select']) === true) { if (empty($secondary_groups['for_select']) === true) {
$secondaryLinks[] = '<em>'.__('N/A').'</em>'; $secondaryLinks = [];
} else { } else {
foreach ($secondary_groups['for_select'] as $id => $name) { foreach ($secondary_groups['for_select'] as $id => $name) {
$secondaryLinks[] = html_print_anchor( $secondaryLinks[] = html_print_anchor(
@ -4811,22 +4811,22 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
'content' => groups_get_name($agent['id_grupo']), 'content' => groups_get_name($agent['id_grupo']),
], ],
true true
); ).' '.ui_print_group_icon($agent['id_grupo'], true, '', 'margin-left: 2%;', true, false, false, '', true);
$table_contact->data[] = $data; $table_contact->data[] = $data;
// Secondary groups. // Secondary groups.
$data = []; $data = [];
$data[0] = '<b>'.__('Secondary groups').'</b>'; if (!empty($secondaryLinks) === true) {
$data[1] = implode(', ', $secondaryLinks); $data[0] = '<b>'.__('Secondary groups').'</b>';
$table_contact->data[] = $data; $data[1] = implode(', ', $secondaryLinks);
$table_contact->data[] = $data;
}
// Parent agent line. // Parent agent line.
if (enterprise_installed() === true) { if (enterprise_installed() === true) {
$data = []; if ((int) $agent['id_parent'] !== 0) {
$data[0] = '<b>'.__('Parent').'</b>'; $data = [];
if ((int) $agent['id_parent'] === 0) { $data[0] = '<b>'.__('Parent').'</b>';
$data[1] = '<em>'.__('N/A').'</em>';
} else {
$data[1] = html_print_anchor( $data[1] = html_print_anchor(
[ [
'href' => 'index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$agent['id_parent'], 'href' => 'index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$agent['id_parent'],
@ -4834,9 +4834,9 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
], ],
true true
); );
}
$table_contact->data[] = $data; $table_contact->data[] = $data;
}
} }
// Last status change line. // Last status change line.
@ -4845,6 +4845,44 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
$data[1] = $time_elapsed; $data[1] = $time_elapsed;
$table_contact->data[] = $data; $table_contact->data[] = $data;
$has_remote_conf = enterprise_hook(
'config_agents_has_remote_configuration',
[$agent['id_agente']]
);
if ((bool) $has_remote_conf) {
$data = [];
$data[0] = __('Remote configuration');
$data[1] = '<spam style="position: relative;top: -10%; margin-right: 10px;">'.__('Enabled').'</spam>';
$data[1] .= html_print_menu_button(
[
'href' => ui_get_full_url('index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=remote_configuration&id_agente='.$agent['id_agente'].'&disk_conf=1'),
'image' => 'images/remote-configuration@svg.svg',
'title' => __('Edit remote config'),
],
true
);
$satellite_server = (int) db_get_value_filter(
'satellite_server',
'tagente',
['id_agente' => $id_agente]
);
if (empty($satellite_server) === false) {
$satellite_name = db_get_value_filter(
'name',
'tserver',
['id_server' => $satellite_server]
);
$data[0] = __('Satellite server');
$data[1] = $satellite_name;
}
$table_contact->data[] = $data;
}
if (enterprise_installed() === true) { if (enterprise_installed() === true) {
// SecurityMon line. // SecurityMon line.
$id_module_group = db_get_value('id_mg', 'tmodule_group', 'name', 'Security'); $id_module_group = db_get_value('id_mg', 'tmodule_group', 'name', 'Security');
@ -4887,6 +4925,43 @@ function get_resume_agent_concat($id_agente, $all_groups, $agent)
} }
} }
// Optional data
// Position Information.
if ((bool) $config['activate_gis'] === true) {
$data = [];
$dataPositionAgent = gis_get_data_last_position_agent(
$agent['id_agente']
);
if (is_array($dataPositionAgent) === true && $dataPositionAgent['stored_longitude'] !== '' && $dataPositionAgent['stored_latitude'] !== '') {
$data[0] = __('Position (Long, Lat)');
$dataOptionalOutput = html_print_anchor(
[
'href' => 'index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;tab=gis&amp;id_agente='.$id_agente,
'content' => $dataPositionAgent['stored_longitude'].', '.$dataPositionAgent['stored_latitude'],
],
true
);
if (empty($dataPositionAgent['description']) === false) {
$dataOptionalOutput .= ' ('.$dataPositionAgent['description'].')';
}
$data[1] = $dataOptionalOutput;
}
$table_contact->data[] = $data;
}
// Timezone Offset.
if ((int) $agent['timezone_offset'] !== 0) {
$data = [];
$data[0] = __('Timezone Offset');
$data[1] = $agent['timezone_offset'];
$table_contact->data[] = $data;
}
$agent_contact = html_print_div( $agent_contact = html_print_div(
[ [
'class' => 'agent_details_header', 'class' => 'agent_details_header',

View File

@ -13698,38 +13698,47 @@ function reporting_tiny_stats(
} }
if ($modern === true) { if ($modern === true) {
$out .= '<div id="bullets_modules">';
if (isset($fired_count) && $fired_count > 0) { if (isset($fired_count) && $fired_count > 0) {
$out .= '<div class="bullets_modules">';
$out .= '<div><div id="fired_count_'.$uniq_id.'" class="forced_title bullet_modules orange_background"></div>'; $out .= '<div><div id="fired_count_'.$uniq_id.'" class="forced_title bullet_modules orange_background"></div>';
$out .= '<span class="font_12pt">'.$fired_count.'</span></div>'; $out .= '<span class="font_12pt">'.$fired_count.'</span></div>';
$out .= '</div>';
} }
if (isset($critical_count) && $critical_count > 0) { if (isset($critical_count) && $critical_count > 0) {
$out .= '<div class="bullets_modules">';
$out .= '<div><div id="critical_count_'.$uniq_id.'" class="forced_title bullet_modules red_background"></div>'; $out .= '<div><div id="critical_count_'.$uniq_id.'" class="forced_title bullet_modules red_background"></div>';
$out .= '<span class="font_12pt">'.$critical_count.'</span></div>'; $out .= '<span class="font_12pt">'.$critical_count.'</span></div>';
$out .= '</div>';
} }
if (isset($warning_count) && $warning_count > 0) { if (isset($warning_count) && $warning_count > 0) {
$out .= '<div class="bullets_modules">';
$out .= '<div><div id="warning_count_'.$uniq_id.'" class="forced_title bullet_modules yellow_background"></div>'; $out .= '<div><div id="warning_count_'.$uniq_id.'" class="forced_title bullet_modules yellow_background"></div>';
$out .= '<span class="font_12pt">'.$warning_count.'</span></div>'; $out .= '<span class="font_12pt">'.$warning_count.'</span></div>';
$out .= '</div>';
} }
if (isset($unknown_count) && $unknown_count > 0) { if (isset($unknown_count) && $unknown_count > 0) {
$out .= '<div class="bullets_modules">';
$out .= '<div><div id="unknown_count_'.$uniq_id.'" class="forced_title bullet_modules grey_background"></div>'; $out .= '<div><div id="unknown_count_'.$uniq_id.'" class="forced_title bullet_modules grey_background"></div>';
$out .= '<span class="font_12pt">'.$unknown_count.'</span></div>'; $out .= '<span class="font_12pt">'.$unknown_count.'</span></div>';
$out .= '</div>';
} }
if (isset($not_init_count) && $not_init_count > 0) { if (isset($not_init_count) && $not_init_count > 0) {
$out .= '<div class="bullets_modules">';
$out .= '<div><div id="not_init_count_'.$uniq_id.'" class="forced_title bullet_modules blue_background"></div>'; $out .= '<div><div id="not_init_count_'.$uniq_id.'" class="forced_title bullet_modules blue_background"></div>';
$out .= '<span class="font_12pt">'.$not_init_count.'</span></div>'; $out .= '<span class="font_12pt">'.$not_init_count.'</span></div>';
$out .= '</div>';
} }
if (isset($normal_count) && $normal_count > 0) { if (isset($normal_count) && $normal_count > 0) {
$out .= '<div class="bullets_modules">';
$out .= '<div><div id="normal_count_'.$uniq_id.'" class="forced_title bullet_modules green_background"></div>'; $out .= '<div><div id="normal_count_'.$uniq_id.'" class="forced_title bullet_modules green_background"></div>';
$out .= '<span class="font_12pt">'.$normal_count.'</span></div>'; $out .= '<span class="font_12pt">'.$normal_count.'</span></div>';
$out .= '</div>';
} }
$out .= '</div>';
} else { } else {
// Classic ones. // Classic ones.
$out .= '<b><span id="total_count_'.$uniq_id.'" class="forced_title" >'.$total_count.'</span>'; $out .= '<b><span id="total_count_'.$uniq_id.'" class="forced_title" >'.$total_count.'</span>';

View File

@ -6,6 +6,10 @@ div#bullets_modules span {
font-weight: 700; font-weight: 700;
} }
div.bullets_modules span {
font-weight: 700;
}
div.agent_details_agent_caption { div.agent_details_agent_caption {
flex: 1; flex: 1;
} }

View File

@ -6043,18 +6043,18 @@ div.switch_radio_button label:last-of-type {
margin-top: -2px; margin-top: -2px;
} }
/*
div#bullets_modules {
display: flex;
margin-left: 2em;
}
*/
div#bullets_modules div { div#bullets_modules div {
display: flex; display: flex;
align-items: center; align-items: center;
margin: 0 5px; margin: 0 5px;
} }
div.bullets_modules div {
display: flex;
align-items: center;
margin: 0 10px;
}
.orange_background { .orange_background {
background: #ffa631; background: #ffa631;
} }
@ -6225,7 +6225,7 @@ div#status_pie {
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
padding: 20px; padding: 20px;
padding-bottom: 0; padding-bottom: 1%;
} }
.agent_details_content_cluster { .agent_details_content_cluster {
@ -6315,6 +6315,7 @@ div#status_pie {
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
width: 100%;
} }
.agent_details_agent_data { .agent_details_agent_data {
@ -6344,23 +6345,45 @@ div#status_pie {
justify-content: flex-start; justify-content: flex-start;
} }
.agent_details_bullets .bullets_modules {
display: flex;
justify-content: flex-start;
}
.agent_details_bullets_cluster #bullets_modules { .agent_details_bullets_cluster #bullets_modules {
display: flex; display: flex;
justify-content: flex-start; justify-content: flex-start;
flex-direction: column; flex-direction: column;
} }
.agent_details_bullets_cluster .bullets_modules {
display: flex;
justify-content: flex-start;
flex-direction: column;
}
.agent_details_bullets_cluster #bullets_modules > div { .agent_details_bullets_cluster #bullets_modules > div {
padding: 0px; padding: 0px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.agent_details_bullets_cluster .bullets_modules > div {
padding: 0px;
margin-bottom: 10px;
}
.agent_details_bullets #bullets_modules > div { .agent_details_bullets #bullets_modules > div {
display: flex; display: flex;
align-items: center; align-items: center;
padding-bottom: 20px; padding-bottom: 20px;
} }
.agent_details_bullets .bullets_modules > div {
display: flex;
align-items: center;
padding-bottom: 20px;
}
#agent_contact_main tr td img { #agent_contact_main tr td img {
max-width: 100%; max-width: 100%;
} }
@ -6412,6 +6435,11 @@ div#status_pie {
float: right; float: right;
} }
.white_table_graph_header div.bullets_modules {
display: flex;
float: right;
}
.white_table_graph_header img, .white_table_graph_header img,
.white_table_graph_header span { .white_table_graph_header span {
vertical-align: middle; vertical-align: middle;

View File

@ -102,17 +102,37 @@ $agentCountModules = html_print_div(
$table_status = new stdClass(); $table_status = new stdClass();
$table_status->id = 'agent_status_main'; $table_status->id = 'agent_status_main';
$table_status->width = '100%'; $table_status->width = '90%';
$table_status->height = 'auto';
$table_status->cellspacing = 0; $table_status->cellspacing = 0;
$table_status->cellpadding = 0; $table_status->cellpadding = 0;
$table_status->class = 'floating_form'; $table_status->class = 'floating_form';
$table_status->style[0] = 'height: 32px; width: 30%; padding-right: 5px; text-align: end; vertical-align: top'; $table_status->style[0] = 'height: 28px; width: 30%; padding-right: 5px; text-align: end; vertical-align: top';
$table_status->style[1] = 'height: 32px; width: 70%; padding-left: 5px; font-weight: lighter; vertical-align: top'; $table_status->style[1] = 'height: 28px; width: 70%; padding-left: 5px; font-weight: lighter; vertical-align: top';
$table_status->data['agent_os'][0] = __('OS');
$agentOS = []; $os_agent_text = '';
$agentOS[] = html_print_div([ 'content' => (empty($agent['os_version']) === true) ? get_os_name((int) $agent['id_os']) : $agent['os_version']], true); $os_name = get_os_name((int) $agent['id_os']);
$agentOS[] = html_print_div([ 'style' => 'width: 16px;padding-left: 5px', 'content' => ui_print_os_icon($agent['id_os'], false, true, true, false, false, false, ['width' => '16px'])], true); if (empty($agent['os_version']) !== true) {
$table_status->data['agent_os'][1] = html_print_div(['class' => 'agent_details_agent_data', 'content' => implode('', $agentOS)], true); $agent['os_version'] = io_safe_output($agent['os_version']);
if (strpos($agent['os_version'], '(') !== false) {
$os_name = preg_split('/[0-9]|[\(]/', $agent['os_version'])[0];
$os_version = explode($os_name, explode('(', $agent['os_version'])[0])[1];
$os_version_name = preg_split('/[\(]|[\)]/', $agent['os_version']);
$os_agent_text = $os_version.' ('.$os_version_name[1].')';
} else {
$os_name = preg_split('/[0-9]/', $agent['os_version'])[0];
$os_version = explode($os_name, explode('(', $agent['os_version'])[0])[1];
$os_agent_text = $os_version;
}
}
$table_status->data['agent_os'][0] = html_print_div([ 'style' => 'width: 16px; position: relative; left: 75%', 'content' => ui_print_os_icon($agent['id_os'], false, true, true, false, false, false, ['width' => '16px'])], true);
$table_status->data['agent_os'][1] = $os_name;
if (empty($agent['os_version']) !== true) {
$table_status->data['agent_os_version'][0] = __('OS Version');
$table_status->data['agent_os_version'][1] = $os_agent_text;
}
$addresses = agents_get_addresses($id_agente); $addresses = agents_get_addresses($id_agente);
$address = agents_get_address($id_agente); $address = agents_get_address($id_agente);
@ -124,43 +144,48 @@ foreach ($addresses as $k => $add) {
} }
if (empty($address) === false) { if (empty($address) === false) {
$address_text = '<span class="bolder" >'.$address.'</span>';
if (!empty($addresses) === true) {
foreach ($addresses as $sec_address) {
$address_text .= '<br/><span class="italic">'.$sec_address.'</span>';
}
}
$table_status->data['ip_address'][0] = __('IP address'); $table_status->data['ip_address'][0] = __('IP address');
$table_status->data['ip_address'][1] = (empty($address) === true) ? '<em>'.__('N/A').'</em>' : $address; $table_status->data['ip_address'][1] = (empty($address) === true) ? '<em>'.__('N/A').'</em>' : $address_text;
} }
$table_status->data['agent_version'][0] = __('Agent Version'); $table_status->data['agent_version'][0] = __('Agent Version');
$table_status->data['agent_version'][1] = (empty($agent['agent_version']) === true) ? '<i>'.__('N/A').'</i>' : $agent['agent_version']; $table_status->data['agent_version'][1] = (empty($agent['agent_version']) === true) ? '<i>'.__('N/A').'</i>' : $agent['agent_version'];
$table_status->data['description'][0] = __('Description'); $table_status->data['description'][0] = __('Description');
$table_status->data['description'][1] = (empty($agent['comentarios']) === true) ? '<em>'.__('N/A').'</em>' : $agent['comentarios']; $table_status->data['description'][1] = (empty($agent['comentarios']) === true) ? '<em>'.__('N/A').'</em>' : ui_print_truncate_text($agent['comentarios'], 'description', true);
$has_remote_conf = enterprise_hook( $agentEventsHeader = html_print_div(
'config_agents_has_remote_configuration', [
[$agent['id_agente']] 'class' => 'agent_details_header',
'content' => '<span class="subsection_header_title">'.__('Events (Last 24h)').'</span>',
],
true
); );
if ((bool) $has_remote_conf) { $agentEventsGraph = html_print_div(
$table_status->data['remote_config'][0] = __('Remote configuration'); [
$table_status->data['remote_config'][1] = __('Enabled'); 'class' => 'white-table-graph-content',
'content' => graph_graphic_agentevents(
$satellite_server = (int) db_get_value_filter( $id_agente,
'satellite_server', 95,
'tagente', 50,
['id_agente' => $id_agente] SECONDS_1DAY,
); '',
true,
if (empty($satellite_server) === false) { true,
$satellite_name = db_get_value_filter( 500
'name', ),
'tserver', 'style' => 'margin-top: -25px',
['id_server' => $satellite_server] ],
); true
);
$table_status->data['remote_config'][0] = __('Satellite server');
$table_status->data['remote_config'][1] = $satellite_name;
}
}
$table_agent = $agentStatusHeader.' $table_agent = $agentStatusHeader.'
<div class="agent_details_content"> <div class="agent_details_content">
@ -170,6 +195,9 @@ $table_agent = $agentStatusHeader.'
<div class="agent_details_info"> <div class="agent_details_info">
'.$alive_animation.html_print_table($table_status, true).' '.$alive_animation.html_print_table($table_status, true).'
</div> </div>
</div>
<div class="agent_details_graph">
'.$agentEventsHeader.$agentEventsGraph.'
</div>'; </div>';
@ -189,11 +217,12 @@ $data_opcional->class = 'floating_form';
// Gis and url address. // Gis and url address.
$agentAdditionalContent = ''; $agentAdditionalContent = '';
// Position Information. // Position Information.
if ((bool) $config['activate_gis'] === true) { /*
if ((bool) $config['activate_gis'] === true) {
$dataPositionAgent = gis_get_data_last_position_agent( $dataPositionAgent = gis_get_data_last_position_agent(
$agent['id_agente'] $agent['id_agente']
); );
if (is_array($dataPositionAgent) === true && $dataPositionAgent['stored_longitude'] !== '' && $dataPositionAgent['stored_longitude'] !== '') { if (is_array($dataPositionAgent) === true && $dataPositionAgent['stored_longitude'] !== '' && $dataPositionAgent['stored_latitude'] !== '') {
$data_opcional->data['agent_position'][0] = __('Position (Long, Lat)'); $data_opcional->data['agent_position'][0] = __('Position (Long, Lat)');
$dataOptionalOutput = html_print_anchor( $dataOptionalOutput = html_print_anchor(
@ -210,10 +239,11 @@ if ((bool) $config['activate_gis'] === true) {
$data_opcional->data['agent_position'][1] = $dataOptionalOutput; $data_opcional->data['agent_position'][1] = $dataOptionalOutput;
} }
} }*/
// If the url description is set. // If the url description is set.
if (empty($agent['url_address']) === false) { /*
if (empty($agent['url_address']) === false) {
$data_opcional->data['url_address'][0] = __('Url address'); $data_opcional->data['url_address'][0] = __('Url address');
$data_opcional->data['url_address'][1] = html_print_anchor( $data_opcional->data['url_address'][1] = html_print_anchor(
[ [
@ -222,11 +252,12 @@ if (empty($agent['url_address']) === false) {
], ],
true true
); );
} }*/
// Other IP address and timezone offset. // Other IP address and timezone offset.
if (empty($addresses) === false) { /*
if (empty($addresses) === false) {
$data_opcional->data['other_ip_address'][0] = __('Other IP addresses'); $data_opcional->data['other_ip_address'][0] = __('Other IP addresses');
$data_opcional->data['other_ip_address'][1] = html_print_div( $data_opcional->data['other_ip_address'][1] = html_print_div(
[ [
@ -235,13 +266,14 @@ if (empty($addresses) === false) {
], ],
true true
); );
} }
*/
// Timezone Offset. // Timezone Offset.
if ((int) $agent['timezone_offset'] !== 0) { /*
if ((int) $agent['timezone_offset'] !== 0) {
$data_opcional->data['timezone_offset'][0] = __('Timezone Offset'); $data_opcional->data['timezone_offset'][0] = __('Timezone Offset');
$data_opcional->data['timezone_offset'][1] = $agent['timezone_offset']; $data_opcional->data['timezone_offset'][1] = $agent['timezone_offset'];
} }*/
// Custom fields. // Custom fields.
$fields = db_get_all_rows_filter( $fields = db_get_all_rows_filter(
@ -485,39 +517,6 @@ $agentContact = html_print_div(
true true
); );
$agentEventsHeader = html_print_div(
[
'class' => 'agent_details_header',
'content' => '<span class="subsection_header_title">'.__('Events (Last 24h)').'</span>',
],
true
);
$agentEventsGraph = html_print_div(
[
'class' => 'white-table-graph-content',
'content' => graph_graphic_agentevents(
$id_agente,
95,
70,
SECONDS_1DAY,
'',
true,
true,
500
),
],
true
);
$agentEvents = html_print_div(
[
'class' => 'box-flat agent_details_col w50p',
'content' => $agentEventsHeader.$agentEventsGraph,
],
true
);
/* /*
* EVENTS TABLE END. * EVENTS TABLE END.
*/ */