From 7e1c6459433e5199be490bd59f9f7327325c0875 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Wed, 3 Jun 2020 22:16:26 +0500 Subject: [PATCH] bug fix: fix email marketing --- .../static/emailMarketing/emailMarketing.js | 2151 +++++++++-------- static/emailMarketing/emailMarketing.js | 2151 +++++++++-------- 2 files changed, 2160 insertions(+), 2142 deletions(-) mode change 100755 => 100644 static/emailMarketing/emailMarketing.js diff --git a/emailMarketing/static/emailMarketing/emailMarketing.js b/emailMarketing/static/emailMarketing/emailMarketing.js index 2e32e0a98..b9c150c64 100755 --- a/emailMarketing/static/emailMarketing/emailMarketing.js +++ b/emailMarketing/static/emailMarketing/emailMarketing.js @@ -2,11 +2,11 @@ * Created by usman on 8/1/17. */ -var emailListURL = "/emailMarketing/"+ $("#domainNamePage").text() + "/emailLists"; +var emailListURL = "/emailMarketing/" + $("#domainNamePage").text() + "/emailLists"; $("#emailLists").attr("href", emailListURL); $("#emailListsChild").attr("href", emailListURL); -var manageListsURL = "/emailMarketing/"+ $("#domainNamePage").text() + "/manageLists"; +var manageListsURL = "/emailMarketing/" + $("#domainNamePage").text() + "/manageLists"; $("#manageLists").attr("href", manageListsURL); $("#manageListsChild").attr("href", manageListsURL); @@ -18,105 +18,105 @@ var composeEmailURL = "/emailMarketing/composeEmailMessage"; $("#composeEmails").attr("href", composeEmailURL); $("#composeEmailsChild").attr("href", composeEmailURL); -var smtpHostsURL = "/emailMarketing/"+ $("#domainNamePage").text() + "/manageSMTP"; +var smtpHostsURL = "/emailMarketing/" + $("#domainNamePage").text() + "/manageSMTP"; $("#manageSMTPHosts").attr("href", smtpHostsURL); $("#manageSMTPHostsChild").attr("href", smtpHostsURL); -app.controller('emailMarketing', function($scope,$http) { +app.controller('emailMarketing', function ($scope, $http) { - $scope.cyberPanelLoading = true; - $scope.fetchUsers = function(){ - $scope.cyberPanelLoading = false; + $scope.cyberPanelLoading = true; + $scope.fetchUsers = function () { + $scope.cyberPanelLoading = false; - url = "/emailMarketing/fetchUsers"; + url = "/emailMarketing/fetchUsers"; - 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) { - $scope.cyberPanelLoading = true; + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; - if(response.data.status === 1){ - $scope.users = JSON.parse(response.data.data); - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + if (response.data.status === 1) { + $scope.users = JSON.parse(response.data.data); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } - } + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); - }; - $scope.fetchUsers(); - $scope.enableDisableMarketing = function(status, userName){ - $scope.cyberPanelLoading = false; + } - url = "/emailMarketing/enableDisableMarketing"; + }; + $scope.fetchUsers(); + $scope.enableDisableMarketing = function (status, userName) { + $scope.cyberPanelLoading = false; - var data = {userName: userName}; + url = "/emailMarketing/enableDisableMarketing"; - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + var data = {userName: userName}; - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - $scope.fetchUsers(); + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + $scope.fetchUsers(); - if(response.data.status === 1){ - new PNotify({ - title: 'Success!', - text: 'Changes successfully saved.', - type:'success' - }); - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + if (response.data.status === 1) { + new PNotify({ + title: 'Success!', + text: 'Changes successfully saved.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } - } + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); - }; + } + + }; }); -app.controller('createEmailList', function($scope, $http, $timeout) { +app.controller('createEmailList', function ($scope, $http, $timeout) { $scope.installationDetailsForm = false; $scope.installationProgress = true; @@ -135,181 +135,178 @@ app.controller('createEmailList', function($scope, $http, $timeout) { $("#installProgress").css("width", "0%"); }; - $scope.createEmailList = function(){ + $scope.createEmailList = function () { + + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.cyberPanelLoading = false; + $scope.goBackDisable = true; + $scope.currentStatus = "Starting to load email addresses.."; + + + url = "/emailMarketing/submitEmailList"; + + var data = { + domain: $("#domainNamePage").text(), + path: $scope.path, + listName: $scope.listName + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + statusFile = response.data.tempStatusPath; + getInstallStatus(); + } else { $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.cyberPanelLoading = false; - $scope.goBackDisable = true; - $scope.currentStatus = "Starting to load email addresses.."; + $scope.cyberPanelLoading = true; + $scope.goBackDisable = false; + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); - url = "/emailMarketing/submitEmailList"; + } - var data = { - domain: $("#domainNamePage").text(), - path:$scope.path, - listName: $scope.listName - }; + } - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.status === 1) - { - statusFile = response.data.tempStatusPath; - getInstallStatus(); - } - else{ - - $scope.installationDetailsForm = true; - $scope.cyberPanelLoading = true; - $scope.goBackDisable = false; - - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - - } - - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } + } }; - function getInstallStatus(){ + function getInstallStatus() { - url = "/websites/installWordpressStatus"; + url = "/websites/installWordpressStatus"; - var data = { - statusFile: statusFile, - domainName: $("#domainNamePage").text() - }; + var data = { + statusFile: statusFile, + domainName: $("#domainNamePage").text() + }; - 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.abort === 1){ + if (response.data.abort === 1) { - if(response.data.installStatus === 1){ + if (response.data.installStatus === 1) { - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.cyberPanelLoading = true; - $scope.goBackDisable = false; - $scope.currentStatus = 'Emails successfully loaded.'; - $timeout.cancel(); - - } - else{ - - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.cyberPanelLoading = true; - $scope.goBackDisable = false; - $scope.currentStatus = response.data.error_message; - - - } - - } - else{ - $scope.installPercentage = response.data.installationProgress; - $scope.currentStatus = response.data.currentStatus; - - $timeout(getInstallStatus,1000); - } - - } - function cantLoadInitialDatas(response) { + $scope.installationDetailsForm = true; + $scope.installationProgress = false; $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + $scope.goBackDisable = false; + $scope.currentStatus = 'Emails successfully loaded.'; + $timeout.cancel(); + } else { - } - - - } - - $scope.fetchEmails = function(){ - $scope.cyberPanelLoading = false; - - url = "/emailMarketing/fetchEmails"; - - var data = {'listName': $scope.listName}; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { + $scope.installationDetailsForm = true; + $scope.installationProgress = false; $scope.cyberPanelLoading = true; + $scope.goBackDisable = false; + $scope.currentStatus = response.data.error_message; - if(response.data.status === 1){ - $scope.records = JSON.parse(response.data.data); - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); } - }; + } else { + $scope.installPercentage = response.data.installationProgress; + $scope.currentStatus = response.data.currentStatus; + + $timeout(getInstallStatus, 1000); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + + } + + + } + + $scope.fetchEmails = function () { + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/fetchEmails"; + + var data = {'listName': $scope.listName}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + + if (response.data.status === 1) { + $scope.records = JSON.parse(response.data.data); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + }; }); -app.controller('manageEmailLists', function($scope, $http, $timeout) { +app.controller('manageEmailLists', function ($scope, $http, $timeout) { $scope.installationDetailsForm = true; $scope.installationProgress = true; @@ -329,134 +326,131 @@ app.controller('manageEmailLists', function($scope, $http, $timeout) { $("#installProgress").css("width", "0%"); }; - $scope.createEmailList = function(){ + $scope.createEmailList = function () { + + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.cyberPanelLoading = false; + $scope.goBackDisable = true; + $scope.currentStatus = "Starting to load email addresses.."; + + + url = "/emailMarketing/submitEmailList"; + + var data = { + domain: $("#domainNamePage").text(), + path: $scope.path, + listName: $scope.listName + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + statusFile = response.data.tempStatusPath; + getInstallStatus(); + } else { $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.cyberPanelLoading = false; - $scope.goBackDisable = true; - $scope.currentStatus = "Starting to load email addresses.."; + $scope.cyberPanelLoading = true; + $scope.goBackDisable = false; + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); - url = "/emailMarketing/submitEmailList"; + } - var data = { - domain: $("#domainNamePage").text(), - path:$scope.path, - listName: $scope.listName - }; + } - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.status === 1) - { - statusFile = response.data.tempStatusPath; - getInstallStatus(); - } - else{ - - $scope.installationDetailsForm = true; - $scope.cyberPanelLoading = true; - $scope.goBackDisable = false; - - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - - } - - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } + } }; - function getInstallStatus(){ + function getInstallStatus() { - url = "/websites/installWordpressStatus"; + url = "/websites/installWordpressStatus"; - var data = { - statusFile: statusFile, - domainName: $("#domainNamePage").text() - }; + var data = { + statusFile: statusFile, + domainName: $("#domainNamePage").text() + }; - 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.abort === 1){ + if (response.data.abort === 1) { - if(response.data.installStatus === 1){ + if (response.data.installStatus === 1) { - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.cyberPanelLoading = true; - $scope.goBackDisable = false; - $scope.currentStatus = 'Emails successfully loaded.'; - $timeout.cancel(); - - } - else{ - - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.cyberPanelLoading = true; - $scope.goBackDisable = false; - $scope.currentStatus = response.data.error_message; - - - } - - } - else{ - $scope.installPercentage = response.data.installationProgress; - $scope.currentStatus = response.data.currentStatus; - - $timeout(getInstallStatus,1000); - } - - } - function cantLoadInitialDatas(response) { + $scope.installationDetailsForm = true; + $scope.installationProgress = false; $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + $scope.goBackDisable = false; + $scope.currentStatus = 'Emails successfully loaded.'; + $timeout.cancel(); + + } else { + + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.cyberPanelLoading = true; + $scope.goBackDisable = false; + $scope.currentStatus = response.data.error_message; } + } else { + $scope.installPercentage = response.data.installationProgress; + $scope.currentStatus = response.data.currentStatus; - } + $timeout(getInstallStatus, 1000); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + + } + + + } /// @@ -470,109 +464,108 @@ app.controller('manageEmailLists', function($scope, $http, $timeout) { $scope.fetchEmails(globalPage); }; - $scope.fetchEmails = function(page){ - globalPage = page; - listVerificationStatus(); + $scope.fetchEmails = function (page) { + globalPage = page; + listVerificationStatus(); - $scope.cyberPanelLoading = false; + $scope.cyberPanelLoading = false; - url = "/emailMarketing/fetchEmails"; + url = "/emailMarketing/fetchEmails"; - var data = { - 'listName': $scope.listName, - 'recordstoShow': $scope.recordstoShow, - 'page': page + var data = { + 'listName': $scope.listName, + 'recordstoShow': $scope.recordstoShow, + 'page': page - }; + }; - 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.cyberPanelLoading = true; + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; - if(response.data.status === 1){ - $scope.currentRecords = false; - $scope.records = JSON.parse(response.data.data); - $scope.pagination = response.data.pagination; - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + if (response.data.status === 1) { + $scope.currentRecords = false; + $scope.records = JSON.parse(response.data.data); + $scope.pagination = response.data.pagination; + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } - } + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); - }; + } + + }; $scope.deleteList = function () { + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/deleteList"; + + var data = { + listName: $scope.listName + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success!', + text: 'Emails Successfully Deleted.', + type: 'success' + }); + } else { + $scope.cyberPanelLoading = false; - url = "/emailMarketing/deleteList"; + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); - var data = { - listName: $scope.listName - }; + } - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + } - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - if (response.data.status === 1) - { - new PNotify({ - title: 'Success!', - text: 'Emails Successfully Deleted.', - type:'success' - }); - } - else{ - - $scope.cyberPanelLoading = false; - - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - - } - - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } + } }; @@ -593,730 +586,746 @@ app.controller('manageEmailLists', function($scope, $http, $timeout) { url = "/emailMarketing/emailVerificationJob"; - var data = { - listName: $scope.listName - }; + var data = { + listName: $scope.listName + }; - 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) - { - listVerificationStatus(); - $scope.verificationButton = true; - } - else{ + if (response.data.status === 1) { + listVerificationStatus(); + $scope.verificationButton = true; + } else { - $scope.cyberPanelLoading = true; - $scope.verificationButton = false; + $scope.cyberPanelLoading = true; + $scope.verificationButton = false; - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); - } + } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - $scope.verificationButton = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + } - } + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + $scope.verificationButton = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } }; var globalCounter = 0; - function listVerificationStatus(){ + function listVerificationStatus() { - $scope.verificationButton = true; - $scope.cyberPanelLoading = false; + $scope.verificationButton = true; + $scope.cyberPanelLoading = false; - url = "/websites/installWordpressStatus"; + url = "/websites/installWordpressStatus"; - var data = { - domain: $("#domainNamePage").text(), - statusFile: "/home/cyberpanel/" + $("#domainNamePage").text() + "/" + $scope.listName - }; + var data = { + domain: $("#domainNamePage").text(), + statusFile: "/home/cyberpanel/" + $("#domainNamePage").text() + "/" + $scope.listName + }; - 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.abort === 1){ + if (response.data.abort === 1) { - if(response.data.installStatus === 1){ - $scope.cyberPanelLoading = true; - $scope.verificationButton = false; - $scope.currentStatusVerification = 'Emails successfully verified.'; - $timeout.cancel(); - - } - else{ - - if(response.data.error_message.search('No such file') > -1){ - $scope.verificationButton = false; - return; - } - $scope.verificationButton = true; - $scope.cyberPanelLoading = false; - $scope.verificationStatus = false; - $scope.currentStatusVerification = response.data.error_message; - - } - - } - else{ - $scope.currentStatusVerification = response.data.currentStatus; - $timeout(listVerificationStatus,1000); - $scope.verificationStatus = false; - } - - } - function cantLoadInitialDatas(response) { + if (response.data.installStatus === 1) { $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + $scope.verificationButton = false; + $scope.currentStatusVerification = 'Emails successfully verified.'; + $timeout.cancel(); + } else { - } - - - } - - // Delete Email from list - - $scope.deleteEmail = function(id){ - - $scope.cyberPanelLoading = false; - - url = "/emailMarketing/deleteEmail"; - - var data = { - id: id - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') + if (response.data.error_message.search('No such file') > -1) { + $scope.verificationButton = false; + return; } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - $scope.fetchEmails(globalPage); - - if (response.data.status === 1) - { - $scope.fetchEmails(globalPage); - new PNotify({ - title: 'Success.', - text: 'Email Successfully deleted.', - type:'success' - }); - - } - else{ - - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - - } - - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } - - }; - - -}); - -app.controller('manageSMTPHostsCTRL', function($scope, $http) { - - $scope.cyberPanelLoading = true; - $scope.fetchSMTPHosts = function(){ + $scope.verificationButton = true; $scope.cyberPanelLoading = false; - - url = "/emailMarketing/fetchSMTPHosts"; - - var data = {}; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - - if(response.data.status === 1){ - $scope.records = JSON.parse(response.data.data); - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + $scope.verificationStatus = false; + $scope.currentStatusVerification = response.data.error_message; } - }; - $scope.fetchSMTPHosts(); - $scope.saveSMTPHost = function(status, userName){ - $scope.cyberPanelLoading = false; + } else { - url = "/emailMarketing/saveSMTPHost"; - - var data = { - smtpHost: $scope.smtpHost, - smtpPort: $scope.smtpPort, - smtpUserName: $scope.smtpUserName, - smtpPassword: $scope.smtpPassword - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - - if(response.data.status === 1){ - $scope.fetchSMTPHosts(); - new PNotify({ - title: 'Success!', - text: 'Successfully saved new SMTP host.', - type:'success' - }); - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } - - }; - $scope.smtpHostOperations = function(operation, id){ - $scope.cyberPanelLoading = false; - - url = "/emailMarketing/smtpHostOperations"; - - var data = { - id: id, - operation: operation - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - $scope.fetchSMTPHosts(); - - if(response.data.status === 1){ - new PNotify({ - title: 'Success!', - text: response.data.message, - type:'success' - }); - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } - - }; -}); - -app.controller('composeMessageCTRL', function($scope, $http) { - - $scope.cyberPanelLoading = true; - $scope.saveTemplate = function(status, userName){ - $scope.cyberPanelLoading = false; - - url = "/emailMarketing/saveEmailTemplate"; - - var data = { - name: $scope.name, - subject: $scope.subject, - fromName: $scope.fromName, - fromEmail: $scope.fromEmail, - replyTo: $scope.replyTo, - emailMessage: $scope.emailMessage - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - - if(response.data.status === 1){ - new PNotify({ - title: 'Success!', - text: 'Template successfully saved.', - type:'success' - }); - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } - - }; -}); - -app.controller('sendEmailsCTRL', function($scope, $http, $timeout) { - - $scope.cyberPanelLoading = true; - $scope.availableFunctions = true; - $scope.sendEmailsView = true; - $scope.jobStatus = true; - - // Button - - $scope.deleteTemplateBTN = false; - $scope.sendEmailBTN = false; - - $scope.templateSelected = function () { - $scope.availableFunctions = false; - $scope.sendEmailsView = true; - $scope.previewLink = '/emailMarketing/preview/' + $scope.selectedTemplate; - $scope.jobStatus = true; - emailJobStatus(); - - }; - - $scope.sendEmails = function () { - $scope.sendEmailsView = false; - $scope.fetchJobs(); - }; - - $scope.fetchJobs = function(){ - - $scope.cyberPanelLoading = false; - - url = "/emailMarketing/fetchJobs"; - - var data = { - 'selectedTemplate': $scope.selectedTemplate - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - - if(response.data.status === 1){ - $scope.currentRecords = false; - $scope.records = JSON.parse(response.data.data); - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } - - }; - - $scope.startEmailJob = function () { - $scope.cyberPanelLoading = false; - $scope.deleteTemplateBTN = true; - $scope.sendEmailBTN = true; - $scope.sendEmailsView = true; - $scope.goBackDisable = true; - - url = "/emailMarketing/startEmailJob"; - - - var data = { - 'selectedTemplate': $scope.selectedTemplate, - 'listName': $scope.listName, - 'host': $scope.host, - 'verificationCheck': $scope.verificationCheck, - 'unsubscribeCheck': $scope.unsubscribeCheck - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - - if(response.data.status === 1){ - emailJobStatus(); - } - else{ - $scope.cyberPanelLoading = true; - $scope.deleteTemplateBTN = false; - $scope.sendEmailBTN = false; - $scope.sendEmailsView = false; - $scope.jobStatus = true; - $scope.goBackDisable = false; - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } - - - }; - - function emailJobStatus(){ - - $scope.cyberPanelLoading = false; - $scope.deleteTemplateBTN = true; - $scope.sendEmailBTN = true; - $scope.sendEmailsView = true; - $scope.jobStatus = false; - $scope.goBackDisable = true; - - url = "/websites/installWordpressStatus"; - - var data = { - domain: 'example.com', - statusFile: "/home/cyberpanel/" + $scope.selectedTemplate + "_pendingJob" - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - - if(response.data.abort === 1){ - - if(response.data.installStatus === 1){ - $scope.cyberPanelLoading = true; - $scope.deleteTemplateBTN = false; - $scope.sendEmailBTN = false; - $scope.sendEmailsView = true; - $scope.jobStatus = false; - $scope.goBackDisable = false; - $scope.currentStatus = 'Emails successfully sent.'; - $scope.fetchJobs(); - $timeout.cancel(); - - } - else{ - - if(response.data.error_message.search('No such file') > -1){ - $scope.cyberPanelLoading = true; - $scope.deleteTemplateBTN = false; - $scope.sendEmailBTN = false; - $scope.sendEmailsView = true; - $scope.jobStatus = true; - $scope.goBackDisable = false; - return; - } - $scope.cyberPanelLoading = true; - $scope.deleteTemplateBTN = false; - $scope.sendEmailBTN = false; - $scope.sendEmailsView = true; - $scope.jobStatus = false; - $scope.goBackDisable = false; - $scope.currentStatus = response.data.error_message; - - } - - } - else{ - $scope.currentStatus = response.data.currentStatus; - $timeout(emailJobStatus,1000); - $scope.cyberPanelLoading = false; - $scope.deleteTemplateBTN = true; - $scope.sendEmailBTN = true; - $scope.sendEmailsView = true; - $scope.jobStatus = false; - $scope.goBackDisable = true; - } - - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page.', - type:'error' - }); - - - } - - - } - - $scope.goBack = function () { + if (response.data.currentStatus.search('No such file') > -1) { $scope.cyberPanelLoading = true; $scope.deleteTemplateBTN = false; $scope.sendEmailBTN = false; - $scope.sendEmailsView = false; + $scope.sendEmailsView = true; $scope.jobStatus = true; - - }; - - $scope.deleteTemplate = function(){ - - $scope.cyberPanelLoading = false; - - url = "/emailMarketing/deleteTemplate"; - - var data = { - selectedTemplate: $scope.selectedTemplate - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - - if (response.data.status === 1) - { - new PNotify({ - title: 'Success.', - text: 'Template Successfully deleted.', - type:'success' - }); - - } - else{ - - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - - } - + $scope.goBackDisable = false; + $timeout.cancel(); + return; } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - } + $scope.currentStatusVerification = response.data.currentStatus; + $timeout(listVerificationStatus, 1000); + $scope.verificationStatus = false; + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + + } + + + } + + // Delete Email from list + + $scope.deleteEmail = function (id) { + + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/deleteEmail"; + + var data = { + id: id + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + $scope.fetchEmails(globalPage); + + if (response.data.status === 1) { + $scope.fetchEmails(globalPage); + new PNotify({ + title: 'Success.', + text: 'Email Successfully deleted.', + type: 'success' + }); + + } else { + + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } }; - $scope.deleteJob = function(id){ - - $scope.cyberPanelLoading = false; - - url = "/emailMarketing/deleteJob"; - - var data = { - id: id - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - function ListInitialDatas(response) { +}); + +app.controller('manageSMTPHostsCTRL', function ($scope, $http) { + + $scope.cyberPanelLoading = true; + $scope.fetchSMTPHosts = function () { + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/fetchSMTPHosts"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + + if (response.data.status === 1) { + $scope.records = JSON.parse(response.data.data); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + }; + $scope.fetchSMTPHosts(); + $scope.saveSMTPHost = function (status, userName) { + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/saveSMTPHost"; + + var data = { + smtpHost: $scope.smtpHost, + smtpPort: $scope.smtpPort, + smtpUserName: $scope.smtpUserName, + smtpPassword: $scope.smtpPassword + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + + if (response.data.status === 1) { + $scope.fetchSMTPHosts(); + new PNotify({ + title: 'Success!', + text: 'Successfully saved new SMTP host.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + }; + $scope.smtpHostOperations = function (operation, id) { + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/smtpHostOperations"; + + var data = { + id: id, + operation: operation + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + $scope.fetchSMTPHosts(); + + if (response.data.status === 1) { + new PNotify({ + title: 'Success!', + text: response.data.message, + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + }; +}); + +app.controller('composeMessageCTRL', function ($scope, $http) { + + $scope.cyberPanelLoading = true; + $scope.saveTemplate = function (status, userName) { + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/saveEmailTemplate"; + + var data = { + name: $scope.name, + subject: $scope.subject, + fromName: $scope.fromName, + fromEmail: $scope.fromEmail, + replyTo: $scope.replyTo, + emailMessage: $scope.emailMessage + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + + if (response.data.status === 1) { + new PNotify({ + title: 'Success!', + text: 'Template successfully saved.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + }; +}); + +app.controller('sendEmailsCTRL', function ($scope, $http, $timeout) { + + $scope.cyberPanelLoading = true; + $scope.availableFunctions = true; + $scope.sendEmailsView = true; + $scope.jobStatus = true; + + // Button + + $scope.deleteTemplateBTN = false; + $scope.sendEmailBTN = false; + + $scope.templateSelected = function () { + $scope.availableFunctions = false; + $scope.sendEmailsView = true; + $scope.previewLink = '/emailMarketing/preview/' + $scope.selectedTemplate; + $scope.jobStatus = true; + emailJobStatus(); + + }; + + $scope.sendEmails = function () { + $scope.sendEmailsView = false; + $scope.fetchJobs(); + }; + + $scope.fetchJobs = function () { + + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/fetchJobs"; + + var data = { + 'selectedTemplate': $scope.selectedTemplate + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + + if (response.data.status === 1) { + $scope.currentRecords = false; + $scope.records = JSON.parse(response.data.data); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + }; + + $scope.startEmailJob = function () { + $scope.cyberPanelLoading = false; + $scope.deleteTemplateBTN = true; + $scope.sendEmailBTN = true; + $scope.sendEmailsView = true; + $scope.goBackDisable = true; + + url = "/emailMarketing/startEmailJob"; + + + var data = { + 'selectedTemplate': $scope.selectedTemplate, + 'listName': $scope.listName, + 'host': $scope.host, + 'verificationCheck': $scope.verificationCheck, + 'unsubscribeCheck': $scope.unsubscribeCheck + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + + if (response.data.status === 1) { + emailJobStatus(); + } else { + $scope.cyberPanelLoading = true; + $scope.deleteTemplateBTN = false; + $scope.sendEmailBTN = false; + $scope.sendEmailsView = false; + $scope.jobStatus = true; + $scope.goBackDisable = false; + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + + }; + + function emailJobStatus() { + + $scope.cyberPanelLoading = false; + $scope.deleteTemplateBTN = true; + $scope.sendEmailBTN = true; + $scope.sendEmailsView = true; + $scope.jobStatus = false; + $scope.goBackDisable = true; + + url = "/websites/installWordpressStatus"; + + var data = { + domain: 'example.com', + statusFile: "/home/cyberpanel/" + $scope.selectedTemplate + "_pendingJob" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.abort === 1) { + + if (response.data.installStatus === 1) { $scope.cyberPanelLoading = true; + $scope.deleteTemplateBTN = false; + $scope.sendEmailBTN = false; + $scope.sendEmailsView = true; + $scope.jobStatus = false; + $scope.goBackDisable = false; + $scope.currentStatus = 'Emails successfully sent.'; $scope.fetchJobs(); + $timeout.cancel(); - if (response.data.status === 1) - { - new PNotify({ - title: 'Success.', - text: 'Template Successfully deleted.', - type:'success' - }); + } else { + if (response.data.error_message.search('No such file') > -1) { + $scope.cyberPanelLoading = true; + $scope.deleteTemplateBTN = false; + $scope.sendEmailBTN = false; + $scope.sendEmailsView = true; + $scope.jobStatus = true; + $scope.goBackDisable = false; + return; } - else{ - - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - - } - - } - function cantLoadInitialDatas(response) { $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + $scope.deleteTemplateBTN = false; + $scope.sendEmailBTN = false; + $scope.sendEmailsView = true; + $scope.jobStatus = false; + $scope.goBackDisable = false; + $scope.currentStatus = response.data.error_message; } + } else { + + if (response.data.currentStatus.search('No such file') > -1) { + $scope.cyberPanelLoading = true; + $scope.deleteTemplateBTN = false; + $scope.sendEmailBTN = false; + $scope.sendEmailsView = true; + $scope.jobStatus = true; + $scope.goBackDisable = false; + $timeout.cancel(); + return; + } + + $scope.currentStatus = response.data.currentStatus; + $timeout(emailJobStatus, 1000); + $scope.cyberPanelLoading = false; + $scope.deleteTemplateBTN = true; + $scope.sendEmailBTN = true; + $scope.sendEmailsView = true; + $scope.jobStatus = false; + $scope.goBackDisable = true; + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + + } + + + } + + $scope.goBack = function () { + $scope.cyberPanelLoading = true; + $scope.deleteTemplateBTN = false; + $scope.sendEmailBTN = false; + $scope.sendEmailsView = false; + $scope.jobStatus = true; + + }; + + $scope.deleteTemplate = function () { + + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/deleteTemplate"; + + var data = { + selectedTemplate: $scope.selectedTemplate + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + + if (response.data.status === 1) { + new PNotify({ + title: 'Success.', + text: 'Template Successfully deleted.', + type: 'success' + }); + + } else { + + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + }; + $scope.deleteJob = function (id) { + + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/deleteJob"; + + var data = { + id: id + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + $scope.fetchJobs(); + + if (response.data.status === 1) { + new PNotify({ + title: 'Success.', + text: 'Template Successfully deleted.', + type: 'success' + }); + + } else { + + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + }; }); diff --git a/static/emailMarketing/emailMarketing.js b/static/emailMarketing/emailMarketing.js old mode 100755 new mode 100644 index 2e32e0a98..b9c150c64 --- a/static/emailMarketing/emailMarketing.js +++ b/static/emailMarketing/emailMarketing.js @@ -2,11 +2,11 @@ * Created by usman on 8/1/17. */ -var emailListURL = "/emailMarketing/"+ $("#domainNamePage").text() + "/emailLists"; +var emailListURL = "/emailMarketing/" + $("#domainNamePage").text() + "/emailLists"; $("#emailLists").attr("href", emailListURL); $("#emailListsChild").attr("href", emailListURL); -var manageListsURL = "/emailMarketing/"+ $("#domainNamePage").text() + "/manageLists"; +var manageListsURL = "/emailMarketing/" + $("#domainNamePage").text() + "/manageLists"; $("#manageLists").attr("href", manageListsURL); $("#manageListsChild").attr("href", manageListsURL); @@ -18,105 +18,105 @@ var composeEmailURL = "/emailMarketing/composeEmailMessage"; $("#composeEmails").attr("href", composeEmailURL); $("#composeEmailsChild").attr("href", composeEmailURL); -var smtpHostsURL = "/emailMarketing/"+ $("#domainNamePage").text() + "/manageSMTP"; +var smtpHostsURL = "/emailMarketing/" + $("#domainNamePage").text() + "/manageSMTP"; $("#manageSMTPHosts").attr("href", smtpHostsURL); $("#manageSMTPHostsChild").attr("href", smtpHostsURL); -app.controller('emailMarketing', function($scope,$http) { +app.controller('emailMarketing', function ($scope, $http) { - $scope.cyberPanelLoading = true; - $scope.fetchUsers = function(){ - $scope.cyberPanelLoading = false; + $scope.cyberPanelLoading = true; + $scope.fetchUsers = function () { + $scope.cyberPanelLoading = false; - url = "/emailMarketing/fetchUsers"; + url = "/emailMarketing/fetchUsers"; - 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) { - $scope.cyberPanelLoading = true; + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; - if(response.data.status === 1){ - $scope.users = JSON.parse(response.data.data); - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + if (response.data.status === 1) { + $scope.users = JSON.parse(response.data.data); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } - } + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); - }; - $scope.fetchUsers(); - $scope.enableDisableMarketing = function(status, userName){ - $scope.cyberPanelLoading = false; + } - url = "/emailMarketing/enableDisableMarketing"; + }; + $scope.fetchUsers(); + $scope.enableDisableMarketing = function (status, userName) { + $scope.cyberPanelLoading = false; - var data = {userName: userName}; + url = "/emailMarketing/enableDisableMarketing"; - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + var data = {userName: userName}; - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - $scope.fetchUsers(); + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + $scope.fetchUsers(); - if(response.data.status === 1){ - new PNotify({ - title: 'Success!', - text: 'Changes successfully saved.', - type:'success' - }); - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + if (response.data.status === 1) { + new PNotify({ + title: 'Success!', + text: 'Changes successfully saved.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } - } + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); - }; + } + + }; }); -app.controller('createEmailList', function($scope, $http, $timeout) { +app.controller('createEmailList', function ($scope, $http, $timeout) { $scope.installationDetailsForm = false; $scope.installationProgress = true; @@ -135,181 +135,178 @@ app.controller('createEmailList', function($scope, $http, $timeout) { $("#installProgress").css("width", "0%"); }; - $scope.createEmailList = function(){ + $scope.createEmailList = function () { + + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.cyberPanelLoading = false; + $scope.goBackDisable = true; + $scope.currentStatus = "Starting to load email addresses.."; + + + url = "/emailMarketing/submitEmailList"; + + var data = { + domain: $("#domainNamePage").text(), + path: $scope.path, + listName: $scope.listName + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + statusFile = response.data.tempStatusPath; + getInstallStatus(); + } else { $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.cyberPanelLoading = false; - $scope.goBackDisable = true; - $scope.currentStatus = "Starting to load email addresses.."; + $scope.cyberPanelLoading = true; + $scope.goBackDisable = false; + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); - url = "/emailMarketing/submitEmailList"; + } - var data = { - domain: $("#domainNamePage").text(), - path:$scope.path, - listName: $scope.listName - }; + } - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.status === 1) - { - statusFile = response.data.tempStatusPath; - getInstallStatus(); - } - else{ - - $scope.installationDetailsForm = true; - $scope.cyberPanelLoading = true; - $scope.goBackDisable = false; - - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - - } - - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } + } }; - function getInstallStatus(){ + function getInstallStatus() { - url = "/websites/installWordpressStatus"; + url = "/websites/installWordpressStatus"; - var data = { - statusFile: statusFile, - domainName: $("#domainNamePage").text() - }; + var data = { + statusFile: statusFile, + domainName: $("#domainNamePage").text() + }; - 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.abort === 1){ + if (response.data.abort === 1) { - if(response.data.installStatus === 1){ + if (response.data.installStatus === 1) { - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.cyberPanelLoading = true; - $scope.goBackDisable = false; - $scope.currentStatus = 'Emails successfully loaded.'; - $timeout.cancel(); - - } - else{ - - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.cyberPanelLoading = true; - $scope.goBackDisable = false; - $scope.currentStatus = response.data.error_message; - - - } - - } - else{ - $scope.installPercentage = response.data.installationProgress; - $scope.currentStatus = response.data.currentStatus; - - $timeout(getInstallStatus,1000); - } - - } - function cantLoadInitialDatas(response) { + $scope.installationDetailsForm = true; + $scope.installationProgress = false; $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + $scope.goBackDisable = false; + $scope.currentStatus = 'Emails successfully loaded.'; + $timeout.cancel(); + } else { - } - - - } - - $scope.fetchEmails = function(){ - $scope.cyberPanelLoading = false; - - url = "/emailMarketing/fetchEmails"; - - var data = {'listName': $scope.listName}; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { + $scope.installationDetailsForm = true; + $scope.installationProgress = false; $scope.cyberPanelLoading = true; + $scope.goBackDisable = false; + $scope.currentStatus = response.data.error_message; - if(response.data.status === 1){ - $scope.records = JSON.parse(response.data.data); - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); } - }; + } else { + $scope.installPercentage = response.data.installationProgress; + $scope.currentStatus = response.data.currentStatus; + + $timeout(getInstallStatus, 1000); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + + } + + + } + + $scope.fetchEmails = function () { + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/fetchEmails"; + + var data = {'listName': $scope.listName}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + + if (response.data.status === 1) { + $scope.records = JSON.parse(response.data.data); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + }; }); -app.controller('manageEmailLists', function($scope, $http, $timeout) { +app.controller('manageEmailLists', function ($scope, $http, $timeout) { $scope.installationDetailsForm = true; $scope.installationProgress = true; @@ -329,134 +326,131 @@ app.controller('manageEmailLists', function($scope, $http, $timeout) { $("#installProgress").css("width", "0%"); }; - $scope.createEmailList = function(){ + $scope.createEmailList = function () { + + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.cyberPanelLoading = false; + $scope.goBackDisable = true; + $scope.currentStatus = "Starting to load email addresses.."; + + + url = "/emailMarketing/submitEmailList"; + + var data = { + domain: $("#domainNamePage").text(), + path: $scope.path, + listName: $scope.listName + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + statusFile = response.data.tempStatusPath; + getInstallStatus(); + } else { $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.cyberPanelLoading = false; - $scope.goBackDisable = true; - $scope.currentStatus = "Starting to load email addresses.."; + $scope.cyberPanelLoading = true; + $scope.goBackDisable = false; + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); - url = "/emailMarketing/submitEmailList"; + } - var data = { - domain: $("#domainNamePage").text(), - path:$scope.path, - listName: $scope.listName - }; + } - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - if (response.data.status === 1) - { - statusFile = response.data.tempStatusPath; - getInstallStatus(); - } - else{ - - $scope.installationDetailsForm = true; - $scope.cyberPanelLoading = true; - $scope.goBackDisable = false; - - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - - } - - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } + } }; - function getInstallStatus(){ + function getInstallStatus() { - url = "/websites/installWordpressStatus"; + url = "/websites/installWordpressStatus"; - var data = { - statusFile: statusFile, - domainName: $("#domainNamePage").text() - }; + var data = { + statusFile: statusFile, + domainName: $("#domainNamePage").text() + }; - 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.abort === 1){ + if (response.data.abort === 1) { - if(response.data.installStatus === 1){ + if (response.data.installStatus === 1) { - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.cyberPanelLoading = true; - $scope.goBackDisable = false; - $scope.currentStatus = 'Emails successfully loaded.'; - $timeout.cancel(); - - } - else{ - - $scope.installationDetailsForm = true; - $scope.installationProgress = false; - $scope.cyberPanelLoading = true; - $scope.goBackDisable = false; - $scope.currentStatus = response.data.error_message; - - - } - - } - else{ - $scope.installPercentage = response.data.installationProgress; - $scope.currentStatus = response.data.currentStatus; - - $timeout(getInstallStatus,1000); - } - - } - function cantLoadInitialDatas(response) { + $scope.installationDetailsForm = true; + $scope.installationProgress = false; $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + $scope.goBackDisable = false; + $scope.currentStatus = 'Emails successfully loaded.'; + $timeout.cancel(); + + } else { + + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.cyberPanelLoading = true; + $scope.goBackDisable = false; + $scope.currentStatus = response.data.error_message; } + } else { + $scope.installPercentage = response.data.installationProgress; + $scope.currentStatus = response.data.currentStatus; - } + $timeout(getInstallStatus, 1000); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + + } + + + } /// @@ -470,109 +464,108 @@ app.controller('manageEmailLists', function($scope, $http, $timeout) { $scope.fetchEmails(globalPage); }; - $scope.fetchEmails = function(page){ - globalPage = page; - listVerificationStatus(); + $scope.fetchEmails = function (page) { + globalPage = page; + listVerificationStatus(); - $scope.cyberPanelLoading = false; + $scope.cyberPanelLoading = false; - url = "/emailMarketing/fetchEmails"; + url = "/emailMarketing/fetchEmails"; - var data = { - 'listName': $scope.listName, - 'recordstoShow': $scope.recordstoShow, - 'page': page + var data = { + 'listName': $scope.listName, + 'recordstoShow': $scope.recordstoShow, + 'page': page - }; + }; - 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.cyberPanelLoading = true; + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; - if(response.data.status === 1){ - $scope.currentRecords = false; - $scope.records = JSON.parse(response.data.data); - $scope.pagination = response.data.pagination; - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + if (response.data.status === 1) { + $scope.currentRecords = false; + $scope.records = JSON.parse(response.data.data); + $scope.pagination = response.data.pagination; + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } - } + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); - }; + } + + }; $scope.deleteList = function () { + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/deleteList"; + + var data = { + listName: $scope.listName + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success!', + text: 'Emails Successfully Deleted.', + type: 'success' + }); + } else { + $scope.cyberPanelLoading = false; - url = "/emailMarketing/deleteList"; + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); - var data = { - listName: $scope.listName - }; + } - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; + } - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - if (response.data.status === 1) - { - new PNotify({ - title: 'Success!', - text: 'Emails Successfully Deleted.', - type:'success' - }); - } - else{ - - $scope.cyberPanelLoading = false; - - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - - } - - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } + } }; @@ -593,730 +586,746 @@ app.controller('manageEmailLists', function($scope, $http, $timeout) { url = "/emailMarketing/emailVerificationJob"; - var data = { - listName: $scope.listName - }; + var data = { + listName: $scope.listName + }; - 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) - { - listVerificationStatus(); - $scope.verificationButton = true; - } - else{ + if (response.data.status === 1) { + listVerificationStatus(); + $scope.verificationButton = true; + } else { - $scope.cyberPanelLoading = true; - $scope.verificationButton = false; + $scope.cyberPanelLoading = true; + $scope.verificationButton = false; - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); - } + } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - $scope.verificationButton = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + } - } + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + $scope.verificationButton = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } }; var globalCounter = 0; - function listVerificationStatus(){ + function listVerificationStatus() { - $scope.verificationButton = true; - $scope.cyberPanelLoading = false; + $scope.verificationButton = true; + $scope.cyberPanelLoading = false; - url = "/websites/installWordpressStatus"; + url = "/websites/installWordpressStatus"; - var data = { - domain: $("#domainNamePage").text(), - statusFile: "/home/cyberpanel/" + $("#domainNamePage").text() + "/" + $scope.listName - }; + var data = { + domain: $("#domainNamePage").text(), + statusFile: "/home/cyberpanel/" + $("#domainNamePage").text() + "/" + $scope.listName + }; - 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.abort === 1){ + if (response.data.abort === 1) { - if(response.data.installStatus === 1){ - $scope.cyberPanelLoading = true; - $scope.verificationButton = false; - $scope.currentStatusVerification = 'Emails successfully verified.'; - $timeout.cancel(); - - } - else{ - - if(response.data.error_message.search('No such file') > -1){ - $scope.verificationButton = false; - return; - } - $scope.verificationButton = true; - $scope.cyberPanelLoading = false; - $scope.verificationStatus = false; - $scope.currentStatusVerification = response.data.error_message; - - } - - } - else{ - $scope.currentStatusVerification = response.data.currentStatus; - $timeout(listVerificationStatus,1000); - $scope.verificationStatus = false; - } - - } - function cantLoadInitialDatas(response) { + if (response.data.installStatus === 1) { $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + $scope.verificationButton = false; + $scope.currentStatusVerification = 'Emails successfully verified.'; + $timeout.cancel(); + } else { - } - - - } - - // Delete Email from list - - $scope.deleteEmail = function(id){ - - $scope.cyberPanelLoading = false; - - url = "/emailMarketing/deleteEmail"; - - var data = { - id: id - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') + if (response.data.error_message.search('No such file') > -1) { + $scope.verificationButton = false; + return; } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - $scope.fetchEmails(globalPage); - - if (response.data.status === 1) - { - $scope.fetchEmails(globalPage); - new PNotify({ - title: 'Success.', - text: 'Email Successfully deleted.', - type:'success' - }); - - } - else{ - - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - - } - - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } - - }; - - -}); - -app.controller('manageSMTPHostsCTRL', function($scope, $http) { - - $scope.cyberPanelLoading = true; - $scope.fetchSMTPHosts = function(){ + $scope.verificationButton = true; $scope.cyberPanelLoading = false; - - url = "/emailMarketing/fetchSMTPHosts"; - - var data = {}; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - - if(response.data.status === 1){ - $scope.records = JSON.parse(response.data.data); - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + $scope.verificationStatus = false; + $scope.currentStatusVerification = response.data.error_message; } - }; - $scope.fetchSMTPHosts(); - $scope.saveSMTPHost = function(status, userName){ - $scope.cyberPanelLoading = false; + } else { - url = "/emailMarketing/saveSMTPHost"; - - var data = { - smtpHost: $scope.smtpHost, - smtpPort: $scope.smtpPort, - smtpUserName: $scope.smtpUserName, - smtpPassword: $scope.smtpPassword - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - - if(response.data.status === 1){ - $scope.fetchSMTPHosts(); - new PNotify({ - title: 'Success!', - text: 'Successfully saved new SMTP host.', - type:'success' - }); - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } - - }; - $scope.smtpHostOperations = function(operation, id){ - $scope.cyberPanelLoading = false; - - url = "/emailMarketing/smtpHostOperations"; - - var data = { - id: id, - operation: operation - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - $scope.fetchSMTPHosts(); - - if(response.data.status === 1){ - new PNotify({ - title: 'Success!', - text: response.data.message, - type:'success' - }); - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } - - }; -}); - -app.controller('composeMessageCTRL', function($scope, $http) { - - $scope.cyberPanelLoading = true; - $scope.saveTemplate = function(status, userName){ - $scope.cyberPanelLoading = false; - - url = "/emailMarketing/saveEmailTemplate"; - - var data = { - name: $scope.name, - subject: $scope.subject, - fromName: $scope.fromName, - fromEmail: $scope.fromEmail, - replyTo: $scope.replyTo, - emailMessage: $scope.emailMessage - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - - if(response.data.status === 1){ - new PNotify({ - title: 'Success!', - text: 'Template successfully saved.', - type:'success' - }); - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } - - }; -}); - -app.controller('sendEmailsCTRL', function($scope, $http, $timeout) { - - $scope.cyberPanelLoading = true; - $scope.availableFunctions = true; - $scope.sendEmailsView = true; - $scope.jobStatus = true; - - // Button - - $scope.deleteTemplateBTN = false; - $scope.sendEmailBTN = false; - - $scope.templateSelected = function () { - $scope.availableFunctions = false; - $scope.sendEmailsView = true; - $scope.previewLink = '/emailMarketing/preview/' + $scope.selectedTemplate; - $scope.jobStatus = true; - emailJobStatus(); - - }; - - $scope.sendEmails = function () { - $scope.sendEmailsView = false; - $scope.fetchJobs(); - }; - - $scope.fetchJobs = function(){ - - $scope.cyberPanelLoading = false; - - url = "/emailMarketing/fetchJobs"; - - var data = { - 'selectedTemplate': $scope.selectedTemplate - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - - if(response.data.status === 1){ - $scope.currentRecords = false; - $scope.records = JSON.parse(response.data.data); - } - else{ - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } - - }; - - $scope.startEmailJob = function () { - $scope.cyberPanelLoading = false; - $scope.deleteTemplateBTN = true; - $scope.sendEmailBTN = true; - $scope.sendEmailsView = true; - $scope.goBackDisable = true; - - url = "/emailMarketing/startEmailJob"; - - - var data = { - 'selectedTemplate': $scope.selectedTemplate, - 'listName': $scope.listName, - 'host': $scope.host, - 'verificationCheck': $scope.verificationCheck, - 'unsubscribeCheck': $scope.unsubscribeCheck - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - - if(response.data.status === 1){ - emailJobStatus(); - } - else{ - $scope.cyberPanelLoading = true; - $scope.deleteTemplateBTN = false; - $scope.sendEmailBTN = false; - $scope.sendEmailsView = false; - $scope.jobStatus = true; - $scope.goBackDisable = false; - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - } - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = false; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - - } - - - }; - - function emailJobStatus(){ - - $scope.cyberPanelLoading = false; - $scope.deleteTemplateBTN = true; - $scope.sendEmailBTN = true; - $scope.sendEmailsView = true; - $scope.jobStatus = false; - $scope.goBackDisable = true; - - url = "/websites/installWordpressStatus"; - - var data = { - domain: 'example.com', - statusFile: "/home/cyberpanel/" + $scope.selectedTemplate + "_pendingJob" - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - - - if(response.data.abort === 1){ - - if(response.data.installStatus === 1){ - $scope.cyberPanelLoading = true; - $scope.deleteTemplateBTN = false; - $scope.sendEmailBTN = false; - $scope.sendEmailsView = true; - $scope.jobStatus = false; - $scope.goBackDisable = false; - $scope.currentStatus = 'Emails successfully sent.'; - $scope.fetchJobs(); - $timeout.cancel(); - - } - else{ - - if(response.data.error_message.search('No such file') > -1){ - $scope.cyberPanelLoading = true; - $scope.deleteTemplateBTN = false; - $scope.sendEmailBTN = false; - $scope.sendEmailsView = true; - $scope.jobStatus = true; - $scope.goBackDisable = false; - return; - } - $scope.cyberPanelLoading = true; - $scope.deleteTemplateBTN = false; - $scope.sendEmailBTN = false; - $scope.sendEmailsView = true; - $scope.jobStatus = false; - $scope.goBackDisable = false; - $scope.currentStatus = response.data.error_message; - - } - - } - else{ - $scope.currentStatus = response.data.currentStatus; - $timeout(emailJobStatus,1000); - $scope.cyberPanelLoading = false; - $scope.deleteTemplateBTN = true; - $scope.sendEmailBTN = true; - $scope.sendEmailsView = true; - $scope.jobStatus = false; - $scope.goBackDisable = true; - } - - } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page.', - type:'error' - }); - - - } - - - } - - $scope.goBack = function () { + if (response.data.currentStatus.search('No such file') > -1) { $scope.cyberPanelLoading = true; $scope.deleteTemplateBTN = false; $scope.sendEmailBTN = false; - $scope.sendEmailsView = false; + $scope.sendEmailsView = true; $scope.jobStatus = true; - - }; - - $scope.deleteTemplate = function(){ - - $scope.cyberPanelLoading = false; - - url = "/emailMarketing/deleteTemplate"; - - var data = { - selectedTemplate: $scope.selectedTemplate - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - - - function ListInitialDatas(response) { - $scope.cyberPanelLoading = true; - - if (response.data.status === 1) - { - new PNotify({ - title: 'Success.', - text: 'Template Successfully deleted.', - type:'success' - }); - - } - else{ - - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - - } - + $scope.goBackDisable = false; + $timeout.cancel(); + return; } - function cantLoadInitialDatas(response) { - $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); - } + $scope.currentStatusVerification = response.data.currentStatus; + $timeout(listVerificationStatus, 1000); + $scope.verificationStatus = false; + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + + } + + + } + + // Delete Email from list + + $scope.deleteEmail = function (id) { + + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/deleteEmail"; + + var data = { + id: id + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + $scope.fetchEmails(globalPage); + + if (response.data.status === 1) { + $scope.fetchEmails(globalPage); + new PNotify({ + title: 'Success.', + text: 'Email Successfully deleted.', + type: 'success' + }); + + } else { + + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } }; - $scope.deleteJob = function(id){ - - $scope.cyberPanelLoading = false; - - url = "/emailMarketing/deleteJob"; - - var data = { - id: id - }; - - var config = { - headers : { - 'X-CSRFToken': getCookie('csrftoken') - } - }; - - $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); - function ListInitialDatas(response) { +}); + +app.controller('manageSMTPHostsCTRL', function ($scope, $http) { + + $scope.cyberPanelLoading = true; + $scope.fetchSMTPHosts = function () { + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/fetchSMTPHosts"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + + if (response.data.status === 1) { + $scope.records = JSON.parse(response.data.data); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + }; + $scope.fetchSMTPHosts(); + $scope.saveSMTPHost = function (status, userName) { + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/saveSMTPHost"; + + var data = { + smtpHost: $scope.smtpHost, + smtpPort: $scope.smtpPort, + smtpUserName: $scope.smtpUserName, + smtpPassword: $scope.smtpPassword + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + + if (response.data.status === 1) { + $scope.fetchSMTPHosts(); + new PNotify({ + title: 'Success!', + text: 'Successfully saved new SMTP host.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + }; + $scope.smtpHostOperations = function (operation, id) { + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/smtpHostOperations"; + + var data = { + id: id, + operation: operation + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + $scope.fetchSMTPHosts(); + + if (response.data.status === 1) { + new PNotify({ + title: 'Success!', + text: response.data.message, + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + }; +}); + +app.controller('composeMessageCTRL', function ($scope, $http) { + + $scope.cyberPanelLoading = true; + $scope.saveTemplate = function (status, userName) { + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/saveEmailTemplate"; + + var data = { + name: $scope.name, + subject: $scope.subject, + fromName: $scope.fromName, + fromEmail: $scope.fromEmail, + replyTo: $scope.replyTo, + emailMessage: $scope.emailMessage + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + + if (response.data.status === 1) { + new PNotify({ + title: 'Success!', + text: 'Template successfully saved.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + }; +}); + +app.controller('sendEmailsCTRL', function ($scope, $http, $timeout) { + + $scope.cyberPanelLoading = true; + $scope.availableFunctions = true; + $scope.sendEmailsView = true; + $scope.jobStatus = true; + + // Button + + $scope.deleteTemplateBTN = false; + $scope.sendEmailBTN = false; + + $scope.templateSelected = function () { + $scope.availableFunctions = false; + $scope.sendEmailsView = true; + $scope.previewLink = '/emailMarketing/preview/' + $scope.selectedTemplate; + $scope.jobStatus = true; + emailJobStatus(); + + }; + + $scope.sendEmails = function () { + $scope.sendEmailsView = false; + $scope.fetchJobs(); + }; + + $scope.fetchJobs = function () { + + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/fetchJobs"; + + var data = { + 'selectedTemplate': $scope.selectedTemplate + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + + if (response.data.status === 1) { + $scope.currentRecords = false; + $scope.records = JSON.parse(response.data.data); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + }; + + $scope.startEmailJob = function () { + $scope.cyberPanelLoading = false; + $scope.deleteTemplateBTN = true; + $scope.sendEmailBTN = true; + $scope.sendEmailsView = true; + $scope.goBackDisable = true; + + url = "/emailMarketing/startEmailJob"; + + + var data = { + 'selectedTemplate': $scope.selectedTemplate, + 'listName': $scope.listName, + 'host': $scope.host, + 'verificationCheck': $scope.verificationCheck, + 'unsubscribeCheck': $scope.unsubscribeCheck + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + + if (response.data.status === 1) { + emailJobStatus(); + } else { + $scope.cyberPanelLoading = true; + $scope.deleteTemplateBTN = false; + $scope.sendEmailBTN = false; + $scope.sendEmailsView = false; + $scope.jobStatus = true; + $scope.goBackDisable = false; + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = false; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + + }; + + function emailJobStatus() { + + $scope.cyberPanelLoading = false; + $scope.deleteTemplateBTN = true; + $scope.sendEmailBTN = true; + $scope.sendEmailsView = true; + $scope.jobStatus = false; + $scope.goBackDisable = true; + + url = "/websites/installWordpressStatus"; + + var data = { + domain: 'example.com', + statusFile: "/home/cyberpanel/" + $scope.selectedTemplate + "_pendingJob" + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.abort === 1) { + + if (response.data.installStatus === 1) { $scope.cyberPanelLoading = true; + $scope.deleteTemplateBTN = false; + $scope.sendEmailBTN = false; + $scope.sendEmailsView = true; + $scope.jobStatus = false; + $scope.goBackDisable = false; + $scope.currentStatus = 'Emails successfully sent.'; $scope.fetchJobs(); + $timeout.cancel(); - if (response.data.status === 1) - { - new PNotify({ - title: 'Success.', - text: 'Template Successfully deleted.', - type:'success' - }); + } else { + if (response.data.error_message.search('No such file') > -1) { + $scope.cyberPanelLoading = true; + $scope.deleteTemplateBTN = false; + $scope.sendEmailBTN = false; + $scope.sendEmailsView = true; + $scope.jobStatus = true; + $scope.goBackDisable = false; + return; } - else{ - - new PNotify({ - title: 'Operation Failed!', - text: response.data.error_message, - type:'error' - }); - - } - - } - function cantLoadInitialDatas(response) { $scope.cyberPanelLoading = true; - new PNotify({ - title: 'Operation Failed!', - text: 'Could not connect to server, please refresh this page', - type:'error' - }); + $scope.deleteTemplateBTN = false; + $scope.sendEmailBTN = false; + $scope.sendEmailsView = true; + $scope.jobStatus = false; + $scope.goBackDisable = false; + $scope.currentStatus = response.data.error_message; } + } else { + + if (response.data.currentStatus.search('No such file') > -1) { + $scope.cyberPanelLoading = true; + $scope.deleteTemplateBTN = false; + $scope.sendEmailBTN = false; + $scope.sendEmailsView = true; + $scope.jobStatus = true; + $scope.goBackDisable = false; + $timeout.cancel(); + return; + } + + $scope.currentStatus = response.data.currentStatus; + $timeout(emailJobStatus, 1000); + $scope.cyberPanelLoading = false; + $scope.deleteTemplateBTN = true; + $scope.sendEmailBTN = true; + $scope.sendEmailsView = true; + $scope.jobStatus = false; + $scope.goBackDisable = true; + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + + } + + + } + + $scope.goBack = function () { + $scope.cyberPanelLoading = true; + $scope.deleteTemplateBTN = false; + $scope.sendEmailBTN = false; + $scope.sendEmailsView = false; + $scope.jobStatus = true; + + }; + + $scope.deleteTemplate = function () { + + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/deleteTemplate"; + + var data = { + selectedTemplate: $scope.selectedTemplate + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + + if (response.data.status === 1) { + new PNotify({ + title: 'Success.', + text: 'Template Successfully deleted.', + type: 'success' + }); + + } else { + + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + }; + $scope.deleteJob = function (id) { + + $scope.cyberPanelLoading = false; + + url = "/emailMarketing/deleteJob"; + + var data = { + id: id + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + $scope.fetchJobs(); + + if (response.data.status === 1) { + new PNotify({ + title: 'Success.', + text: 'Template Successfully deleted.', + type: 'success' + }); + + } else { + + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + }; });