Files
CyberPanel/static/backup/backup.js

1544 lines
38 KiB
JavaScript
Raw Normal View History

2017-10-24 19:16:36 +05:00
/**
* Created by usman on 9/17/17.
*/
//*** Backup site ****//
2019-03-19 01:04:22 +05:00
app.controller('backupWebsiteControl', function ($scope, $http, $timeout) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.destination = true;
$scope.backupButton = true;
$scope.backupLoading = true;
$scope.runningBackup = true;
$scope.cancelButton = true;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
populateCurrentRecords();
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.cancelBackup = function () {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var backupCancellationDomain = $scope.websiteToBeBacked;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
url = "/backup/cancelBackupCreation";
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var data = {
backupCancellationDomain: backupCancellationDomain,
fileName: $scope.fileName,
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.fetchDetails = function () {
getBackupStatus();
populateCurrentRecords();
$scope.destination = false;
$scope.runningBackup = true;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function getBackupStatus() {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.backupLoadingBottom = false;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var websiteToBeBacked = $scope.websiteToBeBacked;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
url = "/backup/backupStatus";
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var data = {
websiteToBeBacked: websiteToBeBacked,
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
if (response.data.backupStatus === 1) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
if (response.data.abort === 1) {
$timeout.cancel();
$scope.backupLoadingBottom = true;
$scope.destination = false;
$scope.runningBackup = false;
$scope.cancelButton = true;
$scope.backupButton = false;
$scope.backupLoading = true;
$scope.fileName = response.data.fileName;
$scope.status = response.data.status;
populateCurrentRecords();
return;
2017-10-24 19:16:36 +05:00
}
2019-03-19 01:04:22 +05:00
else {
$scope.destination = true;
$scope.backupButton = true;
$scope.runningBackup = false;
$scope.cancelButton = false;
$scope.fileName = response.data.fileName;
$scope.status = response.data.status;
$timeout(getBackupStatus, 2000);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
}
else {
$timeout.cancel();
$scope.backupLoadingBottom = true;
$scope.backupLoading = true;
$scope.cancelButton = true;
$scope.backupButton = false;
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function cantLoadInitialDatas(response) {
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.destinationSelection = function () {
$scope.backupButton = false;
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function populateCurrentRecords() {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var websiteToBeBacked = $scope.websiteToBeBacked;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
url = "/backup/getCurrentBackups";
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var data = {
websiteToBeBacked: websiteToBeBacked,
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
if (response.data.fetchStatus == 1) {
$scope.records = JSON.parse(response.data.data);
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function cantLoadInitialDatas(response) {
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.createBackup = function () {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var websiteToBeBacked = $scope.websiteToBeBacked;
$scope.backupLoading = false;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
url = "/backup/submitBackupCreation";
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var data = {
websiteToBeBacked: websiteToBeBacked,
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
if (response.data.metaStatus === 1) {
getBackupStatus();
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function cantLoadInitialDatas(response) {
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.deleteBackup = function (id) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
url = "/backup/deleteBackup";
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var data = {
backupID: id,
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
if (response.data.deleteStatus == 1) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
populateCurrentRecords();
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
else {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function cantLoadInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
});
///** Backup site ends **///
///** Restore site ***//
2019-03-19 01:04:22 +05:00
app.controller('restoreWebsiteControl', function ($scope, $http, $timeout) {
2017-10-24 19:16:36 +05:00
$scope.restoreLoading = true;
$scope.runningRestore = true;
2019-03-19 01:04:22 +05:00
$scope.restoreButton = true;
2017-10-24 19:16:36 +05:00
$scope.restoreFinished = false;
$scope.couldNotConnect = true;
$scope.backupError = true;
$scope.siteExists = true;
2017-12-09 22:30:10 +05:00
// check to start time of status function
var check = 1;
2017-10-24 19:16:36 +05:00
$scope.fetchDetails = function () {
2019-03-19 01:04:22 +05:00
$scope.restoreLoading = false;
getRestoreStatus();
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function getRestoreStatus() {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var backupFile = $scope.backupFile;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
url = "/backup/restoreStatus";
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var data = {
backupFile: backupFile,
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
if (response.data.restoreStatus === 1) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
if (response.data.abort === 1) {
$scope.running = response.data.running;
$scope.fileName = $scope.backupFile;
$scope.restoreLoading = true;
$scope.status = response.data.status;
$scope.runningRestore = false;
$scope.restoreButton = false;
$scope.restoreFinished = true;
$timeout.cancel();
return;
}
else {
$scope.running = response.data.running;
$scope.fileName = $scope.backupFile;
$scope.restoreLoading = false;
$scope.status = response.data.status;
$scope.runningRestore = false;
$scope.restoreButton = true;
$timeout(getRestoreStatus, 2000);
}
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function cantLoadInitialDatas(response) {
$scope.couldNotConnect = false;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.restoreBackup = function () {
2017-10-24 19:16:36 +05:00
var backupFile = $scope.backupFile;
2017-12-09 22:30:10 +05:00
$scope.running = "Lets start.."
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
url = "/backup/submitRestore";
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var data = {
backupFile: backupFile,
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.restoreLoading = true;
if (response.data.restoreStatus == 1) {
$scope.runningRestore = false;
$scope.running = "Running";
$scope.fileName = $scope.backupFile;
$scope.status = "Just Started..";
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
getRestoreStatus();
}
else {
$scope.backupError = false;
$scope.errorMessage = response.data.error_message;
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function cantLoadInitialDatas(response) {
$scope.couldNotConnect = false;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function createWebsite() {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var backupFile = $scope.backupFile;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
url = "/websites/CreateWebsiteFromBackup";
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var data = {
backupFile: backupFile,
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
if (response.data.createWebSiteStatus == 1) {
getRestoreStatus();
}
else if (response.data.existsStatus == 1) {
$scope.backupError = false;
$scope.errorMessage = response.data.error_message;
$scope.restoreButton = true;
$scope.runningRestore = true;
}
else {
$scope.websiteDomain = domainName;
$scope.backupError = false;
$scope.errorMessage = response.data.error_message;
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function cantLoadInitialDatas(response) {
$scope.couldNotConnect = false;
}
2017-10-24 19:16:36 +05:00
};
});
2020-04-29 04:46:01 +05:00
//*** Restore site ends here ***///
2017-10-24 19:16:36 +05:00
///** Backup Destination ***//
2019-03-19 01:04:22 +05:00
app.controller('backupDestinations', function ($scope, $http, $timeout) {
2017-10-24 19:16:36 +05:00
$scope.destinationLoading = true;
$scope.connectionFailed = true;
$scope.connectionSuccess = true;
$scope.canNotAddDestination = true;
$scope.destinationAdded = true;
$scope.couldNotConnect = true;
populateCurrentRecords();
$scope.addDestination = function () {
$scope.destinationLoading = false;
$scope.connectionFailed = true;
$scope.connectionSuccess = true;
$scope.canNotAddDestination = true;
$scope.destinationAdded = true;
$scope.couldNotConnect = true;
url = "/backup/submitDestinationCreation";
2019-03-19 01:04:22 +05:00
var data = {
IPAddress: $scope.IPAddress,
password: $scope.password,
2020-04-29 04:46:01 +05:00
user: $scope.user,
2019-03-19 01:04:22 +05:00
backupSSHPort: $scope.backupSSHPort,
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
if (response.data.destStatus == 1) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.destinationLoading = true;
$scope.connectionFailed = true;
$scope.connectionSuccess = true;
$scope.canNotAddDestination = true;
$scope.destinationAdded = false;
$scope.couldNotConnect = true;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
populateCurrentRecords();
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
else {
$scope.destinationLoading = true;
$scope.connectionFailed = true;
$scope.connectionSuccess = true;
$scope.canNotAddDestination = false;
$scope.destinationAdded = true;
$scope.couldNotConnect = true;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.errorMessage = response.data.error_message;
}
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function cantLoadInitialDatas(response) {
$scope.destinationLoading = true;
$scope.connectionFailed = true;
$scope.connectionSuccess = true;
$scope.canNotAddDestination = true;
$scope.destinationAdded = true;
$scope.couldNotConnect = false;
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
$scope.checkConn = function (ip) {
$scope.destinationLoading = false;
$scope.connectionFailed = true;
$scope.connectionSuccess = true;
$scope.canNotAddDestination = true;
$scope.destinationAdded = true;
$scope.couldNotConnect = true;
url = "/backup/getConnectionStatus";
2019-03-19 01:04:22 +05:00
var data = {
IPAddress: ip,
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
if (response.data.connStatus == 1) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.destinationLoading = true;
$scope.connectionFailed = true;
$scope.connectionSuccess = false;
$scope.canNotAddDestination = true;
$scope.destinationAdded = true;
$scope.couldNotConnect = true;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.IPAddress = ip;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
else {
$scope.destinationLoading = true;
$scope.connectionFailed = false;
$scope.connectionSuccess = true;
$scope.canNotAddDestination = true;
$scope.destinationAdded = true;
$scope.couldNotConnect = true;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.errorMessage = response.data.error_message;
$scope.IPAddress = ip;
}
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function cantLoadInitialDatas(response) {
$scope.destinationLoading = true;
$scope.connectionFailed = true;
$scope.connectionSuccess = true;
$scope.canNotAddDestination = true;
$scope.destinationAdded = true;
$scope.couldNotConnect = false;
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
$scope.delDest = function (ip) {
$scope.destinationLoading = false;
$scope.connectionFailed = true;
$scope.connectionSuccess = true;
$scope.canNotAddDestination = true;
$scope.destinationAdded = true;
$scope.couldNotConnect = true;
url = "/backup/deleteDestination";
2019-03-19 01:04:22 +05:00
var data = {
IPAddress: ip,
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
if (response.data.delStatus == 1) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.destinationLoading = true;
$scope.connectionFailed = true;
$scope.connectionSuccess = true;
$scope.canNotAddDestination = true;
$scope.destinationAdded = true;
$scope.couldNotConnect = true;
populateCurrentRecords();
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.IPAddress = ip;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
else {
$scope.destinationLoading = true;
$scope.connectionFailed = true;
$scope.connectionSuccess = true;
$scope.canNotAddDestination = true;
$scope.destinationAdded = true;
$scope.couldNotConnect = true;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.errorMessage = response.data.error_message;
$scope.IPAddress = ip;
}
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function cantLoadInitialDatas(response) {
$scope.destinationLoading = true;
$scope.connectionFailed = true;
$scope.connectionSuccess = true;
$scope.canNotAddDestination = true;
$scope.destinationAdded = true;
$scope.couldNotConnect = false;
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function populateCurrentRecords() {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
url = "/backup/getCurrentBackupDestinations";
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var data = {};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
if (response.data.fetchStatus == 1) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.records = JSON.parse(response.data.data);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function cantLoadInitialDatas(response) {
$scope.couldNotConnect = false;
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
});
//*** Backup destination ***///
///** Schedule Backup ***//
2019-03-19 01:04:22 +05:00
app.controller('scheduleBackup', function ($scope, $http, $timeout) {
2017-10-24 19:16:36 +05:00
$scope.scheduleBackupLoading = true;
$scope.canNotAddSchedule = true;
$scope.scheduleAdded = true;
$scope.couldNotConnect = true;
$scope.scheduleFreq = true;
$scope.scheduleBtn = true;
2019-08-25 05:25:48 +05:00
$scope.localPath = true;
2017-10-24 19:16:36 +05:00
populateCurrentRecords();
$scope.scheduleFreqView = function () {
$scope.scheduleBackupLoading = true;
$scope.canNotAddSchedule = true;
$scope.scheduleAdded = true;
$scope.couldNotConnect = true;
$scope.scheduleFreq = false;
$scope.scheduleBtn = true;
2019-08-25 05:25:48 +05:00
if($scope.backupDest === 'Home'){
$scope.localPath = false;
}else{
$scope.localPath = true;
}
2017-10-24 19:16:36 +05:00
};
$scope.scheduleBtnView = function () {
$scope.scheduleBackupLoading = true;
$scope.canNotAddSchedule = true;
$scope.scheduleAdded = true;
$scope.couldNotConnect = true;
$scope.scheduleFreq = false;
$scope.scheduleBtn = false;
};
$scope.addSchedule = function () {
$scope.scheduleBackupLoading = false;
$scope.canNotAddSchedule = true;
$scope.scheduleAdded = true;
$scope.couldNotConnect = true;
$scope.scheduleFreq = false;
$scope.scheduleBtn = false;
url = "/backup/submitBackupSchedule";
2019-03-19 01:04:22 +05:00
var data = {
backupDest: $scope.backupDest,
backupFreq: $scope.backupFreq,
2019-08-25 05:25:48 +05:00
localPath: $scope.localPathValue
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
if (response.data.scheduleStatus == 1) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.scheduleBackupLoading = true;
$scope.canNotAddSchedule = true;
$scope.scheduleAdded = false;
$scope.couldNotConnect = true;
$scope.scheduleFreq = true;
$scope.scheduleBtn = true;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
populateCurrentRecords();
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
else {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.scheduleBackupLoading = true;
$scope.canNotAddSchedule = false;
$scope.scheduleAdded = true;
$scope.couldNotConnect = true;
$scope.scheduleFreq = false;
$scope.scheduleBtn = false;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.errorMessage = response.data.error_message;
}
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function cantLoadInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.scheduleBackupLoading = true;
$scope.canNotAddSchedule = true;
$scope.scheduleAdded = true;
$scope.couldNotConnect = false;
$scope.scheduleFreq = false;
$scope.scheduleBtn = false;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
$scope.checkConn = function (ip) {
$scope.destinationLoading = false;
$scope.connectionFailed = true;
$scope.connectionSuccess = true;
$scope.canNotAddDestination = true;
$scope.destinationAdded = true;
$scope.couldNotConnect = true;
url = "/backup/getConnectionStatus";
2019-03-19 01:04:22 +05:00
var data = {
IPAddress: ip,
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
if (response.data.connStatus == 1) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.destinationLoading = true;
$scope.connectionFailed = true;
$scope.connectionSuccess = false;
$scope.canNotAddDestination = true;
$scope.destinationAdded = true;
$scope.couldNotConnect = true;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.IPAddress = ip;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
else {
$scope.destinationLoading = true;
$scope.connectionFailed = false;
$scope.connectionSuccess = true;
$scope.canNotAddDestination = true;
$scope.destinationAdded = true;
$scope.couldNotConnect = true;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.errorMessage = response.data.error_message;
$scope.IPAddress = ip;
}
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function cantLoadInitialDatas(response) {
$scope.destinationLoading = true;
$scope.connectionFailed = true;
$scope.connectionSuccess = true;
$scope.canNotAddDestination = true;
$scope.destinationAdded = true;
$scope.couldNotConnect = false;
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.delSchedule = function (destLoc, frequency) {
2017-10-24 19:16:36 +05:00
$scope.scheduleBackupLoading = false;
$scope.canNotAddSchedule = true;
$scope.scheduleAdded = true;
$scope.couldNotConnect = true;
$scope.scheduleFreq = true;
$scope.scheduleBtn = true;
url = "/backup/scheduleDelete";
2019-03-19 01:04:22 +05:00
var data = {
destLoc: destLoc,
frequency: frequency,
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
if (response.data.delStatus == 1) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.scheduleBackupLoading = true;
$scope.canNotAddSchedule = true;
$scope.scheduleAdded = true;
$scope.couldNotConnect = true;
$scope.scheduleFreq = true;
$scope.scheduleBtn = true;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
populateCurrentRecords();
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
else {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.scheduleBackupLoading = true;
$scope.canNotAddSchedule = true;
$scope.scheduleAdded = true;
$scope.couldNotConnect = true;
$scope.scheduleFreq = true;
$scope.scheduleBtn = true;
$scope.errorMessage = response.data.error_message;
}
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function cantLoadInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.scheduleBackupLoading = true;
$scope.canNotAddSchedule = true;
$scope.scheduleAdded = true;
$scope.couldNotConnect = false;
$scope.scheduleFreq = true;
$scope.scheduleBtn = true;
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function populateCurrentRecords() {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
url = "/backup/getCurrentBackupSchedules";
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var data = {};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function ListInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
if (response.data.fetchStatus == 1) {
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.records = JSON.parse(response.data.data);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
function cantLoadInitialDatas(response) {
$scope.couldNotConnect = false;
}
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
};
2017-10-24 19:16:36 +05:00
});
//*** Schedule Backup ***///
//*** Remote Backup site ****//
2019-03-19 01:04:22 +05:00
app.controller('remoteBackupControl', function ($scope, $http, $timeout) {
2017-10-24 19:16:36 +05:00
$scope.backupButton = true;
2017-10-24 19:16:36 +05:00
$scope.backupLoading = true;
$scope.request = true;
$scope.requestData = "";
$scope.submitDisable = false;
$scope.startRestore = true;
$scope.accountsInRemoteServerTable = true;
$scope.transferBoxBtn = true;
$scope.stopTransferbtn = true;
$scope.fetchAccountsBtn = false;
// notifications boxes
$scope.notificationsBox = true;
$scope.errorMessage = true;
$scope.couldNotConnect = true;
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
// status box
$scope.backupStatus = true;
var websitesToBeBacked = [];
var websitesToBeBackedTemp = [];
var index = 0;
var tempTransferDir = "";
2019-03-19 01:04:22 +05:00
$scope.passwordEnter = function () {
2017-10-24 19:16:36 +05:00
$scope.backupButton = false;
};
2019-03-19 01:04:22 +05:00
$scope.addRemoveWebsite = function (website, websiteStatus) {
2017-12-09 22:30:10 +05:00
2019-03-19 01:04:22 +05:00
if (websiteStatus === true) {
var check = 1;
2019-03-19 01:04:22 +05:00
for (var j = 0; j < websitesToBeBacked.length; j++) {
if (websitesToBeBacked[j] == website) {
check = 0;
break;
}
2019-03-19 01:04:22 +05:00
}
if (check == 1) {
websitesToBeBacked.push(website);
}
2017-10-24 19:16:36 +05:00
}
2019-03-19 01:04:22 +05:00
else {
2017-10-24 19:16:36 +05:00
var tempArray = [];
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
for (var j = 0; j < websitesToBeBacked.length; j++) {
if (websitesToBeBacked[j] != website) {
tempArray.push(websitesToBeBacked[j]);
}
2019-03-19 01:04:22 +05:00
}
websitesToBeBacked = tempArray;
}
};
2017-10-24 19:16:36 +05:00
$scope.allChecked = function (webSiteStatus) {
2019-03-19 01:04:22 +05:00
if (webSiteStatus === true) {
websitesToBeBacked = websitesToBeBackedTemp;
$scope.webSiteStatus = true;
}
2019-03-19 01:04:22 +05:00
else {
websitesToBeBacked = [];
$scope.webSiteStatus = false;
}
};
$scope.fetchAccountsFromRemoteServer = function () {
$scope.backupLoading = false;
// notifications boxes
$scope.notificationsBox = true;
$scope.errorMessage = true;
$scope.couldNotConnect = true;
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
var IPAddress = $scope.IPAddress;
var password = $scope.password;
url = "/backup/submitRemoteBackups";
2017-10-24 19:16:36 +05:00
var data = {
ipAddress: IPAddress,
password: password,
2017-10-24 19:16:36 +05:00
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
2018-02-22 12:17:38 +05:00
if (response.data.status === 1) {
$scope.records = JSON.parse(response.data.data);
var parsed = JSON.parse(response.data.data);
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
for (var j = 0; j < parsed.length; j++) {
websitesToBeBackedTemp.push(parsed[j].website);
2017-10-24 19:16:36 +05:00
}
$scope.accountsInRemoteServerTable = false;
$scope.backupLoading = true;
// enable the transfer/cancel btn
$scope.transferBoxBtn = false;
// notifications boxes
$scope.notificationsBox = false;
$scope.errorMessage = true;
$scope.couldNotConnect = true;
$scope.accountsFetched = false;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
}
else {
$scope.error_message = response.data.error_message;
$scope.backupLoading = true;
// notifications boxes
$scope.notificationsBox = false;
$scope.errorMessage = false;
$scope.couldNotConnect = true;
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
2017-10-24 19:16:36 +05:00
}
}
function cantLoadInitialDatas(response) {
// notifications boxes
$scope.notificationsBox = false;
$scope.errorMessage = true;
$scope.couldNotConnect = false;
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
};
$scope.startTransfer = function () {
// notifications boxes
$scope.notificationsBox = true;
$scope.errorMessage = true;
$scope.couldNotConnect = true;
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
2019-03-19 01:04:22 +05:00
if (websitesToBeBacked.length === 0) {
2018-12-14 00:43:28 +05:00
alert("No websites selected for transfer.");
return;
}
2017-10-24 19:16:36 +05:00
// disable fetch accounts button
$scope.fetchAccountsBtn = true;
2017-10-24 19:16:36 +05:00
$scope.backupLoading = false;
2017-10-24 19:16:36 +05:00
var IPAddress = $scope.IPAddress;
var password = $scope.password;
url = "/backup/starRemoteTransfer";
2017-10-24 19:16:36 +05:00
var data = {
ipAddress: IPAddress,
password: password,
2019-03-19 01:04:22 +05:00
accountsToTransfer: websitesToBeBacked,
2017-10-24 19:16:36 +05:00
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
2018-02-22 12:17:38 +05:00
if (response.data.remoteTransferStatus === 1) {
2019-03-19 01:04:22 +05:00
tempTransferDir = response.data.dir;
$scope.accountsInRemoteServerTable = true;
2019-03-19 01:04:22 +05:00
// notifications boxes
$scope.notificationsBox = false;
$scope.errorMessage = true;
$scope.couldNotConnect = true;
$scope.accountsFetched = true;
$scope.backupProcessStarted = false;
$scope.backupCancelled = true;
2019-03-19 01:04:22 +05:00
// disable transfer button
2019-03-19 01:04:22 +05:00
$scope.startTransferbtn = true;
2019-03-19 01:04:22 +05:00
// enable cancel button
2019-03-19 01:04:22 +05:00
$scope.stopTransferbtn = false;
2019-03-19 01:04:22 +05:00
getBackupStatus();
}
else {
$scope.error_message = response.data.error_message;
2017-10-24 19:16:36 +05:00
$scope.backupLoading = true;
// Notifications box settings
// notifications boxes
$scope.notificationsBox = false;
$scope.errorMessage = false;
$scope.couldNotConnect = true;
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
2017-10-24 19:16:36 +05:00
}
}
function cantLoadInitialDatas(response) {
2019-03-19 01:04:22 +05:00
// Notifications box settings
2019-03-19 01:04:22 +05:00
// notifications boxes
$scope.notificationsBox = false;
$scope.errorMessage = true;
$scope.couldNotConnect = false;
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
2017-10-24 19:16:36 +05:00
}
};
function getBackupStatus(password) {
url = "/backup/getRemoteTransferStatus";
2017-10-24 19:16:36 +05:00
var data = {
2019-03-19 01:04:22 +05:00
password: $scope.password,
ipAddress: $scope.IPAddress,
2018-02-22 12:17:38 +05:00
dir: tempTransferDir
2017-10-24 19:16:36 +05:00
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
2018-02-22 12:17:38 +05:00
if (response.data.remoteTransferStatus === 1) {
2019-03-19 01:04:22 +05:00
if (response.data.backupsSent === 0) {
$scope.backupStatus = false;
$scope.requestData = response.data.status;
$timeout(getBackupStatus, 2000);
}
2019-03-19 01:04:22 +05:00
else {
$scope.requestData = response.data.status;
$timeout.cancel();
2018-02-22 12:17:38 +05:00
// Start the restore of remote backups that are transferred to local server
remoteBackupRestore();
}
}
2019-03-19 01:04:22 +05:00
else {
$scope.error_message = response.data.error_message;
$scope.backupLoading = true;
$scope.couldNotConnect = true;
// Notifications box settings
$scope.couldNotConnect = true;
$scope.errorMessage = false;
$scope.accountsFetched = true;
$scope.notificationsBox = false;
$timeout.cancel();
}
}
function cantLoadInitialDatas(response) {
2019-03-19 01:04:22 +05:00
// Notifications box settings
2019-03-19 01:04:22 +05:00
$scope.couldNotConnect = false;
$scope.errorMessage = true;
$scope.accountsFetched = true;
$scope.notificationsBox = false;
}
};
2019-03-19 01:04:22 +05:00
function remoteBackupRestore() {
url = "/backup/remoteBackupRestore";
var data = {
backupDir: tempTransferDir,
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
2018-02-22 12:17:38 +05:00
if (response.data.remoteRestoreStatus === 1) {
2019-03-19 01:04:22 +05:00
localRestoreStatus();
}
}
function cantLoadInitialDatas(response) {
2019-03-19 01:04:22 +05:00
// Notifications box settings
2019-03-19 01:04:22 +05:00
$scope.couldNotConnect = false;
$scope.errorMessage = true;
$scope.accountsFetched = true;
$scope.notificationsBox = false;
$scope.backupLoading = true;
}
///////////////
};
function localRestoreStatus(password) {
url = "/backup/localRestoreStatus";
var data = {
backupDir: tempTransferDir,
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2017-10-24 19:16:36 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.backupProcessStarted = true;
2018-02-22 12:17:38 +05:00
if (response.data.remoteTransferStatus === 1) {
2019-03-19 01:04:22 +05:00
if (response.data.complete === 0) {
$scope.backupStatus = false;
2017-12-09 22:30:10 +05:00
$scope.restoreData = response.data.status;
$timeout(localRestoreStatus, 2000);
2017-10-24 19:16:36 +05:00
}
2019-03-19 01:04:22 +05:00
else {
2017-12-09 22:30:10 +05:00
$scope.restoreData = response.data.status;
$timeout.cancel();
$scope.backupLoading = true;
$scope.startTransferbtn = false;
2017-10-24 19:16:36 +05:00
}
}
2019-03-19 01:04:22 +05:00
else {
$scope.error_message = response.data.error_message;
$scope.backupLoading = true;
$scope.couldNotConnect = true;
// Notifications box settings
$scope.couldNotConnect = true;
$scope.errorMessage = false;
$scope.accountsFetched = true;
$scope.notificationsBox = false;
}
}
function cantLoadInitialDatas(response) {
2019-03-19 01:04:22 +05:00
// Notifications box settings
2019-03-19 01:04:22 +05:00
$scope.couldNotConnect = false;
$scope.errorMessage = true;
$scope.accountsFetched = true;
$scope.notificationsBox = false;
}
};
2017-10-24 19:16:36 +05:00
function restoreAccounts() {
url = "/backup/getRemoteTransferStatus";
var data = {
2019-03-19 01:04:22 +05:00
password: $scope.password,
ipAddress: $scope.IPAddress,
dir: tempTransferDir,
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.remoteTransferStatus == 1) {
2019-03-19 01:04:22 +05:00
if (response.data.backupsSent == 0) {
$scope.backupStatus = false;
$scope.requestData = response.data.status;
$timeout(getBackupStatus, 2000);
}
2019-03-19 01:04:22 +05:00
else {
$timeout.cancel();
}
2017-10-24 19:16:36 +05:00
}
}
function cantLoadInitialDatas(response) {
2019-03-19 01:04:22 +05:00
// Notifications box settings
2019-03-19 01:04:22 +05:00
$scope.couldNotConnect = false;
$scope.errorMessage = true;
$scope.accountsFetched = true;
$scope.notificationsBox = false;
2017-10-24 19:16:36 +05:00
}
};
$scope.cancelRemoteBackup = function () {
2017-10-24 19:16:36 +05:00
$scope.backupLoading = false;
// notifications boxes
$scope.notificationsBox = true;
$scope.errorMessage = true;
$scope.couldNotConnect = true;
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
var IPAddress = $scope.IPAddress;
var password = $scope.password;
url = "/backup/cancelRemoteBackup";
2017-10-24 19:16:36 +05:00
var data = {
ipAddress: IPAddress,
password: password,
2019-03-19 01:04:22 +05:00
dir: tempTransferDir,
2017-10-24 19:16:36 +05:00
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.cancelStatus == 1) {
2019-03-19 01:04:22 +05:00
$scope.backupLoading = true;
2019-03-19 01:04:22 +05:00
// notifications boxes
$scope.notificationsBox = false;
$scope.errorMessage = true;
$scope.couldNotConnect = true;
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = false;
2019-03-19 01:04:22 +05:00
// enable transfer button
2019-03-19 01:04:22 +05:00
$scope.startTransferbtn = false;
2019-03-19 01:04:22 +05:00
//disable cancel button
2019-03-19 01:04:22 +05:00
$scope.stopTransferbtn = true;
2019-03-19 01:04:22 +05:00
// hide status box
2019-03-19 01:04:22 +05:00
$scope.backupStatus = true;
2019-03-19 01:04:22 +05:00
// bring back websites table
2019-03-19 01:04:22 +05:00
$scope.accountsInRemoteServerTable = false;
2019-03-19 01:04:22 +05:00
// enable fetch button
2019-03-19 01:04:22 +05:00
$scope.fetchAccountsBtn = false;
}
else {
$scope.error_message = response.data.error_message;
2017-10-24 19:16:36 +05:00
$scope.backupLoading = true;
// notifications boxes
$scope.notificationsBox = false;
$scope.errorMessage = false;
$scope.couldNotConnect = true;
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
2017-10-24 19:16:36 +05:00
}
}
function cantLoadInitialDatas(response) {
2019-03-19 01:04:22 +05:00
// notifications boxes
2019-03-19 01:04:22 +05:00
$scope.notificationsBox = false;
$scope.errorMessage = true;
$scope.couldNotConnect = false;
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
2017-10-24 19:16:36 +05:00
}
};
2017-10-24 19:16:36 +05:00
});
///** Backup site ends **///