Review Code

This commit is contained in:
Zarak Khan
2024-02-22 11:35:06 +05:00
parent 8b4c0ffc3b
commit 2fab5982a4
75 changed files with 11067 additions and 1022 deletions

View File

@@ -84,6 +84,12 @@ class BackupManager:
proc = httpProc(request, 'IncBackups/CreateV2Backup.html', {'websiteList': websitesName}, 'createBackup')
return proc.render()
def CreateV2backupSiteV2(self, request=None, userID=None, data=None):
currentACL = ACLManager.loadedACL(userID)
websitesName = ACLManager.findAllSites(currentACL, userID)
proc = httpProc(request, 'IncBackups/CreateV2BackupV2.html', {'websiteList': websitesName}, 'createBackup')
return proc.render()
def schedulev2Backups(self, request=None, userID=None, data=None):
if ACLManager.CheckForPremFeature('all'):
@@ -97,6 +103,19 @@ class BackupManager:
{'websiteList': websitesName, "BackupStat": BackupStat}, 'createBackup')
return proc.render()
def schedulev2BackupsV2(self, request=None, userID=None, data=None):
if ACLManager.CheckForPremFeature('all'):
BackupStat = 1
else:
BackupStat = 0
currentACL = ACLManager.loadedACL(userID)
websitesName = ACLManager.findAllSites(currentACL, userID)
proc = httpProc(request, 'IncBackups/ScheduleV2BackupV2.html',
{'websiteList': websitesName, "BackupStat": BackupStat}, 'createBackup')
return proc.render()
def gDrive(self, request=None, userID=None, data=None):
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
@@ -109,6 +128,18 @@ class BackupManager:
'createBackup')
return proc.render()
def gDriveV2(self, request=None, userID=None, data=None):
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
gDriveAcctsList = []
gDriveAccts = admin.gdrive_set.all()
for items in gDriveAccts:
gDriveAcctsList.append(items.name)
websitesName = ACLManager.findAllSites(currentACL, userID)
proc = httpProc(request, 'backup/googleDriveV2.html', {'accounts': gDriveAcctsList, 'websites': websitesName},
'createBackup')
return proc.render()
def gDriveSetup(self, userID=None, request=None):
try:
currentACL = ACLManager.loadedACL(userID)
@@ -779,6 +810,10 @@ class BackupManager:
proc = httpProc(request, 'backup/backupDestinations.html', {}, 'addDeleteDestinations')
return proc.render()
def backupDestinationsV2(self, request=None, userID=None, data=None):
proc = httpProc(request, 'backup/backupDestinationsV2.html', {}, 'addDeleteDestinations')
return proc.render()
def submitDestinationCreation(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
@@ -951,6 +986,17 @@ class BackupManager:
'scheduleBackups')
return proc.render()
def scheduleBackupV2(self, request, userID=None, data=None):
currentACL = ACLManager.loadedACL(userID)
destinations = NormalBackupDests.objects.all()
dests = []
for dest in destinations:
dests.append(dest.name)
websitesName = ACLManager.findAllSites(currentACL, userID)
proc = httpProc(request, 'backup/backupScheduleV2.html', {'destinations': dests, 'websites': websitesName},
'scheduleBackups')
return proc.render()
def getCurrentBackupSchedules(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
@@ -1077,6 +1123,10 @@ class BackupManager:
proc = httpProc(request, 'backup/remoteBackups.html', None, 'remoteBackups')
return proc.render()
def remoteBackupsV2(self, request, userID=None, data=None):
proc = httpProc(request, 'backup/remoteBackupsV2.html', None, 'remoteBackups')
return proc.render()
def submitRemoteBackups(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,194 @@
{% extends "baseTemplate/newBase.html" %}
{% load i18n %}
{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %}
{% block newContent %}
{% load static %}
<div ng-controller="backupDestinationsV2" class="p-8">
<div class="flex lg:flex-row justify-between items-center sm:flex-col">
<div class="flex items-center">
<p class="text-4xl font-bold">Set up Backup Destinations -</p>
<a target="_blank"
href="https://go.cyberpanel.net/remote-backup"
style="height: 23px;line-height: 21px;"
class="bg-blue-200 px-2 font-bold mt-2 ml-3"
title=""><span>{% trans "Remote Backups" %}</span></a>
</div>
</div>
<p class="text-xs text-gray-600 py-2 font-semibold">On this page you can set up your Backup destinations. (SFTP)
</p>
<div class="py-4">
<p class="text-xl font-bold">Set up Backup Destinations.</p>
<img ng-hide="cyberpanelLoading"
src="{% static 'images/loading.gif' %}">
</div>
<hr>
<div class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Select Type</p>
</div>
<div>
<select ng-change="fetchDetails()" ng-model="destinationType"
class="w-80 bg-gray-100 rounded px-2 py-1">
<option>local</option>
<option>SFTP</option>
</select>
</div>
</div>
<div ng-hide="sftpHide" class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Name</p>
</div>
<div>
<input type="text" class="w-80 bg-gray-100 rounded px-2 py-1" ng-model="name" required>
</div>
</div>
<div ng-hide="sftpHide" class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">IP Address</p>
</div>
<div>
<input type="text" class="w-80 bg-gray-100 rounded px-2 py-1" ng-model="IPAddress" required>
</div>
</div>
<div ng-hide="sftpHide" class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Username</p>
</div>
<div>
<input type="text" class="w-80 bg-gray-100 rounded px-2 py-1" ng-model="userName" required>
</div>
</div>
<div ng-hide="sftpHide" class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Password</p>
</div>
<div>
<input placeholder="" type="password" class="w-80 bg-gray-100 rounded px-2 py-1" ng-model="password"
required>
</div>
</div>
<div ng-hide="sftpHide" class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Port</p>
</div>
<div>
<input placeholder="{% trans "Backup server SSH Port, leave empty for 22." %}"
type="text" class="w-80 bg-gray-100 rounded px-2 py-1" ng-model="backupSSHPort" required>
</div>
</div>
<div ng-hide="sftpHide" class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Path</p>
</div>
<div>
<input placeholder="Path on remote server to store backups." type="text"
class="w-80 bg-gray-100 rounded px-2 py-1"
ng-model="path" required>
</div>
</div>
<div ng-hide="sftpHide" class="flex justify-center mt-6 mb-2">
<button ng-click="addDestination('SFTP')"
class="bg-orange-500 text-white font-bold px-4 py-2 text-xl">
Add Destination
</button>
</div>
<hr>
<div ng-hide="sftpHide" class="relative py-5 overflow-x-auto">
<table class="w-full text-sm text-left rtl:text-right">
<thead>
<tr>
<th scope="col" class="px-6 py-3">
Name
</th>
<th scope="col" class="px-6 py-3">
IP
</th>
<th scope="col" class="px-6 py-3">
Username
</th>
<th scope="col" class="px-6 py-3">
Path
</th>
<th scope="col" class="px-6 py-3">
Port
</th>
<th scope="col" class="px-6 py-3">
Delete
</th>
</tr>
</thead>
<tbody ng-repeat="record in records track by $index" class="border shadow-lg py-3 px-6 rounded-b-lg">
<tr>
<td ng-bind="record.name" class="px-6 py-4">
</td>
<td ng-bind="record.ip" class="px-6 py-4">
</td>
<td ng-bind="record.username" class="px-6 py-4">
</td>
<td ng-bind="record.path" class="px-6 py-4">
</td>
<td ng-bind="record.port" class="px-6 py-4">
</td>
<td ng-click="removeDestination('SFTP', record.name)" class="px-6 py-4">
<img src="{% static 'images/delete.png' %}">
</td>
</tr>
</tbody>
</table>
</div>
<div ng-hide="localHide" class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Name</p>
</div>
<div>
<input type="text" class="w-80 bg-gray-100 rounded px-2 py-1" ng-model="name" required>
</div>
</div>
<div ng-hide="localHide" class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Local Path</p>
</div>
<div>
<input type="text" class="w-80 bg-gray-100 rounded px-2 py-1" ng-model="localPath" required>
</div>
</div>
<div ng-hide="localHide" class="flex justify-center mt-6 mb-2">
<button ng-click="addDestination('local')"
class="bg-orange-500 text-white font-bold px-4 py-2 text-xl">
Add Destination
</button>
</div>
<hr>
<div ng-hide="localHide" class="relative py-5 overflow-x-auto">
<table class="w-full text-sm text-left rtl:text-right">
<thead>
<tr>
<th scope="col" class="px-6 py-3">
Name
</th>
<th scope="col" class="px-6 py-3">
Path
</th>
<th scope="col" class="px-6 py-3">
Delete
</th>
</tr>
</thead>
<tbody ng-repeat="record in records track by $index"
class="border shadow-lg py-3 px-6 rounded-b-lg">
<tr>
<td ng-bind="record.name" class="px-6 py-4">
</td>
<td ng-bind="record.path" class="px-6 py-4">
</td>
<td ng-click="removeDestination('local', record.name)" class="px-6 py-4">
<img src="{% static 'images/delete.png' %}">
</td>
</tr>
</tbody>
</table>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,299 @@
{% extends "baseTemplate/newBase.html" %}
{% load i18n %}
{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %}
{% block newContent %}
{% load static %}
<div ng-controller="scheduleBackupV2" class="p-8">
<div class="flex lg:flex-row justify-between items-center sm:flex-col">
<div class="flex items-center">
<p class="text-4xl font-bold">Schedule Backup -</p>
<a target="_blank"
href="https://go.cyberpanel.net/remote-backup"
style="height: 23px;line-height: 21px; text-decoration: underline"
class="bg-blue-200 px-2 font-bold mt-2 ml-3"
title=""><span>{% trans "Remote Backups" %}</span></a>
</div>
</div>
<p class="text-xs text-gray-600 py-2 font-semibold">On this page you can schedule Backups to localhost or remote
server (If you have added one)</p>
<div class="py-4">
<p class="text-xl font-bold">Create New Backup Schedule</p>
<img ng-hide="cyberPanelLoading"
src="{% static 'images/loading.gif' %}" alt="cyberPanelLoading">
</div>
<hr>
<div class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Select Destination</p>
</div>
<div>
<select ng-model="selectedAccountAdd" class="w-80 bg-gray-100 rounded px-2 py-1">
{% for items in destinations %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Name</p>
</div>
<div>
<input type="text" class="w-80 bg-gray-100 rounded px-2 py-1" ng-model="name" required>
</div>
</div>
<div class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Select Backup Frequency</p>
</div>
<div>
<select ng-model="backupFrequency" class="w-80 bg-gray-100 rounded px-2 py-1">
<option>Never</option>
<option>Daily</option>
<option>Weekly</option>
</select>
</div>
</div>
<div class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Select Backup Retention. Leave 0 for no limit</p>
</div>
<div>
<input ng-model="backupRetention" class="w-80 bg-gray-100 rounded px-2 py-1" type="number" value="0">
</div>
</div>
<div class="flex justify-center mt-6">
<button ng-click="addSchedule()"
class="bg-orange-500 text-white font-bold px-4 py-2 text-xl">
Add Schedule
</button>
</div>
<div class="py-4">
<p class="text-xl font-bold">Manage Existing Backup Schedules</p>
<img ng-hide="cyberPanelLoading"
src="{% static 'images/loading.gif' %}" alt="cyberPanelLoading">
</div>
<hr>
<div class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Select Destination</p>
</div>
<div>
<select ng-change="fetchJobs()" ng-model="selectedAccount" class="w-80 bg-gray-100 rounded px-2 py-1">
{% for items in destinations %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
</div>
<div ng-hide="jobsHidden" class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Select Job</p>
</div>
<div>
<select ng-change="fetchWebsites()" ng-model="selectedJob" class="w-80 bg-gray-100 rounded px-2 py-1">
<option ng-repeat="job in jobs track by $index">{$ job $}</option>
</select>
</div>
<div ng-hide="driveHidden" class="w-80 ml-4">
<button ng-click="deleteAccount()"
class="bg-orange-500 text-white font-semibold px-2 py-1">
Delete
</button>
</div>
</div>
<div ng-hide="driveHidden" class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Add Sites for Backup</p>
</div>
<div>
<select ng-model="selectedWebsite" class="w-80 bg-gray-100 rounded px-2 py-1">
{% for items in websites %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
<div class="w-80 ml-4">
<button ng-click="addSite('one')"
class="bg-orange-500 text-white font-semibold px-2 py-1">
Add Site
</button>
<button ng-click="addSite('all')"
class="bg-orange-500 text-white font-semibold px-2 py-1">
Add All
</button>
</div>
</div>
<hr>
<div ng-hide="driveHidden" class="relative py-5 overflow-x-auto">
<table class="w-full text-sm text-left rtl:text-right">
<thead>
<tr class="bg-gray-200 mt-6 w-full rounded-t-lg border-b-2 border-gray-400">
<th scope="col" class="px-6 py-3">
Last Run
</th>
<th scope="col" class="px-6 py-3">
All Sites
</th>
<th scope="col" class="px-6 py-3">
Frequency ({$ currently $})
</th>
<th scope="col" class="px-6 py-3">
Retention ({$ currently $})
</th>
<th scope="col" class="px-6 py-3">
Current Status
</th>
</tr>
</thead>
<tbody class="border shadow-lg py-3 px-6 rounded-b-lg">
<tr>
<td class="px-6 py-4">
{$ lastRun $}
</td>
<td class="px-6 py-4">
{$ allSites $}
</td>
<td class="px-6 py-4 text-red-500 font-bold">
<select ng-change="changeFrequency()" ng-model="backupFrequency"
class="bg-gray-100 rounded">
<option>Never</option>
<option>Daily</option>
<option>Weekly</option>
</select>
</td>
<td class="px-6 py-4">
{$ currentStatus $}
</td>
</tr>
</tbody>
</table>
</div>
<div ng-hide="driveHidden" class="border border-4 p-2 mt-4">
<div class="flex justify-between mt-2">
<div>
<a onclick="return false;" ng-hide="driveHidden" ng-click="fetchLogs()"
class="bg-orange-500 text-white font-bold px-4 py-2"
href="#" data-modal-target="logs" data-modal-toggle="logs"><i class="fa fa-plus-square"
aria-hidden="true"></i> {% trans "View Logs" %}
</a>
<div id="logs" tabindex="-1"
class="hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full md:inset-0 h-[calc(100%-1rem)] max-h-full">
<div class="relative p-4 w-full max-w-2xl max-h-full">
<div class="relative bg-white shadow dark:bg-gray-700">
<div class="flex items-center bg-blue-400 px-4 py-4">
<p class="font-bold">Backup Logs</p>
<img ng-hide="cyberPanelLoading"
src="{% static 'images/loading.gif' %}">
<button type="button" data-modal-toggle="logs"
class="absolute top-2 end-1 text-black bg-transparent hover:text-black rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center"
data-modal-hide="logs">
<svg class="w-3 h-3" aria-hidden="true"
xmlns="http://www.w3.org/2000/svg" fill="none"
viewBox="0 0 14 14">
<path stroke="currentColor" stroke-linecap="round"
stroke-linejoin="round" stroke-width="2"
d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
</svg>
<span class="sr-only">Close modal</span>
</button>
</div>
<div class="p-4 md:p-5">
<div>
<div class="flex justify-end">
<select ng-model="recordsToShowLogs"
ng-change="fetchLogs()"
class="w-40 bg-gray-100 rounded px-2 py-1" id="example-select">
<option>10</option>
<option>50</option>
<option>100</option>
</select>
</div>
<div class="relative py-5 overflow-x-auto">
<table class="w-full text-sm text-left rtl:text-right">
<thead>
<tr class="bg-gray-200 mt-6 w-full rounded-t-lg border-b-2 border-gray-400">
<th scope="col" class="px-6 py-3">
Type
</th>
<th scope="col" class="px-6 py-3">
Message
</th>
</tr>
</thead>
<tbody ng-repeat="log in logs track by $index"
class="border shadow-lg py-3 px-6 rounded-b-lg">
<tr>
<td ng-bind="log.type" class="px-6 py-4">
</td>
<td ng-bind="log.message" class="px-6 py-4">
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="flex justify-end p-4 md:p-5">
<select ng-model="currentPageLogs"
class="w-40 bg-gray-100 rounded px-2 py-1"
ng-change="fetchLogs()">
<option ng-repeat="page in paginationLogs">
{$
$index + 1
$}
</option>
</select>
</div>
</div>
</div>
</div>
</div>
<div>
<select ng-model="recordsToShow"
ng-change="fetchWebsites()"
class="w-40 bg-gray-100 rounded px-2 py-1" id="example-select">
<option>10</option>
<option>50</option>
<option>100</option>
</select>
</div>
</div>
<div class="relative py-5 overflow-x-auto">
<table class="w-full text-sm text-left rtl:text-right">
<thead>
<tr class="bg-gray-200 mt-6 w-full rounded-t-lg border-b-2 border-gray-400">
<th scope="col" class="px-6 py-3">
Sites
</th>
<th scope="col" class="px-6 py-3">
Action
</th>
</tr>
</thead>
<tbody ng-repeat="website in websites track by $index"
class="border shadow-lg py-3 px-6 rounded-b-lg">
<tr>
<td ng-bind="website.name" class="px-6 py-4">
</td>
<td class="px-6 py-4">
<button type="button" ng-click="deleteSite(website.name)"
class="bg-red-500 text-white font-semibold px-2 py-1">{% trans "Delete" %}</button>
</td>
</tr>
</tbody>
</table>
</div>
<div class="flex justify-end">
<select ng-model="currentPage" class="w-40 bg-gray-100 rounded px-2 py-1"
ng-change="fetchWebsites()">
<option ng-repeat="page in pagination">{$ $index + 1
$}
</option>
</select>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,287 @@
{% extends "baseTemplate/newBase.html" %}
{% load i18n %}
{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %}
{% block newContent %}
{% load static %}
<div ng-controller="googleDriveV2" class="p-8">
<div class="flex lg:flex-row justify-between items-center sm:flex-col">
<div class="flex items-center">
<p class="text-4xl font-bold">Set up Google Drive Backups -</p>
<a target="_blank"
href="https://cyberpanel.net/docs/backup-to-google-drive/"
style="height: 23px;line-height: 21px;"
class="bg-blue-200 px-2 font-bold mt-2 ml-3"
title=""><span>{% trans "Remote Backups" %}</span></a>
</div>
</div>
<p class="text-xs text-gray-600 py-2 font-semibold">On this page you can set up and manage Google Drive
Backups.</p>
<hr>
<div class="py-4">
<div class="flex lg:flex-row justify-between items-center sm:flex-col">
<div class="flex items-center">
<p class="text-sm text-gray-600 py-2 font-semibold">On this page you can set up and manage Google
Drive Backups.
<img ng-hide="cyberPanelLoading" src="{% static 'images/loading.gif' %}"></p>
<div>
<a onclick="return false;"
class="bg-red-300 px-2 py-1 font-bold mt-2 ml-3"
href="https://cyberpanel.net/docs/backup-to-google-drive/" data-modal-target="newAccount"
data-modal-toggle="newAccount"><i class="fa fa-plus-square"
aria-hidden="true"></i> {% trans "Setup new Account" %}
</a>
<div id="newAccount" tabindex="-1"
class="hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full md:inset-0 h-[calc(100%-1rem)] max-h-full">
<div class="relative p-4 w-full max-w-2xl max-h-full">
<div class="relative bg-white shadow dark:bg-gray-700">
<div class="flex items-center bg-blue-400 px-4 py-4">
<p class="font-bold">Set up account</p>
<img ng-hide="cyberPanelLoading"
src="{% static 'images/loading.gif' %}">
<button type="button" data-modal-toggle="newAccount"
class="absolute top-2 end-1 text-black bg-transparent hover:text-black rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center"
data-modal-hide="newAccount">
<svg class="w-3 h-3" aria-hidden="true"
xmlns="http://www.w3.org/2000/svg" fill="none"
viewBox="0 0 14 14">
<path stroke="currentColor" stroke-linecap="round"
stroke-linejoin="round" stroke-width="2"
d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
</svg>
<span class="sr-only">Close modal</span>
</button>
</div>
<div ng-hide="installationDetailsForm" class="p-4 md:p-5">
<div>
<div class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-32">Account Name</p>
</div>
<div>
<input name="accountName" type="text"
class="w-80 bg-gray-100 rounded px-2 py-1"
ng-model="accountName">
</div>
</div>
<div class="flex gap-1 justify-end py-2">
<div>
<button ng-click="setupAccount()" type="button"
data-modal-toggle="newAccount" data-modal-hide="newAccount"
class="text-white bg-green-600 hover:bg-green-800 focus:ring-4 focus:outline-none focus:ring-green-300 dark:focus:ring-green-800 font-medium rounded-lg text-sm inline-flex items-center px-5 py-2.5 text-center me-2">
Save <img
ng-hide="cyberPanelLoading"
src="{% static 'images/loading.gif' %}"></button>
<button ng-disabled="savingSettings" type="button"
data-modal-toggle="newAccount"
data-modal-hide="newAccount"
class="text-white bg-red-600 hover:bg-red-800 focus:ring-4 focus:outline-none focus:ring-red-300 dark:focus:ring-red-800 font-medium rounded-lg text-sm inline-flex items-center px-5 py-2.5 text-center me-2"
data-dismiss="modal">{% trans "Close" %}</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<hr>
<div class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Select Drive Account</p>
</div>
<div>
<select ng-change="fetchWebsites()" ng-model="selectedAccount"
class="w-80 bg-gray-100 rounded px-2 py-1">
{% for items in accounts %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
<div ng-hide="driveHidden" class="w-80 ml-4">
<button ng-click="deleteAccount()"
class="bg-orange-500 text-white font-semibold px-2 py-1">
Delete
</button>
</div>
</div>
<div ng-hide="driveHidden" class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Select Backup Frequency</p>
</div>
<div>
<select ng-change="changeFrequency()" ng-model="backupFrequency"
class="w-80 bg-gray-100 rounded px-2 py-1">
<option>Never</option>
<option>Daily</option>
<option>Weekly</option>
</select>
</div>
<div class="w-80 ml-4">
Currently: {$ currently $}
</div>
</div>
<div ng-hide="driveHidden" class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Add Sites for Backup</p>
</div>
<div>
<select ng-model="selectedWebsite" class="w-80 bg-gray-100 rounded px-2 py-1">
{% for items in websites %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
<div class="w-80 ml-4">
<button ng-click="addSite()"
class="bg-orange-500 text-white font-semibold px-2 py-1">
Add Site
</button>
</div>
</div>
<div ng-hide="driveHidden" id="checkret" class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Backup File Retention
(<a href="https://cyberpanel.net/cyberpanel-addons">Paid Feature</a> )</p>
</div>
<div>
<select id="fileretention" ng-model="Retentiontime" ng-change="changeRetention()"
class="w-80 bg-gray-100 rounded px-2 py-1">
<option value="1d">1 days</option>
<option value="1w"> 1 week</option>
<option value="1m"> 1 month</option>
<option value="6m"> 6 months</option>
</select>
</div>
</div>
<div ng-hide="driveHidden" class="border border-4 p-2 mt-4">
<div class="flex justify-between mt-2">
<div>
<a onclick="return false;" ng-click="fetchLogs()" ng-hide="driveHidden"
class="bg-orange-500 text-white font-bold px-4 py-2"
href="#" data-modal-target="backupLogs" data-modal-toggle="backupLogs"><i
class="fa fa-plus-square"
aria-hidden="true"></i> {% trans "View Logs" %}
</a>
<div id="backupLogs" tabindex="-1"
class="hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full md:inset-0 h-[calc(100%-1rem)] max-h-full">
<div class="relative p-4 w-full max-w-2xl max-h-full">
<div class="relative bg-white shadow dark:bg-gray-700">
<div class="flex items-center bg-blue-400 px-4 py-4">
<p class="font-bold">Git Logs</p>
<img ng-hide="cyberPanelLoading"
src="{% static 'images/loading.gif' %}">
<button type="button" data-modal-toggle="backupLogs"
class="absolute top-2 end-1 text-black bg-transparent hover:text-black rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center"
data-modal-hide="backupLogs">
<svg class="w-3 h-3" aria-hidden="true"
xmlns="http://www.w3.org/2000/svg" fill="none"
viewBox="0 0 14 14">
<path stroke="currentColor" stroke-linecap="round"
stroke-linejoin="round" stroke-width="2"
d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
</svg>
<span class="sr-only">Close modal</span>
</button>
</div>
<div class="p-4 md:p-5">
<div>
<div class="flex justify-end">
<select ng-model="recordsToShowLogs"
ng-change="fetchLogs()"
class="w-40 bg-gray-100 rounded px-2 py-1" id="example-select">
<option>10</option>
<option>50</option>
<option>100</option>
</select>
</div>
<div class="relative py-5 overflow-x-auto">
<table class="w-full text-sm text-left rtl:text-right">
<thead>
<tr class="bg-gray-200 mt-6 w-full rounded-t-lg border-b-2 border-gray-400">
<th scope="col" class="px-6 py-3">
Type
</th>
<th scope="col" class="px-6 py-3">
Message
</th>
</tr>
</thead>
<tbody ng-repeat="log in logs track by $index"
class="border shadow-lg py-3 px-6 rounded-b-lg">
<tr>
<td ng-bind="log.type" class="px-6 py-4">
</td>
<td ng-bind="log.message" class="px-6 py-4">
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="flex justify-end p-4 md:p-5">
<select ng-model="currentPageLogs"
class="w-40 bg-gray-100 rounded px-2 py-1"
ng-change="fetchLogs()">
<option ng-repeat="page in paginationLogs">
{$
$index + 1
$}
</option>
</select>
</div>
</div>
</div>
</div>
</div>
<div>
<select ng-model="recordsToShow"
ng-change="fetchWebsites()"
class="w-40 bg-gray-100 rounded px-2 py-1" id="example-select">
<option>10</option>
<option>50</option>
<option>100</option>
</select>
</div>
</div>
<div class="relative py-5 overflow-x-auto">
<table class="w-full text-sm text-left rtl:text-right">
<thead>
<tr class="bg-gray-200 mt-6 w-full rounded-t-lg border-b-2 border-gray-400">
<th scope="col" class="px-6 py-3">
Sites
</th>
<th scope="col" class="px-6 py-3">
Action
</th>
</tr>
</thead>
<tbody ng-repeat="website in websites track by $index"
class="border shadow-lg py-3 px-6 rounded-b-lg">
<tr>
<td ng-bind="website.name" class="px-6 py-4">
</td>
<td class="px-6 py-4">
<button type="button" ng-click="deleteSite(website.name)"
class="bg-red-500 text-white font-semibold px-2 py-1">{% trans "Delete" %}</button>
</td>
</tr>
</tbody>
</table>
</div>
<div class="flex justify-end">
<select ng-model="currentPage" class="w-40 bg-gray-100 rounded px-2 py-1"
ng-change="fetchWebsites()">
<option ng-repeat="page in pagination">{$ $index + 1
$}
</option>
</select>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,146 @@
{% extends "baseTemplate/newBase.html" %}
{% load i18n %}
{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %}
{% block newContent %}
{% load static %}
<div ng-controller="remoteBackupControlV2" class="p-8">
<div class="flex lg:flex-row justify-between items-center sm:flex-col">
<div class="flex items-center">
<p class="text-4xl font-bold">Remote Backups -</p>
<a target="_blank" href="http://go.cyberpanel.net/remote-transfer"
style="height: 23px;line-height: 21px;" class="bg-blue-200 px-2 font-bold mt-2 ml-3"
title=""><span>{% trans "Remote Transfer" %}</span></a>
</div>
</div>
<p class="text-xs text-gray-600 py-2 font-semibold">This feature can import website(s) from remote server
</p>
<div class="py-4">
<p class="text-xl font-bold">Remote Backups</p>
<img ng-hide="backupLoading" src="{% static 'images/loading.gif' %}">
</div>
<hr>
<p ng-bind="transferStatus"></p>
<div class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">IP Address</p>
</div>
<div>
<input type="text" class="w-80 bg-gray-100 rounded px-2 py-1" ng-model="IPAddress" required>
</div>
</div>
<div class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60">Password</p>
</div>
<div>
<input ng-change="passwordEnter()" type="password" class="w-80 bg-gray-100 rounded px-2 py-1"
ng-model="password" required>
</div>
</div>
<div ng-hide="backupButton" class="flex justify-center mt-6 mb-2">
<button ng-disabled="fetchAccountsBtn" ng-click="fetchAccountsFromRemoteServer()"
class="bg-orange-500 text-white font-bold px-4 py-2 text-xl">
Fetch Accounts
</button>
</div>
<div ng-hide="transferBoxBtn">
<div class="flex justify-center mt-6 mb-2">
<button ng-disabled="startTransferbtn" ng-click="startTransfer()"
class="bg-orange-500 text-white font-bold px-4 py-2 text-xl">
Start Transfer
</button>
</div>
<div class="flex justify-center mt-6 mb-2">
<button ng-disabled="stopTransferbtn" ng-click="cancelRemoteBackup()"
class="bg-orange-500 text-white font-bold px-4 py-2 text-xl">
Cancel
</button>
</div>
</div>
<div ng-hide="notificationsBox" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<div ng-hide="errorMessage"
class="flex justify-center bg-red-500 rounded-lg text-white px-2 py-1 font-semibold">
<p>{$ error_message $}</p>
</div>
<div ng-hide="couldNotConnect"
class="flex justify-center bg-red-500 rounded-lg text-white px-2 py-1 font-semibold">
<p>{% trans "Could not connect, please refresh this page." %}</p>
</div>
<div ng-hide="accountsFetched"
class="flex justify-center bg-green-500 px-2 rounded-lg py-1 font-semibold">
<p>{% trans "Accounts Successfully Fetched from remote server." %}</p>
</div>
<div ng-hide="backupProcessStarted"
class="flex justify-center bg-green-500 px-2 rounded-lg py-1 font-semibold">
<p>{% trans "Backup Process successfully started." %}</p>
</div>
<div ng-hide="backupCancelled"
class="flex justify-center bg-green-500 px-2 rounded-lg py-1 font-semibold">
<p>{% trans "Backup successfully cancelled." %}</p>
</div>
</div>
</div>
<div ng-hide="accountsInRemoteServerTable" class="flex mt-4 py-2 px-6">
<div>
<p class="font-semibold w-60"></p>
</div>
<div>
<input type="text" ng-model="accountsSearch" placeholder="{% trans 'Search Accounts..' %}"
class="w-80 bg-gray-100 rounded px-2 py-1">
</div>
</div>
<hr>
<div ng-hide="accountsInRemoteServerTable" class="relative py-5 overflow-x-auto">
<table class="w-full text-sm text-left rtl:text-right">
<thead>
<tr>
<th scope="col" class="px-6 py-3">
Website
</th>
<th scope="col" class="px-6 py-3">
PHP
</th>
<th scope="col" class="px-6 py-3">
Package
</th>
<th scope="col" class="px-6 py-3">
Email
</th>
<th scope="col" class="px-6 py-3">
<input ng-model="webSiteStatus" ng-change="allChecked(webSiteStatus)" type="checkbox" value="">
</th>
</tr>
</thead>
<tbody ng-repeat="record in records | filter:accountsSearch"
class="border shadow-lg py-3 px-6 rounded-b-lg">
<tr>
<td ng-bind="record.website" class="px-6 py-4">
</td>
<td ng-bind="record.php" class="px-6 py-4">
</td>
<td ng-bind="record.package" class="px-6 py-4">
</td>
<td ng-bind="record.email" class="px-6 py-4">
</td>
<td ng-click="" class="px-6 py-4">
<input ng-model="webSiteStatus" ng-change="addRemoveWebsite(record.website,webSiteStatus)"
type="checkbox" value="">
</td>
</tr>
</tbody>
</table>
</div>
<div ng-hide="backupStatus" class="form-group">
<div class="col-sm-6">
<textarea ng-model="requestData" rows="15" class="form-control"></textarea>
</div>
<div class="col-sm-6">
<textarea ng-model="restoreData" rows="15" class="form-control"></textarea>
</div>
</div>
</div>
{% endblock %}

View File

@@ -9,6 +9,7 @@ urlpatterns = [
url(r'^restoreSite', views.restoreSite, name='restoreSite'),
url(r'^V2/restoreSiteV2', views.restoreSiteV2, name='restoreSiteV2'),
url(r'^gDrive$', views.gDrive, name='gDrive'),
url(r'^V2/gDriveV2$', views.gDriveV2, name='gDriveV2'),
url(r'^gDriveSetup$', views.gDriveSetup, name='gDriveSetup'),
url(r'^fetchgDriveSites$', views.fetchgDriveSites, name='fetchgDriveSites'),
url(r'^addSitegDrive$', views.addSitegDrive, name='addSitegDrive'),
@@ -28,6 +29,7 @@ urlpatterns = [
url(r'^submitRestore', views.submitRestore, name='submitRestore'),
url(r'^backupDestinations', views.backupDestinations, name='backupDestinations'),
url(r'^V2/backupDestinationsV2', views.backupDestinationsV2, name='backupDestinationsV2'),
url(r'^getCurrentBackupDestinations', views.getCurrentBackupDestinations, name='getCurrentBackupDestinations'),
@@ -38,6 +40,7 @@ urlpatterns = [
url(r'^deleteDestination', views.deleteDestination, name='deleteDestination'),
url(r'^scheduleBackup', views.scheduleBackup, name='scheduleBackup'),
url(r'^V2/scheduleBackupV2', views.scheduleBackupV2, name='scheduleBackupV2'),
url(r'^getCurrentBackupSchedules', views.getCurrentBackupSchedules, name='getCurrentBackupSchedules'),
@@ -46,6 +49,7 @@ urlpatterns = [
url(r'^scheduleDelete', views.scheduleDelete, name='scheduleDelete'),
url(r'^remoteBackups', views.remoteBackups, name='remoteBackups'),
url(r'^V2/remoteBackupsV2', views.remoteBackupsV2, name='remoteBackupsV2'),
url(r'^submitRemoteBackups', views.submitRemoteBackups, name='submitRemoteBackups'),
url(r'^getRemoteTransferStatus', views.getRemoteTransferStatus, name='getRemoteTransferStatus'),
url(r'^remoteBackupRestore', views.remoteBackupRestore, name='remoteBackupRestore'),

View File

@@ -51,6 +51,15 @@ def gDrive(request):
return redirect(loadLoginPage)
def gDriveV2(request):
try:
userID = request.session['userID']
bm = BackupManager()
return bm.gDriveV2(request, userID)
except KeyError:
return redirect(loadLoginPage)
def gDriveSetup(request):
try:
userID = request.session['userID']
@@ -238,6 +247,15 @@ def backupDestinations(request):
return redirect(loadLoginPage)
def backupDestinationsV2(request):
try:
userID = request.session['userID']
bm = BackupManager()
return bm.backupDestinationsV2(request, userID)
except KeyError:
return redirect(loadLoginPage)
def submitDestinationCreation(request):
try:
userID = request.session['userID']
@@ -304,6 +322,15 @@ def scheduleBackup(request):
return redirect(loadLoginPage)
def scheduleBackupV2(request):
try:
userID = request.session['userID']
bm = BackupManager()
return bm.scheduleBackupV2(request, userID)
except KeyError:
return redirect(loadLoginPage)
def getCurrentBackupSchedules(request):
try:
userID = request.session['userID']
@@ -360,6 +387,15 @@ def remoteBackups(request):
return redirect(loadLoginPage)
def remoteBackupsV2(request):
try:
userID = request.session['userID']
bm = BackupManager()
return bm.remoteBackupsV2(request, userID)
except KeyError:
return redirect(loadLoginPage)
def submitRemoteBackups(request):
try:
userID = request.session['userID']