Skip to content

Commit

Permalink
feature: edit incremental backup plans
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Jan 21, 2020
1 parent 4e783f0 commit be4b85c
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 2 deletions.
47 changes: 47 additions & 0 deletions IncBackups/static/IncBackups/IncBackups.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
});
}

};


});

Expand Down
114 changes: 112 additions & 2 deletions IncBackups/templates/IncBackups/backupSchedule.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ <h3 class="title-hero">
<th>{% trans "ID" %}</th>
<th>{% trans "Destination" %}</th>
<th>{% trans "Frequency" %}</th>
<th>{% trans "Sites" %}</th>
<th>{% trans "Delete" %}</th>
</tr>
</thead>
Expand All @@ -177,8 +178,117 @@ <h3 class="title-hero">
<td ng-bind="record.id"></td>
<td ng-bind="record.destination"></td>
<td ng-bind="record.frequency"></td>
<td ng-click="delSchedule(record.id)"><img
src="{% static 'images/delete.png' %}"></td>
<td ng-bind="record.numberOfSites"></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>
</tbody>
Expand Down
1 change: 1 addition & 0 deletions IncBackups/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
url(r'^submitBackupSchedule$', views.submitBackupSchedule, name='submitBackupScheduleInc'),
url(r'^scheduleDelete$', views.scheduleDelete, name='scheduleDeleteInc'),
url(r'^getCurrentBackupSchedules$', views.getCurrentBackupSchedules, name='getCurrentBackupSchedulesInc'),
url(r'^fetchSites$', views.fetchSites, name='fetchSites'),
]
36 changes: 36 additions & 0 deletions IncBackups/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,42 @@ def getCurrentBackupSchedules(request):
dic = {'id': items.id,
'destination': items.destination,
'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:
Expand Down
55 changes: 55 additions & 0 deletions static/userManagment/userManagment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
});


}
}

});

Expand Down

0 comments on commit be4b85c

Please sign in to comment.