Skip to content

Commit be4b85c

Browse files
committed
feature: edit incremental backup plans
1 parent 4e783f0 commit be4b85c

5 files changed

Lines changed: 251 additions & 2 deletions

File tree

IncBackups/static/IncBackups/IncBackups.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,53 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
741741

742742
};
743743

744+
$scope.editInitial = function (id) {
745+
746+
$scope.jobID = id;
747+
748+
$scope.cyberpanelLoading = false;
749+
750+
751+
url = "/IncrementalBackups/fetchSites";
752+
753+
754+
var data = {id: id};
755+
756+
var config = {
757+
headers: {
758+
'X-CSRFToken': getCookie('csrftoken')
759+
}
760+
};
761+
762+
763+
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
764+
765+
766+
function ListInitialDatas(response) {
767+
$scope.cyberpanelLoading = true;
768+
if (response.data.status === 1) {
769+
$scope.websites = JSON.parse(response.data.data);
770+
} else {
771+
new PNotify({
772+
title: 'Operation Failed!',
773+
text: response.data.error_message,
774+
type: 'error'
775+
});
776+
}
777+
778+
}
779+
780+
function cantLoadInitialDatas(response) {
781+
$scope.cyberpanelLoading = true;
782+
new PNotify({
783+
title: 'Operation Failed!',
784+
text: 'Could not connect to server, please refresh this page',
785+
type: 'error'
786+
});
787+
}
788+
789+
};
790+
744791

745792
});
746793

IncBackups/templates/IncBackups/backupSchedule.html

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ <h3 class="title-hero">
169169
<th>{% trans "ID" %}</th>
170170
<th>{% trans "Destination" %}</th>
171171
<th>{% trans "Frequency" %}</th>
172+
<th>{% trans "Sites" %}</th>
172173
<th>{% trans "Delete" %}</th>
173174
</tr>
174175
</thead>
@@ -177,8 +178,117 @@ <h3 class="title-hero">
177178
<td ng-bind="record.id"></td>
178179
<td ng-bind="record.destination"></td>
179180
<td ng-bind="record.frequency"></td>
180-
<td ng-click="delSchedule(record.id)"><img
181-
src="{% static 'images/delete.png' %}"></td>
181+
<td ng-bind="record.numberOfSites"></td>
182+
<td>
183+
<a ng-click="delSchedule(record.id)"
184+
class="btn btn-border btn-alt border-red btn-link font-red"
185+
href="#"
186+
title=""><span>{% trans 'Delete' %}</span></a>
187+
<a data-toggle="modal" data-target="#settings"
188+
ng-click="editInitial(record.id)"
189+
class="btn btn-border btn-alt border-purple btn-link font-purple"
190+
href="#"
191+
title=""><span>{% trans 'Edit' %}</span></a>
192+
193+
<!--- Modal --->
194+
<div id="settings" class="modal fade" role="dialog">
195+
<div class="modal-dialog">
196+
197+
<!-- Modal content-->
198+
<div class="modal-content">
199+
<div class="modal-header">
200+
<button type="button" class="close" data-dismiss="modal">
201+
&times;
202+
</button>
203+
<h4 class="modal-title">Edit User
204+
<img ng-hide="cyberpanelLoading"
205+
src="{% static 'images/loading.gif' %}">
206+
</h4>
207+
</div>
208+
<div class="modal-body">
209+
210+
<form name="containerSettingsForm" action="/"
211+
class="form-horizontal">
212+
213+
<div ng-hide="installationDetailsForm"
214+
class="form-group">
215+
<label class="col-sm-3 control-label">{% trans "Job ID" %}</label>
216+
<div class="col-sm-4">
217+
<input name="name" type="number"
218+
class="form-control"
219+
ng-model="jobID" readonly>
220+
</div>
221+
</div>
222+
223+
<div ng-hide="installationDetailsForm"
224+
class="form-group">
225+
<label class="col-sm-3 control-label">{% trans "Data" %}</label>
226+
<div class="checkbox">
227+
<label>
228+
<input ng-model="websiteData"
229+
type="checkbox" value="">
230+
Data
231+
</label>
232+
</div>
233+
</div>
234+
235+
<div ng-hide="installationDetailsForm"
236+
class="form-group">
237+
<label class="col-sm-3 control-label">{% trans "Databases" %}</label>
238+
<div class="checkbox">
239+
<label>
240+
<input ng-model="websiteDatabases"
241+
type="checkbox" value="">
242+
Databases
243+
</label>
244+
</div>
245+
</div>
246+
247+
<div ng-hide="installationDetailsForm"
248+
class="form-group">
249+
<label class="col-sm-3 control-label">{% trans "Emails" %}</label>
250+
<div class="checkbox">
251+
<label>
252+
<input ng-model="websiteEmails"
253+
type="checkbox" value="">
254+
Emails
255+
</label>
256+
</div>
257+
</div>
258+
259+
<hr>
260+
<table class="table">
261+
<thead>
262+
<tr>
263+
<th>{% trans "ID" %}</th>
264+
<th>{% trans "Website" %}</th>
265+
<th>{% trans "Actions" %}</th>
266+
</tr>
267+
</thead>
268+
<tbody>
269+
<tr ng-repeat="record in websites track by $index">
270+
<td ng-bind="record.id"></td>
271+
<td ng-bind="record.website"></td>
272+
<td>
273+
<a ng-click="delSchedule(record.id)"
274+
class="btn btn-border btn-alt border-red btn-link font-red"
275+
href="#"
276+
title=""><span>{% trans 'Delete' %}</span></a>
277+
</td>
278+
279+
</tr>
280+
</tbody>
281+
</table>
282+
283+
284+
</form>
285+
286+
</div>
287+
</div>
288+
</div>
289+
</div>
290+
<!--- Modal End--->
291+
</td>
182292

