From 25ee799909c1c0fdc76b952a053781d986af5add Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Aug 2023 16:34:00 +0500 Subject: [PATCH 01/23] backup v2 delete repo page --- IncBackups/static/IncBackups/IncBackups.js | 175 +++++++++++++++++- .../templates/IncBackups/CreateV2Backup.html | 3 +- .../templates/IncBackups/DeleteV2repo.html | 121 ++++++++++++ IncBackups/urls.py | 2 + IncBackups/views.py | 50 +++++ backup/backupManager.py | 5 + .../templates/baseTemplate/index.html | 3 + plogical/Backupsv2.py | 34 ++++ 8 files changed, 383 insertions(+), 10 deletions(-) create mode 100644 IncBackups/templates/IncBackups/DeleteV2repo.html diff --git a/IncBackups/static/IncBackups/IncBackups.js b/IncBackups/static/IncBackups/IncBackups.js index 4812e755a..ae9d2f765 100644 --- a/IncBackups/static/IncBackups/IncBackups.js +++ b/IncBackups/static/IncBackups/IncBackups.js @@ -1918,10 +1918,10 @@ app.controller('ScheduleV2Backup', function ($scope, $http, $timeout, $compile) if (response.data.status === 1) { $scope.selectwebsite(); new PNotify({ - title: 'Success!', - text: 'Successfully deleted.', - type: 'success' - }); + title: 'Success!', + text: 'Successfully deleted.', + type: 'success' + }); } else { new PNotify({ @@ -2054,10 +2054,10 @@ app.controller('ScheduleV2Backup', function ($scope, $http, $timeout, $compile) if (response.data.status === 1) { $scope.selectwebsite(); new PNotify({ - title: 'Success!', - text: 'Successfully created.', - type: 'success' - }); + title: 'Success!', + text: 'Successfully created.', + type: 'success' + }); } else { new PNotify({ @@ -2242,3 +2242,162 @@ app.controller('ScheduleV2Backup', function ($scope, $http, $timeout, $compile) }); + +app.controller('DeleteBackuprepo', function ($scope, $http, $timeout, $compile) { + + $scope.backupLoading = true; + $scope.installationProgress = true; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = true; + + $scope.selectwebsite = function () { + document.getElementById('reposelectbox').innerHTML = ""; + $scope.backupLoading = false; + // document.getElementById('CreateV2BackupButton').style.display = "block"; + var url = "/IncrementalBackups/selectwebsiteCreatev2"; + + 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 Repo'; + + 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.DeleteV2BackupButton = function () { + $scope.backupLoading = false; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = true; + + var url = "/IncrementalBackups/DeleteV2BackupButton"; + + + data = { + Selectedwebsite: $scope.selwebsite, + Selectedrepo: $('#reposelectbox').val(), + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + //alert('Done..........') + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + if (response.data.status === 1) { + $scope.backupLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = true; + $scope.errorMessageBox = true; + $scope.success = false; + $scope.couldNotConnect = true; + $scope.goBackDisable = true; + new PNotify({ + title: 'Operation Done!', + text: 'Delete Successfully', + type: 'sucess' + }); + } else { + $scope.backupLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = false; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + + $scope.errorMessage = response.data.error_message; + new PNotify({ + title: 'Operation Failed!', + 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' + }); + } + } +}); + diff --git a/IncBackups/templates/IncBackups/CreateV2Backup.html b/IncBackups/templates/IncBackups/CreateV2Backup.html index aa2926f11..13bf303b8 100644 --- a/IncBackups/templates/IncBackups/CreateV2Backup.html +++ b/IncBackups/templates/IncBackups/CreateV2Backup.html @@ -27,7 +27,6 @@

- Restore Backups

-