Merge branch 'ent-5261-Cambio-de-control-de-intervalo-en-alertas' into 'develop'
Ent 5261 cambio de control de intervalo en alertas See merge request artica/pandorafms!3013
This commit is contained in:
commit
587492b40e
|
@ -163,8 +163,23 @@ if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
|
|||
}
|
||||
|
||||
$table->data[3][0] = __('Threshold');
|
||||
$table->data[3][1] = html_print_input_text('module_action_threshold', '0', '', 5, 7, true);
|
||||
$table->data[3][1] .= '<span style="margin-left:0.5em;">'.__('seconds').'</span>';
|
||||
$table->data[3][1] = html_print_extended_select_for_time(
|
||||
'module_action_threshold',
|
||||
0,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
if (!isset($step)) {
|
||||
echo '<form class="add_alert_form" method="post">';
|
||||
|
|
|
@ -734,12 +734,21 @@ foreach ($simple_alerts as $alert) {
|
|||
$data[3] .= __('Threshold');
|
||||
$data[3] .= '</td>';
|
||||
$data[3] .= '<td class="datos2">';
|
||||
$data[3] .= html_print_input_text(
|
||||
$data[3] .= html_print_extended_select_for_time(
|
||||
'module_action_threshold',
|
||||
0,
|
||||
'',
|
||||
'',
|
||||
4,
|
||||
10,
|
||||
'',
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
true
|
||||
);
|
||||
$data[3] .= '</td>';
|
||||
|
|
|
@ -177,7 +177,23 @@ $table->data[2][1] .= '<div id="command_description" style=""></div>';
|
|||
$table->colspan[2][1] = 2;
|
||||
|
||||
$table->data[3][0] = __('Threshold');
|
||||
$table->data[3][1] = html_print_input_text('action_threshold', $action_threshold, '', 5, 7, true);
|
||||
$table->data[3][1] = html_print_extended_select_for_time(
|
||||
'action_threshold',
|
||||
$action_threshold,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
true
|
||||
);
|
||||
$table->colspan[3][1] = 2;
|
||||
|
||||
$table->data[4][0] = '';
|
||||
|
|
|
@ -264,12 +264,21 @@ if ($show_update_action_menu) {
|
|||
$data .= __('Threshold');
|
||||
$data .= '</td>';
|
||||
$data .= '<td class="datos2">';
|
||||
$data .= html_print_input_text(
|
||||
$data .= html_print_extended_select_for_time(
|
||||
'module_action_threshold_ajax',
|
||||
$action_option['module_action_threshold'],
|
||||
'',
|
||||
4,
|
||||
10,
|
||||
'',
|
||||
'',
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
true
|
||||
);
|
||||
$data .= '</td>';
|
||||
|
|
|
@ -2503,12 +2503,13 @@ function get_user_dashboards($id_user)
|
|||
/**
|
||||
* Get all the possible periods in seconds.
|
||||
*
|
||||
* @param bool Flag to show or not custom fist option
|
||||
* @param bool Show the periods by default if it is empty
|
||||
* @param boolean $custom Flag to show or not custom fist option
|
||||
* @param boolean $show_default Show the periods by default if it is empty
|
||||
* @param boolean $allow_zero Allow the use of the value zero.
|
||||
*
|
||||
* @return The possible periods in an associative array.
|
||||
* @return array The possible periods in an associative array.
|
||||
*/
|
||||
function get_periods($custom=true, $show_default=true)
|
||||
function get_periods($custom=true, $show_default=true, $allow_zero=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
@ -2520,6 +2521,10 @@ function get_periods($custom=true, $show_default=true)
|
|||
|
||||
if (empty($config['interval_values'])) {
|
||||
if ($show_default) {
|
||||
if ($allow_zero === true) {
|
||||
$periods[0] = sprintf(__('%s seconds'), '0');
|
||||
}
|
||||
|
||||
$periods[SECONDS_5MINUTES] = sprintf(__('%s minutes'), '5');
|
||||
$periods[SECONDS_30MINUTES] = sprintf(__('%s minutes'), '30 ');
|
||||
$periods[SECONDS_1HOUR] = __('1 hour');
|
||||
|
|
|
@ -988,20 +988,24 @@ function html_print_extended_select_for_post_process(
|
|||
/**
|
||||
* Render a pair of select for times and text box for set the time more fine.
|
||||
*
|
||||
* @param string Select form name
|
||||
* @param variant Current selected value. Can be a single value or an
|
||||
* array of selected values (in combination with multiple)
|
||||
* @param string Javascript onChange (select) code.
|
||||
* @param string Label when nothing is selected.
|
||||
* @param variant Value when nothing is selected
|
||||
* @param integer $size Size of the input.
|
||||
* @param bool Whether to return an output string or echo now (optional, echo by default).
|
||||
* @param bool Wherter to assign to combo a unique name (to have more than one on same page, like dashboard)
|
||||
*
|
||||
* @param string $name Select form name
|
||||
* @param variant $selected Current selected value. Can be a single value or an array of selected values (in combination with multiple)
|
||||
* @param string $script Javascript onChange (select) code.
|
||||
* @param string $nothing Label when nothing is selected.
|
||||
* @param variant $nothing_value Value when nothing is selected
|
||||
* @param integer $size Size of the input.
|
||||
* @param boolean $return Whether to return an output string or echo now (optional, echo by default).
|
||||
* @param boolean $select_style Wherter to assign to combo a unique name (to have more than one on same page, like dashboard)
|
||||
* @param boolean $unique_name
|
||||
* @param string $class
|
||||
* @param boolean $readonly
|
||||
* @param string $custom_fields
|
||||
* @param string $style_icon
|
||||
* @param boolean $no_change
|
||||
* @param boolean $allow_zero Allow the use of the value zero.
|
||||
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
|
||||
|
||||
function html_print_extended_select_for_time(
|
||||
$name,
|
||||
$selected='',
|
||||
|
@ -1016,14 +1020,15 @@ function html_print_extended_select_for_time(
|
|||
$readonly=false,
|
||||
$custom_fields=false,
|
||||
$style_icon='',
|
||||
$no_change=false
|
||||
$no_change=false,
|
||||
$allow_zero=false
|
||||
) {
|
||||
global $config;
|
||||
$admin = is_user_admin($config['id_user']);
|
||||
if ($custom_fields) {
|
||||
$fields = $custom_fields;
|
||||
} else {
|
||||
$fields = get_periods();
|
||||
$fields = get_periods(true, true, $allow_zero);
|
||||
}
|
||||
|
||||
if ($no_change) {
|
||||
|
@ -1045,7 +1050,14 @@ function html_print_extended_select_for_time(
|
|||
}
|
||||
}
|
||||
|
||||
if (($selected !== false) && (!isset($fields[$selected]) && $selected != 0)) {
|
||||
// Allow the use of the value zero.
|
||||
if ($allow_zero === true) {
|
||||
$selected_zero = true;
|
||||
} else {
|
||||
$selected_zero = ($selected != 0) ? true : false;
|
||||
}
|
||||
|
||||
if (($selected !== false) && (!isset($fields[$selected]) && $selected_zero)) {
|
||||
$fields[$selected] = human_time_description_raw($selected, true);
|
||||
}
|
||||
|
||||
|
@ -1136,7 +1148,7 @@ function html_print_extended_select_for_time(
|
|||
echo '</div>';
|
||||
echo "<script type='text/javascript'>
|
||||
$(document).ready (function () {
|
||||
period_select_init('$uniq_name');
|
||||
period_select_init('$uniq_name', $allow_zero);
|
||||
period_select_events('$uniq_name');
|
||||
});
|
||||
function period_select_".$name."_update(seconds) {
|
||||
|
|
|
@ -833,8 +833,9 @@ function post_process_select_events(name) {
|
|||
* This function initialize the values of the control
|
||||
*
|
||||
* @param name string with the name of the select for time
|
||||
* @param allow_zero bool Allow the use of the value zero
|
||||
*/
|
||||
function period_select_init(name) {
|
||||
function period_select_init(name, allow_zero) {
|
||||
// Manual mode is hidden by default
|
||||
$("#" + name + "_manual").hide();
|
||||
$("#" + name + "_default").show();
|
||||
|
@ -849,7 +850,7 @@ function period_select_init(name) {
|
|||
} else {
|
||||
$("#" + name + "_select option:eq(1)").prop("selected", true);
|
||||
}
|
||||
} else if ($("#text-" + name + "_text").val() == 0) {
|
||||
} else if ($("#text-" + name + "_text").val() == 0 && allow_zero != true) {
|
||||
$("#" + name + "_units option:last").prop("selected", false);
|
||||
$("#" + name + "_manual").show();
|
||||
$("#" + name + "_default").hide();
|
||||
|
|
Loading…
Reference in New Issue