From 3e15ed272699b334e9af1bc4b9963d246aedaa8b Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 8 Jun 2022 15:17:03 +0200 Subject: [PATCH] #8302 Added show_empty_groups --- pandora_console/godmode/setup/setup_visuals.php | 9 +++++++++ pandora_console/include/functions_config.php | 8 ++++++++ .../operation/agentes/group_view.php | 17 ++++++++++++----- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index 9a36b3ac1c..811f8fc508 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -1253,6 +1253,15 @@ $table_other->data[$row][1] = html_print_checkbox_switch( ); $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][1] = ''.__('Example').' '.date($config['date_format']); $table_other->data[$row][1] .= html_print_input_text('date_format', $config['date_format'], '', 30, 100, true); diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 855bc67a7d..41be1f284c 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1263,6 +1263,10 @@ function config_update_config() $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) { $error_update[] = __('Default line thickness for the Custom Graph.'); } @@ -3146,6 +3150,10 @@ function config_process_config() 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'])) { config_update_value('custom_graph_width', 1); } diff --git a/pandora_console/operation/agentes/group_view.php b/pandora_console/operation/agentes/group_view.php index 9ec0782e1f..a7ab834665 100644 --- a/pandora_console/operation/agentes/group_view.php +++ b/pandora_console/operation/agentes/group_view.php @@ -167,7 +167,7 @@ if ($total > 0) { } if ($total_agentes > 0) { - // Agents + // Agents. $total_agent_unknown = format_numeric((($agents_unknown * 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); @@ -209,7 +209,7 @@ if ($count == 1) { ui_pagination($count); -if (!empty($result_groups)) { +if (empty($result_groups) === false) { echo ''; echo ''; echo ''; @@ -235,10 +235,17 @@ if (!empty($result_groups)) { echo ''; 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_']; - // Calculate entire row color - if ($groups_id != 0) { + // Calculate entire row color. + if ($groups_id !== '0') { if ($data['_monitors_alerts_fired_'] > 0) { $color_class = 'group_view_alrm'; $status_image = ui_print_status_image('agent_alertsfired_ball.png', '', true); @@ -265,7 +272,7 @@ if (!empty($result_groups)) { echo ""; - // Force + // Force. echo "
"; if (!isset($data['_is_tag_']) && check_acl($config['id_user'], $data['_id_'], 'AW')) { echo ''.html_print_image(