diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index db91be0735..e816c7e8e1 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2014-01-23 Sergio Martin + + * godmode/alerts/alert_view.php + include/styles/pandora.css + include/functions_alerts.php: Fix escalation errors, added action + threshold information, encapsulate code to avoid future headaches. + 2014-01-23 Miguel de Dios * include/functions_visual_map.php, diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php index 77054d22df..7da54b15cb 100644 --- a/pandora_console/godmode/alerts/alert_view.php +++ b/pandora_console/godmode/alerts/alert_view.php @@ -41,7 +41,7 @@ if ($default_action != 0) { $default_action = alerts_get_alert_action($default_action); $default_action['name'] .= ' ' . '(' . __('Default') . ')'; $default_action['default'] = 1; - $actions[0] = $default_action; + $default_action['module_action_threshold'] = '0'; } // Header @@ -205,9 +205,7 @@ $table_days->head[3] = __('Thu'); $table_days->head[4] = __('Fri'); $table_days->head[5] = __('Sat'); $table_days->head[6] = __('Sun'); -$table_days->data[0][0] = $table_days->data[0][1] = $table_days->data[0][2] = - $table_days->data[0][3] = $table_days->data[0][4] = $table_days->data[0][5] = - $table_days->data[0][6] = html_print_image('images/blade.png', true); +$table_days->data[0] = array_fill(0, 7, html_print_image('images/blade.png', true)); $days = array(); if ($template['monday']) { @@ -291,7 +289,7 @@ unset($table_time); $table_conditions->data[] = $data; $data[0] = __('Use special days list'); -$data[1] = $alert['special_day'] == 1 ? __('Yes') : __('No'); +$data[1] = (isset($alert['special_day']) && $alert['special_day'] == 1) ? __('Yes') : __('No'); $table_conditions->data[] = $data; $data[0] = __('Time threshold'); @@ -321,6 +319,66 @@ $table->data[0][1] = html_print_table($table_conditions, true); html_print_table($table); unset($table); +$actions = alerts_get_actions_escalation($actions, $default_action); + +// ESCALATION +$table->class = 'alert_list databox alternate alert_escalation'; +$table->width = '98%'; +$table->size = array (); +$table->head = array(); +$table->data = array(); +$table->styleTable = 'text-align: center;'; + +echo '
'; +$table->head[0] = __('Actions'); +$table->style[0] = 'font-weight: bold; text-align: left;'; + +if (count($actions) == 1 && isset($actions[0])) { + $table->head[1] = __('Every time that the alert is fired'); + $table->data[0][0] = $actions[0]['name']; + $table->data[0][1] = html_print_image('images/tick.png', true); +} +else { + foreach($actions as $kaction => $action) { + $table->data[$kaction][0] = $action['name']; + if($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][$k] = html_print_image('images/tick.png', true); + } + else { + $table->data[$kaction][$k] = html_print_image('images/blade.png', true); + } + + if (count($table->head) <= count($action['escalation'])) { + if ($k == count($action['escalation'])) { + $table->head[$k] = '>#' . ($k-1); + } + else { + $table->head[$k] = '#' . $k; + } + } + } + + $action_threshold = $action['module_action_threshold'] > 0 ? $action['module_action_threshold'] : $action['action_threshold']; + + if ($action_threshold == 0) { + $table->data[$kaction][$k+1] = __('No'); + } + else { + $table->data[$kaction][$k+1] = human_time_description_raw ($action_threshold, true, 'tiny'); + } + + $table->head[$k+1] = __('Threshold') . '' . ui_print_help_icon ('action_threshold', true) . ''; + } +} + +html_print_table($table); +unset($table); +echo '
'; // ESCALATION TABLE $table->class = 'alert_list databox'; $table->width = '98%'; @@ -329,14 +387,18 @@ $table->head = array(); $table->data = array(); $table->rowstyle[1] = 'font-weight: bold;'; +if ($default_action != 0) { + $actions_select[0] = $default_action['name']; +} + foreach($actions as $kaction => $action) { $actions_select[$kaction] = $action['name']; } -$table->data[0][0] = __('Select the desired action and mode to see the Escalation and Firing/Recovery fields for this action'); +$table->data[0][0] = __('Select the desired action and mode to see the Firing/Recovery fields for this action'); $table->colspan[0][0] = 2; -$table->data[1][0] = __('Action') . '
' . html_print_select($actions_select, 'firing_action_select', -1, '', 'Select', -1, true, false, false); +$table->data[1][0] = __('Action') . '
' . html_print_select($actions_select, 'firing_action_select', -1, '', __('Select the action'), -1, true, false, false); $modes = array(); $modes['firing'] = __('Firing'); @@ -347,57 +409,6 @@ $table->data[1][1] = '