From 420adb4630d7c4c0666f888537b2d984ce83b3f4 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Mon, 12 Nov 2018 13:02:37 +0100 Subject: [PATCH 1/2] implemented search filters for module group and agent group in module groups view --- pandora_console/extensions/module_groups.php | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index b7eca3b3e9..d57ab20989 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -61,6 +61,13 @@ function mainModuleGroups() { $info = groupview_plain_groups($info); $counter = count($info); $offset = get_parameter('offset', 0); + $agent_group_search = get_parameter('agent_group_search', ''); + $module_group_search = get_parameter('module_group_search', ''); + + $info = array_filter($info, function($v, $k) use ($agent_group_search) { + return preg_match("/$agent_group_search/i", $v['name']); + }, ARRAY_FILTER_USE_BOTH); + $groups_view = $is_not_paginated ? $info : array_slice($info, $offset, $config['block_size']); @@ -90,6 +97,12 @@ function mainModuleGroups() { $array_module_group[$value['id_mg']] = $value['name']; } $array_module_group[0] = 'Nothing'; + + + $array_module_group = array_filter($array_module_group, function($v, $k) use ($module_group_search) { + return preg_match("/$module_group_search/i", $v); + }, ARRAY_FILTER_USE_BOTH); + foreach ($agents_counters as $key => $value) { $array_for_defect[$key]['gm'] = $array_module_group; $array_for_defect[$key]['data']['name'] = $value['name']; @@ -167,6 +180,25 @@ $sql = ui_print_page_header (__("Combined table of agent group and module group"), "images/module_group.png", false, "", false, ''); + echo " + "; + echo ""; + + echo "
"; + echo __('Search by agent group') . ' '; + html_print_input_text ("agent_group_search", $agent_group_search); + + echo ""; + echo __('Search by module group') . ' '; + html_print_input_text ("module_group_search", $module_group_search); + + echo ""; + echo ""; + echo ""; + echo ""; + echo "
"; + if(count($array_for_defect) > 0){ $table = new StdClass(); $table->style[0] = 'color: #ffffff; background-color: #373737; font-weight: bolder; padding-right: 10px; min-width: 230px;'; From 5c0f85a4bbbf5ab8233ddb02bc9406e5245a47b2 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Thu, 20 Dec 2018 15:37:00 +0100 Subject: [PATCH 2/2] fix bug when searching non existing agent group in module groups view --- pandora_console/extensions/module_groups.php | 23 +++++++++++--------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index d57ab20989..18ba051b60 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -68,17 +68,20 @@ function mainModuleGroups() { return preg_match("/$agent_group_search/i", $v['name']); }, ARRAY_FILTER_USE_BOTH); - $groups_view = $is_not_paginated - ? $info - : array_slice($info, $offset, $config['block_size']); - $agents_counters = array_reduce($groups_view, function($carry, $item){ - $carry[$item['id']] = $item; - return $carry; - }, array()); + if (!empty($info)) { + $groups_view = $is_not_paginated + ? $info + : array_slice($info, $offset, $config['block_size']); + $agents_counters = array_reduce($groups_view, function($carry, $item){ + $carry[$item['id']] = $item; + return $carry; + }, array()); - $ids_array = array_keys($agents_counters); + $ids_array = array_keys($agents_counters); - $ids_group = implode(',', $ids_array); + $ids_group = implode(',', $ids_array); + } else + $ids_group = -1; $condition_critical = modules_get_state_condition(AGENT_MODULE_STATUS_CRITICAL_ALERT); $condition_warning = modules_get_state_condition(AGENT_MODULE_STATUS_WARNING_ALERT); @@ -199,7 +202,7 @@ $sql = echo ""; echo ""; - if(count($array_for_defect) > 0){ + if(true){ $table = new StdClass(); $table->style[0] = 'color: #ffffff; background-color: #373737; font-weight: bolder; padding-right: 10px; min-width: 230px;'; $table->width = '100%';