Merge remote-tracking branch 'origin/develop' into new-vc-line-element

This commit is contained in:
Daniel Barbero Martin 2020-01-16 14:08:07 +01:00
commit d5e21499c2
8 changed files with 104 additions and 37 deletions

View File

@ -163,8 +163,23 @@ if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) {
} }
$table->data[3][0] = __('Threshold'); $table->data[3][0] = __('Threshold');
$table->data[3][1] = html_print_input_text('module_action_threshold', '0', '', 5, 7, true); $table->data[3][1] = html_print_extended_select_for_time(
$table->data[3][1] .= '<span style="margin-left:0.5em;">'.__('seconds').'</span>'; 'module_action_threshold',
0,
'',
'',
'',
false,
true,
false,
true,
'',
false,
false,
'',
false,
true
);
if (!isset($step)) { if (!isset($step)) {
echo '<form class="add_alert_form" method="post">'; echo '<form class="add_alert_form" method="post">';

View File

@ -734,12 +734,21 @@ foreach ($simple_alerts as $alert) {
$data[3] .= __('Threshold'); $data[3] .= __('Threshold');
$data[3] .= '</td>'; $data[3] .= '</td>';
$data[3] .= '<td class="datos2">'; $data[3] .= '<td class="datos2">';
$data[3] .= html_print_input_text( $data[3] .= html_print_extended_select_for_time(
'module_action_threshold', 'module_action_threshold',
0,
'', '',
'', '',
4, '',
10, false,
true,
false,
true,
'',
false,
false,
'',
false,
true true
); );
$data[3] .= '</td>'; $data[3] .= '</td>';

View File

@ -177,7 +177,23 @@ $table->data[2][1] .= '<div id="command_description" style=""></div>';
$table->colspan[2][1] = 2; $table->colspan[2][1] = 2;
$table->data[3][0] = __('Threshold'); $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->colspan[3][1] = 2;
$table->data[4][0] = ''; $table->data[4][0] = '';

View File

@ -264,12 +264,21 @@ if ($show_update_action_menu) {
$data .= __('Threshold'); $data .= __('Threshold');
$data .= '</td>'; $data .= '</td>';
$data .= '<td class="datos2">'; $data .= '<td class="datos2">';
$data .= html_print_input_text( $data .= html_print_extended_select_for_time(
'module_action_threshold_ajax', 'module_action_threshold_ajax',
$action_option['module_action_threshold'], $action_option['module_action_threshold'],
'', '',
4, '',
10, '',
false,
true,
false,
true,
'',
false,
false,
'',
false,
true true
); );
$data .= '</td>'; $data .= '</td>';

View File

@ -2503,12 +2503,13 @@ function get_user_dashboards($id_user)
/** /**
* Get all the possible periods in seconds. * Get all the possible periods in seconds.
* *
* @param bool Flag to show or not custom fist option * @param boolean $custom Flag to show or not custom fist option
* @param bool Show the periods by default if it is empty * @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; global $config;
@ -2520,6 +2521,10 @@ function get_periods($custom=true, $show_default=true)
if (empty($config['interval_values'])) { if (empty($config['interval_values'])) {
if ($show_default) { if ($show_default) {
if ($allow_zero === true) {
$periods[0] = sprintf(__('%s seconds'), '0');
}
$periods[SECONDS_5MINUTES] = sprintf(__('%s minutes'), '5'); $periods[SECONDS_5MINUTES] = sprintf(__('%s minutes'), '5');
$periods[SECONDS_30MINUTES] = sprintf(__('%s minutes'), '30 '); $periods[SECONDS_30MINUTES] = sprintf(__('%s minutes'), '30 ');
$periods[SECONDS_1HOUR] = __('1 hour'); $periods[SECONDS_1HOUR] = __('1 hour');

View File

@ -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. * Render a pair of select for times and text box for set the time more fine.
* *
* @param string Select form name * @param string $name Select form name
* @param variant Current selected value. Can be a single value or an * @param variant $selected Current selected value. Can be a single value or an array of selected values (in combination with multiple)
* array of selected values (in combination with multiple) * @param string $script Javascript onChange (select) code.
* @param string Javascript onChange (select) code. * @param string $nothing Label when nothing is selected.
* @param string Label when nothing is selected. * @param variant $nothing_value Value when nothing is selected
* @param variant Value when nothing is selected * @param integer $size Size of the input.
* @param integer $size Size of the input. * @param boolean $return Whether to return an output string or echo now (optional, echo by default).
* @param bool 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 bool 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. * @return string HTML code if return parameter is true.
*/ */
function html_print_extended_select_for_time( function html_print_extended_select_for_time(
$name, $name,
$selected='', $selected='',
@ -1016,14 +1020,15 @@ function html_print_extended_select_for_time(
$readonly=false, $readonly=false,
$custom_fields=false, $custom_fields=false,
$style_icon='', $style_icon='',
$no_change=false $no_change=false,
$allow_zero=false
) { ) {
global $config; global $config;
$admin = is_user_admin($config['id_user']); $admin = is_user_admin($config['id_user']);
if ($custom_fields) { if ($custom_fields) {
$fields = $custom_fields; $fields = $custom_fields;
} else { } else {
$fields = get_periods(); $fields = get_periods(true, true, $allow_zero);
} }
if ($no_change) { 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); $fields[$selected] = human_time_description_raw($selected, true);
} }
@ -1136,7 +1148,7 @@ function html_print_extended_select_for_time(
echo '</div>'; echo '</div>';
echo "<script type='text/javascript'> echo "<script type='text/javascript'>
$(document).ready (function () { $(document).ready (function () {
period_select_init('$uniq_name'); period_select_init('$uniq_name', $allow_zero);
period_select_events('$uniq_name'); period_select_events('$uniq_name');
}); });
function period_select_".$name."_update(seconds) { function period_select_".$name."_update(seconds) {

View File

@ -833,8 +833,9 @@ function post_process_select_events(name) {
* This function initialize the values of the control * This function initialize the values of the control
* *
* @param name string with the name of the select for time * @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 // Manual mode is hidden by default
$("#" + name + "_manual").hide(); $("#" + name + "_manual").hide();
$("#" + name + "_default").show(); $("#" + name + "_default").show();
@ -849,7 +850,7 @@ function period_select_init(name) {
} else { } else {
$("#" + name + "_select option:eq(1)").prop("selected", true); $("#" + 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 + "_units option:last").prop("selected", false);
$("#" + name + "_manual").show(); $("#" + name + "_manual").show();
$("#" + name + "_default").hide(); $("#" + name + "_default").hide();

View File

@ -1447,7 +1447,7 @@ sub cloud_scan($) {
} else { } else {
# Unrecognized task type. # Unrecognized task type.
call('message', 'Unrecognized task type', 1); $self->call('message', 'Unrecognized task type', 1);
$self->call('update_progress', -1); $self->call('update_progress', -1);
return; return;
} }
@ -1469,7 +1469,7 @@ sub cloud_scan($) {
if (!$cloudObj) { if (!$cloudObj) {
# Failed to initialize, check Cloud credentials or anything. # Failed to initialize, check Cloud credentials or anything.
call('message', 'Unable to initialize PandoraFMS::Recon::Cloud::'.$type, 3); $self->call('message', 'Unable to initialize PandoraFMS::Recon::Cloud::'.$type, 3);
} else { } else {
# Let Cloud object manage scan. # Let Cloud object manage scan.
@ -1581,7 +1581,7 @@ sub app_scan($) {
$type = 'SAP'; $type = 'SAP';
} else { } else {
# Unrecognized task type. # Unrecognized task type.
call('message', 'Unrecognized task type', 1); $self->call('message', 'Unrecognized task type', 1);
$self->call('update_progress', -1); $self->call('update_progress', -1);
return; return;
} }
@ -1607,7 +1607,7 @@ sub app_scan($) {
$self->{'c_network_percent'} = 0; $self->{'c_network_percent'} = 0;
# Send message # Send message
call('message', 'Checking target ' . $target, 10); $self->call('message', 'Checking target ' . $target, 10);
# Force target acquirement. # Force target acquirement.
$self->{'task_data'}->{'dbhost'} = $target; $self->{'task_data'}->{'dbhost'} = $target;
@ -1633,7 +1633,7 @@ sub app_scan($) {
# Verify if object is connected. If cannot connect to current target # Verify if object is connected. If cannot connect to current target
# return with module. # return with module.
if (!$obj->is_connected()) { if (!$obj->is_connected()) {
call('message', 'Cannot connect to target ' . $target, 3); $self->call('message', 'Cannot connect to target ' . $target, 3);
$global_percent += $global_step; $global_percent += $global_step;
$self->{'c_network_percent'} = 90; $self->{'c_network_percent'} = 90;
@ -1739,7 +1739,7 @@ sub deploy_scan($) {
if (!$deployer) { if (!$deployer) {
# Failed to initialize, check Cloud credentials or anything. # Failed to initialize, check Cloud credentials or anything.
call('message', 'Unable to initialize PandoraFMS::Recon::Deployer', 3); $self->call('message', 'Unable to initialize PandoraFMS::Recon::Deployer', 3);
} else { } else {
# Let deployer object manage scan. # Let deployer object manage scan.