2009-01-21 Esteban Sanchez <estebans@artica.es>

* 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
This commit is contained in:
esanchezm 2009-01-21 14:56:55 +00:00
parent 412fa2423d
commit 19828340bb
5 changed files with 93 additions and 93 deletions

View File

@ -1,3 +1,18 @@
2009-01-21 Esteban Sanchez <estebans@artica.es>
* 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 <estebans@artica.es>
* godmode/agentes/alert_manager.php: Added support to disable or

View File

@ -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;
});

View File

@ -40,30 +40,16 @@ if (defined ('AJAX')) {
return;
echo '<h3>'.$template['name'].'</h3>';
echo '<strong>'.get_alert_templates_type_name ($template['type']).':</strong> ';
echo '<strong>'.__('Type').': </strong>';
echo get_alert_templates_type_name ($template['type']);
switch ($template['type']) {
case 'regex':
case 'equal':
case 'not_equal':
if (empty ($template['value']))
echo '<em>'.__('Empty').'</em>';
else
echo '<code>'.$template['value'].'</code>';
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 '<br />';
$example = print_alert_template_example ($template['id'], true);
$example = str_replace ('<span id="value"></span>', $template['value'], $example);
$example = str_replace ('<span id="max"></span>', $template['max_value'], $example);
$example = str_replace ('<span id="min"></span>', $template['min_value'], $example);
echo $example;
echo '<br />';

View File

@ -78,71 +78,6 @@ function print_alert_template_steps ($step, $id) {
echo '</div>';
}
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 .= '<img src="images/information.png" /> ';
$output .= '<span id="example">';
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 <span id="value"></span>');
break;
case 'equal':
/* Do not translate the HTML attributes */
$output .= __('The alert would fire when the value is not <span id="value"></span>');
break;
case 'regex':
if ($template['matches_value'])
/* Do not translate the HTML attributes */
$output .= __('The alert would fire when the value matches <span id="value"></span>');
else
/* Do not translate the HTML attributes */
$output .= __('The alert would fire when the value doesn\'t match <span id="value"></span>');
$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 <span id="min"></span> and <span id="max"></span>');
else
/* Do not translate the HTML attributes */
$output .= __('The alert would fire when the value is not between <span id="min"></span> and <span id="max"></span>');
break;
case 'max':
/* Do not translate the HTML attributes */
$output .= __('The alert would fire when the value is over <span id="max"></span>');
break;
case 'min':
/* Do not translate the HTML attributes */
$output .= __('The alert would fire when the value is under <span id="min"></span>');
break;
}
}
$output .= '</span>';
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 ("<em><?php echo __('Empty');?></em>");
} else {

View File

@ -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 .= '<img src="images/information.png" /> ';
$output .= '<span id="example">';
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 <span id="value"></span>');
break;
case 'equal':
/* Do not translate the HTML attributes */
$output .= __('The alert would fire when the value is not <span id="value"></span>');
break;
case 'regex':
if ($template['matches_value'])
/* Do not translate the HTML attributes */
$output .= __('The alert would fire when the value matches <span id="value"></span>');
else
/* Do not translate the HTML attributes */
$output .= __('The alert would fire when the value doesn\'t match <span id="value"></span>');
$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 <span id="min"></span> and <span id="max"></span>');
else
/* Do not translate the HTML attributes */
$output .= __('The alert would fire when the value is not between <span id="min"></span> and <span id="max"></span>');
break;
case 'max':
/* Do not translate the HTML attributes */
$output .= __('The alert would fire when the value is over <span id="max"></span>');
break;
case 'min':
/* Do not translate the HTML attributes */
$output .= __('The alert would fire when the value is under <span id="min"></span>');
break;
}
}
$output .= '</span>';
if ($return)
return $output;
echo $output;
}
?>