From 0980c9a74a9e671377cad7f0b81a301343620f63 Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Thu, 16 Jan 2020 13:50:39 +0100 Subject: [PATCH] Ent 5261 cambio de control de intervalo en alertas --- .../godmode/alerts/alert_list.builder.php | 19 +++++++- .../godmode/alerts/alert_list.list.php | 15 +++++-- .../godmode/alerts/configure_alert_action.php | 18 +++++++- .../include/ajax/alert_list.ajax.php | 15 +++++-- pandora_console/include/functions.php | 13 ++++-- pandora_console/include/functions_html.php | 44 ++++++++++++------- pandora_console/include/javascript/pandora.js | 5 ++- 7 files changed, 98 insertions(+), 31 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_list.builder.php b/pandora_console/godmode/alerts/alert_list.builder.php index 545ceefa35..4e9772b6d6 100644 --- a/pandora_console/godmode/alerts/alert_list.builder.php +++ b/pandora_console/godmode/alerts/alert_list.builder.php @@ -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] .= ''.__('seconds').''; + $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 '
'; diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index e567f20716..59b78c9e02 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -734,12 +734,21 @@ foreach ($simple_alerts as $alert) { $data[3] .= __('Threshold'); $data[3] .= ''; $data[3] .= ''; - $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] .= ''; diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index 870a6fafc8..60052e9645 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -177,7 +177,23 @@ $table->data[2][1] .= '
'; $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] = ''; diff --git a/pandora_console/include/ajax/alert_list.ajax.php b/pandora_console/include/ajax/alert_list.ajax.php index 3f724b4e58..4beb9efdfa 100644 --- a/pandora_console/include/ajax/alert_list.ajax.php +++ b/pandora_console/include/ajax/alert_list.ajax.php @@ -264,12 +264,21 @@ if ($show_update_action_menu) { $data .= __('Threshold'); $data .= ''; $data .= ''; - $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 .= ''; diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 08a41a00f2..9684dc1fa6 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -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'); diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index eafea851f7..babe4eb7b3 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -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 ''; echo "