diff --git a/emailPremium/static/emailPremium/emailPremium.js b/emailPremium/static/emailPremium/emailPremium.js index 9f580ac0b..df2d37e3e 100755 --- a/emailPremium/static/emailPremium/emailPremium.js +++ b/emailPremium/static/emailPremium/emailPremium.js @@ -4,7 +4,7 @@ /* Java script code to list accounts */ -app.controller('listDomains', function($scope,$http) { +app.controller('listDomains', function ($scope, $http) { $scope.listFail = true; $scope.emailLimitsLoading = true; @@ -13,7 +13,7 @@ app.controller('listDomains', function($scope,$http) { var globalPageNumber; - $scope.getFurtherWebsitesFromDB = function(pageNumber) { + $scope.getFurtherWebsitesFromDB = function (pageNumber) { globalPageNumber = pageNumber; $scope.emailLimitsLoading = false; @@ -23,37 +23,36 @@ app.controller('listDomains', function($scope,$http) { var data = {page: pageNumber}; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.listWebSiteStatus === 1) { + if (response.data.listWebSiteStatus === 1) { - $scope.WebSitesList = JSON.parse(response.data.data); - $scope.listFail = true; - } - else - { - $scope.listFail = false; - $scope.errorMessage = response.data.error_message; + $scope.WebSitesList = JSON.parse(response.data.data); + $scope.listFail = true; + } else { + $scope.listFail = false; + $scope.errorMessage = response.data.error_message; + } } - } + function cantLoadInitialData(response) { $scope.emailLimitsLoading = true; $scope.listFail = false; - } + } - }; + }; $scope.getFurtherWebsitesFromDB(1); $scope.enableDisableEmailLimits = function (operationVal, domainName) { @@ -69,33 +68,32 @@ app.controller('listDomains', function($scope,$http) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.status === 1) { + if (response.data.status === 1) { - $scope.getFurtherWebsitesFromDB(globalPageNumber); - $scope.listFail = true; - } - else - { - $scope.listFail = false; - $scope.errorMessage = response.data.error_message; + $scope.getFurtherWebsitesFromDB(globalPageNumber); + $scope.listFail = true; + } else { + $scope.listFail = false; + $scope.errorMessage = response.data.error_message; + } } - } + function cantLoadInitialData(response) { $scope.emailLimitsLoading = true; $scope.listFail = false; - } + } } }); @@ -104,7 +102,7 @@ app.controller('listDomains', function($scope,$http) { /* Java script code for email domain page */ -app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { +app.controller('emailDomainPage', function ($scope, $http, $timeout, $window) { $scope.listFail = true; $scope.emailLimitsLoading = true; @@ -115,7 +113,7 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { var globalPageNumber; - $scope.getFurtherEmailsFromDB = function(pageNumber) { + $scope.getFurtherEmailsFromDB = function (pageNumber) { globalPageNumber = pageNumber; $scope.emailLimitsLoading = false; @@ -128,37 +126,36 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.status === 1) { + if (response.data.status === 1) { - $scope.emailList = JSON.parse(response.data.data); - $scope.listFail = true; - } - else - { - $scope.listFail = false; - $scope.errorMessage = response.data.error_message; + $scope.emailList = JSON.parse(response.data.data); + $scope.listFail = true; + } else { + $scope.listFail = false; + $scope.errorMessage = response.data.error_message; + } } - } + function cantLoadInitialData(response) { $scope.emailLimitsLoading = true; $scope.listFail = false; - } + } - }; + }; $scope.getFurtherEmailsFromDB(1); $scope.enableDisableEmailLimits = function (operationVal, domainName) { @@ -174,29 +171,34 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.status === 1) { + if (response.data.status === 1) { - $timeout(function() { $window.location.reload(); }, 0); + $timeout(function () { + $window.location.reload(); + }, 0); + } else { + $timeout(function () { + $window.location.reload(); + }, 0); + } } - else - { - $timeout(function() { $window.location.reload(); }, 0); - } - } + function cantLoadInitialData(response) { - $timeout(function() { $window.location.reload(); }, 0); - } + $timeout(function () { + $window.location.reload(); + }, 0); + } }; @@ -219,27 +221,27 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { }; $scope.changeDomainEmailLimits = function (domainName) { - $scope.emailLimitsLoading = false; + $scope.emailLimitsLoading = false; - url = "/emailPremium/changeDomainLimit"; + url = "/emailPremium/changeDomainLimit"; - var data = { - domainName: domainName, - newLimit: $scope.monthlyLimit - }; + var data = { + domainName: domainName, + newLimit: $scope.monthlyLimit + }; - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); - function ListInitialData(response) { + function ListInitialData(response) { - $scope.emailLimitsLoading = true; + $scope.emailLimitsLoading = true; if (response.data.status === 1) { @@ -248,10 +250,10 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { $scope.changeLimitsFail = true; $scope.changeLimitsSuccess = false; $scope.couldNotConnect = true; - $timeout(function() { $window.location.reload(); }, 3000); - } - else - { + $timeout(function () { + $window.location.reload(); + }, 3000); + } else { $scope.changeLimitsForm = false; $scope.changeLimitsFail = false; $scope.changeLimitsSuccess = true; @@ -260,12 +262,13 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { } } - function cantLoadInitialData(response) { - $scope.emailLimitsLoading = true; - $scope.changeLimitsForm = false; - $scope.changeLimitsFail = true; - $scope.changeLimitsSuccess = true; - $scope.couldNotConnect = false; + + function cantLoadInitialData(response) { + $scope.emailLimitsLoading = true; + $scope.changeLimitsForm = false; + $scope.changeLimitsFail = true; + $scope.changeLimitsSuccess = true; + $scope.couldNotConnect = false; } } @@ -283,28 +286,27 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.status === 1) { - $scope.getFurtherEmailsFromDB(1); + if (response.data.status === 1) { + $scope.getFurtherEmailsFromDB(1); + } else { + $scope.getFurtherEmailsFromDB(1); + } } - else - { - $scope.getFurtherEmailsFromDB(1); - } - } + function cantLoadInitialData(response) { $scope.getFurtherEmailsFromDB(1); - } + } }; }); @@ -313,7 +315,7 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { /* Java script code for Email Page */ -app.controller('emailPage', function($scope,$http, $timeout, $window) { +app.controller('emailPage', function ($scope, $http, $timeout, $window) { $scope.emailLimitsLoading = true; @@ -322,7 +324,7 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { // Global page number, to be used in later function to refresh the domains var globalPageNumber; - $scope.getEmailStats = function() { + $scope.getEmailStats = function () { $scope.emailLimitsLoading = false; @@ -338,56 +340,55 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.status === 1) { + if (response.data.status === 1) { - $scope.monthlyLimit = response.data.monthlyLimit; - $scope.monthlyUsed = response.data.monthlyUsed; - $scope.hourlyLimit = response.data.hourlyLimit; - $scope.hourlyUsed = response.data.hourlyUsed; + $scope.monthlyLimit = response.data.monthlyLimit; + $scope.monthlyUsed = response.data.monthlyUsed; + $scope.hourlyLimit = response.data.hourlyLimit; + $scope.hourlyUsed = response.data.hourlyUsed; + + if (response.data.limitStatus === 1) { + $scope.limitsOn = false; + $scope.limitsOff = true; + } else { + $scope.limitsOn = true; + $scope.limitsOff = false; + } + + if (response.data.logsStatus === 1) { + $scope.loggingOn = false; + $scope.loggingOff = true; + } else { + $scope.loggingOn = true; + $scope.loggingOff = false; + } + + } else { + + $scope.errorMessage = response.data.error_message; - if(response.data.limitStatus === 1){ - $scope.limitsOn = false; - $scope.limitsOff = true; - }else{ - $scope.limitsOn = true; - $scope.limitsOff = false; } - - if(response.data.logsStatus === 1){ - $scope.loggingOn = false; - $scope.loggingOff = true; - }else{ - $scope.loggingOn = true; - $scope.loggingOff = false; - } - } - else - { - $scope.errorMessage = response.data.error_message; - - } - } function cantLoadInitialData(response) { $scope.emailLimitsLoading = true; $scope.listFail = false; - } + } - }; + }; $scope.getEmailStats(); $scope.enableDisableIndividualEmailLimits = function (operationVal, emailAddress) { @@ -403,12 +404,12 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { @@ -416,15 +417,14 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { if (response.data.status === 1) { $scope.getEmailStats(); - } - else - { + } else { $scope.getEmailStats(); } - } + } + function cantLoadInitialData(response) { $scope.getEmailStats(); - } + } }; $scope.enableDisableIndividualEmailLogs = function (operationVal, emailAddress) { @@ -439,12 +439,12 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { @@ -452,15 +452,14 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { if (response.data.status === 1) { $scope.getEmailStats(); - } - else - { + } else { $scope.getEmailStats(); } - } + } + function cantLoadInitialData(response) { $scope.getEmailStats(); - } + } }; @@ -477,29 +476,34 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.status === 1) { + if (response.data.status === 1) { - $timeout(function() { $window.location.reload(); }, 0); + $timeout(function () { + $window.location.reload(); + }, 0); + } else { + $timeout(function () { + $window.location.reload(); + }, 0); + } } - else - { - $timeout(function() { $window.location.reload(); }, 0); - } - } + function cantLoadInitialData(response) { - $timeout(function() { $window.location.reload(); }, 0); - } + $timeout(function () { + $window.location.reload(); + }, 0); + } }; @@ -521,28 +525,28 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { }; $scope.changeDomainEmailLimitsIndividual = function () { - $scope.emailLimitsLoading = false; + $scope.emailLimitsLoading = false; - url = "/emailPremium/changeDomainEmailLimitsIndividual"; + url = "/emailPremium/changeDomainEmailLimitsIndividual"; - var data = { - emailAddress: globalEamilAddress, - monthlyLimit: $scope.monthlyLimitForm, - hourlyLimit: $scope.hourlyLimitForm - }; + var data = { + emailAddress: globalEamilAddress, + monthlyLimit: $scope.monthlyLimitForm, + hourlyLimit: $scope.hourlyLimitForm + }; - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); - function ListInitialData(response) { + function ListInitialData(response) { - $scope.emailLimitsLoading = true; + $scope.emailLimitsLoading = true; if (response.data.status === 1) { @@ -553,9 +557,7 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { $scope.couldNotConnect = true; $scope.getEmailStats(); - } - else - { + } else { $scope.changeLimitsForm = false; $scope.changeLimitsFail = false; $scope.changeLimitsSuccess = true; @@ -564,18 +566,19 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { } } - function cantLoadInitialData(response) { - $scope.emailLimitsLoading = true; - $scope.changeLimitsForm = false; - $scope.changeLimitsFail = true; - $scope.changeLimitsSuccess = true; - $scope.couldNotConnect = false; + + function cantLoadInitialData(response) { + $scope.emailLimitsLoading = true; + $scope.changeLimitsForm = false; + $scope.changeLimitsFail = true; + $scope.changeLimitsSuccess = true; + $scope.couldNotConnect = false; } }; /// Get email logs - $scope.getLogEntries = function(pageNumber) { + $scope.getLogEntries = function (pageNumber) { globalPageNumber = pageNumber; $scope.emailLimitsLoading = false; @@ -588,41 +591,40 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.status === 1) { + if (response.data.status === 1) { - $scope.logs = JSON.parse(response.data.data); - $scope.listFail = true; - } - else - { - $scope.listFail = false; - $scope.errorMessage = response.data.error_message; + $scope.logs = JSON.parse(response.data.data); + $scope.listFail = true; + } else { + $scope.listFail = false; + $scope.errorMessage = response.data.error_message; + } } - } + function cantLoadInitialData(response) { $scope.emailLimitsLoading = true; $scope.listFail = false; - } + } - }; + }; $scope.getLogEntries(1); - $scope.flushLogs = function(emailAddress) { + $scope.flushLogs = function (emailAddress) { $scope.emailLimitsLoading = false; @@ -633,36 +635,35 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.status === 1) { - $scope.getLogEntries(1); + if (response.data.status === 1) { + $scope.getLogEntries(1); - } - else - { - $scope.listFail = false; - $scope.errorMessage = response.data.error_message; + } else { + $scope.listFail = false; + $scope.errorMessage = response.data.error_message; } } + function cantLoadInitialData(response) { $scope.emailLimitsLoading = true; $scope.listFail = false; } - }; + }; }); @@ -670,286 +671,285 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { /* Java script code for SpamAssassin */ -app.controller('SpamAssassin', function($scope, $http, $timeout, $window) { +app.controller('SpamAssassin', 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.SpamAssassinNotifyBox = true; + $scope.SpamAssassinInstallBox = true; + $scope.SpamAssassinLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.SpamAssassinSuccessfullyInstalled = true; + $scope.installationFailed = true; + $scope.installSpamAssassin = function () { - $scope.installSpamAssassin = function(){ + $scope.SpamAssassinNotifyBox = true; + $scope.SpamAssassinInstallBox = true; + $scope.SpamAssassinLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.SpamAssassinSuccessfullyInstalled = true; + $scope.installationFailed = true; - $scope.SpamAssassinNotifyBox = true; - $scope.SpamAssassinInstallBox = true; - $scope.SpamAssassinLoading = false; - $scope.failedToStartInallation = true; - $scope.couldNotConnect = true; - $scope.SpamAssassinSuccessfullyInstalled = true; - $scope.installationFailed = true; + url = "/emailPremium/installSpamAssassin"; - url = "/emailPremium/installSpamAssassin"; + var data = {}; - var data = {}; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - function ListInitialDatas(response) { + function ListInitialDatas(response) { - if(response.data.status === 1){ + 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; + $scope.SpamAssassinNotifyBox = true; + $scope.SpamAssassinInstallBox = false; + $scope.SpamAssassinLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.SpamAssassinSuccessfullyInstalled = true; + $scope.installationFailed = true; - getRequestStatus(); + getRequestStatus(); - } - else{ - $scope.errorMessage = response.data.error_message; + } 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; + $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'); } - } - 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; - + $scope.required_hits = response.data.required_hits; + $scope.rewrite_header = response.data.rewrite_header; + $scope.required_score = response.data.required_score; } - } + } - ///// SpamAssassin configs + } - var report_safe = false; + function cantLoadInitialDatas(response) { + $scope.SpamAssassinLoading = true; + } + + } - $('#report_safe').change(function() { - report_safe = $(this).prop('checked'); - }); + ///// - fetchSpamAssassinSettings(); - function fetchSpamAssassinSettings(){ + /// Save SpamAssassin Changes - $scope.SpamAssassinLoading = false; + $scope.failedToSave = true; + $scope.successfullySaved = true; - $('#report_safe').bootstrapToggle('off'); + $scope.saveSpamAssassinConfigurations = function () { - url = "/emailPremium/fetchSpamAssassinSettings"; - - var data = {}; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + $scope.failedToSave = true; + $scope.successfullySaved = true; + $scope.SpamAssassinLoading = false; + $scope.couldNotConnect = true; + url = "/emailPremium/saveSpamAssassinConfigurations"; - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + 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') + } + }; - 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; - } - - } + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - ///// - - /// Save SpamAssassin Changes - - $scope.failedToSave = true; - $scope.successfullySaved = true; - - $scope.saveSpamAssassinConfigurations = function () { - - $scope.failedToSave = true; - $scope.successfullySaved = true; - $scope.SpamAssassinLoading = false; - $scope.couldNotConnect = true; + function ListInitialDatas(response) { - url = "/emailPremium/saveSpamAssassinConfigurations"; + if (response.data.saveStatus === 1) { - var data = { - report_safe:report_safe, - required_hits:$scope.required_hits, - rewrite_header:$scope.rewrite_header, - required_score:$scope.required_score - }; + $scope.failedToSave = true; + $scope.successfullySaved = false; + $scope.SpamAssassinLoading = true; + $scope.couldNotConnect = true; - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + } 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; + } - - $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; - } - - - }; + }; }); @@ -957,129 +957,128 @@ app.controller('SpamAssassin', function($scope, $http, $timeout, $window) { /* Java script code for Email Policy Server */ -app.controller('policyServer', function($scope, $http, $timeout, $window) { +app.controller('policyServer', function ($scope, $http, $timeout, $window) { - $scope.policyServerLoading = true; - $scope.failedToFetch = true; - $scope.couldNotConnect = true; - $scope.changesApplied = true; + $scope.policyServerLoading = true; + $scope.failedToFetch = true; + $scope.couldNotConnect = true; + $scope.changesApplied = true; - ///// SpamAssassin configs + ///// SpamAssassin configs - var report_safe = false; + var report_safe = false; - $('#policServerStatus').change(function() { - policServerStatus = $(this).prop('checked'); - }); + $('#policServerStatus').change(function () { + policServerStatus = $(this).prop('checked'); + }); - fetchPolicServerStatus(); - function fetchPolicServerStatus(){ + fetchPolicServerStatus(); - $scope.policyServerLoading = false; + function fetchPolicServerStatus() { - $('#policServerStatus').bootstrapToggle('off'); + $scope.policyServerLoading = false; - url = "/emailPremium/fetchPolicyServerStatus"; + $('#policServerStatus').bootstrapToggle('off'); - var data = {}; + url = "/emailPremium/fetchPolicyServerStatus"; - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - function ListInitialDatas(response) { + function ListInitialDatas(response) { - $scope.policyServerLoading = true; + $scope.policyServerLoading = true; - if(response.data.status === 1){ + if (response.data.status === 1) { - if (response.data.installCheck === 1) { - $('#policServerStatus').bootstrapToggle('on'); - } - - }else{ - $scope.failedToFetch = false; - $scope.couldNotConnect = true; - $scope.changesApplied = true; - - $scope.errorMessage = response.data.error_message; - - } - - } - function cantLoadInitialDatas(response) { - $scope.policyServerLoading = true; - $scope.failedToFetch = true; - $scope.couldNotConnect = false; - $scope.changesApplied = true; + if (response.data.installCheck === 1) { + $('#policServerStatus').bootstrapToggle('on'); } - } + } else { + $scope.failedToFetch = false; + $scope.couldNotConnect = true; + $scope.changesApplied = true; + + $scope.errorMessage = response.data.error_message; + + } + + } + + function cantLoadInitialDatas(response) { + $scope.policyServerLoading = true; + $scope.failedToFetch = true; + $scope.couldNotConnect = false; + $scope.changesApplied = true; + } + + } - $scope.savePolicServerStatus = function () { + $scope.savePolicServerStatus = function () { - $scope.policyServerLoading = false; - $scope.failedToFetch = true; - $scope.couldNotConnect = true; - $scope.changesApplied = true; + $scope.policyServerLoading = false; + $scope.failedToFetch = true; + $scope.couldNotConnect = true; + $scope.changesApplied = true; + url = "/emailPremium/savePolicyServerStatus"; - url = "/emailPremium/savePolicyServerStatus"; + var data = { + policServerStatus: policServerStatus + }; - var data = { - policServerStatus:policServerStatus - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - function ListInitialDatas(response) { - $scope.policyServerLoading = true; + function ListInitialDatas(response) { + $scope.policyServerLoading = true; - if(response.data.status === 1){ + if (response.data.status === 1) { - $scope.failedToFetch = true; - $scope.couldNotConnect = true; - $scope.changesApplied = false; + $scope.failedToFetch = true; + $scope.couldNotConnect = true; + $scope.changesApplied = false; - } - else{ - $scope.errorMessage = response.data.error_message; + } else { + $scope.errorMessage = response.data.error_message; - $scope.failedToFetch = false; - $scope.couldNotConnect = true; - $scope.changesApplied = true; - } + $scope.failedToFetch = false; + $scope.couldNotConnect = true; + $scope.changesApplied = true; + } - } - function cantLoadInitialDatas(response) { - $scope.policyServerLoading = true; - $scope.failedToFetch = true; - $scope.couldNotConnect = false; - $scope.changesApplied = true; - } + } + + function cantLoadInitialDatas(response) { + $scope.policyServerLoading = true; + $scope.failedToFetch = true; + $scope.couldNotConnect = false; + $scope.changesApplied = true; + } - }; + }; }); @@ -1087,7 +1086,7 @@ app.controller('policyServer', function($scope, $http, $timeout, $window) { /* Java script code to manage mail queue */ -app.controller('mailQueue', function($scope,$http) { +app.controller('mailQueue', function ($scope, $http) { $scope.currentPage = 1; $scope.recordsToShow = 10; @@ -1248,8 +1247,7 @@ app.controller('mailQueue', function($scope,$http) { } }; - var data = { - }; + var data = {}; dataurl = "/emailPremium/flushQueue"; @@ -1289,285 +1287,284 @@ app.controller('mailQueue', function($scope,$http) { /* Java script code to manage mail queue ends here */ -app.controller('MailScanner', function($scope, $http, $timeout, $window) { +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.SpamAssassinNotifyBox = true; + $scope.SpamAssassinInstallBox = true; + $scope.SpamAssassinLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.SpamAssassinSuccessfullyInstalled = true; + $scope.installationFailed = true; + $scope.installSpamAssassin = function () { - $scope.installSpamAssassin = function(){ + $scope.SpamAssassinNotifyBox = true; + $scope.SpamAssassinInstallBox = true; + $scope.SpamAssassinLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.SpamAssassinSuccessfullyInstalled = true; + $scope.installationFailed = true; - $scope.SpamAssassinNotifyBox = true; - $scope.SpamAssassinInstallBox = true; - $scope.SpamAssassinLoading = false; - $scope.failedToStartInallation = true; - $scope.couldNotConnect = true; - $scope.SpamAssassinSuccessfullyInstalled = true; - $scope.installationFailed = true; + url = "/emailPremium/installMailScanner"; - url = "/emailPremium/installMailScanner"; + var data = {}; - var data = {}; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - function ListInitialDatas(response) { + function ListInitialDatas(response) { - if(response.data.status === 1){ + 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; + $scope.SpamAssassinNotifyBox = true; + $scope.SpamAssassinInstallBox = false; + $scope.SpamAssassinLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.SpamAssassinSuccessfullyInstalled = true; + $scope.installationFailed = true; - getRequestStatus(); + getRequestStatus(); - } - else{ - $scope.errorMessage = response.data.error_message; + } 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; + $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/installStatusMailScanner"; + + 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'); } - } - 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; - + $scope.required_hits = response.data.required_hits; + $scope.rewrite_header = response.data.rewrite_header; + $scope.required_score = response.data.required_score; } - } + } - ///// SpamAssassin configs + } - var report_safe = false; + function cantLoadInitialDatas(response) { + $scope.SpamAssassinLoading = true; + } + + } - $('#report_safe').change(function() { - report_safe = $(this).prop('checked'); - }); + ///// - fetchSpamAssassinSettings(); - function fetchSpamAssassinSettings(){ + /// Save SpamAssassin Changes - $scope.SpamAssassinLoading = false; + $scope.failedToSave = true; + $scope.successfullySaved = true; - $('#report_safe').bootstrapToggle('off'); + $scope.saveSpamAssassinConfigurations = function () { - url = "/emailPremium/fetchSpamAssassinSettings"; - - var data = {}; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + $scope.failedToSave = true; + $scope.successfullySaved = true; + $scope.SpamAssassinLoading = false; + $scope.couldNotConnect = true; + url = "/emailPremium/saveSpamAssassinConfigurations"; - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + 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') + } + }; - 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; - } - - } + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - ///// - - /// Save SpamAssassin Changes - - $scope.failedToSave = true; - $scope.successfullySaved = true; - - $scope.saveSpamAssassinConfigurations = function () { - - $scope.failedToSave = true; - $scope.successfullySaved = true; - $scope.SpamAssassinLoading = false; - $scope.couldNotConnect = true; + function ListInitialDatas(response) { - url = "/emailPremium/saveSpamAssassinConfigurations"; + if (response.data.saveStatus === 1) { - var data = { - report_safe:report_safe, - required_hits:$scope.required_hits, - rewrite_header:$scope.rewrite_header, - required_score:$scope.required_score - }; + $scope.failedToSave = true; + $scope.successfullySaved = false; + $scope.SpamAssassinLoading = true; + $scope.couldNotConnect = true; - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + } 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; + } - - $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; - } - - - }; + }; }); \ No newline at end of file diff --git a/emailPremium/views.py b/emailPremium/views.py index 1bfdc9445..a26dd4e60 100755 --- a/emailPremium/views.py +++ b/emailPremium/views.py @@ -1190,7 +1190,6 @@ def MailScanner(request): if mailUtilities.checkIfMailScannerInstalled() == 1: checkIfMailScannerInstalled = 1 - return render(request, 'emailPremium/MailScanner.html',{'checkIfMailScannerInstalled': checkIfMailScannerInstalled, 'ipAddress': ipAddress}) except KeyError: @@ -1220,4 +1219,58 @@ def installMailScanner(request): 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) + +def installStatusMailScanner(request): + try: + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if currentACL['admin'] == 1: + pass + else: + return ACLManager.loadErrorJson() + + try: + if request.method == 'POST': + + command = "sudo cat " + mailUtilities.spamassassinInstallLogPath + installStatus = ProcessUtilities.outputExecutioner(command) + + if installStatus.find("[200]")>-1: + + final_json = json.dumps({ + 'error_message': "None", + 'requestStatus': installStatus, + 'abort': 1, + 'installed': 1, + }) + return HttpResponse(final_json) + + elif installStatus.find("[404]") > -1: + + final_json = json.dumps({ + 'abort':1, + 'installed':0, + 'error_message': "None", + 'requestStatus': installStatus, + }) + return HttpResponse(final_json) + + else: + final_json = json.dumps({ + 'abort':0, + 'error_message': "None", + 'requestStatus': installStatus, + }) + return HttpResponse(final_json) + + + except BaseException as msg: + final_dic = {'abort':1,'installed':0, 'error_message': str(msg)} + final_json = json.dumps(final_dic) + return HttpResponse(final_json) + except KeyError: + final_dic = {'abort':1,'installed':0, 'error_message': "Not Logged In, please refresh the page or login again."} + final_json = json.dumps(final_dic) return HttpResponse(final_json) \ No newline at end of file diff --git a/static/emailPremium/emailPremium.js b/static/emailPremium/emailPremium.js index 9f580ac0b..df2d37e3e 100644 --- a/static/emailPremium/emailPremium.js +++ b/static/emailPremium/emailPremium.js @@ -4,7 +4,7 @@ /* Java script code to list accounts */ -app.controller('listDomains', function($scope,$http) { +app.controller('listDomains', function ($scope, $http) { $scope.listFail = true; $scope.emailLimitsLoading = true; @@ -13,7 +13,7 @@ app.controller('listDomains', function($scope,$http) { var globalPageNumber; - $scope.getFurtherWebsitesFromDB = function(pageNumber) { + $scope.getFurtherWebsitesFromDB = function (pageNumber) { globalPageNumber = pageNumber; $scope.emailLimitsLoading = false; @@ -23,37 +23,36 @@ app.controller('listDomains', function($scope,$http) { var data = {page: pageNumber}; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.listWebSiteStatus === 1) { + if (response.data.listWebSiteStatus === 1) { - $scope.WebSitesList = JSON.parse(response.data.data); - $scope.listFail = true; - } - else - { - $scope.listFail = false; - $scope.errorMessage = response.data.error_message; + $scope.WebSitesList = JSON.parse(response.data.data); + $scope.listFail = true; + } else { + $scope.listFail = false; + $scope.errorMessage = response.data.error_message; + } } - } + function cantLoadInitialData(response) { $scope.emailLimitsLoading = true; $scope.listFail = false; - } + } - }; + }; $scope.getFurtherWebsitesFromDB(1); $scope.enableDisableEmailLimits = function (operationVal, domainName) { @@ -69,33 +68,32 @@ app.controller('listDomains', function($scope,$http) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.status === 1) { + if (response.data.status === 1) { - $scope.getFurtherWebsitesFromDB(globalPageNumber); - $scope.listFail = true; - } - else - { - $scope.listFail = false; - $scope.errorMessage = response.data.error_message; + $scope.getFurtherWebsitesFromDB(globalPageNumber); + $scope.listFail = true; + } else { + $scope.listFail = false; + $scope.errorMessage = response.data.error_message; + } } - } + function cantLoadInitialData(response) { $scope.emailLimitsLoading = true; $scope.listFail = false; - } + } } }); @@ -104,7 +102,7 @@ app.controller('listDomains', function($scope,$http) { /* Java script code for email domain page */ -app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { +app.controller('emailDomainPage', function ($scope, $http, $timeout, $window) { $scope.listFail = true; $scope.emailLimitsLoading = true; @@ -115,7 +113,7 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { var globalPageNumber; - $scope.getFurtherEmailsFromDB = function(pageNumber) { + $scope.getFurtherEmailsFromDB = function (pageNumber) { globalPageNumber = pageNumber; $scope.emailLimitsLoading = false; @@ -128,37 +126,36 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.status === 1) { + if (response.data.status === 1) { - $scope.emailList = JSON.parse(response.data.data); - $scope.listFail = true; - } - else - { - $scope.listFail = false; - $scope.errorMessage = response.data.error_message; + $scope.emailList = JSON.parse(response.data.data); + $scope.listFail = true; + } else { + $scope.listFail = false; + $scope.errorMessage = response.data.error_message; + } } - } + function cantLoadInitialData(response) { $scope.emailLimitsLoading = true; $scope.listFail = false; - } + } - }; + }; $scope.getFurtherEmailsFromDB(1); $scope.enableDisableEmailLimits = function (operationVal, domainName) { @@ -174,29 +171,34 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.status === 1) { + if (response.data.status === 1) { - $timeout(function() { $window.location.reload(); }, 0); + $timeout(function () { + $window.location.reload(); + }, 0); + } else { + $timeout(function () { + $window.location.reload(); + }, 0); + } } - else - { - $timeout(function() { $window.location.reload(); }, 0); - } - } + function cantLoadInitialData(response) { - $timeout(function() { $window.location.reload(); }, 0); - } + $timeout(function () { + $window.location.reload(); + }, 0); + } }; @@ -219,27 +221,27 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { }; $scope.changeDomainEmailLimits = function (domainName) { - $scope.emailLimitsLoading = false; + $scope.emailLimitsLoading = false; - url = "/emailPremium/changeDomainLimit"; + url = "/emailPremium/changeDomainLimit"; - var data = { - domainName: domainName, - newLimit: $scope.monthlyLimit - }; + var data = { + domainName: domainName, + newLimit: $scope.monthlyLimit + }; - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); - function ListInitialData(response) { + function ListInitialData(response) { - $scope.emailLimitsLoading = true; + $scope.emailLimitsLoading = true; if (response.data.status === 1) { @@ -248,10 +250,10 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { $scope.changeLimitsFail = true; $scope.changeLimitsSuccess = false; $scope.couldNotConnect = true; - $timeout(function() { $window.location.reload(); }, 3000); - } - else - { + $timeout(function () { + $window.location.reload(); + }, 3000); + } else { $scope.changeLimitsForm = false; $scope.changeLimitsFail = false; $scope.changeLimitsSuccess = true; @@ -260,12 +262,13 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { } } - function cantLoadInitialData(response) { - $scope.emailLimitsLoading = true; - $scope.changeLimitsForm = false; - $scope.changeLimitsFail = true; - $scope.changeLimitsSuccess = true; - $scope.couldNotConnect = false; + + function cantLoadInitialData(response) { + $scope.emailLimitsLoading = true; + $scope.changeLimitsForm = false; + $scope.changeLimitsFail = true; + $scope.changeLimitsSuccess = true; + $scope.couldNotConnect = false; } } @@ -283,28 +286,27 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.status === 1) { - $scope.getFurtherEmailsFromDB(1); + if (response.data.status === 1) { + $scope.getFurtherEmailsFromDB(1); + } else { + $scope.getFurtherEmailsFromDB(1); + } } - else - { - $scope.getFurtherEmailsFromDB(1); - } - } + function cantLoadInitialData(response) { $scope.getFurtherEmailsFromDB(1); - } + } }; }); @@ -313,7 +315,7 @@ app.controller('emailDomainPage', function($scope,$http, $timeout, $window) { /* Java script code for Email Page */ -app.controller('emailPage', function($scope,$http, $timeout, $window) { +app.controller('emailPage', function ($scope, $http, $timeout, $window) { $scope.emailLimitsLoading = true; @@ -322,7 +324,7 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { // Global page number, to be used in later function to refresh the domains var globalPageNumber; - $scope.getEmailStats = function() { + $scope.getEmailStats = function () { $scope.emailLimitsLoading = false; @@ -338,56 +340,55 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.status === 1) { + if (response.data.status === 1) { - $scope.monthlyLimit = response.data.monthlyLimit; - $scope.monthlyUsed = response.data.monthlyUsed; - $scope.hourlyLimit = response.data.hourlyLimit; - $scope.hourlyUsed = response.data.hourlyUsed; + $scope.monthlyLimit = response.data.monthlyLimit; + $scope.monthlyUsed = response.data.monthlyUsed; + $scope.hourlyLimit = response.data.hourlyLimit; + $scope.hourlyUsed = response.data.hourlyUsed; + + if (response.data.limitStatus === 1) { + $scope.limitsOn = false; + $scope.limitsOff = true; + } else { + $scope.limitsOn = true; + $scope.limitsOff = false; + } + + if (response.data.logsStatus === 1) { + $scope.loggingOn = false; + $scope.loggingOff = true; + } else { + $scope.loggingOn = true; + $scope.loggingOff = false; + } + + } else { + + $scope.errorMessage = response.data.error_message; - if(response.data.limitStatus === 1){ - $scope.limitsOn = false; - $scope.limitsOff = true; - }else{ - $scope.limitsOn = true; - $scope.limitsOff = false; } - - if(response.data.logsStatus === 1){ - $scope.loggingOn = false; - $scope.loggingOff = true; - }else{ - $scope.loggingOn = true; - $scope.loggingOff = false; - } - } - else - { - $scope.errorMessage = response.data.error_message; - - } - } function cantLoadInitialData(response) { $scope.emailLimitsLoading = true; $scope.listFail = false; - } + } - }; + }; $scope.getEmailStats(); $scope.enableDisableIndividualEmailLimits = function (operationVal, emailAddress) { @@ -403,12 +404,12 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { @@ -416,15 +417,14 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { if (response.data.status === 1) { $scope.getEmailStats(); - } - else - { + } else { $scope.getEmailStats(); } - } + } + function cantLoadInitialData(response) { $scope.getEmailStats(); - } + } }; $scope.enableDisableIndividualEmailLogs = function (operationVal, emailAddress) { @@ -439,12 +439,12 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { @@ -452,15 +452,14 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { if (response.data.status === 1) { $scope.getEmailStats(); - } - else - { + } else { $scope.getEmailStats(); } - } + } + function cantLoadInitialData(response) { $scope.getEmailStats(); - } + } }; @@ -477,29 +476,34 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.status === 1) { + if (response.data.status === 1) { - $timeout(function() { $window.location.reload(); }, 0); + $timeout(function () { + $window.location.reload(); + }, 0); + } else { + $timeout(function () { + $window.location.reload(); + }, 0); + } } - else - { - $timeout(function() { $window.location.reload(); }, 0); - } - } + function cantLoadInitialData(response) { - $timeout(function() { $window.location.reload(); }, 0); - } + $timeout(function () { + $window.location.reload(); + }, 0); + } }; @@ -521,28 +525,28 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { }; $scope.changeDomainEmailLimitsIndividual = function () { - $scope.emailLimitsLoading = false; + $scope.emailLimitsLoading = false; - url = "/emailPremium/changeDomainEmailLimitsIndividual"; + url = "/emailPremium/changeDomainEmailLimitsIndividual"; - var data = { - emailAddress: globalEamilAddress, - monthlyLimit: $scope.monthlyLimitForm, - hourlyLimit: $scope.hourlyLimitForm - }; + var data = { + emailAddress: globalEamilAddress, + monthlyLimit: $scope.monthlyLimitForm, + hourlyLimit: $scope.hourlyLimitForm + }; - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); - function ListInitialData(response) { + function ListInitialData(response) { - $scope.emailLimitsLoading = true; + $scope.emailLimitsLoading = true; if (response.data.status === 1) { @@ -553,9 +557,7 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { $scope.couldNotConnect = true; $scope.getEmailStats(); - } - else - { + } else { $scope.changeLimitsForm = false; $scope.changeLimitsFail = false; $scope.changeLimitsSuccess = true; @@ -564,18 +566,19 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { } } - function cantLoadInitialData(response) { - $scope.emailLimitsLoading = true; - $scope.changeLimitsForm = false; - $scope.changeLimitsFail = true; - $scope.changeLimitsSuccess = true; - $scope.couldNotConnect = false; + + function cantLoadInitialData(response) { + $scope.emailLimitsLoading = true; + $scope.changeLimitsForm = false; + $scope.changeLimitsFail = true; + $scope.changeLimitsSuccess = true; + $scope.couldNotConnect = false; } }; /// Get email logs - $scope.getLogEntries = function(pageNumber) { + $scope.getLogEntries = function (pageNumber) { globalPageNumber = pageNumber; $scope.emailLimitsLoading = false; @@ -588,41 +591,40 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.status === 1) { + if (response.data.status === 1) { - $scope.logs = JSON.parse(response.data.data); - $scope.listFail = true; - } - else - { - $scope.listFail = false; - $scope.errorMessage = response.data.error_message; + $scope.logs = JSON.parse(response.data.data); + $scope.listFail = true; + } else { + $scope.listFail = false; + $scope.errorMessage = response.data.error_message; + } } - } + function cantLoadInitialData(response) { $scope.emailLimitsLoading = true; $scope.listFail = false; - } + } - }; + }; $scope.getLogEntries(1); - $scope.flushLogs = function(emailAddress) { + $scope.flushLogs = function (emailAddress) { $scope.emailLimitsLoading = false; @@ -633,36 +635,35 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { }; var config = { - headers : { + headers: { 'X-CSRFToken': getCookie('csrftoken') } }; - $http.post(url, data,config).then(ListInitialData, cantLoadInitialData); + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); function ListInitialData(response) { $scope.emailLimitsLoading = true; - if (response.data.status === 1) { - $scope.getLogEntries(1); + if (response.data.status === 1) { + $scope.getLogEntries(1); - } - else - { - $scope.listFail = false; - $scope.errorMessage = response.data.error_message; + } else { + $scope.listFail = false; + $scope.errorMessage = response.data.error_message; } } + function cantLoadInitialData(response) { $scope.emailLimitsLoading = true; $scope.listFail = false; } - }; + }; }); @@ -670,286 +671,285 @@ app.controller('emailPage', function($scope,$http, $timeout, $window) { /* Java script code for SpamAssassin */ -app.controller('SpamAssassin', function($scope, $http, $timeout, $window) { +app.controller('SpamAssassin', 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.SpamAssassinNotifyBox = true; + $scope.SpamAssassinInstallBox = true; + $scope.SpamAssassinLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.SpamAssassinSuccessfullyInstalled = true; + $scope.installationFailed = true; + $scope.installSpamAssassin = function () { - $scope.installSpamAssassin = function(){ + $scope.SpamAssassinNotifyBox = true; + $scope.SpamAssassinInstallBox = true; + $scope.SpamAssassinLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.SpamAssassinSuccessfullyInstalled = true; + $scope.installationFailed = true; - $scope.SpamAssassinNotifyBox = true; - $scope.SpamAssassinInstallBox = true; - $scope.SpamAssassinLoading = false; - $scope.failedToStartInallation = true; - $scope.couldNotConnect = true; - $scope.SpamAssassinSuccessfullyInstalled = true; - $scope.installationFailed = true; + url = "/emailPremium/installSpamAssassin"; - url = "/emailPremium/installSpamAssassin"; + var data = {}; - var data = {}; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - function ListInitialDatas(response) { + function ListInitialDatas(response) { - if(response.data.status === 1){ + 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; + $scope.SpamAssassinNotifyBox = true; + $scope.SpamAssassinInstallBox = false; + $scope.SpamAssassinLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.SpamAssassinSuccessfullyInstalled = true; + $scope.installationFailed = true; - getRequestStatus(); + getRequestStatus(); - } - else{ - $scope.errorMessage = response.data.error_message; + } 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; + $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'); } - } - 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; - + $scope.required_hits = response.data.required_hits; + $scope.rewrite_header = response.data.rewrite_header; + $scope.required_score = response.data.required_score; } - } + } - ///// SpamAssassin configs + } - var report_safe = false; + function cantLoadInitialDatas(response) { + $scope.SpamAssassinLoading = true; + } + + } - $('#report_safe').change(function() { - report_safe = $(this).prop('checked'); - }); + ///// - fetchSpamAssassinSettings(); - function fetchSpamAssassinSettings(){ + /// Save SpamAssassin Changes - $scope.SpamAssassinLoading = false; + $scope.failedToSave = true; + $scope.successfullySaved = true; - $('#report_safe').bootstrapToggle('off'); + $scope.saveSpamAssassinConfigurations = function () { - url = "/emailPremium/fetchSpamAssassinSettings"; - - var data = {}; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + $scope.failedToSave = true; + $scope.successfullySaved = true; + $scope.SpamAssassinLoading = false; + $scope.couldNotConnect = true; + url = "/emailPremium/saveSpamAssassinConfigurations"; - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + 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') + } + }; - 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; - } - - } + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - ///// - - /// Save SpamAssassin Changes - - $scope.failedToSave = true; - $scope.successfullySaved = true; - - $scope.saveSpamAssassinConfigurations = function () { - - $scope.failedToSave = true; - $scope.successfullySaved = true; - $scope.SpamAssassinLoading = false; - $scope.couldNotConnect = true; + function ListInitialDatas(response) { - url = "/emailPremium/saveSpamAssassinConfigurations"; + if (response.data.saveStatus === 1) { - var data = { - report_safe:report_safe, - required_hits:$scope.required_hits, - rewrite_header:$scope.rewrite_header, - required_score:$scope.required_score - }; + $scope.failedToSave = true; + $scope.successfullySaved = false; + $scope.SpamAssassinLoading = true; + $scope.couldNotConnect = true; - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + } 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; + } - - $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; - } - - - }; + }; }); @@ -957,129 +957,128 @@ app.controller('SpamAssassin', function($scope, $http, $timeout, $window) { /* Java script code for Email Policy Server */ -app.controller('policyServer', function($scope, $http, $timeout, $window) { +app.controller('policyServer', function ($scope, $http, $timeout, $window) { - $scope.policyServerLoading = true; - $scope.failedToFetch = true; - $scope.couldNotConnect = true; - $scope.changesApplied = true; + $scope.policyServerLoading = true; + $scope.failedToFetch = true; + $scope.couldNotConnect = true; + $scope.changesApplied = true; - ///// SpamAssassin configs + ///// SpamAssassin configs - var report_safe = false; + var report_safe = false; - $('#policServerStatus').change(function() { - policServerStatus = $(this).prop('checked'); - }); + $('#policServerStatus').change(function () { + policServerStatus = $(this).prop('checked'); + }); - fetchPolicServerStatus(); - function fetchPolicServerStatus(){ + fetchPolicServerStatus(); - $scope.policyServerLoading = false; + function fetchPolicServerStatus() { - $('#policServerStatus').bootstrapToggle('off'); + $scope.policyServerLoading = false; - url = "/emailPremium/fetchPolicyServerStatus"; + $('#policServerStatus').bootstrapToggle('off'); - var data = {}; + url = "/emailPremium/fetchPolicyServerStatus"; - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - function ListInitialDatas(response) { + function ListInitialDatas(response) { - $scope.policyServerLoading = true; + $scope.policyServerLoading = true; - if(response.data.status === 1){ + if (response.data.status === 1) { - if (response.data.installCheck === 1) { - $('#policServerStatus').bootstrapToggle('on'); - } - - }else{ - $scope.failedToFetch = false; - $scope.couldNotConnect = true; - $scope.changesApplied = true; - - $scope.errorMessage = response.data.error_message; - - } - - } - function cantLoadInitialDatas(response) { - $scope.policyServerLoading = true; - $scope.failedToFetch = true; - $scope.couldNotConnect = false; - $scope.changesApplied = true; + if (response.data.installCheck === 1) { + $('#policServerStatus').bootstrapToggle('on'); } - } + } else { + $scope.failedToFetch = false; + $scope.couldNotConnect = true; + $scope.changesApplied = true; + + $scope.errorMessage = response.data.error_message; + + } + + } + + function cantLoadInitialDatas(response) { + $scope.policyServerLoading = true; + $scope.failedToFetch = true; + $scope.couldNotConnect = false; + $scope.changesApplied = true; + } + + } - $scope.savePolicServerStatus = function () { + $scope.savePolicServerStatus = function () { - $scope.policyServerLoading = false; - $scope.failedToFetch = true; - $scope.couldNotConnect = true; - $scope.changesApplied = true; + $scope.policyServerLoading = false; + $scope.failedToFetch = true; + $scope.couldNotConnect = true; + $scope.changesApplied = true; + url = "/emailPremium/savePolicyServerStatus"; - url = "/emailPremium/savePolicyServerStatus"; + var data = { + policServerStatus: policServerStatus + }; - var data = { - policServerStatus:policServerStatus - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - function ListInitialDatas(response) { - $scope.policyServerLoading = true; + function ListInitialDatas(response) { + $scope.policyServerLoading = true; - if(response.data.status === 1){ + if (response.data.status === 1) { - $scope.failedToFetch = true; - $scope.couldNotConnect = true; - $scope.changesApplied = false; + $scope.failedToFetch = true; + $scope.couldNotConnect = true; + $scope.changesApplied = false; - } - else{ - $scope.errorMessage = response.data.error_message; + } else { + $scope.errorMessage = response.data.error_message; - $scope.failedToFetch = false; - $scope.couldNotConnect = true; - $scope.changesApplied = true; - } + $scope.failedToFetch = false; + $scope.couldNotConnect = true; + $scope.changesApplied = true; + } - } - function cantLoadInitialDatas(response) { - $scope.policyServerLoading = true; - $scope.failedToFetch = true; - $scope.couldNotConnect = false; - $scope.changesApplied = true; - } + } + + function cantLoadInitialDatas(response) { + $scope.policyServerLoading = true; + $scope.failedToFetch = true; + $scope.couldNotConnect = false; + $scope.changesApplied = true; + } - }; + }; }); @@ -1087,7 +1086,7 @@ app.controller('policyServer', function($scope, $http, $timeout, $window) { /* Java script code to manage mail queue */ -app.controller('mailQueue', function($scope,$http) { +app.controller('mailQueue', function ($scope, $http) { $scope.currentPage = 1; $scope.recordsToShow = 10; @@ -1248,8 +1247,7 @@ app.controller('mailQueue', function($scope,$http) { } }; - var data = { - }; + var data = {}; dataurl = "/emailPremium/flushQueue"; @@ -1289,285 +1287,284 @@ app.controller('mailQueue', function($scope,$http) { /* Java script code to manage mail queue ends here */ -app.controller('MailScanner', function($scope, $http, $timeout, $window) { +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.SpamAssassinNotifyBox = true; + $scope.SpamAssassinInstallBox = true; + $scope.SpamAssassinLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.SpamAssassinSuccessfullyInstalled = true; + $scope.installationFailed = true; + $scope.installSpamAssassin = function () { - $scope.installSpamAssassin = function(){ + $scope.SpamAssassinNotifyBox = true; + $scope.SpamAssassinInstallBox = true; + $scope.SpamAssassinLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.SpamAssassinSuccessfullyInstalled = true; + $scope.installationFailed = true; - $scope.SpamAssassinNotifyBox = true; - $scope.SpamAssassinInstallBox = true; - $scope.SpamAssassinLoading = false; - $scope.failedToStartInallation = true; - $scope.couldNotConnect = true; - $scope.SpamAssassinSuccessfullyInstalled = true; - $scope.installationFailed = true; + url = "/emailPremium/installMailScanner"; - url = "/emailPremium/installMailScanner"; + var data = {}; - var data = {}; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - function ListInitialDatas(response) { + function ListInitialDatas(response) { - if(response.data.status === 1){ + 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; + $scope.SpamAssassinNotifyBox = true; + $scope.SpamAssassinInstallBox = false; + $scope.SpamAssassinLoading = false; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = true; + $scope.SpamAssassinSuccessfullyInstalled = true; + $scope.installationFailed = true; - getRequestStatus(); + getRequestStatus(); - } - else{ - $scope.errorMessage = response.data.error_message; + } 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; + $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/installStatusMailScanner"; + + 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'); } - } - 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; - + $scope.required_hits = response.data.required_hits; + $scope.rewrite_header = response.data.rewrite_header; + $scope.required_score = response.data.required_score; } - } + } - ///// SpamAssassin configs + } - var report_safe = false; + function cantLoadInitialDatas(response) { + $scope.SpamAssassinLoading = true; + } + + } - $('#report_safe').change(function() { - report_safe = $(this).prop('checked'); - }); + ///// - fetchSpamAssassinSettings(); - function fetchSpamAssassinSettings(){ + /// Save SpamAssassin Changes - $scope.SpamAssassinLoading = false; + $scope.failedToSave = true; + $scope.successfullySaved = true; - $('#report_safe').bootstrapToggle('off'); + $scope.saveSpamAssassinConfigurations = function () { - url = "/emailPremium/fetchSpamAssassinSettings"; - - var data = {}; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + $scope.failedToSave = true; + $scope.successfullySaved = true; + $scope.SpamAssassinLoading = false; + $scope.couldNotConnect = true; + url = "/emailPremium/saveSpamAssassinConfigurations"; - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + 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') + } + }; - 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; - } - - } + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - ///// - - /// Save SpamAssassin Changes - - $scope.failedToSave = true; - $scope.successfullySaved = true; - - $scope.saveSpamAssassinConfigurations = function () { - - $scope.failedToSave = true; - $scope.successfullySaved = true; - $scope.SpamAssassinLoading = false; - $scope.couldNotConnect = true; + function ListInitialDatas(response) { - url = "/emailPremium/saveSpamAssassinConfigurations"; + if (response.data.saveStatus === 1) { - var data = { - report_safe:report_safe, - required_hits:$scope.required_hits, - rewrite_header:$scope.rewrite_header, - required_score:$scope.required_score - }; + $scope.failedToSave = true; + $scope.successfullySaved = false; + $scope.SpamAssassinLoading = true; + $scope.couldNotConnect = true; - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + } 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; + } - - $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; - } - - - }; + }; }); \ No newline at end of file