From 2b237939497daaa7d352fd465e2d0790207069b9 Mon Sep 17 00:00:00 2001 From: zarzuelo <zarzuelo@gmail.com> Date: Fri, 24 Jan 2014 10:17:23 +0000 Subject: [PATCH] 2014-01-24 Sergio Martin <sergio.martin@artica.es> * godmode/alerts/alert_list.list.php godmode/alerts/alert_view.php include/styles/pandora.css include/functions_alerts.php: Fix some bugs when doesnt exist an action with min-infinite situation. Some visual fixes git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9366 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 9 +++ .../godmode/alerts/alert_list.list.php | 1 + pandora_console/godmode/alerts/alert_view.php | 9 ++- pandora_console/include/functions_alerts.php | 56 +++++++++++++------ pandora_console/include/styles/pandora.css | 2 +- 5 files changed, 56 insertions(+), 21 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e816c7e8e1..d1c42ab1ec 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2014-01-24 Sergio Martin <sergio.martin@artica.es> + + * godmode/alerts/alert_list.list.php + godmode/alerts/alert_view.php + include/styles/pandora.css + include/functions_alerts.php: Fix some bugs when + doesnt exist an action with min-infinite situation. + Some visual fixes + 2014-01-23 Sergio Martin <sergio.martin@artica.es> * godmode/alerts/alert_view.php diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index d308fdcfcf..36f64804bf 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -448,6 +448,7 @@ foreach ($simple_alerts as $alert) { if ($default_action != "") { $data[2] .= "<tr><td><ul class='action_list'><li>"; $data[2] .= db_get_sql ("SELECT name FROM talert_actions WHERE id = $default_action") . ' <em>(' . __('Default') . ')</em>'; + $data[2] .= ui_print_help_tip(__('The default actions will be executed every time that the alert is fired and no other action is executed'), true); $data[2] .= "</li></ul></td>"; $data[2] .= "<td></td>"; $data[2] .= "</tr>"; diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php index 7da54b15cb..5f2a7eab04 100644 --- a/pandora_console/godmode/alerts/alert_view.php +++ b/pandora_console/godmode/alerts/alert_view.php @@ -355,7 +355,12 @@ else { if (count($table->head) <= count($action['escalation'])) { if ($k == count($action['escalation'])) { - $table->head[$k] = '>#' . ($k-1); + if($k == 1) { + $table->head[$k] = __('Every time that the alert is fired'); + } + else { + $table->head[$k] = '>#' . ($k-1); + } } else { $table->head[$k] = '#' . $k; @@ -372,7 +377,7 @@ else { $table->data[$kaction][$k+1] = human_time_description_raw ($action_threshold, true, 'tiny'); } - $table->head[$k+1] = __('Threshold') . '<span style="float: right;">' . ui_print_help_icon ('action_threshold', true) . '</span>'; + $table->head[$k+1] = __('Threshold') . '<span style="float: right;">' . ui_print_help_icon ('action_threshold', true, '', 'images/header_help.png') . '</span>'; } } diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 1cf1c7595e..5fc5675cd4 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -1873,9 +1873,9 @@ function alerts_get_actions_escalation($actions, $default_action = 0) { $default_escalation = alerts_get_default_action_escalation($default_action, $escalation); $escalation = array(0 => $default_escalation) + $escalation; - - $escalation = alerts_normalize_actions_escalation($escalation); + $escalation = alerts_normalize_actions_escalation($escalation); + // Join the actions with the default action $actions = array(0 => $default_action) + $actions; @@ -1926,17 +1926,19 @@ function alerts_get_default_action_escalation($default_action, $escalation) { // Set to 1 the busy executions // Set to 2 the min - infinite situations foreach($busy_times as $k => $v) { - if ($k == ($busy_greater_than + 1)) { - $busy_times[$k] = 2; - } - else if ($k > ($busy_greater_than + 1)) { - unset($busy_times[$k]); + if ($busy_greater_than != -1) { + if ($k == ($busy_greater_than + 1)) { + $busy_times[$k] = 2; + } + else if ($k > ($busy_greater_than + 1)) { + unset($busy_times[$k]); + } } else if ($v > 1) { $busy_times[$k] = 1; } } - + // Set as default execution the not busy times $default_escalation = array(); foreach($busy_times as $k => $v) { @@ -1949,7 +1951,7 @@ function alerts_get_default_action_escalation($default_action, $escalation) { break; case 1: $default_escalation[$k] = 0; - $default_escalation[$k+1] = 2; + $default_escalation[$k] = 2; break; case 2: break; @@ -1967,6 +1969,17 @@ function alerts_get_default_action_escalation($default_action, $escalation) { } } + if (empty($busy_times)) { + if ($busy_greater_than == -1) { + $default_escalation = 'everytime'; + } + else { + for($i=1;$i<=$busy_greater_than;$i++) { + $default_escalation[$i] = 1; + } + } + } + return $default_escalation; } @@ -1982,12 +1995,12 @@ function alerts_normalize_actions_escalation($escalation) { $max_elements = 0; foreach($escalation as $k => $v) { - if (isset($v['greater_than'])) { + if (is_array($v) && isset($v['greater_than'])) { $escalation[$k] = array(); - for($i=1;$i<=$v['greater_than'];$i++) { + for($i=1;$i<$v['greater_than'];$i++) { $escalation[$k][$i] = 0; } - $escalation[$k][$v['greater_than']+1] = 2; + $escalation[$k][$v['greater_than']] = 2; } $n = count($escalation[$k]); @@ -1995,24 +2008,31 @@ function alerts_normalize_actions_escalation($escalation) { $max_elements = $n; } } + + if ($max_elements == 1) { + $nelements = $max_elements; + } + else { + $nelements = $max_elements+1; + } foreach($escalation as $k => $v) { - if ($v == 'always') { - $escalation[$k] = array_fill(1, $max_elements, 1); - $escalation[$k][$max_elements+1] = 1; + if ($v == 'everytime') { + $escalation[$k] = array_fill(1, $nelements, 1); + $escalation[$k][$max_elements] = 2; } else if ($v == 'never') { - $escalation[$k] = array_fill(1, ($max_elements), 0); + $escalation[$k] = array_fill(1, $nelements, 0); } else { $fill_value = 0; - for($i=1;$i<=($max_elements+1);$i++) { + for($i=1;$i<=$nelements;$i++) { if (!isset($escalation[$k][$i])) { $escalation[$k][$i] = $fill_value; } else if ($escalation[$k][$i] == 2) { $fill_value = 1; - $escalation[$k][$i] = $fill_value; + $escalation[$k][$i] = 0; } } } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index a24502162d..dc0bf1a0d6 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -2834,7 +2834,7 @@ div#agent_wizard_subtabs { /* Alert view */ -table.alert_days th, table.alert_time th, table.alert_escalation th{ +table.alert_days th, table.alert_time th{ height: 30px; vertical-align: middle; }