From d46edcd49dcbd1dffbd5057fd838835bcc4cd17f Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 6 Jul 2023 15:51:15 +0200 Subject: [PATCH 1/2] #11701 Fix alert view --- pandora_console/godmode/alerts/alert_view.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php index 3a71292aed..9f5b9a57d4 100644 --- a/pandora_console/godmode/alerts/alert_view.php +++ b/pandora_console/godmode/alerts/alert_view.php @@ -316,6 +316,8 @@ if (count($actions) == 1 && isset($actions[0])) { ['class' => 'invert_filter'] ); } else { + $table->head[1] = __('Every time that the alert is fired'); + $table->head[2] = __('Threshold'); foreach ($actions as $kaction => $action) { $table->data[$kaction][0] = $action['name']; if ((int) $kaction === 0) { @@ -327,13 +329,13 @@ if (count($actions) == 1 && isset($actions[0])) { foreach ($action['escalation'] as $k => $v) { if ($v > 0) { - $table->data[$kaction][$k] .= html_print_image( + $table->data[$kaction][2] .= html_print_image( 'images/tick.png', true, ['class' => 'invert_filter'] ); } else { - $table->data[$kaction][$k] = html_print_image( + $table->data[$kaction][2] = html_print_image( 'images/blade.png', true ); @@ -364,7 +366,7 @@ if (count($actions) == 1 && isset($actions[0])) { } } - $table->head[($kaction + 1)] = '#'.($kaction); + // $table->head[($kaction + 1)] = ''.($kaction); if (count($action['escalation']) === 0) { $table->data[$kaction][($kaction + 2)] = html_print_image( 'images/blade.png', @@ -375,16 +377,16 @@ if (count($actions) == 1 && isset($actions[0])) { $action_threshold = ($action['module_action_threshold'] > 0) ? $action['module_action_threshold'] : $action['action_threshold']; if ($action_threshold == 0) { - $table->data[$kaction][($k + 1)] = __('No'); + $table->data[$kaction][3] = __('No'); } else { - $table->data[$kaction][($k + 1)] = human_time_description_raw( + $table->data[$kaction][1] = human_time_description_raw( $action_threshold, true, 'tiny' ); } - $table->head[($kaction + 1)] = __('Threshold'); + // $table->head[($kaction + 1)] = __('Threshold'); } } From a215620f2e6511b036c2fd48265a9c1fa1f5c6ba Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Mon, 10 Jul 2023 11:39:43 +0200 Subject: [PATCH 2/2] #11701 Fix alert view --- pandora_console/godmode/alerts/alert_view.php | 89 ++++++++----------- 1 file changed, 36 insertions(+), 53 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php index 9f5b9a57d4..1a3e991fde 100644 --- a/pandora_console/godmode/alerts/alert_view.php +++ b/pandora_console/godmode/alerts/alert_view.php @@ -316,78 +316,61 @@ if (count($actions) == 1 && isset($actions[0])) { ['class' => 'invert_filter'] ); } else { - $table->head[1] = __('Every time that the alert is fired'); - $table->head[2] = __('Threshold'); foreach ($actions as $kaction => $action) { $table->data[$kaction][0] = $action['name']; - if ((int) $kaction === 0) { - $table->data[$kaction][0] .= ui_print_help_tip( - __('The default actions will be executed every time that the alert is fired and no other action is executed'), - true - ); - } - - foreach ($action['escalation'] as $k => $v) { - if ($v > 0) { - $table->data[$kaction][2] .= html_print_image( - 'images/tick.png', - true, - ['class' => 'invert_filter'] - ); + if (count($action['escalation']) > 1) { + foreach ($action['escalation'] as $k => $v) { + $table->head[$k] = '#'.$k; + if ($v > 0) { + $table->data[$kaction][$k] .= html_print_image( + 'images/tick.png', + true, + ['class' => 'invert_filter'] + ); + } else { + $table->data[$kaction][$k] = html_print_image( + 'images/blade.png', + true + ); + } + } + } else { + $table->head[1] = __('Every time that the alert is fired'); + if (count($action['escalation']) > 0) { + if ($action['escalation'][0] > 0) { + $table->data[$kaction][1] .= html_print_image( + 'images/tick.png', + true, + ['class' => 'invert_filter'] + ); + } else { + $table->data[$kaction][1] = html_print_image( + 'images/blade.png', + true + ); + } } else { - $table->data[$kaction][2] = html_print_image( + $table->data[$kaction][1] = html_print_image( 'images/blade.png', true ); } - - if (count($table->head) <= count($action['escalation'])) { - if ($k == count($action['escalation'])) { - if ($k == 1) { - $table->head[$kaction] = __('Every time that the alert is fired'); - } else { - $table->head[$kaction] = '>#'.($kaction - 1); - } - } else { - $table->head[$kaction] = '#'.($kaction); - if ($v > 0) { - $table->data[$kaction][($kaction + 1)] = html_print_image( - 'images/tick.png', - true, - ['class' => 'invert_filter'] - ); - } else { - $table->data[$kkaction][($kaction + 1)] = html_print_image( - 'images/blade.png', - true - ); - } - } - } - } - - // $table->head[($kaction + 1)] = ''.($kaction); - if (count($action['escalation']) === 0) { - $table->data[$kaction][($kaction + 2)] = html_print_image( - 'images/blade.png', - true - ); } $action_threshold = ($action['module_action_threshold'] > 0) ? $action['module_action_threshold'] : $action['action_threshold']; if ($action_threshold == 0) { - $table->data[$kaction][3] = __('No'); + $table->data[$kaction][] = __('No'); } else { - $table->data[$kaction][1] = human_time_description_raw( + $table->data[$kaction][] = human_time_description_raw( $action_threshold, true, 'tiny' ); } - - // $table->head[($kaction + 1)] = __('Threshold'); } + + $table->head[] = __('Threshold'); } html_print_table($table);