From 3c84aeb9afe1e0a0d51ec005397b0293d8fc7507 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Sun, 13 Apr 2025 12:58:57 +0500 Subject: [PATCH] add code to fetch existing backups --- backup/static/backup/backup.js | 103 +++++++- backup/templates/backup/oneClickBackups.html | 255 ++++++++++--------- 2 files changed, 229 insertions(+), 129 deletions(-) diff --git a/backup/static/backup/backup.js b/backup/static/backup/backup.js index 83ac2daec..10bd2cc14 100755 --- a/backup/static/backup/backup.js +++ b/backup/static/backup/backup.js @@ -2049,54 +2049,133 @@ app.controller('backupPlanNowOneClick', function ($scope, $http, $window) { $scope.cyberpanelLoading = true; $scope.sftpHide = true; $scope.localHide = true; + $scope.showVerification = false; $scope.verificationCodeSent = false; $scope.emailVerified = false; + $scope.showEmailVerification = function() { + $scope.showVerification = true; + }; + + $scope.cancelVerification = function() { + $scope.showVerification = false; + $scope.verificationCodeSent = false; + $scope.verificationEmail = ''; + $scope.verificationCode = ''; + }; + $scope.sendVerificationCode = function() { - $scope.cyberpanelLoading = true; + $scope.cyberpanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; $http.post('https://platform.cyberpersons.com/Billing/SendBackupVerificationCode', { email: $scope.verificationEmail - }).then(function(response) { + }, config).then(function(response) { + $scope.cyberpanelLoading = true; if (response.data.status == 1) { $scope.verificationCodeSent = true; + new PNotify({ + title: 'Success', + text: 'Verification code sent to your email.', + type: 'success' + }); } else { - alert(response.data.error_message); + new PNotify({ + title: 'Error', + text: response.data.error_message, + type: 'error' + }); } - $scope.cyberpanelLoading = false; + }, function(error) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Error', + text: 'Could not send verification code. Please try again.', + type: 'error' + }); }); }; $scope.verifyCode = function() { - $scope.cyberpanelLoading = true; + $scope.cyberpanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; $http.post('https://platform.cyberpersons.com/Billing/VerifyBackupCode', { email: $scope.verificationEmail, code: $scope.verificationCode - }).then(function(response) { + }, config).then(function(response) { + $scope.cyberpanelLoading = true; if (response.data.status == 1) { $scope.emailVerified = true; + $scope.showVerification = false; // Fetch backup plans after successful verification $scope.fetchBackupPlans(); + new PNotify({ + title: 'Success', + text: 'Email verified successfully.', + type: 'success' + }); } else { - alert(response.data.error_message); + new PNotify({ + title: 'Error', + text: response.data.error_message, + type: 'error' + }); } - $scope.cyberpanelLoading = false; + }, function(error) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Error', + text: 'Could not verify code. Please try again.', + type: 'error' + }); }); }; $scope.fetchBackupPlans = function() { - $scope.cyberpanelLoading = true; + $scope.cyberpanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; $http.post('https://platform.cyberpersons.com/Billing/FetchBackupPlans', { email: $scope.verificationEmail - }).then(function(response) { + }, config).then(function(response) { + $scope.cyberpanelLoading = true; if (response.data.status == 1) { $scope.plans = response.data.plans; + new PNotify({ + title: 'Success', + text: 'Backup plans fetched successfully.', + type: 'success' + }); } else { - alert(response.data.error_message); + new PNotify({ + title: 'Error', + text: response.data.error_message, + type: 'error' + }); } - $scope.cyberpanelLoading = false; + }, function(error) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Error', + text: 'Could not fetch backup plans. Please try again.', + type: 'error' + }); }); }; diff --git a/backup/templates/backup/oneClickBackups.html b/backup/templates/backup/oneClickBackups.html index 0828ebb27..7799d15ff 100755 --- a/backup/templates/backup/oneClickBackups.html +++ b/backup/templates/backup/oneClickBackups.html @@ -21,8 +21,23 @@
+

+ {% trans "Set up Backup Destinations." %} +

+ + +
+
+ +
+
+ -
+

{% trans "Verify Your Email" %}

@@ -53,147 +68,153 @@ class="btn btn-primary" ng-show="verificationCodeSent"> {% trans "Verify Code" %} +
- -
-

- {% trans "Set up Backup Destinations." %} -

-
+
+ +
+

+ {% trans "Set up Backup Destinations." %} +

+
- {% if status == 1 %} -
-

You have successfully purchased a backup plan.

-
- {% elif status == 0 %} -
-

Your purchase was not successful.

{{ message }} -
- {% elif status == 4 %} -
- {{ message }} -
- {% endif %} + {% if status == 1 %} +
+

You have successfully purchased a backup plan.

+
+ {% elif status == 0 %} +
+

Your purchase was not successful.

{{ message }} +
+ {% elif status == 4 %} +
+ {{ message }} +
+ {% endif %} -
-

With CyberPanel's one-click backups, you can easily back - up your website to our secure - servers in just 60 seconds. It's simple, fast, and reliable.

+ +

With CyberPanel's one-click backups, you can easily back + up your website to our secure + servers in just 60 seconds. It's simple, fast, and reliable.

- + -
-
- - - - - - - - - - - - - {% for plan in bPlans %} +
+
+
{% trans "Account" %}{% trans "Plan Name" %}{% trans "Subscription" %}{% trans "Billing Cycle" %}{% trans "Purchase Date" %}{% trans "Actions" %}
+ - - - - {% if plan.months == '1' %} - - {% else %} - - {% endif %} - - + + + + + + + + + {% for plan in bPlans %} + + + + + {% if plan.months == '1' %} + {% else %} - + {% endif %} - - - {% endfor %} - -
{{ plan.sftpUser }}{{ plan.planName }}{{ plan.subscription }}${{ plan.price }}/month${{ plan.price }}/year{{ plan.date }} - {% if plan.state == 1 %} - - - - - - + {% trans "Account" %}{% trans "Plan Name" %}{% trans "Subscription" %}{% trans "Billing Cycle" %}{% trans "Purchase Date" %}{% trans "Actions" %}
{{ plan.sftpUser }}{{ plan.planName }}{{ plan.subscription }}${{ plan.price }}/month${{ plan.price }}/year
+ {{ plan.date }} + + {% if plan.state == 1 %} + + + + + + + {% else %} + + {% endif %} + + + {% endfor %} + + +
-
- + - + -

- {% trans "Subscribe to one-click backup plans." %} -

+

+ {% trans "Subscribe to one-click backup plans." %} +

-
-
- - - - - - - - - - - {% for plan in plans %} +
+
+
{% trans "Plan Name" %}{% trans "Monthly Price" %}{% trans "Yearly Price" %}{% trans "Actions" %}
+ - - - - + + + + - {% endfor %} - -
{{ plan.name }}${{ plan.monthlyPrice }}${{ plan.yearlyPrice }} - {% if plan.name != '100GB' %} - - {% endif %} - - {% if plan.name != '100GB' %} - - {% endif %} - - {% trans "Plan Name" %}{% trans "Monthly Price" %}{% trans "Yearly Price" %}{% trans "Actions" %}
+ + + {% for plan in plans %} + + {{ plan.name }} + ${{ plan.monthlyPrice }} + ${{ plan.yearlyPrice }} + + {% if plan.name != '100GB' %} + + {% endif %} + + {% if plan.name != '100GB' %} + + {% endif %} + + + + {% endfor %} + + +
-
- + - + - + +