From 6dff0273582522d0b1404bae368cb06ec84c0e6b Mon Sep 17 00:00:00 2001 From: Martin Wasley Date: Sat, 29 Dec 2018 13:01:19 +0000 Subject: [PATCH] Add missing entries to Dpinger advanced section; closes #3077 It's only taken 8 months to do this.. impressive. :) Modified by: @fichtner --- src/etc/inc/gwlb.inc | 8 ++-- src/www/system_gateways_edit.php | 66 +++++++++++++++++++++++++++++--- 2 files changed, 64 insertions(+), 10 deletions(-) diff --git a/src/etc/inc/gwlb.inc b/src/etc/inc/gwlb.inc index b8d56a9fb..a9d3ff366 100644 --- a/src/etc/inc/gwlb.inc +++ b/src/etc/inc/gwlb.inc @@ -33,15 +33,15 @@ function return_dpinger_defaults() { return array( - 'alert_interval' => '1', /* XXX not implemented in GUI */ - 'data_payload' => '0', /* XXX not implemented in GUI */ + 'alert_interval' => '1', + 'data_payload' => '0', /* XXX not implemented in GUI */ 'interval' => '1', 'latencyhigh' => '500', 'latencylow' => '200', - 'loss_interval' => '2', /* XXX not implemented in GUI */ + 'loss_interval' => '2', 'losshigh' => '20', 'losslow' => '10', - 'time_period' => '60', /* XXX not implemented in GUI */ + 'time_period' => '60', ); } diff --git a/src/www/system_gateways_edit.php b/src/www/system_gateways_edit.php index b1c489ab0..0fad3aedd 100644 --- a/src/www/system_gateways_edit.php +++ b/src/www/system_gateways_edit.php @@ -274,6 +274,30 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } } + if (!empty($pconfig['alert_interval'])) { + if (!is_numeric($pconfig['alert_interval'])) { + $input_errors[] = gettext("The alert interval needs to be a numeric value."); + } elseif ($pconfig['alert_interval'] < 1) { + $input_errors[] = gettext("The alert interval needs to be positive."); + } + } + + if (!empty($pconfig['time_period'])) { + if (!is_numeric($pconfig['time_period'])) { + $input_errors[] = gettext("The time period needs to be a numeric value."); + } elseif ($pconfig['time_period'] < 1) { + $input_errors[] = gettext("The time period needs to be positive."); + } + } + + if (!empty($pconfig['loss_interval'])) { + if (!is_numeric($pconfig['loss_interval'])) { + $input_errors[] = gettext("The loss interval needs to be a numeric value."); + } elseif ($pconfig['loss_interval'] < 1) { + $input_errors[] = gettext("The loss interval needs to be positive."); + } + } + if (count($input_errors) == 0) { // A result of obfuscating the list of gateways is that over here we need to map things back that should // be aligned with the configuration. Not going to fix this now. @@ -336,7 +360,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $gateway['defaultgw'] = true; } - foreach (array('latencylow', 'latencyhigh', 'losslow', 'losshigh') as $fieldname) { + foreach (array('alert_interval', 'latencylow', 'latencyhigh', 'loss_interval', 'losslow', 'losshigh', 'time_period') as $fieldname) { if (!empty($pconfig[$fieldname])) { $gateway[$fieldname] = $pconfig[$fieldname]; } @@ -420,6 +444,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { 'monitor_disable', 'name', 'weight', + 'alert_interval', + 'time_period', + 'loss_interval', ); foreach ($copy_fields as $fieldname) { if (isset($configId) && isset($a_gateways[$configId][$fieldname])) { @@ -453,7 +480,7 @@ $( document ).ready(function() { // (un)hide advanced on form load when any advanced setting is provided 1) || (!empty($pconfig['interval']) && ($pconfig['interval'] > $dpinger_default['interval'])))): ?> + if ((!empty($pconfig['latencylow']) || !empty($pconfig['latencyhigh']) || !empty($pconfig['losslow']) || !empty($pconfig['losshigh']) || (isset($pconfig['weight']) && $pconfig['weight'] > 1) || (!empty($pconfig['interval']) && ($pconfig['interval'] > $dpinger_default['interval'])) || (!empty($pconfig['alert_interval']) && ($pconfig['alert_interval'] > $dpinger_default['alert_interval'])) || (!empty($pconfig['time_period']) && ($pconfig['time_period'] > $dpinger_default['time_period'])) || (!empty($pconfig['loss_interval']) && ($pconfig['loss_interval'] > $dpinger_default['loss_interval'])))): ?> $("#btn_advanced").click(); @@ -488,8 +515,8 @@ $( document ).ready(function() { /> + @@ -585,8 +612,8 @@ $( document ).ready(function() { " size="28" /> +