From 0228582a7561973e8729992a88c3ecc5651b72a7 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Wed, 21 Mar 2012 10:58:52 +0000 Subject: [PATCH] 012-03-21 Sergio Martin * include/functions_html.php include/javascript/pandora.js include/functions.php include/functions_alerts.php godmode/alerts/configure_alert_template.php godmode/alerts/alert_list.builder.php: Improved the periods control and added it to the alerts action threshold and alert template threshold git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5805 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 11 +++++++ .../godmode/alerts/alert_list.builder.php | 3 +- .../alerts/configure_alert_template.php | 21 ++----------- pandora_console/include/functions.php | 2 +- pandora_console/include/functions_alerts.php | 31 ++----------------- pandora_console/include/functions_html.php | 20 ++++++------ pandora_console/include/javascript/pandora.js | 11 ++++++- 7 files changed, 39 insertions(+), 60 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 224f04419c..f4a0228ea3 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2012-03-21 Sergio Martin + + * include/functions_html.php + include/javascript/pandora.js + include/functions.php + include/functions_alerts.php + godmode/alerts/configure_alert_template.php + godmode/alerts/alert_list.builder.php: Improved the + periods control and added it to the alerts action threshold + and alert template threshold + 2012-03-21 Sergio Martin * include/config_process.php diff --git a/pandora_console/godmode/alerts/alert_list.builder.php b/pandora_console/godmode/alerts/alert_list.builder.php index 46b33d49e2..11dc8c8a5d 100644 --- a/pandora_console/godmode/alerts/alert_list.builder.php +++ b/pandora_console/godmode/alerts/alert_list.builder.php @@ -111,7 +111,8 @@ if (check_acl ($config['id_user'], 0, "LM")) { $table->data[2][1] .= ''; } $table->data[3][0] = __('Threshold'); -$table->data[3][1] = html_print_input_text ('module_action_threshold', '', '', 4, 10, true) . ui_print_help_icon ('action_threshold', true); +$table->data[3][1] = html_print_extended_select_for_time ('module_action_threshold', 0, '', 0, + __('None'), false, true) . ui_print_help_icon ('action_threshold', true); echo '
'; diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index e40d1c5f11..9f5c2ffffb 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -211,8 +211,6 @@ function update_template ($step) { $threshold = (int) get_parameter ('threshold'); $max_alerts = (int) get_parameter ('max_alerts'); $min_alerts = (int) get_parameter ('min_alerts'); - if ($threshold == -1) - $threshold = (int) get_parameter ('other_threshold'); $field1 = (string) get_parameter ('field1'); $field2 = (string) get_parameter ('field2'); $field3 = (string) get_parameter ('field3'); @@ -446,16 +444,6 @@ $table->size[2] = '20%'; if ($step == 2) { /* Firing conditions and events */ - $threshold_values = alerts_get_alert_template_threshold_values (); - if (in_array ($threshold, array_keys ($threshold_values))) { - $table->style['other_label'] = 'display:none; font-weight: bold'; - $table->style['other_input'] = 'display:none'; - $threshold_selected = $threshold; - } else { - $table->style['other_label'] = 'font-weight: bold'; - $threshold_selected = -1; - } - $table->colspan = array (); $table->colspan[4][1] = 3; $table->colspan['field1'][1] = 3; @@ -488,13 +476,10 @@ if ($step == 2) { $table->data[1][3] = html_print_input_text ('time_to', $time_to, '', 7, 7, true); + $table->colspan['threshold'][1] = 3; $table->data['threshold'][0] = __('Time threshold'); - $table->data['threshold'][1] = html_print_select ($threshold_values, - 'threshold', $threshold_selected, '', '', '', true, false, false); - $table->data['threshold']['other_label'] = __('Other value'); - $table->data['threshold']['other_input'] = html_print_input_text ('other_threshold', - $threshold, '', 5, 7, true); - $table->data['threshold']['other_input'] .= ' '.__('seconds'); + $table->data['threshold'][1] = html_print_extended_select_for_time ('threshold', $threshold, '', '', + '', false, true); $table->data[3][0] = __('Min. number of alerts'); $table->data[3][1] = html_print_input_text ('min_alerts', $min_alerts, '', diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index e13859fb2b..02a70f1886 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1591,7 +1591,7 @@ function get_user_dashboards ($id_user) { function get_periods () { $periods = array (); - $periods[0] = __('custom'); + $periods[-1] = __('custom'); $periods[SECONDS_5MINUTES] = '5 '.__('minutes'); $periods[SECONDS_30MINUTES] = '30 '.__('minutes'); $periods[SECONDS_1HOUR] = __('1 hour'); diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index dad259ede2..fc7b7fca2d 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -771,34 +771,6 @@ function alerts_get_alert_template_field3_recovery ($id_alert_template) { return db_get_value ('field3_recovery', 'talert_templates', 'id', $id_alert_template); } -/** - * Get threshold values of alert template. - * - * @param int Id of an alert template. - * - * @return mixed Threshold values or false if something goes wrong. - */ -function alerts_get_alert_template_threshold_values () { - $times = array (); - - $times['300'] = '5 '.__('minutes'); - $times['600'] = '10 '.__('minutes'); - $times['900'] = '15 '.__('minutes'); - $times['1800'] = '30 '.__('minutes'); - $times['3600'] = '1 '.__('hour'); - $times['7200'] = '2 '.__('hours'); - $times['18000'] = '5 '.__('hours'); - $times['43200'] = '12 '.__('hours'); - $times['86400'] = '1 '.__('day'); - $times['604800'] = '1 '.__('week'); - $times['1209600'] = '2 '.__('weeks'); - $times['18144000'] = '1 '.__('month'); - $times['108864000'] = '6 '.__('months'); - $times['-1'] = __('Other value'); - - return $times; -} - /** * Duplicates an alert template. * @@ -1243,7 +1215,8 @@ function alerts_copy_alert_module_to_module ($id_agent_alert, $id_destiny_module */ function alerts_compound_threshold_values () { /* At this moment we don't need different threshold values */ - return alerts_get_alert_template_threshold_values (); + // TODO: Delete when compound alerts will be deleted + return get_periods (); } /** diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 6816201bf7..b07bdc3f5d 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -422,35 +422,35 @@ function html_print_extended_select_for_time ($name, $selected = '', $script = ' $fields = get_periods(); - if (($selected !== false) && (!isset($fields[$selected]))) { + if (($selected !== false) && (!isset($fields[$selected]) && $selected != 0)) { $fields[$selected] = human_time_description_raw($selected,true); } $units = array( 1 => __('seconds'), - 60 => __('minutes'), - 3600 => __('hours'), - 86400 => __('days'), - 2592000 => __('months'), - 31104000 => __('years')); + SECONDS_1MINUTE => __('minutes'), + SECONDS_1HOUR => __('hours'), + SECONDS_1DAY => __('days'), + SECONDS_1MONTH => __('months'), + SECONDS_1YEAR => __('years')); $uniq_name = uniqid($name); ob_start(); - echo '
'; + echo '
'; + echo ' '.html_print_image('images/pencil.png',true,array('class' => $uniq_name . '_toggler', 'alt' => __('Custom'), 'title' => __('Custom'))).''; html_print_select ($fields, $uniq_name . '_select', $selected,"" . $script, $nothing, $nothing_value, false, false, false, '', false, 'font-size: xx-small;'.$select_style); - echo ' '.html_print_image('images/pencil.png',true,array('class' => $uniq_name . '_toggler', 'alt' => __('Custom'), 'title' => __('Custom'))).''; echo '
'; - echo '
'; + echo '
'; + echo ' '.html_print_image('images/default_list.png',true,array('class' => $uniq_name . '_toggler', 'alt' => __('List'), 'title' => __('List'))).''; html_print_input_text ($uniq_name . '_text', $selected, '', $size); html_print_input_hidden ($name, $selected, false, $uniq_name); html_print_select ($units, $uniq_name . '_units', 1, "" . $script, $nothing, $nothing_value, false, false, false, '', false, 'font-size: xx-small;'.$select_style); - echo ' '.html_print_image('images/default_list.png',true,array('class' => $uniq_name . '_toggler', 'alt' => __('List'), 'title' => __('List'))).''; echo '
'; echo " diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 290349173a..dc8e5168c4 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -618,6 +618,11 @@ function period_select_events(name) { $('#text-'+name+'_text').val(300); $('#'+name+'_select option:eq(1)').attr('selected', true); } + else if($('#text-'+name+'_text').val() == 0) { + $('#'+name+'_default').toggle(); + $('#'+name+'_manual').toggle(); + $('#'+name+'_units option:last').removeAttr('selected'); + } $('.'+name+'_toggler').click(function() { $('#'+name+'_default').toggle(); @@ -631,7 +636,7 @@ function period_select_events(name) { $('#'+name+'_select').change(function() { var value = $('#'+name+'_select').val(); - if(value == 0) { + if(value == -1) { value = 300; } @@ -692,4 +697,8 @@ function adjustTextUnits(name) { $('#'+name+'_units option:last').attr('selected', true); $('#text-'+name+'_text').val(restPrev); } + + if($('#text-'+name+'_text').val() == 0) { + $('#'+name+'_units option:eq(0)').attr('selected', true); + } }