10066-Recursion group widget alerts triggered

This commit is contained in:
Pablo Aragon 2023-04-05 12:59:52 +02:00
parent cc2709c42c
commit 2dc8b25ddc
1 changed files with 41 additions and 0 deletions

View File

@ -208,6 +208,10 @@ class AlertsFiredWidget extends Widget
$values['groupId'] = $decoder['groupId'];
}
if (isset($decoder['group_recursion']) === true) {
$values['group_recursion'] = $decoder['group_recursion'];
}
return $values;
}
@ -245,6 +249,18 @@ class AlertsFiredWidget extends Widget
],
];
// Group recursion.
$inputs[] = [
'label' => __('Recursion'),
'arguments' => [
'wrapper' => 'div',
'name' => 'group_recursion',
'type' => 'switch',
'value' => $values['group_recursion'],
'return' => true,
],
];
return $inputs;
}
@ -260,6 +276,7 @@ class AlertsFiredWidget extends Widget
$values = parent::getPost();
$values['groupId'] = \get_parameter('groupId', 0);
$values['group_recursion'] = \get_parameter_switch('group_recursion');
return $values;
}
@ -282,6 +299,11 @@ class AlertsFiredWidget extends Widget
$groups = [$this->values['groupId'] => ''];
}
$group_recursion = false;
if (empty($this->values['group_recursion']) === false) {
$group_recursion = true;
}
if (isset($groups) === true && is_array($groups) === true) {
$table = new \StdClass();
$table->class = 'databox data centered';
@ -300,6 +322,25 @@ class AlertsFiredWidget extends Widget
$url .= '&refr=60&filter=fired&filter_standby=all';
$flag = false;
$groups_ids = [];
$groups_ids_tmp = [];
foreach ($groups as $id_group => $name) {
if ($group_recursion === true) {
$groups_ids_tmp[] = groups_get_children_ids($id_group);
}
}
if ($group_recursion === true) {
foreach ($groups_ids_tmp as $ids_tmp => $values) {
foreach ($values as $value) {
$groups_ids[$value] = '';
}
}
$groups = $groups_ids;
}
foreach ($groups as $id_group => $name) {
$alerts_group = get_group_alerts([$id_group]);
if (isset($alerts_group['simple']) === true) {