Files
CyberPanel/static/backup/backup.js

1993 lines
52 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
2020-09-20 23:00:54 +05:00
//*** Remote Backup site ****//
app.controller('remoteBackupControl', function ($scope, $http, $timeout) {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.backupButton = true;
$scope.backupLoading = true;
$scope.request = true;
$scope.requestData = "";
$scope.submitDisable = false;
$scope.startRestore = true;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.accountsInRemoteServerTable = true;
$scope.transferBoxBtn = true;
$scope.stopTransferbtn = true;
$scope.fetchAccountsBtn = false;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
// notifications boxes
$scope.notificationsBox = true;
$scope.errorMessage = true;
$scope.couldNotConnect = true;
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
// status box
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.backupStatus = true;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
var websitesToBeBacked = [];
var websitesToBeBackedTemp = [];
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
var index = 0;
var tempTransferDir = "";
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.passwordEnter = function () {
$scope.backupButton = false;
};
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.addRemoveWebsite = function (website, websiteStatus) {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
if (websiteStatus === true) {
var check = 1;
for (var j = 0; j < websitesToBeBacked.length; j++) {
if (websitesToBeBacked[j] == website) {
check = 0;
break;
}
}
if (check == 1) {
websitesToBeBacked.push(website);
}
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
}
else {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
var tempArray = [];
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
for (var j = 0; j < websitesToBeBacked.length; j++) {
if (websitesToBeBacked[j] != website) {
tempArray.push(websitesToBeBacked[j]);
}
}
websitesToBeBacked = tempArray;
}
};
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.allChecked = function (webSiteStatus) {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
if (webSiteStatus === true) {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
websitesToBeBacked = websitesToBeBackedTemp;
$scope.webSiteStatus = true;
2019-03-19 01:04:22 +05:00
}
2020-09-20 23:00:54 +05:00
else {
websitesToBeBacked = [];
$scope.webSiteStatus = false;
2019-03-19 01:04:22 +05:00
}
};
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.fetchAccountsFromRemoteServer = function () {
$scope.backupLoading = false;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
// notifications boxes
$scope.notificationsBox = true;
$scope.errorMessage = true;
2017-10-24 19:16:36 +05:00
$scope.couldNotConnect = true;
2020-09-20 23:00:54 +05:00
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
var IPAddress = $scope.IPAddress;
var password = $scope.password;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
url = "/backup/submitRemoteBackups";
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var data = {
2020-09-20 23:00:54 +05:00
ipAddress: IPAddress,
password: password,
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
2020-09-20 23:00:54 +05:00
if (response.data.status === 1) {
$scope.records = JSON.parse(response.data.data);
var parsed = JSON.parse(response.data.data);
for (var j = 0; j < parsed.length; j++) {
websitesToBeBackedTemp.push(parsed[j].website);
}
$scope.accountsInRemoteServerTable = false;
$scope.backupLoading = true;
// enable the transfer/cancel btn
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.transferBoxBtn = false;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
// notifications boxes
$scope.notificationsBox = false;
$scope.errorMessage = true;
2019-03-19 01:04:22 +05:00
$scope.couldNotConnect = true;
2020-09-20 23:00:54 +05:00
$scope.accountsFetched = false;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
else {
2020-09-20 23:00:54 +05:00
$scope.error_message = response.data.error_message;
$scope.backupLoading = true;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
// notifications boxes
$scope.notificationsBox = false;
$scope.errorMessage = false;
$scope.couldNotConnect = true;
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
2019-03-19 01:04:22 +05:00
}
2020-09-20 23:00:54 +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) {
2020-09-20 23:00:54 +05:00
// notifications boxes
$scope.notificationsBox = false;
$scope.errorMessage = true;
2019-03-19 01:04:22 +05:00
$scope.couldNotConnect = false;
2020-09-20 23:00:54 +05:00
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
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
2020-09-20 23:00:54 +05:00
$scope.startTransfer = function () {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
// notifications boxes
$scope.notificationsBox = true;
$scope.errorMessage = true;
2017-10-24 19:16:36 +05:00
$scope.couldNotConnect = true;
2020-09-20 23:00:54 +05:00
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
if (websitesToBeBacked.length === 0) {
alert("No websites selected for transfer.");
return;
}
// disable fetch accounts button
$scope.fetchAccountsBtn = true;
$scope.backupLoading = false;
var IPAddress = $scope.IPAddress;
var password = $scope.password;
url = "/backup/starRemoteTransfer";
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var data = {
2020-09-20 23:00:54 +05:00
ipAddress: IPAddress,
password: password,
accountsToTransfer: websitesToBeBacked,
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
2020-09-20 23:00:54 +05:00
if (response.data.remoteTransferStatus === 1) {
tempTransferDir = response.data.dir;
$scope.accountsInRemoteServerTable = true;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
// notifications boxes
$scope.notificationsBox = false;
$scope.errorMessage = true;
2019-03-19 01:04:22 +05:00
$scope.couldNotConnect = true;
2020-09-20 23:00:54 +05:00
$scope.accountsFetched = true;
$scope.backupProcessStarted = false;
$scope.backupCancelled = true;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
// disable transfer button
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.startTransferbtn = true;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
// enable cancel button
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.stopTransferbtn = false;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
getBackupStatus();
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
2020-09-20 23:00:54 +05:00
else {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.error_message = response.data.error_message;
$scope.backupLoading = true;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
// Notifications box settings
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
// 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
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
2020-09-20 23:00:54 +05:00
function cantLoadInitialDatas(response) {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
// Notifications box settings
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +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
2019-08-25 05:25:48 +05:00
}
2017-10-24 19:16:36 +05:00
};
2020-09-20 23:00:54 +05:00
function getBackupStatus(password) {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
url = "/backup/getRemoteTransferStatus";
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var data = {
2020-09-20 23:00:54 +05:00
password: $scope.password,
ipAddress: $scope.IPAddress,
dir: tempTransferDir
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
2020-09-20 23:00:54 +05:00
if (response.data.remoteTransferStatus === 1) {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
if (response.data.backupsSent === 0) {
$scope.backupStatus = false;
$scope.requestData = response.data.status;
$timeout(getBackupStatus, 2000);
}
else {
$scope.requestData = response.data.status;
$timeout.cancel();
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
// Start the restore of remote backups that are transferred to local server
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
remoteBackupRestore();
}
2019-03-19 01:04:22 +05:00
}
else {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.error_message = response.data.error_message;
$scope.backupLoading = true;
$scope.couldNotConnect = true;
// Notifications box settings
2019-03-19 01:04:22 +05:00
$scope.couldNotConnect = true;
2020-09-20 23:00:54 +05:00
$scope.errorMessage = false;
$scope.accountsFetched = true;
$scope.notificationsBox = false;
$timeout.cancel();
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
}
2020-09-20 23:00:54 +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) {
2020-09-20 23:00:54 +05:00
// Notifications box settings
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.couldNotConnect = false;
2020-09-20 23:00:54 +05:00
$scope.errorMessage = true;
$scope.accountsFetched = true;
$scope.notificationsBox = false;
2019-03-19 01:04:22 +05:00
}
};
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
function remoteBackupRestore() {
url = "/backup/remoteBackupRestore";
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var data = {
2020-09-20 23:00:54 +05:00
backupDir: tempTransferDir,
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
2020-09-20 23:00:54 +05:00
if (response.data.remoteRestoreStatus === 1) {
localRestoreStatus();
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) {
2020-09-20 23:00:54 +05:00
// Notifications box settings
2019-03-19 01:04:22 +05:00
$scope.couldNotConnect = false;
2020-09-20 23:00:54 +05:00
$scope.errorMessage = true;
$scope.accountsFetched = true;
$scope.notificationsBox = false;
$scope.backupLoading = true;
2019-03-19 01:04:22 +05:00
}
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
///////////////
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
};
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
function localRestoreStatus(password) {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
url = "/backup/localRestoreStatus";
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
var data = {
2020-09-20 23:00:54 +05:00
backupDir: tempTransferDir,
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) {
2020-09-20 23:00:54 +05:00
$scope.backupProcessStarted = true;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
if (response.data.remoteTransferStatus === 1) {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
if (response.data.complete === 0) {
$scope.backupStatus = false;
$scope.restoreData = response.data.status;
$timeout(localRestoreStatus, 2000);
}
else {
$scope.restoreData = response.data.status;
$timeout.cancel();
$scope.backupLoading = true;
$scope.startTransferbtn = false;
}
}
else {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.error_message = response.data.error_message;
$scope.backupLoading = true;
2019-03-19 01:04:22 +05:00
$scope.couldNotConnect = true;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
// Notifications box settings
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.couldNotConnect = true;
$scope.errorMessage = false;
$scope.accountsFetched = true;
$scope.notificationsBox = 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 cantLoadInitialDatas(response) {
2020-09-20 23:00:54 +05:00
// Notifications box settings
2017-10-24 19:16:36 +05:00
2019-03-19 01:04:22 +05:00
$scope.couldNotConnect = false;
2020-09-20 23:00:54 +05:00
$scope.errorMessage = true;
$scope.accountsFetched = true;
$scope.notificationsBox = false;
2019-03-19 01:04:22 +05:00
}
};
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
function restoreAccounts() {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
url = "/backup/getRemoteTransferStatus";
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
var data = {
password: $scope.password,
ipAddress: $scope.IPAddress,
dir: tempTransferDir,
};
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
2020-09-20 23:00:54 +05:00
if (response.data.remoteTransferStatus == 1) {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
if (response.data.backupsSent == 0) {
$scope.backupStatus = false;
$scope.requestData = response.data.status;
$timeout(getBackupStatus, 2000);
}
else {
$timeout.cancel();
}
}
2017-10-24 19:16:36 +05:00
}
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
function cantLoadInitialDatas(response) {
// Notifications box settings
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.couldNotConnect = false;
$scope.errorMessage = true;
$scope.accountsFetched = true;
$scope.notificationsBox = false;
}
};
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.cancelRemoteBackup = 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;
2020-09-20 23:00:54 +05:00
url = "/backup/cancelRemoteBackup";
2017-10-24 19:16:36 +05:00
var data = {
ipAddress: IPAddress,
password: password,
2020-09-20 23:00:54 +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) {
2020-09-20 23:00:54 +05:00
if (response.data.cancelStatus == 1) {
$scope.backupLoading = true;
// notifications boxes
$scope.notificationsBox = false;
$scope.errorMessage = true;
$scope.couldNotConnect = true;
2020-09-20 23:00:54 +05:00
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
2020-09-20 23:00:54 +05:00
$scope.backupCancelled = false;
// enable transfer button
$scope.startTransferbtn = false;
//disable cancel button
$scope.stopTransferbtn = true;
// hide status box
$scope.backupStatus = true;
// bring back websites table
$scope.accountsInRemoteServerTable = false;
// enable fetch button
$scope.fetchAccountsBtn = false;
}
else {
2020-09-20 23:00:54 +05:00
$scope.error_message = response.data.error_message;
$scope.backupLoading = true;
// notifications boxes
2020-09-20 23:00:54 +05:00
$scope.notificationsBox = false;
$scope.errorMessage = false;
$scope.couldNotConnect = true;
$scope.accountsFetched = true;
$scope.backupProcessStarted = true;
$scope.backupCancelled = true;
2020-09-20 23:00:54 +05:00
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
};
2020-09-20 23:00:54 +05:00
});
2020-09-20 23:00:54 +05:00
///** Backup site ends **///
2020-09-20 23:00:54 +05:00
//*** Remote Backup site ****//
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
app.controller('backupLogsScheduled', function ($scope, $http, $timeout) {
2020-09-20 23:00:54 +05:00
$scope.cyberpanelLoading = true;
$scope.logDetails = true;
2020-09-20 23:00:54 +05:00
$scope.currentPage = 1;
$scope.recordsToShow = 10;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.fetchLogs = function () {
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.cyberpanelLoading = false;
2017-10-24 19:16:36 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2020-09-20 23:00:54 +05:00
var data = {
logFile: $scope.logFile,
recordsToShow: $scope.recordsToShow,
page: $scope.currentPage
};
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
dataurl = "/backup/fetchLogs";
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
function ListInitialData(response) {
$scope.cyberpanelLoading = true;
if (response.data.status === 1) {
$scope.logDetails = false;
$scope.logs = JSON.parse(response.data.logs);
$scope.pagination = response.data.pagination;
$scope.jobSuccessSites = response.data.jobSuccessSites;
$scope.jobFailedSites = response.data.jobFailedSites;
$scope.location = response.data.location;
} else {
new PNotify({
title: 'Error!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialData(response) {
$scope.cyberpanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
2020-09-20 23:00:54 +05:00
};
2020-09-20 23:00:54 +05:00
});
2020-09-20 23:00:54 +05:00
///** Backup site ends **///
2020-09-20 23:00:54 +05:00
app.controller('googleDrive', function ($scope, $http) {
2020-09-20 23:00:54 +05:00
$scope.cyberPanelLoading = true;
$scope.driveHidden = true;
2020-09-20 23:00:54 +05:00
$scope.setupAccount = function(){
window.open("https://platform.cyberpanel.net/gDrive?name=" + $scope.accountName + '&server=' + window.location.href + 'Setup');
};
2020-09-20 23:00:54 +05:00
$scope.currentPage = 1;
$scope.recordsToShow = 10;
$scope.fetchWebsites = function () {
2020-09-20 23:00:54 +05:00
$scope.cyberPanelLoading = false;
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
2020-09-20 23:00:54 +05:00
};
2020-09-20 23:00:54 +05:00
var data = {
selectedAccount: $scope.selectedAccount,
page: $scope.currentPage,
recordsToShow: $scope.recordsToShow
};
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
dataurl = "/backup/fetchgDriveSites";
2020-09-20 23:00:54 +05:00
$http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
function ListInitialDatas(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
$scope.driveHidden = false;
new PNotify({
title: 'Success',
text: 'Successfully fetched.',
type: 'success'
});
$scope.websites = JSON.parse(response.data.websites);
$scope.pagination = response.data.pagination;
$scope.currently = response.data.currently;
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
2017-10-24 19:16:36 +05:00
}
function cantLoadInitialDatas(response) {
2020-09-20 23:00:54 +05:00
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page.',
type: 'error'
});
2017-10-24 19:16:36 +05:00
}
};
2020-09-20 23:00:54 +05:00
$scope.addSite = function () {
$scope.cyberPanelLoading = false;
2017-10-24 19:16:36 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2020-09-20 23:00:54 +05:00
var data = {
selectedWebsite: $scope.selectedWebsite,
selectedAccount: $scope.selectedAccount
};
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
dataurl = "/backup/addSitegDrive";
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
2020-09-20 23:00:54 +05:00
function ListInitialData(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success',
text: 'Site successfully added.',
type: 'success'
});
$scope.fetchWebsites();
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
2020-09-20 23:00:54 +05:00
}
2020-09-20 23:00:54 +05:00
function cantLoadInitialData(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
2020-09-20 23:00:54 +05:00
$scope.deleteAccount = function () {
$scope.cyberPanelLoading = false;
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2020-09-20 23:00:54 +05:00
var data = {
selectedAccount: $scope.selectedAccount
};
2020-09-20 23:00:54 +05:00
dataurl = "/backup/deleteAccountgDrive";
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
function ListInitialData(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success',
text: 'Account successfully deleted.',
type: 'success'
});
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
}
2020-09-20 23:00:54 +05:00
function cantLoadInitialData(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
2020-09-20 23:00:54 +05:00
$scope.changeFrequency = function () {
$scope.cyberPanelLoading = false;
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2020-09-20 23:00:54 +05:00
var data = {
selectedAccount: $scope.selectedAccount,
backupFrequency: $scope.backupFrequency
};
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
dataurl = "/backup/changeAccountFrequencygDrive";
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
2020-09-20 23:00:54 +05:00
function ListInitialData(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success',
text: 'Changes successfully applied',
type: 'success'
});
$scope.fetchWebsites();
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
}
2020-09-20 23:00:54 +05:00
function cantLoadInitialData(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
$scope.deleteSite = function (website) {
$scope.cyberPanelLoading = false;
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
2020-09-20 23:00:54 +05:00
};
var data = {
selectedAccount: $scope.selectedAccount,
website: website
};
2020-09-20 23:00:54 +05:00
dataurl = "/backup/deleteSitegDrive";
2020-09-20 23:00:54 +05:00
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
2020-09-20 23:00:54 +05:00
function ListInitialData(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success',
text: 'Website Deleted.',
type: 'success'
});
$scope.fetchWebsites();
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
2020-09-20 23:00:54 +05:00
}
2020-09-20 23:00:54 +05:00
function cantLoadInitialData(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
2020-09-20 23:00:54 +05:00
$scope.currentPageLogs = 1;
$scope.recordsToShowLogs = 10;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.fetchLogs = function () {
2020-09-20 23:00:54 +05:00
$scope.cyberPanelLoading = false;
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2020-09-20 23:00:54 +05:00
var data = {
selectedAccount: $scope.selectedAccount,
page: $scope.currentPageLogs,
recordsToShow: $scope.recordsToShowLogs
};
2020-09-20 23:00:54 +05:00
dataurl = "/backup/fetchDriveLogs";
2020-09-20 23:00:54 +05:00
$http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2020-09-20 23:00:54 +05:00
function ListInitialDatas(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
$scope.driveHidden = false;
new PNotify({
title: 'Success',
text: 'Successfully fetched.',
type: 'success'
});
$scope.logs = JSON.parse(response.data.logs);
$scope.paginationLogs = response.data.pagination;
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
2017-10-24 19:16:36 +05:00
}
}
function cantLoadInitialDatas(response) {
2020-09-20 23:00:54 +05:00
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page.',
type: 'error'
});
2017-10-24 19:16:36 +05:00
}
2020-09-20 23:00:54 +05:00
2017-10-24 19:16:36 +05:00
};
2020-09-20 23:00:54 +05:00
});
2020-09-20 23:00:54 +05:00
///
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
app.controller('backupDestinations', function ($scope, $http) {
$scope.cyberpanelLoading = true;
$scope.sftpHide = true;
$scope.localHide = true;
2017-10-24 19:16:36 +05:00
2020-09-20 23:00:54 +05:00
$scope.fetchDetails = function () {
2020-09-20 23:00:54 +05:00
if ($scope.destinationType === 'SFTP') {
$scope.sftpHide = false;
$scope.localHide = true;
$scope.populateCurrentRecords();
} else {
$scope.sftpHide = true;
$scope.localHide = false;
$scope.populateCurrentRecords();
}
};
2020-09-20 23:00:54 +05:00
$scope.populateCurrentRecords = function () {
$scope.cyberpanelLoading = false;
url = "/backup/getCurrentBackupDestinations";
var type = 'SFTP';
if ($scope.destinationType === 'SFTP') {
type = 'SFTP';
} else {
type = 'local';
}
2017-10-24 19:16:36 +05:00
var data = {
2020-09-20 23:00:54 +05:00
type: type
2017-10-24 19:16:36 +05:00
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2020-09-20 23:00:54 +05:00
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'
});
}
2020-09-20 23:00:54 +05:00
}
2020-09-20 23:00:54 +05:00
function cantLoadInitialDatas(response) {
$scope.cyberpanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
2020-09-20 23:00:54 +05:00
};
2020-09-20 23:00:54 +05:00
$scope.addDestination = function (type) {
$scope.cyberpanelLoading = false;
2020-09-20 23:00:54 +05:00
url = "/backup/submitDestinationCreation";
2020-09-20 23:00:54 +05:00
if (type === 'SFTP') {
var data = {
type: type,
name: $scope.name,
IPAddress: $scope.IPAddress,
userName: $scope.userName,
password: $scope.password,
backupSSHPort: $scope.backupSSHPort,
path: $scope.path
};
} else {
var data = {
type: type,
path: $scope.localPath,
name: $scope.name
};
}
2020-09-20 23:00:54 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
2020-09-20 23:00:54 +05:00
};
2020-09-20 23:00:54 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2020-09-20 23:00:54 +05:00
function ListInitialDatas(response) {
$scope.cyberpanelLoading = true;
$scope.populateCurrentRecords();
if (response.data.status === 1) {
new PNotify({
title: 'Success!',
text: 'Destination successfully added.',
type: 'success'
});
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
2017-10-24 19:16:36 +05:00
}
}
function cantLoadInitialDatas(response) {
2020-09-20 23:00:54 +05:00
$scope.cyberpanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
2017-10-24 19:16:36 +05:00
}
};
2020-09-20 23:00:54 +05:00
$scope.removeDestination = function (type, nameOrPath) {
$scope.cyberpanelLoading = false;
2020-05-21 23:21:36 +05:00
2020-09-20 23:00:54 +05:00
url = "/backup/deleteDestination";
2020-05-21 23:21:36 +05:00
2020-09-20 23:00:54 +05:00
var data = {
type: type,
nameOrPath: nameOrPath,
};
2020-05-21 23:21:36 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
2020-09-20 23:00:54 +05:00
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
2020-05-21 23:21:36 +05:00
2020-09-20 23:00:54 +05:00
function ListInitialDatas(response) {
2020-05-21 23:21:36 +05:00
$scope.cyberpanelLoading = true;
2020-09-20 23:00:54 +05:00
$scope.populateCurrentRecords();
2020-05-21 23:21:36 +05:00
if (response.data.status === 1) {
2020-09-20 23:00:54 +05:00
new PNotify({
title: 'Success!',
text: 'Destination successfully removed.',
type: 'success'
});
2020-05-21 23:21:36 +05:00
} else {
new PNotify({
2020-09-20 23:00:54 +05:00
title: 'Operation Failed!',
2020-05-21 23:21:36 +05:00
text: response.data.error_message,
type: 'error'
});
}
2020-09-20 23:00:54 +05:00
2020-05-21 23:21:36 +05:00
}
2020-09-20 23:00:54 +05:00
function cantLoadInitialDatas(response) {
2020-05-21 23:21:36 +05:00
$scope.cyberpanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
});
2020-09-20 23:00:54 +05:00
//
2020-06-13 21:56:37 +05:00
app.controller('scheduleBackup', function ($scope, $http, $window) {
2020-06-13 21:56:37 +05:00
$scope.cyberPanelLoading = true;
$scope.driveHidden = true;
$scope.jobsHidden = true;
2020-06-13 21:56:37 +05:00
$scope.currentPage = 1;
$scope.recordsToShow = 10;
$scope.fetchJobs = function () {
2020-06-13 21:56:37 +05:00
$scope.cyberPanelLoading = false;
2020-09-30 11:10:22 +05:00
$scope.jobsHidden = true;
2020-06-13 21:56:37 +05:00
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
var data = {
selectedAccount: $scope.selectedAccount,
};
dataurl = "/backup/fetchNormalJobs";
$http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
$scope.jobsHidden = false;
new PNotify({
title: 'Success',
text: 'Successfully fetched.',
type: 'success'
});
$scope.jobs = response.data.jobs;
} 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.addSchedule = function () {
$scope.cyberPanelLoading = false;
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
var data = {
2020-09-30 11:10:22 +05:00
selectedAccount: $scope.selectedAccountAdd,
name: $scope.name,
backupFrequency: $scope.backupFrequency
};
dataurl = "/backup/submitBackupSchedule";
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
function ListInitialData(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success',
text: 'Schedule successfully added.',
type: 'success'
});
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialData(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
$scope.fetchWebsites = function () {
$scope.cyberPanelLoading = false;
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
var data = {
selectedAccount: $scope.selectedJob,
2020-06-13 21:56:37 +05:00
page: $scope.currentPage,
recordsToShow: $scope.recordsToShow
};
dataurl = "/backup/fetchgNormalSites";
2020-06-13 21:56:37 +05:00
$http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
$scope.driveHidden = false;
new PNotify({
title: 'Success',
text: 'Successfully fetched.',
type: 'success'
});
$scope.websites = JSON.parse(response.data.websites);
$scope.pagination = response.data.pagination;
$scope.currently = response.data.currently;
$scope.allSites = response.data.allSites;
$scope.lastRun = response.data.lastRun;
$scope.currentStatus = response.data.currentStatus;
2020-06-13 21:56:37 +05:00
} 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.addSite = function (type) {
2020-06-13 21:56:37 +05:00
$scope.cyberPanelLoading = false;
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
var data = {
selectedWebsite: $scope.selectedWebsite,
selectedJob: $scope.selectedJob,
type: type
2020-06-13 21:56:37 +05:00
};
dataurl = "/backup/addSiteNormal";
2020-06-13 21:56:37 +05:00
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
function ListInitialData(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success',
text: 'Site successfully added.',
type: 'success'
});
$scope.fetchWebsites();
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialData(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
$scope.deleteAccount = function () {
$scope.cyberPanelLoading = false;
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
var data = {
selectedJob: $scope.selectedJob
2020-06-13 21:56:37 +05:00
};
dataurl = "/backup/deleteAccountNormal";
2020-06-13 21:56:37 +05:00
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
function ListInitialData(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success',
text: 'Account successfully deleted.',
type: 'success'
});
location.reload();
2020-06-13 21:56:37 +05:00
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialData(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
$scope.changeFrequency = function () {
$scope.cyberPanelLoading = false;
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
var data = {
selectedJob: $scope.selectedJob,
2020-06-13 21:56:37 +05:00
backupFrequency: $scope.backupFrequency
};
dataurl = "/backup/changeAccountFrequencyNormal";
2020-06-13 21:56:37 +05:00
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
function ListInitialData(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success',
text: 'Changes successfully applied',
type: 'success'
});
$scope.fetchWebsites();
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialData(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
$scope.deleteSite = function (website) {
$scope.cyberPanelLoading = false;
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
var data = {
selectedJob: $scope.selectedJob,
2020-06-13 21:56:37 +05:00
website: website
};
dataurl = "/backup/deleteSiteNormal";
2020-06-13 21:56:37 +05:00
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
function ListInitialData(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success',
text: 'Website Deleted.',
type: 'success'
});
$scope.fetchWebsites();
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialData(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
$scope.currentPageLogs = 1;
$scope.recordsToShowLogs = 10;
$scope.fetchLogs = function () {
$scope.cyberPanelLoading = false;
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
var data = {
selectedJob: $scope.selectedJob,
2020-06-13 21:56:37 +05:00
page: $scope.currentPageLogs,
recordsToShow: $scope.recordsToShowLogs
};
dataurl = "/backup/fetchNormalLogs";
2020-06-13 21:56:37 +05:00
$http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
$scope.driveHidden = false;
new PNotify({
title: 'Success',
text: 'Successfully fetched.',
type: 'success'
});
$scope.logs = JSON.parse(response.data.logs);
$scope.paginationLogs = response.data.pagination;
} 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'
});
}
};
});