From f21f59031a54b923ed8d332998528a3d417395fe Mon Sep 17 00:00:00 2001 From: Ghassan <99238055+jojkhan@users.noreply.github.com> Date: Fri, 10 Mar 2023 22:35:34 +0500 Subject: [PATCH] Cyberpanel_Haabi --- IncBackups/static/IncBackups/IncBackups.js | 69 +++++++++++ .../templates/IncBackups/RestoreV2Backup.html | 113 ++++++++++++++++++ IncBackups/urls.py | 1 + IncBackups/views.py | 8 ++ backup/backupManager.py | 6 + .../templates/baseTemplate/index.html | 3 + 6 files changed, 200 insertions(+) create mode 100644 IncBackups/templates/IncBackups/RestoreV2Backup.html diff --git a/IncBackups/static/IncBackups/IncBackups.js b/IncBackups/static/IncBackups/IncBackups.js index a1f0305ff..6d61cc288 100644 --- a/IncBackups/static/IncBackups/IncBackups.js +++ b/IncBackups/static/IncBackups/IncBackups.js @@ -172,6 +172,63 @@ app.controller('createIncrementalBackups', function ($scope, $http, $timeout) { }; + // $scope.RestoreV2Backup = function () { + // + // // $scope.status = ''; + // // + // // $scope.cyberpanelLoading = false; + // // + // // + // // url = "/IncrementalBackups/submitBackupCreation"; + // + // + // console.log($scope.websiteToBeBacked) + // console.log($scope.websiteData) + // var websites = document.getElementById('create-backup-select'); + // var selected_website = websites.options[websites.selectedIndex].innerHTML; + // console.log(selected_website); + // + // var data = { + // websiteToBeBacked: $scope.websiteToBeBacked, + // backupDestinations: $scope.backupDestinations, + // websiteData: $scope.websiteData, + // websiteEmails: $scope.websiteEmails, + // websiteSSLs: $scope.websiteSSLs, + // websiteDatabases: $scope.websiteDatabases + // + // }; + // + // // var config = { + // // headers: { + // // 'X-CSRFToken': getCookie('csrftoken') + // // } + // // }; + // // + // // + // // $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + // // + // // + // // function ListInitialDatas(response) { + // // + // // if (response.data.status === 1) { + // // $scope.tempPath = response.data.tempPath; + // // getBackupStatus(); + // // } else { + // // $scope.cyberpanelLoading = true; + // // new PNotify({ + // // title: 'Operation Failed!', + // // text: response.data.error_message, + // // type: 'error' + // // }); + // // } + // // + // // } + // // + // // function cantLoadInitialDatas(response) { + // // } + // + // }; + $scope.deleteBackup = function (id) { @@ -1143,7 +1200,19 @@ app.controller('restoreRemoteBackupsInc', function ($scope, $http, $timeout) { }); +function RestoreV2Backup() { + + var websites = document.getElementById('create-backup-select'); + var selected_website = websites.options[websites.selectedIndex].innerHTML; + console.log(selected_website); + url = "/IncrementalBackups/submitBackupCreation"; + data = { + website:selected_website, + + } + +} app.controller('createV2Backups', function ($scope, $http, $timeout){ $scope.cyberpanelLoading = true; $scope.selectbackuptype = function () { diff --git a/IncBackups/templates/IncBackups/RestoreV2Backup.html b/IncBackups/templates/IncBackups/RestoreV2Backup.html new file mode 100644 index 000000000..6aeaf7b11 --- /dev/null +++ b/IncBackups/templates/IncBackups/RestoreV2Backup.html @@ -0,0 +1,113 @@ +{% extends "baseTemplate/index.html" %} +{% load i18n %} +{% block title %}{% trans "Backup Website" %}{% endblock %} +{% block content %} + + {% load static %} + + {% get_current_language as LANGUAGE_CODE %} + + +
+
+

{% trans "Restore V2 Backup Site" %} - {% trans "Backup Docs" %}

+

{% trans "This page can be used to restore your backup sites" %}

+
+ +
+
+

+ {% trans "Restore V2 Backup Site" %} +

+
+ +
+ + +
+ +
+ +
+
+ +{#
#} +{# #} +{#
#} +{# #} +{#
#} +{#
#} + + + + +{#
#} +{##} +{#
#} +{##} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{#
{% trans "File Name" %}{% trans "Status" %}
{% trans "Running" %}{$ fileName $}{$ status $}
#} +{#
#} +{#
#} + + + + +
+ +
+ +
+
+ +
+ +
+ +
+
+ + + + + + + + + + + + +
+ + + +
+
+
+ + +
+ + +{% endblock %} \ No newline at end of file diff --git a/IncBackups/urls.py b/IncBackups/urls.py index cec048a9b..070501884 100644 --- a/IncBackups/urls.py +++ b/IncBackups/urls.py @@ -25,5 +25,6 @@ urlpatterns = [ ### V2 Backups URls url(r'^createV2Backup$', views.createV2Backup, name='createV2Backup'), url(r'^createV2BackupSetup$', views.createV2BackupSetup, name='createV2BackupSetup'), + url(r'^RestoreV2backupSite$', views.RestoreV2backupSite, name='RestoreV2backupSite'), ] \ No newline at end of file diff --git a/IncBackups/views.py b/IncBackups/views.py index 2a44e1843..99fcb5151 100644 --- a/IncBackups/views.py +++ b/IncBackups/views.py @@ -51,6 +51,14 @@ def _get_user_acl(request): return user_id, current_acl +def RestoreV2backupSite(request): + try: + userID = request.session['userID'] + bm = BackupManager() + return bm.RestoreV2backupSite(request, userID) + except KeyError: + return redirect(loadLoginPage) + def create_backup(request): try: diff --git a/backup/backupManager.py b/backup/backupManager.py index c42a80d32..e4f2dd4c7 100755 --- a/backup/backupManager.py +++ b/backup/backupManager.py @@ -52,6 +52,12 @@ class BackupManager: proc = httpProc(request, 'backup/backup.html', {'websiteList': websitesName}, 'createBackup') return proc.render() + def RestoreV2backupSite(self, request=None, userID=None, data=None): + currentACL = ACLManager.loadedACL(userID) + websitesName = ACLManager.findAllSites(currentACL, userID) + proc = httpProc(request, 'IncBackups/RestoreV2Backup.html', {'websiteList': websitesName}, 'createBackup') + return proc.render() + def gDrive(self, request=None, userID=None, data=None): currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html index 96e63e638..49984e451 100755 --- a/baseTemplate/templates/baseTemplate/index.html +++ b/baseTemplate/templates/baseTemplate/index.html @@ -727,6 +727,9 @@
  • {% trans "Create V2 Backup" %}
  • +
  • {% trans "Restore V2 Backup" %} +