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->colspan[2][4] = 3;
$table_advanced->data[3][0] = __('Dynamic Threshold Interval');
$table_advanced->data[3][1] = html_print_extended_select_for_time(
'dynamic_interval',
$dynamic_interval,
'',
'None',
__('None'),
'0',
10,
true,

View File

@ -2075,7 +2075,7 @@ function html_print_extended_select_for_time(
$custom_fields=false,
$style_icon='',
$no_change=false,
$allow_zero=false
$allow_zero=0
) {
global $config;
$admin = is_user_admin($config['id_user']);
@ -2089,32 +2089,21 @@ function html_print_extended_select_for_time(
$fields['-2'] = __('No change');
}
if (! $selected) {
foreach ($fields as $t_key => $t_value) {
if ($t_key != -1) {
if ($nothing == '') {
// -1 means 'custom'
$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)) {
if (empty($selected) === false
&& $selected !== '0'
&& isset($fields[$selected]) === false
) {
$allow_zero = false;
$fields[$selected] = human_time_description_raw($selected, true);
}
if (empty($nothing) === true
&& (empty($selected) === true
|| $selected === '0')
) {
$selected = 300;
}
$units = [
1 => __('seconds'),
SECONDS_1MINUTE => __('minutes'),
@ -2180,14 +2169,23 @@ function html_print_extended_select_for_time(
$uniq_name.'_units',
'1',
''.$script,
$nothing,
$nothing_value,
'',
0,
false,
false,
false,
$class,
$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(
'images/list.png',
@ -2202,7 +2200,7 @@ function html_print_extended_select_for_time(
echo '</div>';
echo "<script type='text/javascript'>
$(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."');
});
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
$("#" + name + "_manual").css("display", "none");
$("#" + name + "_default").css("display", "inline");
// If the text input is empty, we put on it 5 minutes by default
if ($("#text-" + name + "_text").val() == "") {
$("#text-" + name + "_text").val(300);
@ -897,7 +896,7 @@ function period_select_init(name, allow_zero) {
} else {
$("#" + 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 + "_manual").css("display", "inline");
$("#" + name + "_default").css("display", "none");
@ -1041,10 +1040,10 @@ function adjustTextUnits(name) {
var restInt = parseInt(rest).toString();
if (rest != restInt && unitsSelected == false) {
$("#" + name + "_units option:eq(" + ($(this).index() - 1) + ")").prop(
"selected",
true
);
var value_selected = $(
"#" + name + "_units option:eq(" + ($(this).index() - 1) + ")"
).val();
$("#" + name + "_units").val(value_selected);
$("#text-" + name + "_text").val(restPrev);
unitsSelected = true;