Merge branch 'ent-13328-color-elemento-grupos-en-vista-tactica-muestra-datos-incongruentes-por-culpa-de-la-recursion' into 'develop'

Ent 13328 color elemento grupos en vista tactica muestra datos incongruentes por culpa de la recursion

See merge request artica/pandorafms!7151
This commit is contained in:
Matias Didier 2024-04-09 15:19:47 +00:00
commit 44f41f67ba
2 changed files with 45 additions and 1 deletions

View File

@ -206,3 +206,43 @@ function groupview_get_groups_list($id_user=false, $access='AR', $is_not_paginat
'counter' => $counter,
];
}
function get_recursive_groups_heatmap($parent_group, $acl)
{
if ($parent_group['counter'] > 0) {
foreach ($parent_group['groups'] as $group_key => $group_value) {
if ((int) $group_value['_id_'] === 0) {
continue;
}
$childrens = groups_get_children($group_value['_id_'], true, $acl, false);
if (empty($childrens) === false) {
foreach ($childrens as $children) {
$children_status = groups_get_status($children['id_grupo']);
$parent_group['groups'][$group_key]['_monitor_checks_']++;
switch ($children_status) {
case AGENT_STATUS_CRITICAL:
$parent_group['groups'][$group_key]['_monitors_critical_']++;
break;
case AGENT_STATUS_WARNING:
$parent_group['groups'][$group_key]['_monitors_warning_']++;
break;
case AGENT_STATUS_UNKNOWN:
$parent_group['groups'][$group_key]['_monitors_unknown_']++;
break;
case AGENT_STATUS_NORMAL:
default:
$parent_group['groups'][$group_key]['_monitors_ok_']++;
break;
}
}
}
}
}
return $parent_group;
}

View File

@ -454,13 +454,17 @@ class Groups extends Element
// ACL Check.
$agent_a = check_acl($config['id_user'], 0, 'AR');
$agent_w = check_acl($config['id_user'], 0, 'AW');
$acl = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR');
$groups_list = groupview_get_groups_list(
$config['id_user'],
($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'),
$acl,
true
);
// Recursive groups.
$groups_list = get_recursive_groups_heatmap($groups_list, $acl);
$total_groups = $groups_list['counter'];
$groups = $groups_list['groups'];
// Best square.