Skip to content

Commit 34b7216

Browse files
committed
bug fix: snapshot delete backups v2
1 parent ce4b06f commit 34b7216

File tree

6 files changed

+198
-3
lines changed

6 files changed

+198
-3
lines changed

IncBackups/static/IncBackups/IncBackups.js

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,7 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
12961296
}
12971297

12981298
$scope.RestorePathV2Model = function (SnapshotId, Path) {
1299+
12991300
$('#RestoreSnapshotPath').modal('show');
13001301

13011302
document.getElementById('Snapshot_id').innerText = SnapshotId
@@ -1304,6 +1305,14 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
13041305

13051306
}
13061307

1308+
$scope.DeleteSnapshotBackupsv2 = function (SnapshotId, Path) {
1309+
$('#DeleteSnapshotmodelv2').modal('show');
1310+
1311+
document.getElementById('Snapshot_id_delete').innerText = SnapshotId;
1312+
//alert(document.getElementById('Snapshot_id_delete').innerText);
1313+
1314+
}
1315+
13071316
function getCreationStatus() {
13081317

13091318
url = "/IncrementalBackups/CreateV2BackupStatus";
@@ -1443,6 +1452,61 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
14431452

14441453
}
14451454

1455+
$scope.DeleteSnapshotV2Final = function (SnapshotId, Path) {
1456+
1457+
$scope.backupLoading = false;
1458+
1459+
SnapshotId = document.getElementById('Snapshot_id_delete').innerText
1460+
console.log("SnapshotId: " + SnapshotId)
1461+
var url = "/IncrementalBackups/DeleteSnapshotV2Final";
1462+
var data = {
1463+
snapshotid: SnapshotId,
1464+
selwebsite: $scope.selwebsite,
1465+
selectedrepo: $scope.testhabbi
1466+
}
1467+
1468+
var config = {
1469+
headers: {
1470+
'X-CSRFToken': getCookie('csrftoken')
1471+
}
1472+
};
1473+
1474+
1475+
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
1476+
1477+
1478+
function ListInitialDatas(response) {
1479+
$scope.backupLoading = true;
1480+
if (response.data.status === 1) {
1481+
new PNotify({
1482+
title: 'Success!',
1483+
text: 'Snapshot Deleted.',
1484+
type: 'success'
1485+
});
1486+
1487+
} else {
1488+
$scope.backupLoading = true;
1489+
$scope.installationDetailsForm = true;
1490+
$scope.installationProgress = false;
1491+
$scope.errorMessageBox = false;
1492+
$scope.success = true;
1493+
$scope.couldNotConnect = true;
1494+
$scope.goBackDisable = false;
1495+
1496+
new PNotify({
1497+
title: 'Error!',
1498+
text: response.data.error_message,
1499+
type: 'error'
1500+
});
1501+
}
1502+
1503+
}
1504+
1505+
function cantLoadInitialDatas(response) {
1506+
}
1507+
1508+
1509+
}
14461510

