mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-06 21:35:55 +01:00
restoreremotebackupupdate
This commit is contained in:
@@ -1090,6 +1090,7 @@ Automatic backup failed for %s on %s.
|
||||
obj.lastrun = time.time()
|
||||
obj.save()
|
||||
except BaseException as msg:
|
||||
print("Error in Sites:%s"%str(msg))
|
||||
continue
|
||||
except BaseException as msg:
|
||||
print("Error: [RemoteBackup]: %s"%str(msg))
|
||||
|
||||
@@ -2049,7 +2049,7 @@ app.controller('RemoteBackupConfig', function ($scope, $http, $timeout, $window)
|
||||
|
||||
});
|
||||
|
||||
|
||||
var UpdatescheduleID;
|
||||
app.controller('BackupSchedule', function ($scope, $http, $timeout, $window) {
|
||||
$scope.BackupScheduleLoading = true;
|
||||
$scope.SaveBackupSchedule = function () {
|
||||
@@ -2108,8 +2108,67 @@ app.controller('BackupSchedule', function ($scope, $http, $timeout, $window) {
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
$scope.getupdateid = function (ID) {
|
||||
UpdatescheduleID = ID;
|
||||
}
|
||||
|
||||
$scope.UpdateRemoteschedules = function () {
|
||||
$scope.RemoteBackupLoading = false;
|
||||
var Frequency = $scope.RemoteFrequency;
|
||||
var fretention = $scope.RemoteFileretention;
|
||||
|
||||
var data = {
|
||||
ScheduleID:UpdatescheduleID,
|
||||
Frequency: Frequency,
|
||||
FileRetention: fretention
|
||||
}
|
||||
var url = "/websites/UpdateRemoteschedules";
|
||||
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.RemoteBackupLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Successfully Updated!.',
|
||||
type: 'success'
|
||||
});
|
||||
location.reload();
|
||||
|
||||
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.RemoteBackupLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
$scope.AddWPsiteforRemoteBackup = function () {
|
||||
$scope.RemoteBackupLoading = false;
|
||||
@@ -2163,7 +2222,7 @@ app.controller('BackupSchedule', function ($scope, $http, $timeout, $window) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
});
|
||||
/* Java script code to create account */
|
||||
app.controller('createWebsite', function ($scope, $http, $timeout, $window) {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<input name="Hostname" type="text" class="form-control" ng-model="ScheduleName"
|
||||
required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<span style="display: none" id="RemoteConfigID"> {{ RemoteConfigID }}</span>
|
||||
|
||||
@@ -86,6 +87,10 @@
|
||||
<tr>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">ID</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Schedule Name</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Backup Frequency</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Backup File Retention
|
||||
</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Last Run</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Remote Configuration
|
||||
</th>
|
||||
<th style="padding: 18px; color: white; width: 161px; font-size: 12px;">Action</th>
|
||||
@@ -97,6 +102,9 @@
|
||||
<tr>
|
||||
<td style="padding: 13px;">{{ sub.id }}</td>
|
||||
<td style="padding: 13px;">{{ sub.Name }}</td>
|
||||
<td style="padding: 13px;">{{ sub.Frequency }}</td>
|
||||
<td style="padding: 13px;">{{ sub.Retention }}</td>
|
||||
<td style="padding: 13px;">{{ sub.LastRun }}</td>
|
||||
<td style="padding: 13px;">{{ sub.RemoteConfiguration }}</td>
|
||||
<td style="padding: 13px;">
|
||||
<button
|
||||
@@ -105,9 +113,14 @@
|
||||
type="button" class="btn btn-border btn-alt border-red btn-link font-red">
|
||||
Delete
|
||||
</button>
|
||||
<button ng-click="getupdateid({{ sub.id }})" data-toggle="modal" data-target="#EidtRemoteShedule"
|
||||
aria-label=""
|
||||
type="button" class="btn btn-border btn-alt border-yellow btn-link font-yellow">
|
||||
Eidt
|
||||
</button>
|
||||
<a href="{% url 'AddRemoteBackupsite' %}?ID={{ sub.id }}"
|
||||
aria-label=""
|
||||
|
||||
style="margin-top: 5px;"
|
||||
type="button" class="btn btn-border btn-alt border-green btn-link font-green">
|
||||
Add WordPress Sites
|
||||
</a>
|
||||
@@ -117,6 +130,68 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="EidtRemoteShedule" 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">×</button>
|
||||
<h4 class="modal-title">Update Remote Backup Schedules
|
||||
<img id="containerSettingLoading" src="/static/images/loading.gif"
|
||||
style="display: none;">
|
||||
</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 "Backup Frequency" %}</label>
|
||||
<div class="col-sm-6">
|
||||
|
||||
<select ng-model="RemoteFrequency"
|
||||
class="form-control">
|
||||
<option>30 Minutes</option>
|
||||
<option>1 Hour</option>
|
||||
<option>6 Hours</option>
|
||||
<option>12 Hours</option>
|
||||
<option>1 Day</option>
|
||||
<option>3 Days</option>
|
||||
<option>1 Week</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Backup File Retention" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-model="RemoteFileretention"
|
||||
class="form-control">
|
||||
<option>3 Days</option>
|
||||
<option>1 Week</option>
|
||||
<option>3 Weeks</option>
|
||||
<option>1 Month</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" ng-disabled="savingSettings" class="btn btn-primary"
|
||||
ng-click="UpdateRemoteschedules()">Save
|
||||
</button>
|
||||
<button type="button" ng-disabled="savingSettings" class="btn btn-default"
|
||||
data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ urlpatterns = [
|
||||
url(r'^SaveBackupConfig', views.SaveBackupConfig, name='SaveBackupConfig'),
|
||||
url(r'^SaveBackupSchedule', views.SaveBackupSchedule, name='SaveBackupSchedule'),
|
||||
url(r'^AddWPsiteforRemoteBackup', views.AddWPsiteforRemoteBackup, name='AddWPsiteforRemoteBackup'),
|
||||
url(r'^UpdateRemoteschedules', views.UpdateRemoteschedules, name='UpdateRemoteschedules'),
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -502,6 +502,27 @@ def AddWPsiteforRemoteBackup(request):
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def UpdateRemoteschedules(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
result = pluginManager.preWebsiteCreation(request)
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
wm = WebsiteManager()
|
||||
coreResult = wm.UpdateRemoteschedules(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postWebsiteCreation(request, coreResult)
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
return coreResult
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def installwpcore(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
@@ -254,10 +254,15 @@ class WebsiteManager:
|
||||
allsechedule = RemoteBackupSchedule.objects.filter(RemoteBackupConfig=RemoteConfigobj)
|
||||
Data['Backupschedule'] = []
|
||||
for i in allsechedule:
|
||||
lastrun = i.lastrun
|
||||
LastRun = time.strftime('%Y-%m-%d', time.localtime(float(lastrun)))
|
||||
Data['Backupschedule'].append({
|
||||
'id': i.pk,
|
||||
'Name': i.Name,
|
||||
'RemoteConfiguration': i.RemoteBackupConfig.configtype
|
||||
'RemoteConfiguration': i.RemoteBackupConfig.configtype,
|
||||
'Retention': i.fileretention,
|
||||
'Frequency': i.timeintervel,
|
||||
'LastRun': LastRun
|
||||
})
|
||||
proc = httpProc(request, 'websiteFunctions/BackupfileConfig.html',
|
||||
Data, 'createWebsite')
|
||||
@@ -1241,6 +1246,30 @@ class WebsiteManager:
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def UpdateRemoteschedules(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
ScheduleID = data['ScheduleID']
|
||||
Frequency = data['Frequency']
|
||||
FileRetention = data['FileRetention']
|
||||
|
||||
scheduleobj = RemoteBackupSchedule.objects.get(pk=ScheduleID)
|
||||
scheduleobj.timeintervel = Frequency
|
||||
scheduleobj.fileretention = FileRetention
|
||||
scheduleobj.save()
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None',}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
|
||||
def installwpcore(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user