diff --git a/IncBackups/static/IncBackups/IncBackups.js b/IncBackups/static/IncBackups/IncBackups.js index b1ba61062..32b01ef70 100644 --- a/IncBackups/static/IncBackups/IncBackups.js +++ b/IncBackups/static/IncBackups/IncBackups.js @@ -767,6 +767,181 @@ app.controller('scheduleBackupInc', function ($scope, $http) { $scope.cyberpanelLoading = true; if (response.data.status === 1) { $scope.websites = JSON.parse(response.data.data); + + if(response.data.websiteData === 1){ + $scope.websiteData = true; + } + if(response.data.websiteDatabases === 1){ + $scope.websiteDatabases = true; + } + if(response.data.websiteEmails === 1){ + $scope.websiteEmails = true; + } + + } 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.saveChanges = function () { + + $scope.cyberpanelLoading = false; + + url = "/IncrementalBackups/saveChanges"; + + + var data = { + id: $scope.jobID, + websiteData: $scope.websiteData, + websiteDatabases: $scope.websiteDatabases, + websiteEmails: $scope.websiteEmails + + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + + if (response.data.status === 1) { + $scope.editInitial($scope.jobID); + new PNotify({ + title: 'Success!', + text: 'Operation successful.', + type: 'success' + }); + } 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.removeSite = function (website) { + + $scope.cyberpanelLoading = false; + + url = "/IncrementalBackups/removeSite"; + + + var data = { + id: $scope.jobID, + website: website + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + + if (response.data.status === 1) { + $scope.editInitial($scope.jobID); + new PNotify({ + title: 'Success!', + text: 'Operation successful.', + type: 'success' + }); + } 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.cyberpanelLoading = true; + + $scope.addWebsite = function () { + + $scope.cyberpanelLoading = false; + + url = "/IncrementalBackups/addWebsite"; + + + var data = { + id: $scope.jobID, + website: $scope.websiteToBeAdded + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + + if (response.data.status === 1) { + $scope.editInitial($scope.jobID); + new PNotify({ + title: 'Success!', + text: 'Operation successful.', + type: 'success' + }); } else { new PNotify({ title: 'Operation Failed!', diff --git a/IncBackups/templates/IncBackups/backupSchedule.html b/IncBackups/templates/IncBackups/backupSchedule.html index 8de13fb28..7724ca483 100755 --- a/IncBackups/templates/IncBackups/backupSchedule.html +++ b/IncBackups/templates/IncBackups/backupSchedule.html @@ -200,7 +200,7 @@ - @@ -225,7 +225,7 @@
@@ -237,7 +237,7 @@
@@ -249,36 +249,104 @@
-
- - - - - - - - - - - - - +
+ + +
- - -
{% trans "ID" %}{% trans "Website" %}{% trans "Actions" %}
- {% trans 'Delete' %} -
+
+ +
+
+
+ + + + + + + + + + + + + + + + +
{% trans "ID" %}{% trans "Website" %}{% trans "Actions" %}
+ {% trans 'Delete' %} +
+
+
+ + +
+ +
+ + +
+ +
+ +
+ +
+ +
+ +
+ + +
+
+ + +
+ + +
+
diff --git a/IncBackups/urls.py b/IncBackups/urls.py index b7d227773..2cb3e7928 100644 --- a/IncBackups/urls.py +++ b/IncBackups/urls.py @@ -19,4 +19,7 @@ urlpatterns = [ url(r'^scheduleDelete$', views.scheduleDelete, name='scheduleDeleteInc'), url(r'^getCurrentBackupSchedules$', views.getCurrentBackupSchedules, name='getCurrentBackupSchedulesInc'), url(r'^fetchSites$', views.fetchSites, name='fetchSites'), + url(r'^saveChanges$', views.saveChanges, name='saveChanges'), + url(r'^removeSite$', views.removeSite, name='removeSite'), + url(r'^addWebsite$', views.addWebsite, name='addWebsite'), ] \ No newline at end of file diff --git a/IncBackups/views.py b/IncBackups/views.py index 2850ad29e..cee76d479 100644 --- a/IncBackups/views.py +++ b/IncBackups/views.py @@ -606,6 +606,8 @@ def scheduleBackups(request): for items in os.listdir(path): destinations.append('s3:s3.amazonaws.com/%s' % (items)) + websitesName = ACLManager.findAllSites(currentACL, userID) + return defRenderer(request, 'IncBackups/backupSchedule.html', {'websiteList': websitesName, 'destinations': destinations}) except BaseException as msg: logging.writeToFile(str(msg)) @@ -723,7 +725,9 @@ def fetchSites(request): json_data = json_data + ',' + json.dumps(dic) json_data = json_data + ']' - final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data}) + final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data, + 'websiteData': job.websiteData, 'websiteDatabases': job.websiteDatabases, + 'websiteEmails': job.websiteDataEmails}) return HttpResponse(final_json) except BaseException as msg: @@ -779,4 +783,91 @@ def restoreRemoteBackups(request): return defRenderer(request, 'IncBackups/restoreRemoteBackups.html', {'websiteList': websitesName, 'destinations': destinations}) except BaseException as msg: logging.writeToFile(str(msg)) - return redirect(loadLoginPage) \ No newline at end of file + return redirect(loadLoginPage) + +def saveChanges(request): + try: + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0: + return ACLManager.loadErrorJson('scheduleStatus', 0) + + data = json.loads(request.body) + + id = data['id'] + websiteData = data['websiteData'] + websiteDatabases = data['websiteDatabases'] + websiteEmails = data['websiteEmails'] + + job = BackupJob.objects.get(pk=id) + + job.websiteData = int(websiteData) + job.websiteDatabases = int(websiteDatabases) + job.websiteEmails = int(websiteEmails) + job.save() + + final_json = json.dumps({'status': 1, 'error_message': "None"}) + return HttpResponse(final_json) + + + except BaseException as msg: + final_json = json.dumps({'status': 0, 'error_message': str(msg)}) + return HttpResponse(final_json) + +def removeSite(request): + try: + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0: + return ACLManager.loadErrorJson('scheduleStatus', 0) + + data = json.loads(request.body) + + id = data['id'] + website = data['website'] + + + job = BackupJob.objects.get(pk=id) + + site = JobSites.objects.get(job=job, website=website) + site.delete() + + final_json = json.dumps({'status': 1, 'error_message': "None"}) + return HttpResponse(final_json) + + + except BaseException as msg: + final_json = json.dumps({'status': 0, 'error_message': str(msg)}) + return HttpResponse(final_json) + +def addWebsite(request): + try: + userID = request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0: + return ACLManager.loadErrorJson('scheduleStatus', 0) + + data = json.loads(request.body) + + id = data['id'] + website = data['website'] + + + job = BackupJob.objects.get(pk=id) + + try: + JobSites.objects.get(job=job, website=website) + except: + site = JobSites(job=job, website=website) + site.save() + + final_json = json.dumps({'status': 1, 'error_message': "None"}) + return HttpResponse(final_json) + + + except BaseException as msg: + final_json = json.dumps({'status': 0, 'error_message': str(msg)}) + return HttpResponse(final_json) \ No newline at end of file diff --git a/static/IncBackups/IncBackups.js b/static/IncBackups/IncBackups.js index b1ba61062..32b01ef70 100644 --- a/static/IncBackups/IncBackups.js +++ b/static/IncBackups/IncBackups.js @@ -767,6 +767,181 @@ app.controller('scheduleBackupInc', function ($scope, $http) { $scope.cyberpanelLoading = true; if (response.data.status === 1) { $scope.websites = JSON.parse(response.data.data); + + if(response.data.websiteData === 1){ + $scope.websiteData = true; + } + if(response.data.websiteDatabases === 1){ + $scope.websiteDatabases = true; + } + if(response.data.websiteEmails === 1){ + $scope.websiteEmails = true; + } + + } 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.saveChanges = function () { + + $scope.cyberpanelLoading = false; + + url = "/IncrementalBackups/saveChanges"; + + + var data = { + id: $scope.jobID, + websiteData: $scope.websiteData, + websiteDatabases: $scope.websiteDatabases, + websiteEmails: $scope.websiteEmails + + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + + if (response.data.status === 1) { + $scope.editInitial($scope.jobID); + new PNotify({ + title: 'Success!', + text: 'Operation successful.', + type: 'success' + }); + } 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.removeSite = function (website) { + + $scope.cyberpanelLoading = false; + + url = "/IncrementalBackups/removeSite"; + + + var data = { + id: $scope.jobID, + website: website + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + + if (response.data.status === 1) { + $scope.editInitial($scope.jobID); + new PNotify({ + title: 'Success!', + text: 'Operation successful.', + type: 'success' + }); + } 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.cyberpanelLoading = true; + + $scope.addWebsite = function () { + + $scope.cyberpanelLoading = false; + + url = "/IncrementalBackups/addWebsite"; + + + var data = { + id: $scope.jobID, + website: $scope.websiteToBeAdded + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + + if (response.data.status === 1) { + $scope.editInitial($scope.jobID); + new PNotify({ + title: 'Success!', + text: 'Operation successful.', + type: 'success' + }); } else { new PNotify({ title: 'Operation Failed!',