bug fix: snapshot delete backups v2

This commit is contained in:
usmannasir 2024-02-02 20:15:07 +05:00
parent ce4b06f5cc
commit 34b7216a8a
6 changed files with 198 additions and 3 deletions

View File

@ -1296,6 +1296,7 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
}
$scope.RestorePathV2Model = function (SnapshotId, Path) {
$('#RestoreSnapshotPath').modal('show');
document.getElementById('Snapshot_id').innerText = SnapshotId
@ -1304,6 +1305,14 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
}
$scope.DeleteSnapshotBackupsv2 = function (SnapshotId, Path) {
$('#DeleteSnapshotmodelv2').modal('show');
document.getElementById('Snapshot_id_delete').innerText = SnapshotId;
//alert(document.getElementById('Snapshot_id_delete').innerText);
}
function getCreationStatus() {
url = "/IncrementalBackups/CreateV2BackupStatus";
@ -1443,6 +1452,61 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
}
$scope.DeleteSnapshotV2Final = function (SnapshotId, Path) {
$scope.backupLoading = false;
SnapshotId = document.getElementById('Snapshot_id_delete').innerText
console.log("SnapshotId: " + SnapshotId)
var url = "/IncrementalBackups/DeleteSnapshotV2Final";
var data = {
snapshotid: SnapshotId,
selwebsite: $scope.selwebsite,
selectedrepo: $scope.testhabbi
}
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) {
new PNotify({
title: 'Success!',
text: 'Snapshot Deleted.',
type: 'success'
});
} else {
$scope.backupLoading = true;
$scope.installationDetailsForm = true;
$scope.installationProgress = false;
$scope.errorMessageBox = false;
$scope.success = true;
$scope.couldNotConnect = true;
$scope.goBackDisable = false;
new PNotify({
title: 'Error!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialDatas(response) {
}
}
$scope.selectrepo = function () {
$scope.backupLoading = false;
@ -1479,7 +1543,7 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
var tml = '<tr style="">\n' +
' <td>' + snapshots[i][1][j].id + '</td>' +
' <td>' + snapshots[i][1][j].time + '</td>' +
' <td><button type="button" class="btn btn-danger">Delete</button></td>\n' +
' <td><button ng-click=\'DeleteSnapshotBackupsv2("' + snapshots[i][1][j].id + '","' + snapshots[i][1][j].paths[k] + '")\' type="button" class="btn btn-danger">Delete</button></td>\n' +
'</tr>' +
'<tr style="border: none!important;"> <td colspan="2" style="display: inherit;max-height: 10px;background-color: transparent; border: none">\n' +
' <button id="' + snapshots[i][1][j].id + 'button" class="my-4 mx-4 btn " style="margin-bottom: 15px;margin-top: -8px;background-color: #161a69; color: white;border-radius: 6px" onclick=listpaths("' + snapshots[i][1][j].id + '","' + snapshots[i][1][j].id + 'button")>+</button>\n' +

View File

@ -162,6 +162,88 @@
</div>
</div>
<div id="DeleteSnapshotmodelv2" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content" style="height: 80%">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;
</button>
<h4 id="restore_header_text" class="modal-title">{% trans "Delete" %} <img
ng-hide="backupLoading" src="{% static 'images/loading.gif' %}"> </h4>
</div>
<div class="modal-body" style="">
<span style="font-weight: bolder"><span style="font-weight: bolder">ID: <span style="font-weight: normal"
id="Snapshot_id_delete"></span></span><br>
<span style="display: flex;justify-content: center;margin-top: 20px;font-weight: bolder">{% trans "Are you ready to delete this snapshot? This process can not be undone." %} </span>
<div style="display: flex;justify-content: center;margin-top: 10px;margin-bottom: 20px">
<button type="button" class="btn btn-primary "
style="margin-right: 20px!important;"
ng-click="DeleteSnapshotV2Final()">Yes <img
ng-hide="backupLoading"
src="">
</button>
<button type="button" ng-disabled="savingSettings"
class="btn btn-default mx-3" data-dismiss="modal">
No
</button>
</div>
<div ng-hide="installationProgress" class="form-group">
<label class="col-sm-12 control-label"></label>
<div class="col-sm-12">
<div class="alert alert-success text-center">
{# <h2>{$ currentStatus $}</h2>#}
<h2 class="ng-binding">Successfully Restored</h2>
</div>
<div class="progress">
<div id="installProgress" class="progress-bar" role="progressbar"
aria-valuenow="70"
aria-valuemin="0" aria-valuemax="100" style="width:0%">
<span class="sr-only">70% Complete</span>
</div>
</div>
<div ng-hide="errorMessageBox" class="alert alert-danger">
<p>{% trans "Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="success" class="alert alert-success">
<p>{% trans "Restored succesfully." %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
</div>
</div>
<div ng-hide="installationProgress" class="form-group">
<label class="col-sm-12 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-disabled="goBackDisable" ng-click="goBack()"
class="btn btn-primary btn-lg">{% trans "Go Back" %}</button>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" ng-disabled="savingSettings"
class="btn btn-default" data-dismiss="modal">
Close
</button>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -30,6 +30,7 @@ urlpatterns = [
url(r'^selectwebsiteRetorev2$', views.selectwebsiteRetorev2, name='selectwebsiteRetorev2'),
url(r'^selectreporestorev2$', views.selectreporestorev2, name='selectreporestorev2'),
url(r'^RestorePathV2$', views.RestorePathV2, name='RestorePathV2'),
url(r'^DeleteSnapshotV2Final$', views.DeleteSnapshotV2Final, name='DeleteSnapshotV2Final'),
url(r'^CreateV2BackupButton$', views.CreateV2BackupButton, name='CreateV2BackupButton'),
url(r'^selectwebsiteCreatev2$', views.selectwebsiteCreatev2, name='selectwebsiteCreatev2'),
url(r'^CreateV2BackupStatus$', views.CreateV2BackupStatus, name='CreateV2BackupStatus'),

View File

@ -895,6 +895,49 @@ def RestorePathV2(request):
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def DeleteSnapshotV2Final(request):
try:
userID = request.session['userID']
data = json.loads(request.body)
SnapShotId = data['snapshotid']
Selectedwebsite = data['selwebsite']
Selectedrepo = data['selectedrepo']
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(str(Selectedwebsite), admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
extra_args = {}
extra_args['function'] = 'InitiateRestore'
extra_args['website'] = Selectedwebsite
extra_args['domain'] = Selectedwebsite
extra_args['BasePath'] = '/home/backup'
extra_args['BackendName'] = Selectedrepo
extra_args['snapshotid'] = SnapShotId
# extra_args['BackupData'] = data['websiteData'] if 'websiteData' in data else False
# extra_args['BackupEmails'] = data['websiteEmails'] if 'websiteEmails' in data else False
# extra_args['BackupDatabase'] = data['websiteDatabases'] if 'websiteDatabases' in data else False
background = CPBackupsV2(extra_args)
background.DeleteSnapshots(SnapShotId)
# vm = CPBackupsV2({'domain': Selectedwebsite, 'BackendName': Selectedrepo, "function": "", 'BasePath': '/home/backup'})
# status = vm.InitiateRestore(SnapShotId, Path)
data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None',}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException as msg:
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def selectwebsiteRetorev2(request):
import re
try:

View File

@ -18,7 +18,7 @@
<h3 class="content-box-header">
{% trans "Create Email Account" %} - <a style="font-size: large; color: red" target="_blank"
href="https://platform.cyberpersons.com/MailTester/MailTester?utm_source=from-cyberpanel-inside&utm_medium=from-cyberpanel-inside&utm_campaign=from-cyberpanel-inside&utm_id=from-cyberpanel-inside&utm_term=from-cyberpanel-inside">
<u>Test Email Delivery<u></u></a> <img ng-hide="emailLoading"
<u>Test Email Delivery</u></a> <img ng-hide="emailLoading"
src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">

View File

@ -45,7 +45,6 @@ class CPBackupsV2(multi.Thread):
multi.Thread.__init__(self)
self.data = data
try:
self.function = data['function']
except:
pass
@ -141,6 +140,12 @@ class CPBackupsV2(multi.Thread):
if os.path.exists(self.StatusFile):
os.remove(self.StatusFile)
# ### delete repo function
# try:
# self.repo = data['BackendName']
# except:
# pass
def run(self):
try:
if self.function == 'InitiateBackup':