File manager - Edit - /usr/local/cpanel/whostmgr/docroot/templates/mod_security/views/reportController.min.js
Back
define(["angular","cjt/util/locale","uiBootstrap","app/services/reportService","cjt/validator/email-validator","cjt/directives/validationContainerDirective","cjt/directives/validationItemDirective","cjt/directives/spinnerDirective","cjt/filters/wrapFilter","cjt/filters/breakFilter"],(function(angular,LOCALE){angular.module("App").controller("reportController",["$scope","reportService","alertService","$route","$window","$location","spinnerAPI",function($scope,reportService,alertService,$route,$window,$location,spinnerAPI){var view,report;function initialize(){view=$scope.view={step:"input",loading:{init:false,report:false},submitting:false,ruleExpanded:false};report=$scope.report={hits:null,rule:null,inputs:{}};_getReport($route.current.pathParams).then(_updateViewModel)}function _getReport(lookup){view.loading.init=true;var reportPromise=reportService.getCurrent();if(!reportPromise){if(lookup.hitId){reportPromise=reportService.fetchByHit(lookup.hitId)}else if(lookup.ruleId&&lookup.vendorId){reportPromise=reportService.fetchByRule(lookup.ruleId,lookup.vendorId)}else{throw new ReferenceError("Cannot populate the report without a ruleId or hitId.")}}reportPromise.then((function success(response){if(report.invalid){delete report.invalid}report.rule=response.rule;report.hits=response.hits.map((function(hit){hit.included=true;return hit}));view.includedHitCount=report.hits.length}),(function failure(error){report.invalid=true;if(error&&error.message){alertService.add({type:"danger",message:error.message,id:"report-retrieval-error"})}else{alertService.add({type:"danger",message:error,id:"report-retrieval-error"})}})).finally((function(){view.loading.init=false}));return reportPromise}function _updateViewModel(){view.vendorId=report.rule.vendor_id;view.isDisabled={overall:report.rule.disabled||!report.rule.config_active||!report.rule.vendor_active,rule:report.rule.disabled,config:!report.rule.config_active,vendor:!report.rule.vendor_active}}function getTitleText(){return view.vendorId?LOCALE.maketext("Report a [asis,ModSecurity] Rule to [_1]",view.vendorId):LOCALE.maketext("Report a [asis,ModSecurity] Rule")}function isExpanded(hit){return view.expandedHit===hit}function toggleExpandCollapse(hit){view.expandedHit=view.expandedHit===hit?null:hit}function toggleIncludeExclude(hit){if(view.includedHitCount===1){alertService.add({type:"info",message:LOCALE.maketext("You must include at least one hit record with your report."),id:"report-last-hit-info"});return}hit.included=!hit.included;view.includedHitCount--}function _includedHitIds(){var includedHits=[];if(report.hits){report.hits.forEach((function(hit){if(hit.included){includedHits.push(hit.id)}}))}return includedHits}function _consolidateReportInputs(){return{hits:_includedHitIds(),email:report.inputs.email,reason:report.inputs.reason,message:report.inputs.comments}}var destroyed;$scope.$on("$destroy",(function(){destroyed=true}));function changeToTab(tabName){if(!destroyed){if(tabName!=="hitList"){alertService.removeById("report-last-hit-info")}if(tabName==="rawReport"){_updateRawTab()}}}function _includedHitIdsChanged(){var currentIds=_includedHitIds();if(!view.lastIncludedHitIds||currentIds.length!==view.lastIncludedHitIds.length){return false}else{return currentIds.some((function(val,index){return view.lastIncludedHitIds.indexOf(val)===-1}))}}function rawTabIsStale(){return view.form.$dirty||_includedHitIdsChanged()}function _updateRawTab(){if(rawTabIsStale()){view.form.$setPristine();view.lastIncludedHitIds=_includedHitIds();viewReport().then((function(response){report.json=JSON.stringify(response,false,2)}),(function(error){alertService.add({type:"danger",message:error,id:"fetch-generated-report-error"})}))}}function viewReport(){view.loading.report=true;return reportService.viewReport(_consolidateReportInputs()).finally((function(){view.loading.report=false}))}function submitReport(){alertService.clear();view.submitting=true;var promise,disableParams;if(!view.isDisabled.rule&&report.inputs.disableRule){disableParams={deployRule:report.inputs.deployRule,ruleConfig:report.rule.config,ruleId:report.rule.id};promise=reportService.sendReport(_consolidateReportInputs(),disableParams)}else{promise=reportService.sendReport(_consolidateReportInputs())}promise.then((function success(response){alertService.add({type:"success",message:LOCALE.maketext("You have successfully submitted a report for the rule ID “[_1]” to “[_2]”.",report.rule.id,view.vendorId),id:"report-rule-submit-success"});$scope.loadView("hitList")}),(function failure(error){alertService.add({type:"warning",message:error,id:"report-rule-submit-error"})})).finally((function(){view.submitting=false}));return promise}function cancelSubmission(){alertService.clear();if($location.state){$window.history.back()}else if($route.current.pathParams.hitId){$scope.loadView("hitList")}else{$scope.loadView("rulesList")}}function changeStep(newStep){view.step=newStep;if(newStep==="review"&&view.rawReportActive){_updateRawTab()}}angular.extend($scope,{getTitleText:getTitleText,isExpanded:isExpanded,toggleExpandCollapse:toggleExpandCollapse,toggleIncludeExclude:toggleIncludeExclude,changeToTab:changeToTab,viewReport:viewReport,submitReport:submitReport,cancelSubmission:cancelSubmission,changeStep:changeStep,rawTabIsStale:rawTabIsStale});initialize()}]).filter("onlyTrueHitFields",(function(){var EXCLUDED_KEYS=["included","reportable","file_exists"];return function(hitObj){var filteredObj={};angular.forEach(hitObj,(function(val,key){if(EXCLUDED_KEYS.indexOf(key)===-1){filteredObj[key]=val}}));return filteredObj}}))}));
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Generation time: 0.04 |
proxy
|
phpinfo
|
Settings