diff --git a/firewall/static/firewall/firewall.js b/firewall/static/firewall/firewall.js index c0a25cf7d..3ecf38322 100644 --- a/firewall/static/firewall/firewall.js +++ b/firewall/static/firewall/firewall.js @@ -1563,4 +1563,165 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) { }); -/* Java script code for ModSec */ \ No newline at end of file +/* Java script code for ModSec */ + + +/* Java script code for CSF */ + +app.controller('csf', function($scope, $http, $timeout, $window) { + + $scope.csfLoading = true; + $scope.modeSecInstallBox = true; + $scope.modsecLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + + + $scope.installCSF = function(){ + + $scope.modSecNotifyBox = true; + $scope.modeSecInstallBox = true; + $scope.modsecLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + url = "/firewall/installCSF"; + + var data = {}; + + var config = { + headers : { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + + $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if(response.data.installStatus === 1){ + + $scope.modSecNotifyBox = true; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + getRequestStatus(); + + } + else{ + $scope.errorMessage = response.data.error_message; + + $scope.modSecNotifyBox = false; + $scope.modeSecInstallBox = true; + $scope.modsecLoading = true; + $scope.failedToStartInallation = false; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + } + + } + function cantLoadInitialDatas(response) { + + $scope.modSecNotifyBox = false; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = false; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + } + + }; + + function getRequestStatus(){ + + $scope.modSecNotifyBox = true; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + url = "/firewall/installStatusCSF"; + + var data = {}; + + var config = { + headers : { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + + $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if(response.data.abort === 0){ + + $scope.modSecNotifyBox = true; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + $scope.requestData = response.data.requestStatus; + $timeout(getRequestStatus,1000); + } + else{ + // Notifications + $timeout.cancel(); + $scope.modSecNotifyBox = false; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + + $scope.requestData = response.data.requestStatus; + + if(response.data.installed === 0) { + $scope.installationFailed = false; + $scope.errorMessage = response.data.error_message; + }else{ + $scope.modSecSuccessfullyInstalled = false; + //$timeout(function() { $window.location.reload(); }, 3000); + } + + } + + } + function cantLoadInitialDatas(response) { + + $scope.modSecNotifyBox = false; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = false; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + + } + + } + +}); \ No newline at end of file diff --git a/firewall/templates/firewall/csf.html b/firewall/templates/firewall/csf.html new file mode 100644 index 000000000..f61849335 --- /dev/null +++ b/firewall/templates/firewall/csf.html @@ -0,0 +1,200 @@ +{% extends "baseTemplate/index.html" %} +{% load i18n %} +{% block title %}{% trans "CSF (ConfigServer Security and Firewall) - CyberPanel" %}{% endblock %} +{% block content %} + +{% load static %} +{% get_current_language as LANGUAGE_CODE %} + + + +
{% trans "On this page you can configure CSF (ConfigServer Security and Firewall) settings." %}
+
+ {% trans "Failed to start installation, Error message: " %} {$ errorMessage $}
+{% trans "Could not connect. Please refresh this page." %}
+{% trans "Installation failed." %} {$ errorMessage $}
+{% trans "CSF successfully installed, refreshing page in 3 seconds.." %}
+