183293
</tr>
184294
</tbody>

IncBackups/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
url(r'^submitBackupSchedule$', views.submitBackupSchedule, name='submitBackupScheduleInc'),
1919
url(r'^scheduleDelete$', views.scheduleDelete, name='scheduleDeleteInc'),
2020
url(r'^getCurrentBackupSchedules$', views.getCurrentBackupSchedules, name='getCurrentBackupSchedulesInc'),
21+
url(r'^fetchSites$', views.fetchSites, name='fetchSites'),
2122
]

IncBackups/views.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,42 @@ def getCurrentBackupSchedules(request):
678678
dic = {'id': items.id,
679679
'destination': items.destination,
680680
'frequency': items.frequency,
681+
'numberOfSites': items.jobsites_set.all().count()
682+
}
683+
684+
if checker == 0:
685+
json_data = json_data + json.dumps(dic)
686+
checker = 1
687+
else:
688+
json_data = json_data + ',' + json.dumps(dic)
689+
690+
json_data = json_data + ']'
691+
final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
692+
return HttpResponse(final_json)
693+
694+
except BaseException as msg:
695+
final_dic = {'status': 0, 'error_message': str(msg)}
696+
final_json = json.dumps(final_dic)
697+
return HttpResponse(final_json)
698+
699+
def fetchSites(request):
700+
try:
701+
userID = request.session['userID']
702+
currentACL = ACLManager.loadedACL(userID)
703+
704+
if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0:
705+
return ACLManager.loadErrorJson('fetchStatus', 0)
706+
707+
data = json.loads(request.body)
708+
709+
job = BackupJob.objects.get(pk=data['id'])
710+
711+
json_data = "["
712+
checker = 0
713+
714+
for items in job.jobsites_set.all():
715+
dic = {'id': items.id,
716+
'website': items.website,
681717
}
682718

683719
if checker == 0:

static/userManagment/userManagment.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,61 @@ app.controller('listTableUsers', function ($scope, $http) {
16851685

16861686

16871687
};
1688+
1689+
$scope.controlUserState = function (userName, state) {
1690+
$scope.cyberpanelLoading = false;
1691+
1692+
var url = "/users/controlUserState";
1693+
1694+
var data = {
1695+
accountUsername: userName,
1696+
state : state
1697+
};
1698+
1699+
var config = {
1700+
headers: {
1701+
'X-CSRFToken': getCookie('csrftoken')
1702+
}
1703+
};
1704+
1705+
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
1706+
1707+
1708+
function ListInitialDatas(response) {
1709+
$scope.cyberpanelLoading = true;
1710+
if (response.data.status === 1) {
1711+
$scope.populateCurrentRecords();
1712+
new PNotify({
1713+
title: 'Success!',
1714+
text: 'Action successfully started.',
1715+
type: 'success'
1716+
});
1717+
1718+
} else {
1719+
1720+
new PNotify({
1721+
title: 'Error!',
1722+
text: response.data.error_message,
1723+
type: 'error'
1724+
});
1725+
1726+
1727+
}
1728+
1729+
}
1730+
1731+
function cantLoadInitialDatas(response) {
1732+
1733+
$scope.cyberpanelLoading = false;
1734+
new PNotify({
1735+
title: 'Error!',
1736+
text: 'Could not connect to server, please refresh this page.',
1737+
type: 'error'
1738+
});
1739+
1740+
1741+
}
1742+
}
16881743

16891744
});
16901745

0 commit comments

Comments
 (0)