Files
CyberPanel/static/mailServer/mailServer.js

1110 lines
28 KiB
JavaScript
Raw Normal View History

2017-10-24 19:16:36 +05:00
/**
* Created by usman on 8/15/17.
*/
/* Java script code to create account */
app.controller('createEmailAccount', function ($scope, $http) {
2017-10-24 19:16:36 +05:00
$scope.emailDetails = true;
$scope.emailLoading = true;
$scope.canNotCreate = true;
$scope.successfullyCreated = true;
$scope.couldNotConnect = true;
$scope.showEmailDetails = function () {
2017-10-24 19:16:36 +05:00
$scope.emailDetails = false;
$scope.emailLoading = true;
$scope.canNotCreate = true;
$scope.successfullyCreated = true;
$scope.couldNotConnect = true;
$scope.selectedDomain = $scope.emailDomain;
};
$scope.createEmailAccount = function () {
2017-10-24 19:16:36 +05:00
$scope.emailDetails = false;
$scope.emailLoading = false;
$scope.canNotCreate = true;
$scope.successfullyCreated = true;
$scope.couldNotConnect = true;
2017-10-24 19:16:36 +05:00
var url = "/email/submitEmailCreation";
2017-10-24 19:16:36 +05:00
var domain = $scope.emailDomain;
var username = $scope.emailUsername;
var password = $scope.emailPassword;
2017-10-24 19:16:36 +05:00
var data = {
domain: domain,
username: username,
passwordByPass: password,
};
2017-10-24 19:16:36 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
if (response.data.createEmailStatus === 1) {
2017-10-24 19:16:36 +05:00
$scope.emailDetails = false;
$scope.emailLoading = true;
$scope.canNotCreate = true;
$scope.successfullyCreated = false;
$scope.couldNotConnect = true;
2017-10-24 19:16:36 +05:00
$scope.createdID = username + "@" + domain;
2017-10-24 19:16:36 +05:00
} else {
$scope.emailDetails = false;
$scope.emailLoading = true;
$scope.canNotCreate = false;
$scope.successfullyCreated = true;
$scope.couldNotConnect = true;
2017-10-24 19:16:36 +05:00
$scope.errorMessage = response.data.error_message;
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
function cantLoadInitialDatas(response) {
2017-10-24 19:16:36 +05:00
$scope.emailDetails = false;
$scope.emailLoading = true;
$scope.canNotCreate = true;
$scope.successfullyCreated = true;
$scope.couldNotConnect = false;
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
};
$scope.hideFewDetails = function () {
2017-10-24 19:16:36 +05:00
$scope.successfullyCreated = true;
};
2019-03-13 18:22:12 +05:00
$scope.generatedPasswordView = true;
$scope.generatePassword = function () {
$scope.generatedPasswordView = false;
$scope.emailPassword = randomPassword(12);
2019-03-13 18:22:12 +05:00
};
$scope.usePassword = function () {
$scope.generatedPasswordView = true;
};
2017-10-24 19:16:36 +05:00
});
/* Java script code to create account ends here */
/* Java script code to create account */
app.controller('deleteEmailAccount', function ($scope, $http) {
2017-10-24 19:16:36 +05:00
$scope.emailDetails = true;
$scope.emailLoading = true;
$scope.canNotDelete = true;
$scope.successfullyDeleted = true;
$scope.couldNotConnect = true;
$scope.emailDetailsFinal = true;
$scope.noEmails = true;
$scope.showEmailDetails = function () {
2017-10-24 19:16:36 +05:00
$scope.emailDetails = true;
$scope.emailLoading = false;
$scope.canNotDelete = true;
$scope.successfullyDeleted = true;
$scope.couldNotConnect = true;
$scope.emailDetailsFinal = true;
$scope.noEmails = true;
var url = "/email/getEmailsForDomain";
var domain = $scope.emailDomain;
var data = {
domain: domain,
};
2017-10-24 19:16:36 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
if (response.data.fetchStatus == 1) {
2017-10-24 19:16:36 +05:00
$scope.emails = JSON.parse(response.data.data);
2017-10-24 19:16:36 +05:00
$scope.emailDetails = false;
$scope.emailLoading = true;
$scope.canNotDelete = true;
$scope.successfullyDeleted = true;
$scope.couldNotConnect = true;
$scope.emailDetailsFinal = true;
$scope.noEmails = true;
2017-10-24 19:16:36 +05:00
} else {
$scope.emailDetails = true;
$scope.emailLoading = true;
$scope.canNotDelete = true;
$scope.successfullyDeleted = true;
$scope.couldNotConnect = true;
$scope.emailDetailsFinal = true;
$scope.noEmails = false;
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
function cantLoadInitialDatas(response) {
2017-10-24 19:16:36 +05:00
$scope.emailDetails = true;
$scope.emailLoading = true;
$scope.canNotDelete = true;
$scope.successfullyDeleted = true;
$scope.couldNotConnect = false;
$scope.emailDetailsFinal = true;
$scope.noEmails = true;
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
};
$scope.deleteEmailAccountFinal = function () {
2017-10-24 19:16:36 +05:00
$scope.emailLoading = false;
var url = "/email/submitEmailDeletion";
var email = $scope.selectedEmail;
var data = {
email: email,
};
2017-10-24 19:16:36 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
if (response.data.deleteEmailStatus === 1) {
2017-10-24 19:16:36 +05:00
$scope.emailDetails = true;
$scope.emailLoading = true;
$scope.canNotDelete = true;
$scope.successfullyDeleted = false;
$scope.couldNotConnect = true;
$scope.emailDetailsFinal = true;
$scope.noEmails = true;
2017-10-24 19:16:36 +05:00
$scope.deletedID = email;
2017-10-24 19:16:36 +05:00
} else {
$scope.emailDetails = true;
$scope.emailLoading = true;
$scope.canNotDelete = false;
$scope.successfullyDeleted = true;
$scope.couldNotConnect = true;
$scope.emailDetailsFinal = true;
$scope.noEmails = true;
2017-10-24 19:16:36 +05:00
$scope.errorMessage = response.data.error_message;
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
function cantLoadInitialDatas(response) {
2017-10-24 19:16:36 +05:00
$scope.emailDetails = true;
$scope.emailLoading = true;
$scope.canNotDelete = true;
$scope.successfullyDeleted = true;
$scope.couldNotConnect = false;
$scope.emailDetailsFinal = true;
$scope.noEmails = true;
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
};
$scope.deleteEmailAccount = function () {
2017-10-24 19:16:36 +05:00
var domain = $scope.selectedEmail;
if (domain.length > 0) {
2017-10-24 19:16:36 +05:00
$scope.emailDetailsFinal = false;
}
};
});
/* Java script code to create account ends here */
/* Java script code to create account */
app.controller('changeEmailPassword', function ($scope, $http) {
2017-10-24 19:16:36 +05:00
$scope.emailLoading = true;
$scope.emailDetails = true;
$scope.canNotChangePassword = true;
$scope.passwordChanged = true;
$scope.couldNotConnect = true;
$scope.noEmails = true;
$scope.showEmailDetails = function () {
2017-10-24 19:16:36 +05:00
$scope.emailLoading = false;
$scope.emailDetails = true;
$scope.canNotChangePassword = true;
$scope.passwordChanged = true;
$scope.couldNotConnect = true;
$scope.noEmails = true;
var url = "/email/getEmailsForDomain";
var domain = $scope.emailDomain;
var data = {
domain: domain,
};
2017-10-24 19:16:36 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
if (response.data.fetchStatus == 1) {
2017-10-24 19:16:36 +05:00
$scope.emails = JSON.parse(response.data.data);
2017-10-24 19:16:36 +05:00
$scope.emailLoading = true;
$scope.emailDetails = false;
$scope.canNotChangePassword = true;
$scope.passwordChanged = true;
$scope.couldNotConnect = true;
$scope.noEmails = true;
2017-10-24 19:16:36 +05:00
} else {
$scope.emailLoading = true;
$scope.emailDetails = true;
$scope.canNotChangePassword = true;
$scope.passwordChanged = true;
$scope.couldNotConnect = true;
$scope.noEmails = false;
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
function cantLoadInitialDatas(response) {
2017-10-24 19:16:36 +05:00
$scope.emailLoading = true;
$scope.emailDetails = true;
$scope.canNotChangePassword = true;
$scope.passwordChanged = true;
$scope.couldNotConnect = false;
$scope.noEmails = true;
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
};
$scope.changePassword = function () {
2017-10-24 19:16:36 +05:00
$scope.emailLoading = false;
var url = "/email/submitPasswordChange";
var email = $scope.selectedEmail;
var password = $scope.emailPassword;
var domain = $scope.emailDomain;
var data = {
domain: domain,
email: email,
password: password,
};
2017-10-24 19:16:36 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
if (response.data.passChangeStatus == 1) {
2017-10-24 19:16:36 +05:00
$scope.emailLoading = true;
$scope.emailDetails = true;
$scope.canNotChangePassword = true;
$scope.passwordChanged = false;
$scope.couldNotConnect = true;
$scope.noEmails = true;
2017-10-24 19:16:36 +05:00
$scope.passEmail = email;
2017-10-24 19:16:36 +05:00
} else {
$scope.emailLoading = true;
$scope.emailDetails = false;
$scope.canNotChangePassword = false;
$scope.passwordChanged = true;
$scope.couldNotConnect = true;
$scope.noEmails = true;
2017-10-24 19:16:36 +05:00
$scope.errorMessage = response.data.error_message;
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
function cantLoadInitialDatas(response) {
2017-10-24 19:16:36 +05:00
$scope.emailLoading = true;
$scope.emailDetails = false;
$scope.canNotChangePassword = true;
$scope.passwordChanged = true;
$scope.couldNotConnect = false;
$scope.noEmails = true;
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
};
$scope.deleteEmailAccount = function () {
2017-10-24 19:16:36 +05:00
var domain = $scope.selectedEmail;
if (domain.length > 0) {
2017-10-24 19:16:36 +05:00
$scope.emailDetailsFinal = false;
}
};
2019-03-13 18:22:12 +05:00
///
$scope.generatedPasswordView = true;
$scope.generatePassword = function () {
$scope.generatedPasswordView = false;
$scope.emailPassword = randomPassword(12);
2019-03-13 18:22:12 +05:00
};
$scope.usePassword = function () {
$scope.generatedPasswordView = true;
};
2017-10-24 19:16:36 +05:00
});
/* Java script code to create account ends here */
2018-05-03 01:22:28 +05:00
/* Java script code for DKIM Manager */
app.controller('dkimManager', function ($scope, $http, $timeout, $window) {
2018-05-03 01:22:28 +05:00
$scope.manageDKIMLoading = true;
$scope.dkimError = true;
$scope.dkimSuccess = true;
$scope.couldNotConnect = true;
$scope.domainRecords = true;
$scope.noKeysAvailable = true;
2018-05-03 01:22:28 +05:00
$scope.fetchKeys = function () {
2018-05-03 01:22:28 +05:00
$scope.manageDKIMLoading = false;
$scope.dkimError = true;
$scope.dkimSuccess = true;
$scope.couldNotConnect = true;
$scope.domainRecords = true;
$scope.noKeysAvailable = true;
2018-05-03 01:22:28 +05:00
url = "/email/fetchDKIMKeys";
2018-05-03 01:22:28 +05:00
var data = {
domainName: $scope.domainName
};
2018-05-03 01:22:28 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2018-05-03 01:22:28 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2018-05-03 01:22:28 +05:00
function ListInitialDatas(response) {
2018-05-03 01:22:28 +05:00
if (response.data.fetchStatus === 1) {
2018-05-03 01:22:28 +05:00
if (response.data.keysAvailable === 1) {
2018-05-03 01:22:28 +05:00
$scope.manageDKIMLoading = true;
$scope.dkimError = true;
$scope.dkimSuccess = false;
$scope.couldNotConnect = true;
$scope.domainRecords = false;
$scope.noKeysAvailable = true;
2018-05-03 01:22:28 +05:00
$scope.privateKey = response.data.privateKey;
$scope.publicKey = response.data.publicKey;
$scope.dkimSuccessMessage = response.data.dkimSuccessMessage;
2018-05-03 01:22:28 +05:00
} else {
2018-05-03 01:22:28 +05:00
$scope.manageDKIMLoading = true;
$scope.dkimError = true;
$scope.dkimSuccess = true;
$scope.couldNotConnect = true;
2018-05-03 01:22:28 +05:00
$scope.domainRecords = true;
$scope.noKeysAvailable = false;
2018-05-03 01:22:28 +05:00
}
} else {
$scope.errorMessage = response.data.error_message;
2018-05-03 01:22:28 +05:00
$scope.manageDKIMLoading = true;
$scope.dkimError = false;
$scope.dkimSuccess = true;
$scope.couldNotConnect = true;
$scope.domainRecords = true;
$scope.noKeysAvailable = true;
}
2018-05-03 01:22:28 +05:00
}
2018-05-03 01:22:28 +05:00
function cantLoadInitialDatas(response) {
2018-05-03 01:22:28 +05:00
$scope.manageDKIMLoading = true;
$scope.dkimError = true;
$scope.dkimSuccess = true;
$scope.couldNotConnect = false;
$scope.domainRecords = true;
$scope.noKeysAvailable = true;
2018-05-03 01:22:28 +05:00
}
2018-05-03 01:22:28 +05:00
};
2018-05-03 01:22:28 +05:00
$scope.createDomainDKIMKeys = function () {
2018-05-03 01:22:28 +05:00
$scope.manageDKIMLoading = false;
$scope.dkimError = true;
$scope.dkimSuccess = true;
$scope.couldNotConnect = true;
$scope.domainRecords = true;
$scope.noKeysAvailable = false;
2018-05-03 01:22:28 +05:00
url = "/email/generateDKIMKeys";
2018-05-03 01:22:28 +05:00
var data = {
domainName: $scope.domainName
};
2018-05-03 01:22:28 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2018-05-03 01:22:28 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2018-05-03 01:22:28 +05:00
function ListInitialDatas(response) {
2018-05-03 01:22:28 +05:00
if (response.data.generateStatus === 1) {
2018-05-03 01:22:28 +05:00
$scope.manageDKIMLoading = true;
$scope.dkimError = true;
$scope.dkimSuccess = true;
$scope.couldNotConnect = true;
$scope.domainRecords = true;
$scope.noKeysAvailable = true;
2018-05-03 01:22:28 +05:00
$scope.fetchKeys();
2018-05-03 01:22:28 +05:00
} else {
$scope.errorMessage = response.data.error_message;
2018-05-03 01:22:28 +05:00
$scope.manageDKIMLoading = true;
$scope.dkimError = false;
$scope.dkimSuccess = true;
$scope.couldNotConnect = true;
$scope.domainRecords = true;
$scope.noKeysAvailable = false;
}
2018-05-03 01:22:28 +05:00
}
2018-05-03 01:22:28 +05:00
function cantLoadInitialDatas(response) {
2018-05-03 01:22:28 +05:00
$scope.manageDKIMLoading = true;
$scope.dkimError = true;
$scope.dkimSuccess = true;
$scope.couldNotConnect = false;
$scope.domainRecords = true;
$scope.noKeysAvailable = true;
2018-05-03 01:22:28 +05:00
}
2018-05-03 01:22:28 +05:00
};
2018-05-03 01:22:28 +05:00
// Installation
2018-05-03 01:22:28 +05:00
$scope.openDKIMNotifyBox = true;
$scope.openDKIMError = true;
$scope.couldNotConnect = true;
$scope.openDKIMSuccessfullyInstalled = true;
$scope.openDKIMInstallBox = true;
$scope.manageDKIMLoading = true;
2018-05-03 01:22:28 +05:00
$scope.installOpenDKIM = function () {
2018-05-03 01:22:28 +05:00
$scope.openDKIMNotifyBox = true;
$scope.openDKIMError = true;
$scope.couldNotConnect = true;
$scope.openDKIMSuccessfullyInstalled = true;
$scope.openDKIMInstallBox = true;
$scope.manageDKIMLoading = false;
2018-05-03 01:22:28 +05:00
url = "/email/installOpenDKIM";
2018-05-03 01:22:28 +05:00
var data = {};
2018-05-03 01:22:28 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2018-05-03 01:22:28 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2018-05-03 01:22:28 +05:00
function ListInitialDatas(response) {
2018-05-03 01:22:28 +05:00
if (response.data.installOpenDKIM === 1) {
2018-05-03 01:22:28 +05:00
$scope.openDKIMNotifyBox = true;
$scope.openDKIMError = true;
$scope.couldNotConnect = true;
$scope.openDKIMSuccessfullyInstalled = true;
$scope.openDKIMInstallBox = false;
$scope.manageDKIMLoading = true;
2018-05-03 01:22:28 +05:00
getRequestStatus();
2018-05-03 01:22:28 +05:00
} else {
$scope.errorMessage = response.data.error_message;
2018-05-03 01:22:28 +05:00
$scope.openDKIMNotifyBox = false;
$scope.openDKIMError = false;
$scope.couldNotConnect = true;
$scope.openDKIMSuccessfullyInstalled = true;
$scope.openDKIMInstallBox = true;
$scope.manageDKIMLoading = true;
}
2018-05-03 01:22:28 +05:00
}
2018-05-03 01:22:28 +05:00
function cantLoadInitialDatas(response) {
2018-05-03 01:22:28 +05:00
$scope.openDKIMNotifyBox = false;
$scope.openDKIMError = true;
$scope.couldNotConnect = false;
$scope.openDKIMSuccessfullyInstalled = true;
$scope.openDKIMInstallBox = true;
$scope.manageDKIMLoading = false;
}
2018-05-03 01:22:28 +05:00
};
2018-05-03 01:22:28 +05:00
function getRequestStatus() {
2018-05-03 01:22:28 +05:00
$scope.openDKIMNotifyBox = true;
$scope.openDKIMError = true;
$scope.couldNotConnect = true;
$scope.openDKIMSuccessfullyInstalled = true;
$scope.openDKIMInstallBox = false;
$scope.manageDKIMLoading = false;
2018-05-03 01:22:28 +05:00
url = "/email/installStatusOpenDKIM";
2018-05-03 01:22:28 +05:00
var data = {};
2018-05-03 01:22:28 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2018-05-03 01:22:28 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2018-05-03 01:22:28 +05:00
function ListInitialDatas(response) {
2018-05-03 01:22:28 +05:00
if (response.data.abort === 0) {
$scope.requestData = response.data.requestStatus;
$timeout(getRequestStatus, 1000);
} else {
// Notifications
$timeout.cancel();
2018-05-03 01:22:28 +05:00
$scope.openDKIMNotifyBox = false;
$scope.openDKIMError = true;
$scope.couldNotConnect = true;
$scope.openDKIMSuccessfullyInstalled = true;
$scope.openDKIMInstallBox = true;
$scope.manageDKIMLoading = true;
$scope.requestData = response.data.requestStatus;
if (response.data.installed === 0) {
$scope.openDKIMError = false;
$scope.errorMessage = response.data.error_message;
} else {
$scope.openDKIMSuccessfullyInstalled = false;
$timeout(function () {
$window.location.reload();
}, 3000);
2018-05-03 01:22:28 +05:00
}
}
}
function cantLoadInitialDatas(response) {
$scope.modSecNotifyBox = false;
$scope.modeSecInstallBox = false;
$scope.modsecLoading = true;
$scope.failedToStartInallation = true;
$scope.couldNotConnect = false;
$scope.modSecSuccessfullyInstalled = true;
$scope.installationFailed = true;
2018-05-03 01:22:28 +05:00
}
}
2018-05-03 01:22:28 +05:00
});
2018-06-12 03:56:19 +05:00
/* Java script code for email forwarding */
app.controller('emailForwarding', function ($scope, $http) {
2018-06-12 03:56:19 +05:00
$scope.creationBox = true;
$scope.emailDetails = true;
$scope.forwardLoading = true;
$scope.forwardError = true;
$scope.forwardSuccess = true;
$scope.couldNotConnect = true;
$scope.notifyBox = true;
$scope.showEmailDetails = function () {
2018-06-12 03:56:19 +05:00
$scope.creationBox = true;
$scope.emailDetails = true;
$scope.forwardLoading = false;
$scope.forwardError = true;
$scope.forwardSuccess = true;
$scope.couldNotConnect = true;
$scope.notifyBox = true;
var url = "/email/getEmailsForDomain";
var data = {
domain: $scope.emailDomain
};
2018-06-12 03:56:19 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2018-06-12 03:56:19 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2018-06-12 03:56:19 +05:00
function ListInitialDatas(response) {
2018-06-12 03:56:19 +05:00
if (response.data.fetchStatus === 1) {
2018-06-12 03:56:19 +05:00
$scope.emails = JSON.parse(response.data.data);
2018-06-12 03:56:19 +05:00
$scope.creationBox = true;
$scope.emailDetails = false;
$scope.forwardLoading = true;
$scope.forwardError = true;
$scope.forwardSuccess = true;
$scope.couldNotConnect = true;
$scope.notifyBox = false;
} else {
$scope.creationBox = true;
$scope.emailDetails = true;
$scope.forwardLoading = true;
$scope.forwardError = false;
$scope.forwardSuccess = true;
$scope.couldNotConnect = true;
$scope.notifyBox = false;
2018-06-12 03:56:19 +05:00
$scope.errorMessage = response.data.error_message;
2018-06-12 03:56:19 +05:00
}
2018-06-12 03:56:19 +05:00
}
2018-06-12 03:56:19 +05:00
function cantLoadInitialDatas(response) {
2018-06-12 03:56:19 +05:00
$scope.creationBox = true;
$scope.emailDetails = true;
$scope.forwardLoading = true;
$scope.forwardError = true;
$scope.forwardSuccess = true;
$scope.couldNotConnect = false;
$scope.notifyBox = false;
2018-06-12 03:56:19 +05:00
}
2018-06-12 03:56:19 +05:00
};
$scope.selectForwardingEmail = function () {
$scope.creationBox = true;
$scope.emailDetails = false;
$scope.forwardLoading = false;
$scope.forwardError = true;
$scope.forwardSuccess = true;
$scope.couldNotConnect = true;
$scope.notifyBox = true;
$scope.fetchCurrentForwardings();
};
$scope.fetchCurrentForwardings = function () {
2018-06-12 03:56:19 +05:00
$scope.creationBox = false;
$scope.emailDetails = false;
$scope.forwardLoading = false;
$scope.forwardError = true;
$scope.forwardSuccess = true;
$scope.couldNotConnect = true;
$scope.notifyBox = true;
var url = "/email/fetchCurrentForwardings";
var data = {
emailAddress: $scope.selectedEmail
};
2018-06-12 03:56:19 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2018-06-12 03:56:19 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2018-06-12 03:56:19 +05:00
function ListInitialDatas(response) {
2018-06-12 03:56:19 +05:00
if (response.data.fetchStatus === 1) {
2018-06-12 03:56:19 +05:00
$scope.records = JSON.parse(response.data.data);
2018-06-12 03:56:19 +05:00
$scope.creationBox = false;
$scope.emailDetails = false;
$scope.forwardLoading = true;
$scope.forwardError = true;
$scope.forwardSuccess = true;
$scope.couldNotConnect = true;
$scope.notifyBox = true;
} else {
$scope.creationBox = true;
$scope.emailDetails = true;
$scope.forwardLoading = true;
$scope.forwardError = false;
$scope.forwardSuccess = true;
$scope.couldNotConnect = true;
$scope.notifyBox = false;
2018-06-12 03:56:19 +05:00
$scope.errorMessage = response.data.error_message;
2018-06-12 03:56:19 +05:00
}
2018-06-12 03:56:19 +05:00
}
2018-06-12 03:56:19 +05:00
function cantLoadInitialDatas(response) {
2018-06-12 03:56:19 +05:00
$scope.creationBox = true;
$scope.emailDetails = true;
$scope.forwardLoading = true;
$scope.forwardError = true;
$scope.forwardSuccess = true;
$scope.couldNotConnect = false;
$scope.notifyBox = false;
2018-06-12 03:56:19 +05:00
}
2018-06-12 03:56:19 +05:00
};
$scope.deleteForwarding = function (source, destination) {
2018-06-12 03:56:19 +05:00
$scope.creationBox = true;
$scope.emailDetails = true;
$scope.forwardLoading = false;
$scope.forwardError = true;
$scope.forwardSuccess = true;
$scope.couldNotConnect = true;
$scope.notifyBox = true;
var url = "/email/submitForwardDeletion";
var data = {
destination: destination,
source: source
};
2018-06-12 03:56:19 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2018-06-12 03:56:19 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2018-06-12 03:56:19 +05:00
function ListInitialDatas(response) {
2018-06-12 03:56:19 +05:00
if (response.data.deleteForwardingStatus === 1) {
2018-06-12 03:56:19 +05:00
$scope.creationBox = false;
$scope.emailDetails = false;
$scope.forwardLoading = true;
$scope.forwardError = true;
$scope.forwardSuccess = true;
$scope.couldNotConnect = true;
$scope.notifyBox = true;
2018-06-12 03:56:19 +05:00
$scope.fetchCurrentForwardings();
2018-06-12 03:56:19 +05:00
} else {
$scope.creationBox = false;
$scope.emailDetails = false;
$scope.forwardLoading = true;
$scope.forwardError = false;
$scope.forwardSuccess = true;
$scope.couldNotConnect = true;
$scope.notifyBox = false;
2018-06-12 03:56:19 +05:00
$scope.errorMessage = response.data.error_message;
2018-06-12 03:56:19 +05:00
}
2018-06-12 03:56:19 +05:00
}
2018-06-12 03:56:19 +05:00
function cantLoadInitialDatas(response) {
2018-06-12 03:56:19 +05:00
$scope.creationBox = true;
$scope.emailDetails = true;
$scope.forwardLoading = true;
$scope.forwardError = true;
$scope.forwardSuccess = true;
$scope.couldNotConnect = false;
$scope.notifyBox = false;
2018-06-12 03:56:19 +05:00
}
2018-06-12 03:56:19 +05:00
};
$scope.forwardEmail = function () {
2018-06-12 03:56:19 +05:00
$scope.creationBox = false;
$scope.emailDetails = false;
$scope.forwardLoading = false;
$scope.forwardError = true;
$scope.forwardSuccess = true;
$scope.couldNotConnect = true;
$scope.notifyBox = true;
var url = "/email/submitEmailForwardingCreation";
var data = {
source: $scope.selectedEmail,
destination: $scope.destinationEmail
};
2018-06-12 03:56:19 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2018-06-12 03:56:19 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2018-06-12 03:56:19 +05:00
function ListInitialDatas(response) {
2018-06-12 03:56:19 +05:00
if (response.data.createStatus === 1) {
2018-06-12 03:56:19 +05:00
$scope.creationBox = false;
$scope.emailDetails = false;
$scope.forwardLoading = true;
$scope.forwardError = true;
$scope.forwardSuccess = true;
$scope.couldNotConnect = true;
$scope.notifyBox = true;
2018-06-12 03:56:19 +05:00
$scope.fetchCurrentForwardings();
2018-06-12 03:56:19 +05:00
} else {
$scope.creationBox = false;
$scope.emailDetails = false;
$scope.forwardLoading = true;
$scope.forwardError = false;
$scope.forwardSuccess = true;
$scope.couldNotConnect = true;
$scope.notifyBox = false;
2018-06-12 03:56:19 +05:00
$scope.errorMessage = response.data.error_message;
2018-06-12 03:56:19 +05:00
}
2018-06-12 03:56:19 +05:00
}
2018-06-12 03:56:19 +05:00
function cantLoadInitialDatas(response) {
2018-06-12 03:56:19 +05:00
$scope.creationBox = true;
$scope.emailDetails = true;
$scope.forwardLoading = true;
$scope.forwardError = true;
$scope.forwardSuccess = true;
$scope.couldNotConnect = false;
$scope.notifyBox = false;
2018-06-12 03:56:19 +05:00
}
2018-06-12 03:56:19 +05:00
};
});
/* Java script for email forwarding */