ent 9467 warning and critical thresholds

This commit is contained in:
edu.corral 2022-09-28 15:02:11 +02:00
parent 3ec710a62f
commit b43d548312
3 changed files with 32 additions and 36 deletions

View File

@ -669,13 +669,12 @@ $table_advanced->data[2][3] = __('Max. Value');
$table_advanced->data[2][4] = html_print_input_text('max', $max, '', 5, 15, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy); $table_advanced->data[2][4] = html_print_input_text('max', $max, '', 5, 15, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy);
$table_advanced->colspan[2][4] = 3; $table_advanced->colspan[2][4] = 3;
$table_advanced->data[3][0] = __('Dynamic Threshold Interval'); $table_advanced->data[3][0] = __('Dynamic Threshold Interval');
$table_advanced->data[3][1] = html_print_extended_select_for_time( $table_advanced->data[3][1] = html_print_extended_select_for_time(
'dynamic_interval', 'dynamic_interval',
$dynamic_interval, $dynamic_interval,
'', '',
'None', __('None'),
'0', '0',
10, 10,
true, true,

View File

@ -2075,7 +2075,7 @@ function html_print_extended_select_for_time(
$custom_fields=false, $custom_fields=false,
$style_icon='', $style_icon='',
$no_change=false, $no_change=false,
$allow_zero=false $allow_zero=0
) { ) {
global $config; global $config;
$admin = is_user_admin($config['id_user']); $admin = is_user_admin($config['id_user']);
@ -2089,32 +2089,21 @@ function html_print_extended_select_for_time(
$fields['-2'] = __('No change'); $fields['-2'] = __('No change');
} }
if (! $selected) { if (empty($selected) === false
foreach ($fields as $t_key => $t_value) { && $selected !== '0'
if ($t_key != -1) { && isset($fields[$selected]) === false
if ($nothing == '') { ) {
// -1 means 'custom' $allow_zero = false;
$selected = $t_key;
break;
} else {
$selected = $nothing;
break;
}
}
}
}
// 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);
} }
if (empty($nothing) === true
&& (empty($selected) === true
|| $selected === '0')
) {
$selected = 300;
}
$units = [ $units = [
1 => __('seconds'), 1 => __('seconds'),
SECONDS_1MINUTE => __('minutes'), SECONDS_1MINUTE => __('minutes'),
@ -2180,14 +2169,23 @@ function html_print_extended_select_for_time(
$uniq_name.'_units', $uniq_name.'_units',
'1', '1',
''.$script, ''.$script,
$nothing, '',
$nothing_value, 0,
false, false,
false, false,
false, false,
$class, $class,
$readonly, $readonly,
'font-size: xx-small;'.$select_style 'padding: 7px 3px;'.$select_style,
false,
false,
false,
'',
false,
false,
false,
false,
false
); );
echo ' <a href="javascript:">'.html_print_image( echo ' <a href="javascript:">'.html_print_image(
'images/list.png', 'images/list.png',
@ -2202,7 +2200,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."', ".(($allow_zero) ? 'true' : 'null')."); period_select_init('".$uniq_name."', ".(($allow_zero) ? 1 : 0).");
period_select_events('".$uniq_name."'); period_select_events('".$uniq_name."');
}); });
function period_select_".$name."_update(seconds) { function period_select_".$name."_update(seconds) {

View File

@ -886,7 +886,6 @@ function period_select_init(name, allow_zero) {
// Manual mode is hidden by default // Manual mode is hidden by default
$("#" + name + "_manual").css("display", "none"); $("#" + name + "_manual").css("display", "none");
$("#" + name + "_default").css("display", "inline"); $("#" + name + "_default").css("display", "inline");
// If the text input is empty, we put on it 5 minutes by default // If the text input is empty, we put on it 5 minutes by default
if ($("#text-" + name + "_text").val() == "") { if ($("#text-" + name + "_text").val() == "") {
$("#text-" + name + "_text").val(300); $("#text-" + name + "_text").val(300);
@ -897,7 +896,7 @@ function period_select_init(name, allow_zero) {
} 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 && allow_zero != true) { } else if ($("#text-" + name + "_text").val() == 0 && allow_zero == 1) {
$("#" + name + "_units option:last").prop("selected", false); $("#" + name + "_units option:last").prop("selected", false);
$("#" + name + "_manual").css("display", "inline"); $("#" + name + "_manual").css("display", "inline");
$("#" + name + "_default").css("display", "none"); $("#" + name + "_default").css("display", "none");
@ -1041,10 +1040,10 @@ function adjustTextUnits(name) {
var restInt = parseInt(rest).toString(); var restInt = parseInt(rest).toString();
if (rest != restInt && unitsSelected == false) { if (rest != restInt && unitsSelected == false) {
$("#" + name + "_units option:eq(" + ($(this).index() - 1) + ")").prop( var value_selected = $(
"selected", "#" + name + "_units option:eq(" + ($(this).index() - 1) + ")"
true ).val();
); $("#" + name + "_units").val(value_selected);
$("#text-" + name + "_text").val(restPrev); $("#text-" + name + "_text").val(restPrev);
unitsSelected = true; unitsSelected = true;