14471511
$scope.selectrepo = function () {
14481512
$scope.backupLoading = false;
@@ -1479,7 +1543,7 @@ app.controller('restorev2backupoage', function ($scope, $http, $timeout, $compil
14791543
var tml = '<tr style="">\n' +
14801544
' <td>' + snapshots[i][1][j].id + '</td>' +
14811545
' <td>' + snapshots[i][1][j].time + '</td>' +
1482-
' <td><button type="button" class="btn btn-danger">Delete</button></td>\n' +
1546+
' <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' +
14831547
'</tr>' +
14841548
'<tr style="border: none!important;"> <td colspan="2" style="display: inherit;max-height: 10px;background-color: transparent; border: none">\n' +
14851549
' <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' +

IncBackups/templates/IncBackups/RestoreV2Backup.html

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,88 @@ <h2 class="ng-binding">Successfully Restored</h2>
162162

163163
</div>
164164
</div>
165+
<div id="DeleteSnapshotmodelv2" class="modal fade" role="dialog">
166+
<div class="modal-dialog modal-lg">
167+
168+
<!-- Modal content-->
169+
<div class="modal-content" style="height: 80%">
170+
<div class="modal-header">
171+
<button type="button" class="close" data-dismiss="modal">&times;
172+
</button>
173+
<h4 id="restore_header_text" class="modal-title">{% trans "Delete" %} <img
174+
ng-hide="backupLoading" src="{% static 'images/loading.gif' %}"> </h4>
175+
</div>
176+
<div class="modal-body" style="">
177+
178+
<span style="font-weight: bolder"><span style="font-weight: bolder">ID: <span style="font-weight: normal"
179+
id="Snapshot_id_delete"></span></span><br>
180+
<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>
181+
<div style="display: flex;justify-content: center;margin-top: 10px;margin-bottom: 20px">
182+
<button type="button" class="btn btn-primary "
183+
style="margin-right: 20px!important;"
184+
ng-click="DeleteSnapshotV2Final()">Yes <img
185+
ng-hide="backupLoading"
186+
src="">
187+
</button>
188+
<button type="button" ng-disabled="savingSettings"
189+
class="btn btn-default mx-3" data-dismiss="modal">
190+
No
191+
</button>
192+
</div>
193+
194+
<div ng-hide="installationProgress" class="form-group">
195+
<label class="col-sm-12 control-label"></label>
196+
<div class="col-sm-12">
197+
198+
<div class="alert alert-success text-center">
199+
{# <h2>{$ currentStatus $}</h2>#}
200+
<h2 class="ng-binding">Successfully Restored</h2>
201+
</div>
202+
203+
<div class="progress">
204+
<div id="installProgress" class="progress-bar" role="progressbar"
205+
aria-valuenow="70"
206+
aria-valuemin="0" aria-valuemax="100" style="width:0%">
207+
<span class="sr-only">70% Complete</span>
208+
</div>
209+
</div>
210+
211+
<div ng-hide="errorMessageBox" class="alert alert-danger">
212+
<p>{% trans "Error message:" %} {$ errorMessage $}</p>
213+
</div>
214+
215+
<div ng-hide="success" class="alert alert-success">
216+
<p>{% trans "Restored succesfully." %}</p>
217+
</div>
218+
219+
220+
<div ng-hide="couldNotConnect" class="alert alert-danger">
221+
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
222+
</div>
223+
224+
225+
</div>
226+
</div>
227+
228+
<div ng-hide="installationProgress" class="form-group">
229+
<label class="col-sm-12 control-label"></label>
230+
<div class="col-sm-4">
231+
<button type="button" ng-disabled="goBackDisable" ng-click="goBack()"
232+
class="btn btn-primary btn-lg">{% trans "Go Back" %}</button>
233+
</div>
234+
</div>
235+
</div>
236+
<div class="modal-footer">
237+
238+
<button type="button" ng-disabled="savingSettings"
239+
class="btn btn-default" data-dismiss="modal">
240+
Close
241+
</button>
242+
</div>
243+
</div>
244+
245+
</div>
246+
</div>
165247
</div>
166248
</div>
167249

IncBackups/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
url(r'^selectwebsiteRetorev2$', views.selectwebsiteRetorev2, name='selectwebsiteRetorev2'),
3131
url(r'^selectreporestorev2$', views.selectreporestorev2, name='selectreporestorev2'),
3232
url(r'^RestorePathV2$', views.RestorePathV2, name='RestorePathV2'),
33+
url(r'^DeleteSnapshotV2Final$', views.DeleteSnapshotV2Final, name='DeleteSnapshotV2Final'),
3334
url(r'^CreateV2BackupButton$', views.CreateV2BackupButton, name='CreateV2BackupButton'),
3435
url(r'^selectwebsiteCreatev2$', views.selectwebsiteCreatev2, name='selectwebsiteCreatev2'),
3536
url(r'^CreateV2BackupStatus$', views.CreateV2BackupStatus, name='CreateV2BackupStatus'),

IncBackups/views.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,49 @@ def RestorePathV2(request):
895895
json_data = json.dumps(data_ret)
896896
return HttpResponse(json_data)
897897

898+
def DeleteSnapshotV2Final(request):
899+
try:
900+
userID = request.session['userID']
901+
data = json.loads(request.body)
902+
SnapShotId = data['snapshotid']
903+
Selectedwebsite = data['selwebsite']
904+
Selectedrepo = data['selectedrepo']
905+
906+
currentACL = ACLManager.loadedACL(userID)
907+
admin = Administrator.objects.get(pk=userID)
908+
909+
if ACLManager.checkOwnership(str(Selectedwebsite), admin, currentACL) == 1:
910+
pass
911+
else:
912+
return ACLManager.loadError()
913+
914+
extra_args = {}
915+
extra_args['function'] = 'InitiateRestore'
916+
extra_args['website'] = Selectedwebsite
917+
extra_args['domain'] = Selectedwebsite
918+
extra_args['BasePath'] = '/home/backup'
919+
extra_args['BackendName'] = Selectedrepo
920+
extra_args['snapshotid'] = SnapShotId
921+
# extra_args['BackupData'] = data['websiteData'] if 'websiteData' in data else False
922+
# extra_args['BackupEmails'] = data['websiteEmails'] if 'websiteEmails' in data else False
923+
# extra_args['BackupDatabase'] = data['websiteDatabases'] if 'websiteDatabases' in data else False
924+
925+
926+
background = CPBackupsV2(extra_args)
927+
background.DeleteSnapshots(SnapShotId)
928+
929+
# vm = CPBackupsV2({'domain': Selectedwebsite, 'BackendName': Selectedrepo, "function": "", 'BasePath': '/home/backup'})
930+
# status = vm.InitiateRestore(SnapShotId, Path)
931+
932+
data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None',}
933+
json_data = json.dumps(data_ret)
934+
return HttpResponse(json_data)
935+
936+
except BaseException as msg:
937+
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
938+
json_data = json.dumps(data_ret)
939+
return HttpResponse(json_data)
940+
898941
def selectwebsiteRetorev2(request):
899942
import re
900943
try:

mailServer/templates/mailServer/createEmailAccount.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ <h2>{% trans "Create Email Account" %}</h2>
1818
<h3 class="content-box-header">
1919
{% trans "Create Email Account" %} - <a style="font-size: large; color: red" target="_blank"
2020
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">
21-
<u>Test Email Delivery<u></u></a> <img ng-hide="emailLoading"
21+
<u>Test Email Delivery</u></a> <img ng-hide="emailLoading"
2222
src="{% static 'images/loading.gif' %}">
2323
</h3>
2424
<div class="example-box-wrapper">

plogical/Backupsv2.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def __init__(self, data):
4545
multi.Thread.__init__(self)
4646
self.data = data
4747
try:
48-
4948
self.function = data['function']
5049
except:
5150
pass
@@ -141,6 +140,12 @@ def __init__(self, data):
141140
if os.path.exists(self.StatusFile):
142141
os.remove(self.StatusFile)
143142

143+
# ### delete repo function
144+
# try:
145+
# self.repo = data['BackendName']
146+
# except:
147+
# pass
148+
144149
def run(self):
145150
try:
146151
if self.function == 'InitiateBackup':

0 commit comments

Comments
 (0)