diff --git a/app/js/ui/main.js b/app/js/ui/main.js index 406b3620..c387ea50 100644 --- a/app/js/ui/main.js +++ b/app/js/ui/main.js @@ -582,8 +582,13 @@ $(document) .ready(loadWifiStations()); // To auto-close Bootstrap alerts; time is in milliseconds -window.setTimeout(function() { +const alertTimeout = parseInt(getCookie('alert_timeout'), 10); + +if (!isNaN(alertTimeout) && alertTimeout > 0) { + window.setTimeout(function() { $(".alert").fadeTo(500, 0).slideUp(500, function(){ - $(this).remove(); + $(this).remove(); }); -}, 5000); \ No newline at end of file + }, alertTimeout); +} + diff --git a/includes/system.php b/includes/system.php index 6bc73875..5bace1ef 100755 --- a/includes/system.php +++ b/includes/system.php @@ -12,6 +12,10 @@ function DisplaySystem(&$extraFooterScripts) $dashboard = new \RaspAP\UI\Dashboard; $pluginInstaller = \RaspAP\Plugins\PluginInstaller::getInstance(); + // set defaults + $optAutoclose = true; + $alertTimeout = 5000; + if (isset($_POST['SaveLanguage'])) { if (isset($_POST['locale'])) { $_SESSION['locale'] = $_POST['locale']; @@ -51,6 +55,21 @@ function DisplaySystem(&$extraFooterScripts) $status->addMessage(sprintf(_('Changing log limit size to %s KB'), $_SESSION['log_limit']), 'info'); } } + // Validate alert timout + if (isset($_POST['autoClose'])) { + $alertTimeout = trim($_POST['alertTimeout'] ?? ''); + if (strlen($alertTimeout) > 7 || !is_numeric($alertTimeout)) { + $status->addMessage('Invalid value for alert close timeout', 'danger'); + $good_input = false; + } else { + setcookie('alert_timeout', (int) $alertTimeout); + $status->addMessage(sprintf(_('Changing alert close timeout to %s ms'), $alertTimeout), 'info'); + } + } else { + setcookie('alert_timeout', '', time() - 3600, '/'); + $optAutoclose = false; + } + // Save settings if ($good_input) { exec("sudo /etc/raspap/lighttpd/configport.sh $serverPort $serverBind " .RASPI_LIGHTTPD_CONFIG. " ".$_SERVER['SERVER_NAME'], $return); @@ -155,7 +174,9 @@ function DisplaySystem(&$extraFooterScripts) "themes", "selectedTheme", "logLimit", - "pluginsTable" + "pluginsTable", + "optAutoclose", + "alertTimeout" )); } diff --git a/templates/system/advanced.php b/templates/system/advanced.php index 66612f16..3ea11efc 100644 --- a/templates/system/advanced.php +++ b/templates/system/advanced.php @@ -22,6 +22,22 @@ +