feature: edit incremental backup plans

This commit is contained in:
Usman Nasir
2020-01-21 22:10:58 +05:00
parent 4e783f0a2f
commit be4b85cbe3
5 changed files with 251 additions and 2 deletions

View File

@@ -741,6 +741,53 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
}; };
$scope.editInitial = function (id) {
$scope.jobID = id;
$scope.cyberpanelLoading = false;
url = "/IncrementalBackups/fetchSites";
var data = {id: id};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.cyberpanelLoading = true;
if (response.data.status === 1) {
$scope.websites = JSON.parse(response.data.data);
} else {
new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.cyberpanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
}); });

View File

@@ -169,6 +169,7 @@
<th>{% trans "ID" %}</th> <th>{% trans "ID" %}</th>
<th>{% trans "Destination" %}</th> <th>{% trans "Destination" %}</th>
<th>{% trans "Frequency" %}</th> <th>{% trans "Frequency" %}</th>
<th>{% trans "Sites" %}</th>
<th>{% trans "Delete" %}</th> <th>{% trans "Delete" %}</th>
</tr> </tr>
</thead> </thead>
@@ -177,8 +178,117 @@
<td ng-bind="record.id"></td> <td ng-bind="record.id"></td>
<td ng-bind="record.destination"></td> <td ng-bind="record.destination"></td>
<td ng-bind="record.frequency"></td> <td ng-bind="record.frequency"></td>
<td ng-click="delSchedule(record.id)"><img <td ng-bind="record.numberOfSites"></td>
src="{% static 'images/delete.png' %}"></td> <td>
<a ng-click="delSchedule(record.id)"
class="btn btn-border btn-alt border-red btn-link font-red"
href="#"
title=""><span>{% trans 'Delete' %}</span></a>
<a data-toggle="modal" data-target="#settings"
ng-click="editInitial(record.id)"
class="btn btn-border btn-alt border-purple btn-link font-purple"
href="#"
title=""><span>{% trans 'Edit' %}</span></a>
<!--- Modal --->
<div id="settings" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
&times;
</button>
<h4 class="modal-title">Edit User
<img ng-hide="cyberpanelLoading"
src="{% static 'images/loading.gif' %}">
</h4>
</div>
<div class="modal-body">
<form name="containerSettingsForm" action="/"
class="form-horizontal">
<div ng-hide="installationDetailsForm"
class="form-group">
<label class="col-sm-3 control-label">{% trans "Job ID" %}</label>
<div class="col-sm-4">
<input name="name" type="number"
class="form-control"
ng-model="jobID" readonly>
</div>
</div>
<div ng-hide="installationDetailsForm"
class="form-group">
<label class="col-sm-3 control-label">{% trans "Data" %}</label>
<div class="checkbox">
<label>
<input ng-model="websiteData"
type="checkbox" value="">
Data
</label>
</div>
</div>
<div ng-hide="installationDetailsForm"
class="form-group">
<label class="col-sm-3 control-label">{% trans "Databases" %}</label>
<div class="checkbox">
<label>
<input ng-model="websiteDatabases"
type="checkbox" value="">
Databases
</label>
</div>
</div>
<div ng-hide="installationDetailsForm"
class="form-group">
<label class="col-sm-3 control-label">{% trans "Emails" %}</label>
<div class="checkbox">
<label>
<input ng-model="websiteEmails"
type="checkbox" value="">
Emails
</label>
</div>
</div>
<hr>
<table class="table">
<thead>
<tr>
<th>{% trans "ID" %}</th>
<th>{% trans "Website" %}</th>
<th>{% trans "Actions" %}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="record in websites track by $index">
<td ng-bind="record.id"></td>
<td ng-bind="record.website"></td>
<td>
<a ng-click="delSchedule(record.id)"
class="btn btn-border btn-alt border-red btn-link font-red"
href="#"
title=""><span>{% trans 'Delete' %}</span></a>
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</div>
</div>
<!--- Modal End--->
</td>
</tr> </tr>
</tbody> </tbody>

View File

@@ -18,4 +18,5 @@ urlpatterns = [
url(r'^submitBackupSchedule$', views.submitBackupSchedule, name='submitBackupScheduleInc'), url(r'^submitBackupSchedule$', views.submitBackupSchedule, name='submitBackupScheduleInc'),
url(r'^scheduleDelete$', views.scheduleDelete, name='scheduleDeleteInc'), url(r'^scheduleDelete$', views.scheduleDelete, name='scheduleDeleteInc'),
url(r'^getCurrentBackupSchedules$', views.getCurrentBackupSchedules, name='getCurrentBackupSchedulesInc'), url(r'^getCurrentBackupSchedules$', views.getCurrentBackupSchedules, name='getCurrentBackupSchedulesInc'),
url(r'^fetchSites$', views.fetchSites, name='fetchSites'),
] ]

View File

@@ -678,6 +678,42 @@ def getCurrentBackupSchedules(request):
dic = {'id': items.id, dic = {'id': items.id,
'destination': items.destination, 'destination': items.destination,
'frequency': items.frequency, 'frequency': items.frequency,
'numberOfSites': items.jobsites_set.all().count()
}
if checker == 0:
json_data = json_data + json.dumps(dic)
checker = 1
else:
json_data = json_data + ',' + json.dumps(dic)
json_data = json_data + ']'
final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
return HttpResponse(final_json)
except BaseException as msg:
final_dic = {'status': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
def fetchSites(request):
try:
userID = request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0:
return ACLManager.loadErrorJson('fetchStatus', 0)
data = json.loads(request.body)
job = BackupJob.objects.get(pk=data['id'])
json_data = "["
checker = 0
for items in job.jobsites_set.all():
dic = {'id': items.id,
'website': items.website,
} }
if checker == 0: if checker == 0:

View File

@@ -1685,6 +1685,61 @@ app.controller('listTableUsers', function ($scope, $http) {
}; };
$scope.controlUserState = function (userName, state) {
$scope.cyberpanelLoading = false;
var url = "/users/controlUserState";
var data = {
accountUsername: userName,
state : state
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.cyberpanelLoading = true;
if (response.data.status === 1) {
$scope.populateCurrentRecords();
new PNotify({
title: 'Success!',
text: 'Action successfully started.',
type: 'success'
});
} else {
new PNotify({
title: 'Error!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.cyberpanelLoading = false;
new PNotify({
title: 'Error!',
text: 'Could not connect to server, please refresh this page.',
type: 'error'
});
}
}
}); });