#8302 Added show_empty_groups

This commit is contained in:
Daniel Maya 2022-06-08 15:17:03 +02:00
parent a40efcfee5
commit 3e15ed2726
3 changed files with 29 additions and 5 deletions

View File

@ -1253,6 +1253,15 @@ $table_other->data[$row][1] = html_print_checkbox_switch(
); );
$row++; $row++;
$table_other->data[$row][0] = __('Show empty groups in group view');
$table_other->data[$row][1] = html_print_checkbox_switch(
'show_empty_groups',
1,
$config['show_empty_groups'],
true
);
$row++;
$table_other->data[$row][0] = __('Date format string'); $table_other->data[$row][0] = __('Date format string');
$table_other->data[$row][1] = '<em>'.__('Example').'</em> '.date($config['date_format']); $table_other->data[$row][1] = '<em>'.__('Example').'</em> '.date($config['date_format']);
$table_other->data[$row][1] .= html_print_input_text('date_format', $config['date_format'], '', 30, 100, true); $table_other->data[$row][1] .= html_print_input_text('date_format', $config['date_format'], '', 30, 100, true);

View File

@ -1263,6 +1263,10 @@ function config_update_config()
$error_update[] = __('Show the group name instead the group icon.'); $error_update[] = __('Show the group name instead the group icon.');
} }
if (config_update_value('show_empty_groups', get_parameter('show_empty_groups'), true) === false) {
$error_update[] = __('Show empty groups in group view.');
}
if (config_update_value('custom_graph_width', (int) get_parameter('custom_graph_width', 1), true) === false) { if (config_update_value('custom_graph_width', (int) get_parameter('custom_graph_width', 1), true) === false) {
$error_update[] = __('Default line thickness for the Custom Graph.'); $error_update[] = __('Default line thickness for the Custom Graph.');
} }
@ -3146,6 +3150,10 @@ function config_process_config()
config_update_value('show_group_name', 0); config_update_value('show_group_name', 0);
} }
if (!isset($config['show_empty_groups'])) {
config_update_value('show_empty_groups', 1);
}
if (!isset($config['custom_graph_width'])) { if (!isset($config['custom_graph_width'])) {
config_update_value('custom_graph_width', 1); config_update_value('custom_graph_width', 1);
} }

View File

@ -167,7 +167,7 @@ if ($total > 0) {
} }
if ($total_agentes > 0) { if ($total_agentes > 0) {
// Agents // Agents.
$total_agent_unknown = format_numeric((($agents_unknown * 100) / $total_agentes), 2); $total_agent_unknown = format_numeric((($agents_unknown * 100) / $total_agentes), 2);
$total_agent_critical = format_numeric((($agents_critical * 100) / $total_agentes), 2); $total_agent_critical = format_numeric((($agents_critical * 100) / $total_agentes), 2);
$total_agent_warning = format_numeric((($agents_warning * 100) / $total_agentes), 2); $total_agent_warning = format_numeric((($agents_warning * 100) / $total_agentes), 2);
@ -209,7 +209,7 @@ if ($count == 1) {
ui_pagination($count); ui_pagination($count);
if (!empty($result_groups)) { if (empty($result_groups) === false) {
echo '<table cellpadding="0" cellspacing="0" class="databox data mrgn_top_10px" border="0" width="100%">'; echo '<table cellpadding="0" cellspacing="0" class="databox data mrgn_top_10px" border="0" width="100%">';
echo '<tr>'; echo '<tr>';
echo '<th colspan=2 ></th>'; echo '<th colspan=2 ></th>';
@ -235,10 +235,17 @@ if (!empty($result_groups)) {
echo '</tr>'; echo '</tr>';
foreach ($result_groups as $data) { foreach ($result_groups as $data) {
if ((bool) $config['show_empty_groups'] === false
&& $data['_total_agents_'] === 0
&& $data['_monitor_checks_'] === 0
) {
continue;
}
$groups_id = $data['_id_']; $groups_id = $data['_id_'];
// Calculate entire row color // Calculate entire row color.
if ($groups_id != 0) { if ($groups_id !== '0') {
if ($data['_monitors_alerts_fired_'] > 0) { if ($data['_monitors_alerts_fired_'] > 0) {
$color_class = 'group_view_alrm'; $color_class = 'group_view_alrm';
$status_image = ui_print_status_image('agent_alertsfired_ball.png', '', true); $status_image = ui_print_status_image('agent_alertsfired_ball.png', '', true);
@ -265,7 +272,7 @@ if (!empty($result_groups)) {
echo "<tr class='height_35px'>"; echo "<tr class='height_35px'>";
// Force // Force.
echo "<td class='group_view_data center vertical_middle'>"; echo "<td class='group_view_data center vertical_middle'>";
if (!isset($data['_is_tag_']) && check_acl($config['id_user'], $data['_id_'], 'AW')) { if (!isset($data['_is_tag_']) && check_acl($config['id_user'], $data['_id_'], 'AW')) {
echo '<a href="index.php?sec=estado&sec2=operation/agentes/group_view&update_netgroup='.$data['_id_'].'">'.html_print_image( echo '<a href="index.php?sec=estado&sec2=operation/agentes/group_view&update_netgroup='.$data['_id_'].'">'.html_print_image(