Fix OWASP toggle: ensure flags reset and prevent loader on page load

1. Move flag reset outside conditional blocks - flags now always reset
   even if ModSecurity is not installed or AJAX fails
2. Reset flags in error handler (cantLoadInitialDatas) as well
3. Add showLoader parameter to getOWASPAndComodoStatus - loader only
   shows when explicitly requested, not during initial status check

This fixes:
- Toggle not responding to clicks (flags were stuck as true)
- Spinner showing on initial page load (now only shows during install)
This commit is contained in:
usmannasir
2025-11-26 22:09:43 +05:00
parent f0ed6aaff1
commit 9a1ebccbc6

View File

@@ -1278,9 +1278,12 @@ app.controller('modSecRulesPack', function ($scope, $http, $timeout, $window) {
getOWASPAndComodoStatus(true);
function getOWASPAndComodoStatus(updateToggle) {
function getOWASPAndComodoStatus(updateToggle, showLoader) {
$scope.modsecLoading = false;
// Only show loader if explicitly requested (during installations)
if (showLoader === true) {
$scope.modsecLoading = false;
}
url = "/firewall/getOWASPAndComodoStatus";
@@ -1324,12 +1327,6 @@ app.controller('modSecRulesPack', function ($scope, $http, $timeout, $window) {
$scope.comodoDisable = true;
}
// Reset flags after toggle update
$timeout(function() {
updatingOWASPStatus = false;
updatingComodoStatus = false;
}, 100);
} else {
if (response.data.owaspInstalled === 1) {
@@ -1346,10 +1343,19 @@ app.controller('modSecRulesPack', function ($scope, $http, $timeout, $window) {
}
// Always reset flags after status check completes
$timeout(function() {
updatingOWASPStatus = false;
updatingComodoStatus = false;
}, 100);
}
function cantLoadInitialDatas(response) {
$scope.modsecLoading = true;
// Reset flags even on error
updatingOWASPStatus = false;
updatingComodoStatus = false;
}
}