diff --git a/IncBackups/static/IncBackups/IncBackups.js b/IncBackups/static/IncBackups/IncBackups.js index 94f9d5406..0728c8ec5 100644 --- a/IncBackups/static/IncBackups/IncBackups.js +++ b/IncBackups/static/IncBackups/IncBackups.js @@ -1201,7 +1201,7 @@ app.controller('restoreRemoteBackupsInc', function ($scope, $http, $timeout) { }); -app.controller('restorev2backupoage', function ($scope, $http, $timeout) { +app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compile) { $scope.backupLoading = true; @@ -1214,6 +1214,7 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout) { var data = { Selectedwebsite: $scope.selwebsite, + }; //alert( $scope.selwebsite); @@ -1289,6 +1290,46 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout) { } } + $scope.RestorePathV2 = function (SnapshotId, Path){ + + console.log("SnapshotId: " + SnapshotId) + console.log("Path: "+Path) + var url = "/IncrementalBackups/RestorePathV2"; + var data ={ + snapshotid: SnapshotId, + path: Path + } + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + $scope.SnapShotId = response.data.SnapShotId; + $scope.tempPath = response.data.Path; + + console.log("Returned ID on ListInitialDatas: " + $scope.SnapShotId) + console.log("Returned PATH on ListInitialDatas: " + $scope.tempPath) + + } + + } + + function cantLoadInitialDatas(response) { + } + + + + } + $scope.selectrepo = function () { $scope.backupLoading = false; @@ -1337,8 +1378,10 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout) { ' \n'; for (var j = 0; j < snaphots[i].paths.length; j++) { - tml += '\n' + - '\n' + + tml += '\n' + + '\n' + + '\n' + '\n'; } @@ -1346,8 +1389,9 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout) { '\n' + '\n' + '\n'; + var mp = $compile(tml)($scope); - $('#listsnapshots').append(tml); + $('#listsnapshots').append(mp); } // $scope.Snaphot_ID @@ -1399,7 +1443,140 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout) { }); -app.controller('createV2Backups', function ($scope, $http, $timeout){ +app.controller('CreateV2Backup', function ($scope, $http, $timeout, $compile) { + + + $scope.backupLoading = true; + + $scope.selectwebsite = function () { + document.getElementById('reposelectbox').innerHTML = ""; + $scope.backupLoading = false; + // document.getElementById('CreateV2BackupButton').style.display = "block"; + var url = "/IncrementalBackups/selectwebsiteRetorev2"; + + var data = { + Selectedwebsite: $scope.selwebsite, + Selectedrepo: $('#reposelectbox').val(), + }; + //alert( $scope.selwebsite); + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.backupLoading = true; + if (response.data.status === 1) { + + + + const selectBox = document.getElementById('reposelectbox'); + + + const options = response.data.data; + const option = document.createElement('option'); + + + option.value = 1; + option.text = 'Choose Repooo'; + + selectBox.appendChild(option); + + if (options.length >= 1) + { + for (let i = 0; i < options.length; i++) { + + const option = document.createElement('option'); + + + option.value = options[i]; + option.text = options[i]; + + selectBox.appendChild(option); + } + + } + else { + new PNotify({ + title: 'Error!', + text: 'file empty', + type: 'error' + }); + } + + + + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.backupLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + } + + + $scope.CreateV2BackupButton = function(){ + $scope.backupLoading = false; + + var url = "/IncrementalBackups/CreateV2BackupButton"; + + var data = { + Selectedwebsite: $scope.selwebsite, + Selectedrepo: $('#reposelectbox').val(), + }; + alert($scope.selwebsite + "...... repo...." + $('#reposelectbox').val(),); + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.backupLoading = true; + if (response.data.status === 1) { + + console.log("Returned Selectedwebsite: " + response.data.Selectedwebsite) + console.log("Returned Selectedrepo: " + response.data.Selectedrepo) + + } + + } + + function cantLoadInitialDatas(response) { + + } + } + + + + + +}); + +app.controller('ConfigureV2Backup', function ($scope, $http, $timeout){ $scope.cyberpanelLoading = true; $scope.selectbackuptype = function () { @@ -1434,4 +1611,5 @@ function listpaths(pathid,button){ document.getElementById(button).innerText="+" } -} \ No newline at end of file +} + diff --git a/IncBackups/templates/IncBackups/createV2Backup.html b/IncBackups/templates/IncBackups/ConfigureV2Backup.html similarity index 96% rename from IncBackups/templates/IncBackups/createV2Backup.html rename to IncBackups/templates/IncBackups/ConfigureV2Backup.html index 6f0e3e28c..eebb09ffe 100644 --- a/IncBackups/templates/IncBackups/createV2Backup.html +++ b/IncBackups/templates/IncBackups/ConfigureV2Backup.html @@ -1,6 +1,6 @@ {% extends "baseTemplate/index.html" %} {% load i18n %} -{% block title %}{% trans "Create V2 Backup" %}{% endblock %} +{% block title %}{% trans "Configure V2 Backup" %}{% endblock %} {% block content %} {% load static %} @@ -10,7 +10,7 @@
-
+

{% trans "Backup V2" %} + + +
+
+

{% trans "Create V2 Backup Site" %} - {% trans "Backup Docs" %}

+

{% trans "This page can be used to create your backup sites" %}

+
+ +
+
+

+ {% trans "Create V2 Backup Site" %} +

+
+ +
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + + + +
+ +{#
#} +{##} +{#
#} +{##} +{#

' + snaphots[i].paths[j] + '
' + snaphots[i].paths[j] + '' + + '
#} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{##} +{##} +{# #} +{##} +{#
{% trans "Snapshot ID" %}{% trans "Action" %} >
#} +{# #} +{# #} + + + + + + + + +{% endblock %} \ No newline at end of file diff --git a/IncBackups/urls.py b/IncBackups/urls.py index 04bb00ebf..a0ce3c403 100644 --- a/IncBackups/urls.py +++ b/IncBackups/urls.py @@ -23,10 +23,14 @@ urlpatterns = [ url(r'^removeSite$', views.remove_site, name='removeSite'), url(r'^addWebsite$', views.add_website, name='addWebsite'), ### V2 Backups URls - url(r'^createV2Backup$', views.createV2Backup, name='createV2Backup'), + + url(r'^CreateV2Backup$', views.CreateV2Backup, name='CreateV2Backup'), + url(r'^ConfigureV2Backup$', views.ConfigureV2Backup, name='ConfigureV2Backup'), url(r'^createV2BackupSetup$', views.createV2BackupSetup, name='createV2BackupSetup'), url(r'^RestoreV2backupSite$', views.RestoreV2backupSite, name='RestoreV2backupSite'), url(r'^selectwebsiteRetorev2$', views.selectwebsiteRetorev2, name='selectwebsiteRetorev2'), url(r'^selectreporestorev2$', views.selectreporestorev2, name='selectreporestorev2'), + url(r'^RestorePathV2$', views.RestorePathV2, name='RestorePathV2'), + url(r'^CreateV2BackupButton$', views.CreateV2BackupButton, name='CreateV2BackupButton'), ] \ No newline at end of file diff --git a/IncBackups/views.py b/IncBackups/views.py index 81de3ca8d..4b53982e4 100644 --- a/IncBackups/views.py +++ b/IncBackups/views.py @@ -712,7 +712,7 @@ def add_website(request): -def createV2Backup(request): +def ConfigureV2Backup(request): try: user_id, current_acl = _get_user_acl(request) if ACLManager.currentContextPermission(current_acl, 'createBackup') == 0: @@ -721,14 +721,20 @@ def createV2Backup(request): # websites = ACLManager.findAllSites(current_acl, user_id) # # destinations = _get_destinations(local=True) - proc = httpProc(request, 'IncBackups/createV2Backup.html') + proc = httpProc(request, 'IncBackups/ConfigureV2Backup.html') return proc.render() except BaseException as msg: logging.writeToFile(str(msg)) return redirect(loadLoginPage) - +def CreateV2Backup(request): + try: + userID = request.session['userID'] + bm = BackupManager() + return bm.CreateV2backupSite(request, userID) + except KeyError: + return redirect(loadLoginPage) def createV2BackupSetup(request): try: @@ -760,7 +766,22 @@ def createV2BackupSetup(request): return redirect(loadLoginPage) +def CreateV2BackupButton(request): + import re + try: + userID = request.session['userID'] + data = json.loads(request.body) + Selectedwebsite = data['Selectedwebsite'] + Selectedrepo = data['Selectedrepo'] + final_dic = {'status': 1, 'Selectedwebsite': Selectedwebsite, 'Selectedrepo': Selectedrepo} + 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_json = json.dumps(final_dic) + return HttpResponse(final_json) def RestoreV2backupSite(request): try: @@ -770,6 +791,22 @@ def RestoreV2backupSite(request): except KeyError: return redirect(loadLoginPage) +def RestorePathV2(request): + import re + try: + userID = request.session['userID'] + data = json.loads(request.body) + SnapShotId = data['snapshotid'] + Path = data['path'] + + final_dic = {'status': 1, 'SnapShotId': SnapShotId, 'Path': Path} + 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_json = json.dumps(final_dic) + return HttpResponse(final_json) def selectwebsiteRetorev2(request): import re diff --git a/backup/backupManager.py b/backup/backupManager.py index e4f2dd4c7..acea516ef 100755 --- a/backup/backupManager.py +++ b/backup/backupManager.py @@ -57,6 +57,11 @@ class BackupManager: websitesName = ACLManager.findAllSites(currentACL, userID) proc = httpProc(request, 'IncBackups/RestoreV2Backup.html', {'websiteList': websitesName}, 'createBackup') return proc.render() + def CreateV2backupSite(self, request=None, userID=None, data=None): + currentACL = ACLManager.loadedACL(userID) + websitesName = ACLManager.findAllSites(currentACL, userID) + proc = httpProc(request, 'IncBackups/CreateV2Backup.html', {'websiteList': websitesName}, 'createBackup') + return proc.render() def gDrive(self, request=None, userID=None, data=None): currentACL = ACLManager.loadedACL(userID) diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html index 49984e451..99b892e98 100755 --- a/baseTemplate/templates/baseTemplate/index.html +++ b/baseTemplate/templates/baseTemplate/index.html @@ -723,10 +723,12 @@