From 19828340bb028b4f805309647f18e4988c0a4b3a Mon Sep 17 00:00:00 2001 From: esanchezm Date: Wed, 21 Jan 2009 14:56:55 +0000 Subject: [PATCH] 2009-01-21 Esteban Sanchez * godmode/agentes/alert_manager.php: Fixed a little bug that avoids showing the alert editor. * godmode/alerts/alert_templates.php: Added the example text for alert templates to the tooltip. * godmode/alerts/configure_alert_template.php: Function print_alert_template_example() moved to functions_ui.php. Little fix when max or min values are not numerics. * include/functions_ui.php: Added function print_alert_template_example(). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1385 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 15 ++++ .../godmode/agentes/alert_manager.php | 1 + .../godmode/alerts/alert_templates.php | 32 +++----- .../alerts/configure_alert_template.php | 75 ++----------------- pandora_console/include/functions_ui.php | 63 ++++++++++++++++ 5 files changed, 93 insertions(+), 93 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 59922eccda..4d595bf5b6 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,18 @@ +2009-01-21 Esteban Sanchez + + * godmode/agentes/alert_manager.php: Fixed a little bug that avoids + showing the alert editor. + + * godmode/alerts/alert_templates.php: Added the example text for + alert templates to the tooltip. + + * godmode/alerts/configure_alert_template.php: Function + print_alert_template_example() moved to functions_ui.php. Little fix + when max or min values are not numerics. + + * include/functions_ui.php: Added function + print_alert_template_example(). + 2009-01-21 Esteban Sanchez * godmode/agentes/alert_manager.php: Added support to disable or diff --git a/pandora_console/godmode/agentes/alert_manager.php b/pandora_console/godmode/agentes/alert_manager.php index 4c2b6a03c9..13c91fc106 100644 --- a/pandora_console/godmode/agentes/alert_manager.php +++ b/pandora_console/godmode/agentes/alert_manager.php @@ -311,6 +311,7 @@ $(document).ready (function () { $("input#hidden-id_agent_module", form).attr ("value", id); $(place).append (form); $(form).show (); + $(this).parents ("tbody").children ("tr:last").show (); return false; }); diff --git a/pandora_console/godmode/alerts/alert_templates.php b/pandora_console/godmode/alerts/alert_templates.php index 9f47824d3d..8dcbcf5a2a 100644 --- a/pandora_console/godmode/alerts/alert_templates.php +++ b/pandora_console/godmode/alerts/alert_templates.php @@ -40,30 +40,16 @@ if (defined ('AJAX')) { return; echo '

'.$template['name'].'

'; - echo ''.get_alert_templates_type_name ($template['type']).': '; + echo ''.__('Type').': '; + echo get_alert_templates_type_name ($template['type']); - switch ($template['type']) { - case 'regex': - case 'equal': - case 'not_equal': - if (empty ($template['value'])) - echo ''.__('Empty').''; - else - echo ''.$template['value'].''; - - break; - case 'max_min': - echo __('Between').' '; - case 'max': - echo format_numeric ($template['max_value']); - - /* Break on max to not show min */ - if ($template['type'] == 'max') - break; - echo ''.__('and').' '; - case 'min': - echo format_numeric ($template['min_value']); - } + echo '
'; + $example = print_alert_template_example ($template['id'], true); + + $example = str_replace ('', $template['value'], $example); + $example = str_replace ('', $template['max_value'], $example); + $example = str_replace ('', $template['min_value'], $example); + echo $example; echo '
'; diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index f81a70c61d..439734ed2f 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -78,71 +78,6 @@ function print_alert_template_steps ($step, $id) { echo ''; } -function print_alert_template_example ($id, $return = false) { - $output = ''; - - $is = false; - $is_not = false; - $matches = false; - $matches_not = false; - $between = false; - $between_not = false; - $under = false; - $over = false; - $max = false; - $min = false; - $value = false; - - $output .= ' '; - $output .= ''; - - if ($id) { - $template = get_alert_template ($id); - - switch ($template['type']) { - case 'not_equal': - /* Do not translate the HTML attributes */ - $output .= __('The alert would fire when the value is '); - break; - case 'equal': - /* Do not translate the HTML attributes */ - $output .= __('The alert would fire when the value is not '); - break; - case 'regex': - if ($template['matches_value']) - /* Do not translate the HTML attributes */ - $output .= __('The alert would fire when the value matches '); - else - /* Do not translate the HTML attributes */ - $output .= __('The alert would fire when the value doesn\'t match '); - $value = $template['value']; - break; - case 'max_min': - if ($template['matches_value']) - /* Do not translate the HTML attributes */ - $output .= __('The alert would fire when the value is between and '); - else - /* Do not translate the HTML attributes */ - $output .= __('The alert would fire when the value is not between and '); - break; - case 'max': - /* Do not translate the HTML attributes */ - $output .= __('The alert would fire when the value is over '); - - break; - case 'min': - /* Do not translate the HTML attributes */ - $output .= __('The alert would fire when the value is under '); - break; - } - } - - $output .= ''; - if ($return) - return $output; - echo $output; -} - function update_template ($step) { $id = (int) get_parameter ('id'); @@ -588,23 +523,23 @@ function check_regex () { function render_example () { /* Set max */ - max = $("input#text-max").attr ("value") - if (max == '') { + max = parseInt ($("input#text-max").attr ("value")); + if (isNaN (max) || max == '') { $("span#max").empty ().append ("0"); } else { $("span#max").empty ().append (max); } /* Set min */ - min = $("input#text-min").attr ("value") - if (min == '') { + min = parseInt ($("input#text-min").attr ("value")); + if (isNaN (min) || min == '') { $("span#min").empty ().append ("0"); } else { $("span#min").empty ().append (min); } /* Set value */ - value = $("input#text-value").attr ("value") + value = $("input#text-value").attr ("value"); if (value == '') { $("span#value").empty ().append (""); } else { diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 89b966ae9b..5e12d97064 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -308,4 +308,67 @@ function print_string_substr ($string, $cutoff = 16, $return = false) { } return $string; } + +/** + * Gets a helper text explaining the requirement needs for an alert template + * to get it fired. + * + * @param int Alert template id. + * @param bool Wheter to return or print it out. + * + * @return An HTML string if return was true. + */ +function print_alert_template_example ($id_alert_template, $return = false) { + $output = ''; + + $output .= ' '; + $output .= ''; + + if ($id_alert_template) { + $template = get_alert_template ($id_alert_template); + + switch ($template['type']) { + case 'not_equal': + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is '); + break; + case 'equal': + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is not '); + break; + case 'regex': + if ($template['matches_value']) + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value matches '); + else + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value doesn\'t match '); + $value = $template['value']; + break; + case 'max_min': + if ($template['matches_value']) + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is between and '); + else + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is not between and '); + break; + case 'max': + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is over '); + + break; + case 'min': + /* Do not translate the HTML attributes */ + $output .= __('The alert would fire when the value is under '); + break; + } + } + + $output .= ''; + if ($return) + return $output; + echo $output; +} + ?>