File manager - Edit - /usr/local/cpanel/whostmgr/docroot/templates/mod_security/views/enableDisableConfigController.min.js
Back
define(["angular","lodash","cjt/util/locale","cjt/util/parse","uiBootstrap","cjt/directives/toggleSortDirective","cjt/directives/spinnerDirective","cjt/directives/autoFocus","cjt/filters/wrapFilter","cjt/filters/breakFilter","cjt/filters/replaceFilter","cjt/directives/actionButtonDirective","cjt/directives/validationItemDirective","cjt/services/alertService","app/services/vendorService"],(function(angular,_,LOCALE,PARSE){var app=angular.module("App");app.controller("enableDisableConfigController",["$scope","$q","$location","$timeout","vendorService","alertService","spinnerAPI",function($scope,$q,$location,$timeout,vendorService,alertService,spinnerAPI){var _initializeView=function(){$scope.filter="";$scope.filterExpression=null;$scope.hasIssues=false;$scope.meta={sortBy:"config",sortDirection:"asc"};_clearIssues();$scope.configs=[]};var _loadVendor=function(){if(!$scope.vendor){_loadVendorFromServer()}else if(!$scope.vendor.configs){_loadVendorFromParent()}};var _loadForceFlag=function(){var value=$location.search().force;if(value){$scope.force=PARSE.parseBoolean(value)}else{$scope.force=false}};var _loadVendorFromServer=function(){_loadForceFlag();var id=$location.search().id;if(id){$scope.fetch(id)}else{alertService.add({type:"danger",message:LOCALE.maketext("The system failed to pass the ID query string parameter."),id:"errorInvalidParameterId"})}};var _loadVendorFromParent=function(){$scope.serverRequest=true;_loadForceFlag();if($scope.$parent.vendor&&$scope.$parent.vendor.configs){$scope.configs=$scope.$parent.vendor.configs;$scope.serverRequest=false;_updateTotals()}};var _updateTotals=function(){var totalEnabled=0;$scope.configs.forEach((function(config){if(config.enabled){totalEnabled++}}));$scope.totalEnabled=totalEnabled;$scope.totalDisabled=$scope.configs.length-totalEnabled};$scope.$watch("filter",(function(newValue,oldValue){if(newValue){newValue=newValue.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");$scope.filterExpression=new RegExp(newValue,"i")}else{$scope.filterExpression=null}}));$scope.filterConfigs=function(value){return $scope.filterExpression?$scope.filterExpression.test(value.config)||value.exception&&$scope.filterExpression.test(value.exception):true};$scope.triggerClearFilter=function(event){if(event.keyCode===27){$scope.clearFilter()}};$scope.clearFilter=function(){$scope.filter=""};$scope.toggleFilter=function(){if($scope.filter){$scope.clearFilter()}};if(!$scope.vendor){$scope.fetch=function(id){$scope.serverRequest=true;spinnerAPI.start("loadingSpinner2");return vendorService.fetchVendorById(id).then((function(vendor){$scope.vendor=vendor;$scope.configs=vendor.configs}),(function(error){alertService.add({type:"danger",message:error,id:"errorFetchRulesList"})})).finally((function(){$scope.serverRequest=false;_updateTotals();spinnerAPI.stop("loadingSpinner2")}))}}$scope.setConfig=function(config){var operation=config.enabled?"enable":"disable";var enabling=operation==="enable";var message=enabling?LOCALE.maketext("You have successfully enabled the configuration file: [_1]",config.config):LOCALE.maketext("You have successfully disabled the configuration file: [_1]",config.config);spinnerAPI.start("loadingSpinner2");config.serverRequest=true;return vendorService[operation+"Config"](config.config).then((function(){_clearIssues();config.enabled=enabling;if(config.exception){delete config.exception}alertService.add({type:"success",message:message,id:operation+"OneSuccess"})}),(function(error){config.enabled=!enabling;config.exception=error})).finally((function(){_updateIssues();_updateTotals();delete config.serverRequest;spinnerAPI.stop("loadingSpinner2")}))};var _updateConfigs=function(configs,outcomes){angular.forEach(outcomes,(function(outcome){var match=_.find(configs,(function(config){return config.config===outcome.config}));match.enabled=outcome.enabled;if(!outcome.ok){match.exception=outcome.exception}else if(match.exception){delete match.exception}}))};var _updateIssues=function(){var match=_.find($scope.configs,(function(config){return!!config.exception}));$scope.hasIssues=typeof match!=="undefined"};$scope.hasIssue=function(config){return!!config.exception};var _clearIssues=function(){delete $scope.hasIssues};$scope.enableAllConfigs=function(){return _modifyAllConfigs("enable")};$scope.disableAllConfigs=function(){return _modifyAllConfigs("disable")};function _modifyAllConfigs(operation){if(operation==="enable"&&$scope.totalDisabled===0||operation==="disable"&&$scope.totalEnabled===0){return}var messages={disable:{success:LOCALE.maketext("You have successfully disabled all of the configuration files."),partial:LOCALE.maketext("You have successfully disabled some of the configuration files. The files that the system failed to disable are marked below."),failure:LOCALE.maketext("The system could not disable the configuration files.")},enable:{success:LOCALE.maketext("You have successfully enabled all of the configuration files."),partial:LOCALE.maketext("You have successfully enabled some of the configuration files. The files that the system failed to enable are marked below."),failure:LOCALE.maketext("The system could not enable the configuration files.")}};spinnerAPI.start("loadingSpinner2");$scope.serverRequest=true;return vendorService[operation+"AllConfigs"]($scope.vendor.vendor_id).then((function(outcomes){_clearIssues();_updateConfigs($scope.configs,outcomes.configs);alertService.add({type:"success",message:messages[operation].success,id:operation+"AllSuccess"})}),(function(outcomes){_clearIssues();if(outcomes.configs.length){_updateConfigs($scope.configs,outcomes.configs);alertService.add({type:"warning",message:messages[operation].partial,id:operation+"AllWarning"})}else{alertService.add({type:"danger",message:messages[operation].failure,id:operation+"AllError"})}})).finally((function(){_updateIssues();_updateTotals();$scope.serverRequest=false;spinnerAPI.stop("loadingSpinner2")}))}$scope.buttonDisabled=function(type,loading){if($scope.serverRequest){return true}switch(type){case"enableAll":return $scope.totalDisabled===0;case"disableAll":return $scope.totalEnabled===0;case"configToggle":return loading}};if($scope.$parent.vendor){$scope.$parent.$watch("vendor.configs",(function(){_loadVendorFromParent()}))}$scope.$on("$viewContentLoaded",(function(){_loadVendor()}));_initializeView()}])}));
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Generation time: 0.04 |
proxy
|
phpinfo
|
Settings