Skip to content

Commit 77bf26a

Browse files
committed
feature: edit/manage inc backups
1 parent 4f47b84 commit 77bf26a

File tree

5 files changed

+540
-28
lines changed

5 files changed

+540
-28
lines changed

IncBackups/static/IncBackups/IncBackups.js

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,181 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
767767
$scope.cyberpanelLoading = true;
768768
if (response.data.status === 1) {
769769
$scope.websites = JSON.parse(response.data.data);
770+
771+
if(response.data.websiteData === 1){
772+
$scope.websiteData = true;
773+
}
774+
if(response.data.websiteDatabases === 1){
775+
$scope.websiteDatabases = true;
776+
}
777+
if(response.data.websiteEmails === 1){
778+
$scope.websiteEmails = true;
779+
}
780+
781+
} else {
782+
new PNotify({
783+
title: 'Operation Failed!',
784+
text: response.data.error_message,
785+
type: 'error'
786+
});
787+
}
788+
789+
}
790+
791+
function cantLoadInitialDatas(response) {
792+
$scope.cyberpanelLoading = true;
793+
new PNotify({
794+
title: 'Operation Failed!',
795+
text: 'Could not connect to server, please refresh this page',
796+
type: 'error'
797+
});
798+
}
799+
800+
};
801+
802+
$scope.saveChanges = function () {
803+
804+
$scope.cyberpanelLoading = false;
805+
806+
url = "/IncrementalBackups/saveChanges";
807+
808+
809+
var data = {
810+
id: $scope.jobID,
811+
websiteData: $scope.websiteData,
812+
websiteDatabases: $scope.websiteDatabases,
813+
websiteEmails: $scope.websiteEmails
814+
815+
};
816+
817+
var config = {
818+
headers: {
819+
'X-CSRFToken': getCookie('csrftoken')
820+
}
821+
};
822+
823+
824+
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
825+
826+
827+
function ListInitialDatas(response) {
828+
$scope.cyberpanelLoading = true;
829+
830+
if (response.data.status === 1) {
831+
$scope.editInitial($scope.jobID);
832+
new PNotify({
833+
title: 'Success!',
834+
text: 'Operation successful.',
835+
type: 'success'
836+
});
837+
} else {
838+
new PNotify({
839+
title: 'Operation Failed!',
840+
text: response.data.error_message,
841+
type: 'error'
842+
});
843+
}
844+
845+
}
846+
847+
function cantLoadInitialDatas(response) {
848+
$scope.cyberpanelLoading = true;
849+
new PNotify({
850+
title: 'Operation Failed!',
851+
text: 'Could not connect to server, please refresh this page',
852+
type: 'error'
853+
});
854+
}
855+
856+
};
857+
858+
$scope.removeSite = function (website) {
859+
860+
$scope.cyberpanelLoading = false;
861+
862+
url = "/IncrementalBackups/removeSite";
863+
864+
865+
var data = {
866+
id: $scope.jobID,
867+
website: website
868+
};
869+
870+
var config = {
871+
headers: {
872+
'X-CSRFToken': getCookie('csrftoken')
873+
}
874+
};
875+
876+
877+
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
878+
879+
880+
function ListInitialDatas(response) {
881+
$scope.cyberpanelLoading = true;
882+
883+
if (response.data.status === 1) {
884+
$scope.editInitial($scope.jobID);
885+
new PNotify({
886+
title: 'Success!',
887+
text: 'Operation successful.',
888+
type: 'success'
889+
});
890+
} else {
891+
new PNotify({
892+
title: 'Operation Failed!',
893+
text: response.data.error_message,
894+
type: 'error'
895+
});
896+
}
897+
898+
}
899+
900+
function cantLoadInitialDatas(response) {
901+
$scope.cyberpanelLoading = true;
902+
new PNotify({
903+
title: 'Operation Failed!',
904+
text: 'Could not connect to server, please refresh this page',
905+
type: 'error'
906+
});
907+
}
908+
909+
};
910+
911+
$scope.cyberpanelLoading = true;
912+
913+
$scope.addWebsite = function () {
914+
915+
$scope.cyberpanelLoading = false;
916+
917+
url = "/IncrementalBackups/addWebsite";
918+
919+
920+
var data = {
921+
id: $scope.jobID,
922+
website: $scope.websiteToBeAdded
923+
};
924+
925+
var config = {
926+
headers: {
927+
'X-CSRFToken': getCookie('csrftoken')
928+
}
929+
};
930+
931+
932+
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
933+
934+
935+
function ListInitialDatas(response) {
936+
$scope.cyberpanelLoading = true;
937+
938+
if (response.data.status === 1) {
939+
$scope.editInitial($scope.jobID);
940+
new PNotify({
941+
title: 'Success!',
942+
text: 'Operation successful.',
943+
type: 'success'
944+
});
770945
} else {
771946
new PNotify({
772947
title: 'Operation Failed!',

IncBackups/templates/IncBackups/backupSchedule.html

Lines changed: 94 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ <h3 class="title-hero">
200200
<button type="button" class="close" data-dismiss="modal">
201201
&times;
202202
</button>
203-
<h4 class="modal-title">Edit User
203+
<h4 class="modal-title">Edit Job
204204
<img ng-hide="cyberpanelLoading"
205205
src="{% static 'images/loading.gif' %}">
206206
</h4>
@@ -225,7 +225,7 @@ <h4 class="modal-title">Edit User
225225
<label class="col-sm-3 control-label">{% trans "Data" %}</label>
226226
<div class="checkbox">
227227
<label>
228-
<input ng-model="websiteData"
228+
<input ng-model="$parent.websiteData"
229229
type="checkbox" value="">
230230
Data
231231
</label>
@@ -237,7 +237,7 @@ <h4 class="modal-title">Edit User
237237
<label class="col-sm-3 control-label">{% trans "Databases" %}</label>
238238
<div class="checkbox">
239239
<label>
240-
<input ng-model="websiteDatabases"
240+
<input ng-model="$parent.websiteDatabases"
241241
type="checkbox" value="">
242242
Databases
243243
</label>
@@ -249,36 +249,104 @@ <h4 class="modal-title">Edit User
249249
<label class="col-sm-3 control-label">{% trans "Emails" %}</label>
250250
<div class="checkbox">
251251
<label>
252-
<input ng-model="websiteEmails"
252+
<input ng-model="$parent.websiteEmails"
253253
type="checkbox" value="">
254254
Emails
255255
</label>
256256
</div>
257257
</div>
258258

259+
<div ng-hide="installationDetailsForm"
260+
class="form-group">
261+
<label class="col-sm-3 control-label">{% trans "" %}</label>
262+
<button type="button" ng-click="saveChanges()"
263+
class="btn btn-primary btn-lg">{% trans "Save Changes" %}</button>
264+
</div>
265+
259266
<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>
267+
<ul class="nav nav-tabs">
268+
269+
<li class="col-md-3 nav-item tab-mod active">
270+
<a href="#tab-example-1" data-toggle="tab"
271+
class="h4 nav-link">
272+
<span>{% trans "Sites" %}</span>
273+
</a>
274+
275+
</li>
276+
<li class="col-md-4 tab-mod nav-item">
277+
<a href="#tab-example-3" data-toggle="tab"
278+
class="h4 nav-link">
279+
<span>{% trans "Add Sites" %}</span>
280+
</a>
281+
</li>
282+
</ul>
283+
<div class="tab-content">
284+
<div class="tab-pane fade active in"
285+
id="tab-example-1">
286+
<div class="example-box-wrapper">
287+
<table class="table">
288+
<thead>
289+
<tr>
290+
<th>{% trans "ID" %}</th>
291+
<th>{% trans "Website" %}</th>
292+
<th>{% trans "Actions" %}</th>
293+
</tr>
294+
</thead>
295+
<tbody>
296+
<tr ng-repeat="record in websites track by $index">
297+
<td ng-bind="record.id"></td>
298+
<td ng-bind="record.website"></td>
299+
<td>
300+
<a ng-click="removeSite(record.website)"
301+
class="btn btn-border btn-alt border-red btn-link font-red"
302+
href="#"
303+
title=""><span>{% trans 'Delete' %}</span></a>
304+
</td>
305+
306+
</tr>
307+
</tbody>
308+
</table>
309+
</div>
310+
</div>
311+
312+
313+
<div class="tab-pane fade" id="tab-example-3">
314+
315+
<form action="/"
316+
class="form-horizontal bordered-row">
317+
318+
319+
<div class="form-group">
320+
<label class="col-sm-3 control-label">{% trans "Select Site" %}</label>
321+
<div class="col-sm-6">
322+
<select ng-model="$parent.websiteToBeAdded"
323+
class="form-control">
324+
{% for items in websiteList %}
325+
<option>{{ items }}</option>
326+
{% endfor %}
327+
</select>
328+
</div>
329+
<img ng-hide="cyberpanelLoading"
330+
src="{% static 'images/loading.gif' %}">
331+
</div>
332+
333+
<div ng-hide="savebtn"
334+
class="form-group">
335+
<label class="col-sm-3 control-label"></label>
336+
<div class="col-sm-4">
337+
<button type="button"
338+
ng-click="addWebsite()"
339+
class="btn btn-primary btn-lg btn-block">{% trans "Add" %}</button>
340+
341+
</div>
342+
</div>
343+
344+
345+
</form>
346+
347+
348+
</div>
349+
</div>
282350

283351

284352
</form>

IncBackups/urls.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@
1919
url(r'^scheduleDelete$', views.scheduleDelete, name='scheduleDeleteInc'),
2020
url(r'^getCurrentBackupSchedules$', views.getCurrentBackupSchedules, name='getCurrentBackupSchedulesInc'),
2121
url(r'^fetchSites$', views.fetchSites, name='fetchSites'),
22+
url(r'^saveChanges$', views.saveChanges, name='saveChanges'),
23+
url(r'^removeSite$', views.removeSite, name='removeSite'),
24+
url(r'^addWebsite$', views.addWebsite, name='addWebsite'),
2225
]

0 commit comments

Comments
 (0)