mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 06:16:08 +01:00
complete mailscanner
This commit is contained in:
@@ -60,6 +60,7 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<!--[if IE]><meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'><![endif]-->
|
||||
<title>{% block title %}Page Title{% endblock %}</title>
|
||||
@@ -72,7 +73,20 @@
|
||||
<script src="https://code.angularjs.org/1.6.5/angular.min.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'baseTemplate/assets/finalBase/finalBase.css' %}"
|
||||
<!-- HELPERS -->
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'baseTemplate/assets/finalBase/finalBase.css' %}">
|
||||
|
||||
<!-- ELEMENTS -->
|
||||
|
||||
<!-- ICONS -->
|
||||
|
||||
<!-- WIDGETS -->
|
||||
|
||||
<!-- SNIPPETS -->
|
||||
|
||||
<!-- APPLICATIONS -->
|
||||
<!-- Admin theme -->
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'baseTemplate/assets/finalBase/finalBaseTheme.css' %}">
|
||||
|
||||
|
||||
@@ -1287,4 +1287,287 @@ app.controller('mailQueue', function($scope,$http) {
|
||||
};
|
||||
});
|
||||
|
||||
/* Java script code to manage mail queue ends here */
|
||||
/* Java script code to manage mail queue ends here */
|
||||
|
||||
app.controller('MailScanner', function($scope, $http, $timeout, $window) {
|
||||
|
||||
$scope.SpamAssassinNotifyBox = true;
|
||||
$scope.SpamAssassinInstallBox = true;
|
||||
$scope.SpamAssassinLoading = true;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.SpamAssassinSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
|
||||
|
||||
$scope.installSpamAssassin = function(){
|
||||
|
||||
$scope.SpamAssassinNotifyBox = true;
|
||||
$scope.SpamAssassinInstallBox = true;
|
||||
$scope.SpamAssassinLoading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.SpamAssassinSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
url = "/emailPremium/installMailScanner";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.status === 1){
|
||||
|
||||
$scope.SpamAssassinNotifyBox = true;
|
||||
$scope.SpamAssassinInstallBox = false;
|
||||
$scope.SpamAssassinLoading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.SpamAssassinSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
getRequestStatus();
|
||||
|
||||
}
|
||||
else{
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
$scope.SpamAssassinNotifyBox = false;
|
||||
$scope.SpamAssassinInstallBox = true;
|
||||
$scope.SpamAssassinLoading = true;
|
||||
$scope.failedToStartInallation = false;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.SpamAssassinSuccessfullyInstalled = true;
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.SpamAssassinNotifyBox = false;
|
||||
$scope.SpamAssassinInstallBox = false;
|
||||
$scope.SpamAssassinLoading = true;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.SpamAssassinSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function getRequestStatus(){
|
||||
|
||||
$scope.SpamAssassinNotifyBox = true;
|
||||
$scope.SpamAssassinInstallBox = false;
|
||||
$scope.SpamAssassinLoading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.SpamAssassinSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
url = "/emailPremium/installStatusSpamAssassin";
|
||||
|
||||
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.SpamAssassinNotifyBox = true;
|
||||
$scope.SpamAssassinInstallBox = false;
|
||||
$scope.SpamAssassinLoading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.SpamAssassinSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
$timeout(getRequestStatus,1000);
|
||||
}
|
||||
else{
|
||||
// Notifications
|
||||
$timeout.cancel();
|
||||
$scope.SpamAssassinNotifyBox = false;
|
||||
$scope.SpamAssassinInstallBox = false;
|
||||
$scope.SpamAssassinLoading = 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.SpamAssassinSuccessfullyInstalled = false;
|
||||
$timeout(function() { $window.location.reload(); }, 3000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.SpamAssassinNotifyBox = false;
|
||||
$scope.SpamAssassinInstallBox = false;
|
||||
$scope.SpamAssassinLoading = true;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.SpamAssassinSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///// SpamAssassin configs
|
||||
|
||||
var report_safe = false;
|
||||
|
||||
|
||||
$('#report_safe').change(function() {
|
||||
report_safe = $(this).prop('checked');
|
||||
});
|
||||
|
||||
fetchSpamAssassinSettings();
|
||||
function fetchSpamAssassinSettings(){
|
||||
|
||||
$scope.SpamAssassinLoading = false;
|
||||
|
||||
$('#report_safe').bootstrapToggle('off');
|
||||
|
||||
url = "/emailPremium/fetchSpamAssassinSettings";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
$scope.SpamAssassinLoading = true;
|
||||
|
||||
if(response.data.fetchStatus === 1){
|
||||
|
||||
if(response.data.installed === 1) {
|
||||
|
||||
if (response.data.report_safe === 1) {
|
||||
$('#report_safe').bootstrapToggle('on');
|
||||
}
|
||||
|
||||
$scope.required_hits = response.data.required_hits;
|
||||
$scope.rewrite_header = response.data.rewrite_header;
|
||||
$scope.required_score = response.data.required_score;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.SpamAssassinLoading = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/////
|
||||
|
||||
/// Save SpamAssassin Changes
|
||||
|
||||
$scope.failedToSave = true;
|
||||
$scope.successfullySaved = true;
|
||||
|
||||
$scope.saveSpamAssassinConfigurations = function () {
|
||||
|
||||
$scope.failedToSave = true;
|
||||
$scope.successfullySaved = true;
|
||||
$scope.SpamAssassinLoading = false;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
url = "/emailPremium/saveSpamAssassinConfigurations";
|
||||
|
||||
var data = {
|
||||
report_safe:report_safe,
|
||||
required_hits:$scope.required_hits,
|
||||
rewrite_header:$scope.rewrite_header,
|
||||
required_score:$scope.required_score
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.saveStatus === 1){
|
||||
|
||||
$scope.failedToSave = true;
|
||||
$scope.successfullySaved = false;
|
||||
$scope.SpamAssassinLoading = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
}
|
||||
else{
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
$scope.failedToSave = false;
|
||||
$scope.successfullySaved = true;
|
||||
$scope.SpamAssassinLoading = true;
|
||||
$scope.couldNotConnect = true;
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.failedToSave = true;
|
||||
$scope.successfullySaved = false;
|
||||
$scope.SpamAssassinLoading = true;
|
||||
$scope.couldNotConnect = true;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
@@ -17,7 +17,7 @@
|
||||
<div ng-controller="MailScanner" class="example-box-wrapper">
|
||||
<div class="panel panel-body">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "SpamAssassin" %} <img ng-hide="SpamAssassinLoading" src="/static/images/loading.gif">
|
||||
{% trans "MailScanner" %} <img ng-hide="SpamAssassinLoading" src="/static/images/loading.gif">
|
||||
</h3>
|
||||
|
||||
<div class="content-box-wrapper">
|
||||
@@ -66,7 +66,7 @@
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 text-center">
|
||||
<h3><img
|
||||
src="{% static 'firewall/icons/firewall.png' %}"> {% trans "Winter is coming, but so is SpamAssassin." %}
|
||||
src="{% static 'firewall/icons/firewall.png' %}"> {% trans "Winter is coming, but so is MailScanner." %}
|
||||
<img ng-hide="SpamAssassinLoading" src="/static/images/loading.gif">
|
||||
</h3>
|
||||
</div>
|
||||
@@ -83,12 +83,13 @@
|
||||
{% else %}
|
||||
|
||||
<div class="col-md-12 text-center" style="margin-bottom: 2%;">
|
||||
<h4 class="mb-10">{% trans "MailScanner is not installed " %}
|
||||
<h4 class="mb-10">{% trans "MailScanner is installed. " %}
|
||||
</h4>
|
||||
<button ng-click="installSpamAssassin()" class="btn btn-alt btn-hover btn-blue-alt">
|
||||
<span>{% trans "Install Now." %}</span>
|
||||
<a href="https://{{ ipAddress }}:8090/mailwatch/mailscanner/">
|
||||
<button class="btn btn-alt btn-hover btn-blue-alt">
|
||||
<span>{% trans "Access Now." %}</span>
|
||||
<i class="glyph-icon icon-arrow-right"></i>
|
||||
</button>
|
||||
</button></a>
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
||||
@@ -39,6 +39,7 @@ urlpatterns = [
|
||||
url(r'^flushQueue$', views.flushQueue, name='flushQueue'),
|
||||
url(r'^delete$', views.delete, name='delete'),
|
||||
url(r'^MailScanner$', views.MailScanner, name='MailScanner'),
|
||||
url(r'^installMailScanner$', views.installMailScanner, name='installMailScanner'),
|
||||
|
||||
url(r'^(?P<domain>(.*))$', views.emailLimits, name='emailLimits'),
|
||||
|
||||
|
||||
@@ -1182,10 +1182,42 @@ def MailScanner(request):
|
||||
|
||||
checkIfMailScannerInstalled = 0
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
|
||||
if mailUtilities.checkIfMailScannerInstalled() == 1:
|
||||
checkIfMailScannerInstalled = 1
|
||||
|
||||
return render(request, 'emailPremium/MailScanner.html',{'checkIfMailScannerInstalled': checkIfMailScannerInstalled})
|
||||
|
||||
return render(request, 'emailPremium/MailScanner.html',{'checkIfMailScannerInstalled': checkIfMailScannerInstalled, 'ipAddress': ipAddress})
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def installMailScanner(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
try:
|
||||
|
||||
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/mailUtilities.py"
|
||||
execPath = execPath + " installMailScanner"
|
||||
ProcessUtilities.popenExecutioner(execPath)
|
||||
|
||||
final_json = json.dumps({'status': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
except BaseException as msg:
|
||||
final_dic = {'status': 0, 'error_message': str(msg)}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
except KeyError:
|
||||
final_dic = {'status': 0, 'error_message': "Not Logged In, please refresh the page or login again."}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
@@ -449,6 +449,9 @@ milter_default_action = accept
|
||||
def installSpamAssassin(install, SpamAssassin):
|
||||
try:
|
||||
|
||||
if os.path.exists(mailUtilities.spamassassinInstallLogPath):
|
||||
os.remove(mailUtilities.spamassassinInstallLogPath)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'sudo yum install spamassassin -y'
|
||||
else:
|
||||
@@ -477,6 +480,51 @@ milter_default_action = accept
|
||||
writeToFile.close()
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installSpamAssassin]")
|
||||
|
||||
@staticmethod
|
||||
def installMailScanner(install, SpamAssassin):
|
||||
try:
|
||||
|
||||
if os.path.exists(mailUtilities.spamassassinInstallLogPath):
|
||||
os.remove(mailUtilities.spamassassinInstallLogPath)
|
||||
|
||||
if mailUtilities.checkIfSpamAssassinInstalled():
|
||||
|
||||
command = 'chmod +x /usr/local/CyberCP/CPScripts/mailscannerinstaller.sh'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
|
||||
command = '/usr/local/CyberCP/CPScripts/mailscannerinstaller.sh'
|
||||
|
||||
cmd = shlex.split(command)
|
||||
|
||||
with open(mailUtilities.spamassassinInstallLogPath, 'w') as f:
|
||||
res = subprocess.call(cmd, stdout=f)
|
||||
|
||||
if res == 1:
|
||||
writeToFile = open(mailUtilities.spamassassinInstallLogPath, 'a')
|
||||
writeToFile.writelines("Can not be installed.[404]\n")
|
||||
writeToFile.close()
|
||||
logging.CyberCPLogFileWriter.writeToFile("[Could not Install MailScanner.]")
|
||||
return 0
|
||||
else:
|
||||
writeToFile = open(mailUtilities.spamassassinInstallLogPath, 'a')
|
||||
writeToFile.writelines("MailScanner Installed.[200]\n")
|
||||
writeToFile.close()
|
||||
|
||||
return 1
|
||||
else:
|
||||
writeToFile = open(mailUtilities.spamassassinInstallLogPath, 'a')
|
||||
writeToFile.writelines("Please install SpamAssassin from CyberPanel before installing MailScanner.[404]\n")
|
||||
writeToFile.close()
|
||||
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
writeToFile = open(mailUtilities.spamassassinInstallLogPath, 'a')
|
||||
writeToFile.writelines("Can not be installed.[404]\n")
|
||||
writeToFile.close()
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installSpamAssassin]")
|
||||
|
||||
@staticmethod
|
||||
def checkIfSpamAssassinInstalled():
|
||||
try:
|
||||
@@ -670,7 +718,7 @@ milter_default_action = accept
|
||||
def checkIfMailScannerInstalled():
|
||||
try:
|
||||
|
||||
path = "/usr/local/CyberCP/public/mailscanner"
|
||||
path = "/usr/local/CyberCP/public/mailwatch"
|
||||
|
||||
if os .path.exists(path):
|
||||
return 1
|
||||
@@ -711,6 +759,8 @@ def main():
|
||||
mailUtilities.savePolicyServerStatus(args.install)
|
||||
elif args.function == 'installSpamAssassin':
|
||||
mailUtilities.installSpamAssassin("install", "SpamAssassin")
|
||||
elif args.function == 'installMailScanner':
|
||||
mailUtilities.installMailScanner("install", "installMailScanner")
|
||||
elif args.function == 'AfterEffects':
|
||||
mailUtilities.AfterEffects(args.domain)
|
||||
|
||||
|
||||
@@ -1287,4 +1287,287 @@ app.controller('mailQueue', function($scope,$http) {
|
||||
};
|
||||
});
|
||||
|
||||
/* Java script code to manage mail queue ends here */
|
||||
/* Java script code to manage mail queue ends here */
|
||||
|
||||
app.controller('MailScanner', function($scope, $http, $timeout, $window) {
|
||||
|
||||
$scope.SpamAssassinNotifyBox = true;
|
||||
$scope.SpamAssassinInstallBox = true;
|
||||
$scope.SpamAssassinLoading = true;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.SpamAssassinSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
|
||||
|
||||
$scope.installSpamAssassin = function(){
|
||||
|
||||
$scope.SpamAssassinNotifyBox = true;
|
||||
$scope.SpamAssassinInstallBox = true;
|
||||
$scope.SpamAssassinLoading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.SpamAssassinSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
url = "/emailPremium/installMailScanner";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.status === 1){
|
||||
|
||||
$scope.SpamAssassinNotifyBox = true;
|
||||
$scope.SpamAssassinInstallBox = false;
|
||||
$scope.SpamAssassinLoading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.SpamAssassinSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
getRequestStatus();
|
||||
|
||||
}
|
||||
else{
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
$scope.SpamAssassinNotifyBox = false;
|
||||
$scope.SpamAssassinInstallBox = true;
|
||||
$scope.SpamAssassinLoading = true;
|
||||
$scope.failedToStartInallation = false;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.SpamAssassinSuccessfullyInstalled = true;
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.SpamAssassinNotifyBox = false;
|
||||
$scope.SpamAssassinInstallBox = false;
|
||||
$scope.SpamAssassinLoading = true;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.SpamAssassinSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function getRequestStatus(){
|
||||
|
||||
$scope.SpamAssassinNotifyBox = true;
|
||||
$scope.SpamAssassinInstallBox = false;
|
||||
$scope.SpamAssassinLoading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.SpamAssassinSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
url = "/emailPremium/installStatusSpamAssassin";
|
||||
|
||||
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.SpamAssassinNotifyBox = true;
|
||||
$scope.SpamAssassinInstallBox = false;
|
||||
$scope.SpamAssassinLoading = false;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.SpamAssassinSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
$scope.requestData = response.data.requestStatus;
|
||||
$timeout(getRequestStatus,1000);
|
||||
}
|
||||
else{
|
||||
// Notifications
|
||||
$timeout.cancel();
|
||||
$scope.SpamAssassinNotifyBox = false;
|
||||
$scope.SpamAssassinInstallBox = false;
|
||||
$scope.SpamAssassinLoading = 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.SpamAssassinSuccessfullyInstalled = false;
|
||||
$timeout(function() { $window.location.reload(); }, 3000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.SpamAssassinNotifyBox = false;
|
||||
$scope.SpamAssassinInstallBox = false;
|
||||
$scope.SpamAssassinLoading = true;
|
||||
$scope.failedToStartInallation = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.SpamAssassinSuccessfullyInstalled = true;
|
||||
$scope.installationFailed = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///// SpamAssassin configs
|
||||
|
||||
var report_safe = false;
|
||||
|
||||
|
||||
$('#report_safe').change(function() {
|
||||
report_safe = $(this).prop('checked');
|
||||
});
|
||||
|
||||
fetchSpamAssassinSettings();
|
||||
function fetchSpamAssassinSettings(){
|
||||
|
||||
$scope.SpamAssassinLoading = false;
|
||||
|
||||
$('#report_safe').bootstrapToggle('off');
|
||||
|
||||
url = "/emailPremium/fetchSpamAssassinSettings";
|
||||
|
||||
var data = {};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
$scope.SpamAssassinLoading = true;
|
||||
|
||||
if(response.data.fetchStatus === 1){
|
||||
|
||||
if(response.data.installed === 1) {
|
||||
|
||||
if (response.data.report_safe === 1) {
|
||||
$('#report_safe').bootstrapToggle('on');
|
||||
}
|
||||
|
||||
$scope.required_hits = response.data.required_hits;
|
||||
$scope.rewrite_header = response.data.rewrite_header;
|
||||
$scope.required_score = response.data.required_score;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.SpamAssassinLoading = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/////
|
||||
|
||||
/// Save SpamAssassin Changes
|
||||
|
||||
$scope.failedToSave = true;
|
||||
$scope.successfullySaved = true;
|
||||
|
||||
$scope.saveSpamAssassinConfigurations = function () {
|
||||
|
||||
$scope.failedToSave = true;
|
||||
$scope.successfullySaved = true;
|
||||
$scope.SpamAssassinLoading = false;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
url = "/emailPremium/saveSpamAssassinConfigurations";
|
||||
|
||||
var data = {
|
||||
report_safe:report_safe,
|
||||
required_hits:$scope.required_hits,
|
||||
rewrite_header:$scope.rewrite_header,
|
||||
required_score:$scope.required_score
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers : {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if(response.data.saveStatus === 1){
|
||||
|
||||
$scope.failedToSave = true;
|
||||
$scope.successfullySaved = false;
|
||||
$scope.SpamAssassinLoading = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
}
|
||||
else{
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
$scope.failedToSave = false;
|
||||
$scope.successfullySaved = true;
|
||||
$scope.SpamAssassinLoading = true;
|
||||
$scope.couldNotConnect = true;
|
||||
}
|
||||
|
||||
}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.failedToSave = true;
|
||||
$scope.successfullySaved = false;
|
||||
$scope.SpamAssassinLoading = true;
|
||||
$scope.couldNotConnect = true;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user