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:
parent
38513eedf7
commit
e3bd76dccb
|
@ -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>
|
2009-01-21 Esteban Sanchez <estebans@artica.es>
|
||||||
|
|
||||||
* godmode/agentes/alert_manager.php: Added support to disable or
|
* godmode/agentes/alert_manager.php: Added support to disable or
|
||||||
|
|
|
@ -311,6 +311,7 @@ $(document).ready (function () {
|
||||||
$("input#hidden-id_agent_module", form).attr ("value", id);
|
$("input#hidden-id_agent_module", form).attr ("value", id);
|
||||||
$(place).append (form);
|
$(place).append (form);
|
||||||
$(form).show ();
|
$(form).show ();
|
||||||
|
$(this).parents ("tbody").children ("tr:last").show ();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -40,30 +40,16 @@ if (defined ('AJAX')) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
echo '<h3>'.$template['name'].'</h3>';
|
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']) {
|
echo '<br />';
|
||||||
case 'regex':
|
$example = print_alert_template_example ($template['id'], true);
|
||||||
case 'equal':
|
|
||||||
case 'not_equal':
|
$example = str_replace ('<span id="value"></span>', $template['value'], $example);
|
||||||
if (empty ($template['value']))
|
$example = str_replace ('<span id="max"></span>', $template['max_value'], $example);
|
||||||
echo '<em>'.__('Empty').'</em>';
|
$example = str_replace ('<span id="min"></span>', $template['min_value'], $example);
|
||||||
else
|
echo $example;
|
||||||
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 />';
|
echo '<br />';
|
||||||
|
|
||||||
|
|
|
@ -78,71 +78,6 @@ function print_alert_template_steps ($step, $id) {
|
||||||
echo '</div>';
|
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) {
|
function update_template ($step) {
|
||||||
$id = (int) get_parameter ('id');
|
$id = (int) get_parameter ('id');
|
||||||
|
|
||||||
|
@ -588,23 +523,23 @@ function check_regex () {
|
||||||
|
|
||||||
function render_example () {
|
function render_example () {
|
||||||
/* Set max */
|
/* Set max */
|
||||||
max = $("input#text-max").attr ("value")
|
max = parseInt ($("input#text-max").attr ("value"));
|
||||||
if (max == '') {
|
if (isNaN (max) || max == '') {
|
||||||
$("span#max").empty ().append ("0");
|
$("span#max").empty ().append ("0");
|
||||||
} else {
|
} else {
|
||||||
$("span#max").empty ().append (max);
|
$("span#max").empty ().append (max);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set min */
|
/* Set min */
|
||||||
min = $("input#text-min").attr ("value")
|
min = parseInt ($("input#text-min").attr ("value"));
|
||||||
if (min == '') {
|
if (isNaN (min) || min == '') {
|
||||||
$("span#min").empty ().append ("0");
|
$("span#min").empty ().append ("0");
|
||||||
} else {
|
} else {
|
||||||
$("span#min").empty ().append (min);
|
$("span#min").empty ().append (min);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set value */
|
/* Set value */
|
||||||
value = $("input#text-value").attr ("value")
|
value = $("input#text-value").attr ("value");
|
||||||
if (value == '') {
|
if (value == '') {
|
||||||
$("span#value").empty ().append ("<em><?php echo __('Empty');?></em>");
|
$("span#value").empty ().append ("<em><?php echo __('Empty');?></em>");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -308,4 +308,67 @@ function print_string_substr ($string, $cutoff = 16, $return = false) {
|
||||||
}
|
}
|
||||||
return $string;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue