Skip to content

Commit

Permalink
feature: edit/manage inc backups
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Jan 22, 2020
1 parent 4f47b84 commit 77bf26a
Show file tree
Hide file tree
Showing 5 changed files with 540 additions and 28 deletions.
175 changes: 175 additions & 0 deletions IncBackups/static/IncBackups/IncBackups.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,181 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
$scope.cyberpanelLoading = true;
if (response.data.status === 1) {
$scope.websites = JSON.parse(response.data.data);

if(response.data.websiteData === 1){
$scope.websiteData = true;
}
if(response.data.websiteDatabases === 1){
$scope.websiteDatabases = true;
}
if(response.data.websiteEmails === 1){
$scope.websiteEmails = true;
}

} 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'
});
}

};

$scope.saveChanges = function () {

$scope.cyberpanelLoading = false;

url = "/IncrementalBackups/saveChanges";


var data = {
id: $scope.jobID,
websiteData: $scope.websiteData,
websiteDatabases: $scope.websiteDatabases,
websiteEmails: $scope.websiteEmails

};

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.editInitial($scope.jobID);
new PNotify({
title: 'Success!',
text: 'Operation successful.',
type: 'success'
});
} 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'
});
}

};

$scope.removeSite = function (website) {

$scope.cyberpanelLoading = false;

url = "/IncrementalBackups/removeSite";


var data = {
id: $scope.jobID,
website: website
};

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.editInitial($scope.jobID);
new PNotify({
title: 'Success!',
text: 'Operation successful.',
type: 'success'
});
} 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'
});
}

};

$scope.cyberpanelLoading = true;

$scope.addWebsite = function () {

$scope.cyberpanelLoading = false;

url = "/IncrementalBackups/addWebsite";


var data = {
id: $scope.jobID,
website: $scope.websiteToBeAdded
};

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.editInitial($scope.jobID);
new PNotify({
title: 'Success!',
text: 'Operation successful.',
type: 'success'
});
} else {
new PNotify({
title: 'Operation Failed!',
Expand Down
120 changes: 94 additions & 26 deletions IncBackups/templates/IncBackups/backupSchedule.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ <h3 class="title-hero">
<button type="button" class="close" data-dismiss="modal">
&times;
</button>
<h4 class="modal-title">Edit User
<h4 class="modal-title">Edit Job
<img ng-hide="cyberpanelLoading"
src="{% static 'images/loading.gif' %}">
</h4>
Expand All @@ -225,7 +225,7 @@ <h4 class="modal-title">Edit User
<label class="col-sm-3 control-label">{% trans "Data" %}</label>
<div class="checkbox">
<label>
<input ng-model="websiteData"
<input ng-model="$parent.websiteData"
type="checkbox" value="">
Data
</label>
Expand All @@ -237,7 +237,7 @@ <h4 class="modal-title">Edit User
<label class="col-sm-3 control-label">{% trans "Databases" %}</label>
<div class="checkbox">
<label>
<input ng-model="websiteDatabases"
<input ng-model="$parent.websiteDatabases"
type="checkbox" value="">
Databases
</label>
Expand All @@ -249,36 +249,104 @@ <h4 class="modal-title">Edit User
<label class="col-sm-3 control-label">{% trans "Emails" %}</label>
<div class="checkbox">
<label>
<input ng-model="websiteEmails"
<input ng-model="$parent.websiteEmails"
type="checkbox" value="">
Emails
</label>
</div>
</div>

<div ng-hide="installationDetailsForm"
class="form-group">
<label class="col-sm-3 control-label">{% trans "" %}</label>
<button type="button" ng-click="saveChanges()"
class="btn btn-primary btn-lg">{% trans "Save Changes" %}</button>
</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>
<ul class="nav nav-tabs">

<li class="col-md-3 nav-item tab-mod active">
<a href="#tab-example-1" data-toggle="tab"
class="h4 nav-link">
<span>{% trans "Sites" %}</span>
</a>

</li>
<li class="col-md-4 tab-mod nav-item">
<a href="#tab-example-3" data-toggle="tab"
class="h4 nav-link">
<span>{% trans "Add Sites" %}</span>
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade active in"
id="tab-example-1">
<div class="example-box-wrapper">
<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="removeSite(record.website)"
class="btn btn-border btn-alt border-red btn-link font-red"
href="#"
title=""><span>{% trans 'Delete' %}</span></a>
</td>

</tr>
</tbody>
</table>
</div>
</div>


<div class="tab-pane fade" id="tab-example-3">

<form action="/"
class="form-horizontal bordered-row">


<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Site" %}</label>
<div class="col-sm-6">
<select ng-model="$parent.websiteToBeAdded"
class="form-control">
{% for items in websiteList %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
<img ng-hide="cyberpanelLoading"
src="{% static 'images/loading.gif' %}">
</div>

<div ng-hide="savebtn"
class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button"
ng-click="addWebsite()"
class="btn btn-primary btn-lg btn-block">{% trans "Add" %}</button>

</div>
</div>


</form>


</div>
</div>


</form>
Expand Down
3 changes: 3 additions & 0 deletions IncBackups/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@
url(r'^scheduleDelete$', views.scheduleDelete, name='scheduleDeleteInc'),
url(r'^getCurrentBackupSchedules$', views.getCurrentBackupSchedules, name='getCurrentBackupSchedulesInc'),
url(r'^fetchSites$', views.fetchSites, name='fetchSites'),
url(r'^saveChanges$', views.saveChanges, name='saveChanges'),
url(r'^removeSite$', views.removeSite, name='removeSite'),
url(r'^addWebsite$', views.addWebsite, name='addWebsite'),
]
Loading

0 comments on commit 77bf26a

Please sign in to comment.