gdrive5
This commit is contained in:
parent
0195da8094
commit
4ce65856b6
|
|
@ -825,13 +825,13 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
|
|||
if (response.data.status === 1) {
|
||||
$scope.websites = response.data.data;
|
||||
|
||||
if(response.data.websiteData === 1){
|
||||
if (response.data.websiteData === 1) {
|
||||
$scope.websiteData = true;
|
||||
}
|
||||
if(response.data.websiteDatabases === 1){
|
||||
if (response.data.websiteDatabases === 1) {
|
||||
$scope.websiteDatabases = true;
|
||||
}
|
||||
if(response.data.websiteEmails === 1){
|
||||
if (response.data.websiteEmails === 1) {
|
||||
$scope.websiteEmails = true;
|
||||
}
|
||||
|
||||
|
|
@ -1084,9 +1084,9 @@ app.controller('restoreRemoteBackupsInc', function ($scope, $http, $timeout) {
|
|||
$scope.runningBackup = false;
|
||||
|
||||
$scope.fileName = response.data.fileName;
|
||||
if(response.data.status === 1){
|
||||
if (response.data.status === 1) {
|
||||
$scope.status = 'Fetching status..'
|
||||
}else{
|
||||
} else {
|
||||
$scope.status = response.data.status;
|
||||
}
|
||||
|
||||
|
|
@ -1208,7 +1208,7 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
|
|||
|
||||
$scope.selectwebsite = function () {
|
||||
document.getElementById('reposelectbox').innerHTML = "";
|
||||
$scope.backupLoading = false;
|
||||
$scope.backupLoading = false;
|
||||
|
||||
var url = "/IncrementalBackups/selectwebsiteRetorev2";
|
||||
|
||||
|
|
@ -1233,7 +1233,6 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
|
|||
if (response.data.status === 1) {
|
||||
|
||||
|
||||
|
||||
const selectBox = document.getElementById('reposelectbox');
|
||||
|
||||
|
||||
|
|
@ -1246,28 +1245,25 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
|
|||
|
||||
selectBox.appendChild(option);
|
||||
|
||||
if (options.length >= 1)
|
||||
{
|
||||
if (options.length >= 1) {
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
|
||||
const option = document.createElement('option');
|
||||
const option = document.createElement('option');
|
||||
|
||||
|
||||
option.value = options[i];
|
||||
option.text = options[i];
|
||||
option.value = options[i];
|
||||
option.text = options[i];
|
||||
|
||||
selectBox.appendChild(option);
|
||||
selectBox.appendChild(option);
|
||||
}
|
||||
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: 'file empty',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: 'file empty',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
|
@ -1290,12 +1286,12 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
|
|||
}
|
||||
}
|
||||
|
||||
$scope.RestorePathV2 = function (SnapshotId, Path){
|
||||
$scope.RestorePathV2 = function (SnapshotId, Path) {
|
||||
|
||||
console.log("SnapshotId: " + SnapshotId)
|
||||
console.log("Path: "+Path)
|
||||
console.log("Path: " + Path)
|
||||
var url = "/IncrementalBackups/RestorePathV2";
|
||||
var data ={
|
||||
var data = {
|
||||
snapshotid: SnapshotId,
|
||||
path: Path
|
||||
}
|
||||
|
|
@ -1313,7 +1309,7 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
|
|||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.status === 1) {
|
||||
$scope.SnapShotId = response.data.SnapShotId;
|
||||
$scope.SnapShotId = response.data.SnapShotId;
|
||||
$scope.tempPath = response.data.Path;
|
||||
|
||||
console.log("Returned ID on ListInitialDatas: " + $scope.SnapShotId)
|
||||
|
|
@ -1327,12 +1323,11 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$scope.selectrepo = function () {
|
||||
$scope.backupLoading = false;
|
||||
$scope.backupLoading = false;
|
||||
|
||||
var url = "/IncrementalBackups/selectreporestorev2";
|
||||
|
||||
|
|
@ -1352,7 +1347,6 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
|
|||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.backupLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
|
|
@ -1396,27 +1390,27 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
|
|||
|
||||
// $scope.Snaphot_ID
|
||||
|
||||
// var table = document.getElementById("snapshotstable");
|
||||
//
|
||||
// // Loop through the data and create a new row for each item
|
||||
// for (var i = 0; i < data.length; i++) {
|
||||
// // Create a new row element
|
||||
// var row = table.insertRow();
|
||||
//
|
||||
// // Create the first cell and set its value to the current item in the data array
|
||||
// var idCell = row.insertCell(0);
|
||||
// idCell.innerHTML = data[i];
|
||||
//
|
||||
// // Create the second cell and add a delete button to it
|
||||
// var deleteCell = row.insertCell(1);
|
||||
// var deleteButton = document.createElement("button");
|
||||
// deleteButton.innerHTML = "Delete";
|
||||
// deleteButton.addEventListener("click", function() {
|
||||
// // Call your delete function here
|
||||
// console.log("Deleting item:", data[i]);
|
||||
// });
|
||||
// deleteCell.appendChild(deleteButton);
|
||||
// }
|
||||
// var table = document.getElementById("snapshotstable");
|
||||
//
|
||||
// // Loop through the data and create a new row for each item
|
||||
// for (var i = 0; i < data.length; i++) {
|
||||
// // Create a new row element
|
||||
// var row = table.insertRow();
|
||||
//
|
||||
// // Create the first cell and set its value to the current item in the data array
|
||||
// var idCell = row.insertCell(0);
|
||||
// idCell.innerHTML = data[i];
|
||||
//
|
||||
// // Create the second cell and add a delete button to it
|
||||
// var deleteCell = row.insertCell(1);
|
||||
// var deleteButton = document.createElement("button");
|
||||
// deleteButton.innerHTML = "Delete";
|
||||
// deleteButton.addEventListener("click", function() {
|
||||
// // Call your delete function here
|
||||
// console.log("Deleting item:", data[i]);
|
||||
// });
|
||||
// deleteCell.appendChild(deleteButton);
|
||||
// }
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
|
|
@ -1438,9 +1432,6 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
app.controller('CreateV2Backup', function ($scope, $http, $timeout, $compile) {
|
||||
|
|
@ -1475,7 +1466,6 @@ app.controller('CreateV2Backup', function ($scope, $http, $timeout, $compile) {
|
|||
if (response.data.status === 1) {
|
||||
|
||||
|
||||
|
||||
const selectBox = document.getElementById('reposelectbox');
|
||||
|
||||
|
||||
|
|
@ -1488,8 +1478,7 @@ app.controller('CreateV2Backup', function ($scope, $http, $timeout, $compile) {
|
|||
|
||||
selectBox.appendChild(option);
|
||||
|
||||
if (options.length >= 1)
|
||||
{
|
||||
if (options.length >= 1) {
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
|
||||
const option = document.createElement('option');
|
||||
|
|
@ -1501,8 +1490,7 @@ app.controller('CreateV2Backup', function ($scope, $http, $timeout, $compile) {
|
|||
selectBox.appendChild(option);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: 'file empty',
|
||||
|
|
@ -1511,7 +1499,6 @@ app.controller('CreateV2Backup', function ($scope, $http, $timeout, $compile) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
|
|
@ -1533,7 +1520,10 @@ app.controller('CreateV2Backup', function ($scope, $http, $timeout, $compile) {
|
|||
}
|
||||
|
||||
|
||||
$scope.CreateV2BackupButton = function(){
|
||||
|
||||
|
||||
|
||||
$scope.CreateV2BackupButton = function () {
|
||||
$scope.backupLoading = false;
|
||||
|
||||
var url = "/IncrementalBackups/CreateV2BackupButton";
|
||||
|
|
@ -1542,7 +1532,7 @@ app.controller('CreateV2Backup', function ($scope, $http, $timeout, $compile) {
|
|||
Selectedwebsite: $scope.selwebsite,
|
||||
Selectedrepo: $('#reposelectbox').val(),
|
||||
};
|
||||
alert($scope.selwebsite + "...... repo...." + $('#reposelectbox').val(),);
|
||||
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
|
|
@ -1550,7 +1540,7 @@ app.controller('CreateV2Backup', function ($scope, $http, $timeout, $compile) {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
//alert('Done..........')
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
|
|
@ -1558,57 +1548,60 @@ app.controller('CreateV2Backup', function ($scope, $http, $timeout, $compile) {
|
|||
$scope.backupLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
|
||||
console.log("Returned Selectedwebsite: " + response.data.Selectedwebsite)
|
||||
console.log("Returned Selectedrepo: " + response.data.Selectedrepo)
|
||||
alert("....................."+response.data.status);
|
||||
|
||||
}
|
||||
else {
|
||||
alert('fail..........'+response.data.status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.backupLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
app.controller('ConfigureV2Backup', function ($scope, $http, $timeout){
|
||||
app.controller('ConfigureV2Backup', function ($scope, $http, $timeout) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.selectbackuptype = function () {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
var backuptype = $scope.v2backuptype
|
||||
if (backuptype === 'GDrive')
|
||||
{
|
||||
if (backuptype === 'GDrive') {
|
||||
$scope.cyberpanelLoading = true;
|
||||
$('#GdriveModal').modal('show');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$scope.setupAccount = function(){
|
||||
$scope.setupAccount = function () {
|
||||
window.open("https://platform.cyberpersons.com/gDrive?name=" + $scope.accountName + '&server=' + window.location.href + 'Setup');
|
||||
};
|
||||
});
|
||||
|
||||
function listpaths(pathid,button){
|
||||
function listpaths(pathid, button) {
|
||||
|
||||
console.log("LIST PAYH FUNCTIOB CALLED WITH ID "+ pathid);
|
||||
console.log("LIST PAYH FUNCTIOB CALLED WITH ID " + pathid);
|
||||
var pathlist = document.getElementById(pathid)
|
||||
if (pathlist.style.display === "none") {
|
||||
pathlist.style.display = "revert";
|
||||
|
||||
document.getElementById(button).innerText="-"
|
||||
document.getElementById(button).innerText = "-"
|
||||
|
||||
} else {
|
||||
pathlist.style.display = "none";
|
||||
pathlist.style.display = "none";
|
||||
|
||||
document.getElementById(button).innerText="+"
|
||||
document.getElementById(button).innerText = "+"
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary"
|
||||
ng-click="setupAccount()">Save <img
|
||||
ng-hide="cyberPanelLoading"
|
||||
ng-hide="cyberpanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</button>
|
||||
<button type="button" ng-disabled="savingSettings"
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
</h3>
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<form action="/IncBackups/static" class="form-horizontal bordered-row">
|
||||
<form class="form-horizontal bordered-row">
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
|
|
@ -51,31 +51,13 @@
|
|||
<button class="btn" id="CreateV2BackupButton" ng-click="CreateV2BackupButton()" style="border-radius: 6px;background-color: #3447b7;color: white !important;"> Create Backup</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{# <div ng-hide="runningSnapshot" class="form-group">#}
|
||||
{##}
|
||||
{# <div class="col-sm-12">#}
|
||||
{##}
|
||||
{# <table id="snapshotstable" class="table">#}
|
||||
{# <thead>#}
|
||||
{# <tr style="border-bottom: #cccccc solid 1px!important;" >#}
|
||||
{# <th style="border: none">{% trans "Snapshot ID" %}</th>#}
|
||||
{# <th style="border: none">{% trans "Action" %} ></th>#}
|
||||
{# </tr>#}
|
||||
{# </thead>#}
|
||||
{# <tbody id="listsnapshots">#}
|
||||
{##}
|
||||
{##}
|
||||
{# </tbody>#}
|
||||
{##}
|
||||
{# </table>#}
|
||||
{# </div>#}
|
||||
{# </div>#}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ urlpatterns = [
|
|||
|
||||
url(r'^CreateV2Backup$', views.CreateV2Backup, name='CreateV2Backup'),
|
||||
url(r'^ConfigureV2Backup$', views.ConfigureV2Backup, name='ConfigureV2Backup'),
|
||||
url(r'^createV2BackupSetup$', views.createV2BackupSetup, name='createV2BackupSetup'),
|
||||
url(r'^ConfigureV2BackupSetup$', views.createV2BackupSetup, name='ConfigureV2BackupSetup'),
|
||||
url(r'^RestoreV2backupSite$', views.RestoreV2backupSite, name='RestoreV2backupSite'),
|
||||
url(r'^selectwebsiteRetorev2$', views.selectwebsiteRetorev2, name='selectwebsiteRetorev2'),
|
||||
url(r'^selectreporestorev2$', views.selectreporestorev2, name='selectreporestorev2'),
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ from .IncBackupsControl import IncJobs
|
|||
from .models import IncJob, BackupJob, JobSites
|
||||
|
||||
|
||||
|
||||
|
||||
def def_renderer(request, templateName, args, context=None):
|
||||
proc = httpProc(request, templateName,
|
||||
args, context)
|
||||
|
|
@ -759,10 +761,10 @@ def createV2BackupSetup(request):
|
|||
|
||||
# wm = BackupManager()
|
||||
# return wm.gDriveSetup(userID, request)
|
||||
|
||||
final_dic = {'status': 1}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
# currentACL = ACLManager.loadedACL(userID)
|
||||
# websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
# proc = httpProc(request, 'IncBackups/RestoreV2Backup.html', {'websiteList': websitesName}, 'createBackup')
|
||||
# return proc.render()
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
|
@ -775,12 +777,12 @@ def CreateV2BackupButton(request):
|
|||
Selectedwebsite = data['Selectedwebsite']
|
||||
Selectedrepo = data['Selectedrepo']
|
||||
|
||||
final_dic = {'status': 1, 'Selectedwebsite': Selectedwebsite, 'Selectedrepo': Selectedrepo}
|
||||
final_dic = {'status': 1, 'data': None}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException as msg:
|
||||
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
|
||||
final_dic = {'status': 0, 'error_message': str(msg)}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import requests
|
|||
sys.path.append('/usr/local/CyberCP')
|
||||
import django
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
|
||||
import plogical.mysqlUtilities as mysqlUtilities
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
|
|
@ -64,6 +65,7 @@ class CPBackupsV2:
|
|||
return 0, str(msg)
|
||||
|
||||
def SetupRcloneBackend(self, type, config):
|
||||
|
||||
self.LocalRclonePath = f'/home/{self.website.domain}/.config/rclone'
|
||||
self.ConfigFilePath = f'{self.LocalRclonePath}/rclone.conf'
|
||||
|
||||
|
|
@ -97,10 +99,12 @@ pass = {ObsecurePassword}
|
|||
command = f"chmod 600 {self.ConfigFilePath}"
|
||||
ProcessUtilities.executioner(command, self.website.externalApp)
|
||||
elif type == CPBackupsV2.GDrive:
|
||||
## config = {"name":, "host":, "user":, "port":, "path":, "password":,}
|
||||
logging.CyberCPLogFileWriter.writeToFile('tes 2,...gdive..........in')
|
||||
command = f'rclone obscure {config["password"]}'
|
||||
ObsecurePassword = ProcessUtilities.outputExecutioner(command).rstrip('\n')
|
||||
|
||||
token = """{"access_token":"%s","token_type":"Bearer","refresh_token":"%s"}""" %(config["token"], config["refresh_token"])
|
||||
|
||||
content = f'''[{config["name"]}]
|
||||
type = Gdrive
|
||||
[Gdrive_Mount]
|
||||
|
|
@ -109,7 +113,7 @@ client_secret = ""
|
|||
scope = drive
|
||||
root_folder_id = ""
|
||||
service_account_file = ""
|
||||
token = {"access_token":"{config["token"]}","token_type":"Bearer","refresh_token":"{config["refresh_token"]}"}
|
||||
token = {token}
|
||||
'''
|
||||
command = f"echo '{content}' > {self.ConfigFilePath}"
|
||||
ProcessUtilities.executioner(command, self.website.externalApp, True)
|
||||
|
|
@ -117,6 +121,7 @@ token = {"access_token":"{config["token"]}","token_type":"Bearer","refresh_token
|
|||
command = f"chmod 600 {self.ConfigFilePath}"
|
||||
ProcessUtilities.executioner(command, self.website.externalApp)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def FetchCurrentTimeStamp():
|
||||
import time
|
||||
|
|
|
|||
Loading…
Reference in New Issue