012-03-21 Sergio Martin <sergio.martin@artica.es>

* 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
This commit is contained in:
zarzuelo 2012-03-21 10:58:52 +00:00
parent 1d2cb33c36
commit 0228582a75
7 changed files with 39 additions and 60 deletions

View File

@ -1,3 +1,14 @@
2012-03-21 Sergio Martin <sergio.martin@artica.es>
* 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 <sergio.martin@artica.es>
* include/config_process.php

View File

@ -111,7 +111,8 @@ if (check_acl ($config['id_user'], 0, "LM")) {
$table->data[2][1] .= '</a>';
}
$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 '<form class="add_alert_form" method="post">';

View File

@ -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, '',

View File

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

View File

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

View File

@ -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 '<div id="'.$uniq_name.'_default" style="width:100%">';
echo '<div id="'.$uniq_name.'_default" style="width:100%;display:inline;">';
echo ' <a href="javascript:">'.html_print_image('images/pencil.png',true,array('class' => $uniq_name . '_toggler', 'alt' => __('Custom'), 'title' => __('Custom'))).'</a>';
html_print_select ($fields, $uniq_name . '_select', $selected,"" . $script,
$nothing, $nothing_value, false, false, false, '', false, 'font-size: xx-small;'.$select_style);
echo ' <a href="javascript:">'.html_print_image('images/pencil.png',true,array('class' => $uniq_name . '_toggler', 'alt' => __('Custom'), 'title' => __('Custom'))).'</a>';
echo '</div>';
echo '<div id="'.$uniq_name.'_manual" style="width:100%">';
echo '<div id="'.$uniq_name.'_manual" style="width:100%;display:inline;">';
echo ' <a href="javascript:">'.html_print_image('images/default_list.png',true,array('class' => $uniq_name . '_toggler', 'alt' => __('List'), 'title' => __('List'))).'</a>';
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 ' <a href="javascript:">'.html_print_image('images/default_list.png',true,array('class' => $uniq_name . '_toggler', 'alt' => __('List'), 'title' => __('List'))).'</a>';
echo '</div>';
echo "

View File

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