bug fix: restore backup page

This commit is contained in:
usmannasir
2025-06-15 12:46:33 +05:00
parent 13784fe03d
commit cd9bd47a18
4 changed files with 984 additions and 352 deletions

View File

@@ -4,306 +4,611 @@
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<div ng-controller="scheduleBackup" class="container">
<div id="page-title">
<h2>{% trans "Schedule Backup" %} - <a target="_blank"
href="https://cyberpanel.net/KnowledgeBase/home/schedule-backups-local-or-sftp/"
style="height: 23px;line-height: 21px; text-decoration: underline"
class="btn btn-border btn-alt border-red btn-link font-red"
title=""><span>{% trans "Remote Backups" %}</span></a>
</h2>
<p>{% trans "On this page you can schedule Backups to localhost or remote server (If you have added one)" %}</p>
</div>
<style>
.modern-container {
max-width: 1400px;
margin: 0 auto;
padding: 2rem;
}
.page-header {
text-align: center;
margin-bottom: 3rem;
padding: 3rem 0;
background: linear-gradient(135deg, #f8f9ff 0%, #f0f1ff 100%);
border-radius: 20px;
animation: fadeInDown 0.5s ease-out;
}
.page-title {
font-size: 3rem;
font-weight: 700;
color: #1e293b;
margin-bottom: 1rem;
display: flex;
align-items: center;
justify-content: center;
gap: 1rem;
}
.page-subtitle {
font-size: 1.25rem;
color: #64748b;
margin-bottom: 1.5rem;
max-width: 600px;
margin-left: auto;
margin-right: auto;
}
.header-actions {
display: flex;
gap: 1rem;
justify-content: center;
flex-wrap: wrap;
}
.btn-primary {
background: #5b5fcf;
color: white;
border: none;
padding: 0.75rem 2rem;
border-radius: 10px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
display: inline-flex;
align-items: center;
gap: 0.5rem;
text-decoration: none;
font-size: 0.875rem;
}
.btn-primary:hover {
background: #4547a9;
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(91, 95, 207, 0.4);
color: white;
}
.btn-secondary {
background: #fff;
color: #5b5fcf;
border: 1px solid #e8e9ff;
padding: 0.75rem 2rem;
border-radius: 10px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
display: inline-flex;
align-items: center;
gap: 0.5rem;
text-decoration: none;
font-size: 0.875rem;
}
.btn-secondary:hover {
background: #f8f9ff;
border-color: #5b5fcf;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(91, 95, 207, 0.2);
}
.btn-danger {
background: #ef4444;
color: white;
border: none;
padding: 0.5rem 1rem;
border-radius: 8px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
font-size: 0.825rem;
}
.btn-danger:hover {
background: #dc2626;
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.btn-gray {
background: #6b7280;
color: white;
border: none;
padding: 0.5rem 1rem;
border-radius: 8px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
font-size: 0.825rem;
}
.btn-gray:hover {
background: #4b5563;
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
}
.main-card {
background: white;
border-radius: 16px;
box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 10px 40px rgba(0,0,0,0.08);
border: 1px solid #e8e9ff;
overflow: hidden;
margin-bottom: 2rem;
animation: fadeInUp 0.5s ease-out;
}
.card-header {
background: linear-gradient(135deg, #f8f9ff 0%, #f0f1ff 100%);
padding: 1.5rem 2rem;
border-bottom: 1px solid #e8e9ff;
}
.card-title {
font-size: 1.25rem;
font-weight: 600;
color: #1e293b;
margin: 0;
display: flex;
align-items: center;
gap: 0.75rem;
}
.card-body {
padding: 2rem;
}
.form-group {
margin-bottom: 1.5rem;
}
.form-row {
display: flex;
gap: 1rem;
align-items: center;
margin-bottom: 1.5rem;
}
.form-label {
flex: 0 0 200px;
font-weight: 500;
color: #1e293b;
font-size: 0.875rem;
}
.form-control {
flex: 1;
padding: 0.875rem 1rem;
border: 1px solid #e8e9ff;
border-radius: 10px;
font-size: 0.875rem;
transition: all 0.3s ease;
background: #fff;
}
.form-control:focus {
outline: none;
border-color: #5b5fcf;
box-shadow: 0 0 0 3px rgba(91, 95, 207, 0.1);
}
.data-table {
width: 100%;
background: white;
border-radius: 12px;
overflow: hidden;
border: 1px solid #e8e9ff;
}
.data-table thead {
background: linear-gradient(135deg, #f8f9ff 0%, #f0f1ff 100%);
}
.data-table th {
padding: 1rem;
text-align: left;
font-weight: 600;
color: #1e293b;
font-size: 0.875rem;
text-transform: uppercase;
letter-spacing: 0.05em;
border-bottom: 1px solid #e8e9ff;
}
.data-table td {
padding: 1rem;
color: #64748b;
font-size: 0.875rem;
border-bottom: 1px solid #f3f4f6;
}
.data-table tbody tr:hover {
background: #f8f9ff;
}
.data-table tbody tr:last-child td {
border-bottom: none;
}
.sites-section {
background: #f8f9ff;
border-radius: 12px;
padding: 1.5rem;
margin-top: 2rem;
}
.section-title {
font-size: 1rem;
font-weight: 600;
color: #1e293b;
margin-bottom: 1rem;
display: flex;
align-items: center;
gap: 0.5rem;
}
.info-box {
background: #f0f9ff;
border: 1px solid #bae6fd;
border-radius: 12px;
padding: 1.5rem;
margin-bottom: 1.5rem;
}
.info-box-content {
display: flex;
justify-content: space-between;
align-items: center;
}
.info-item {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.info-label {
font-size: 0.75rem;
color: #64748b;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.info-value {
font-size: 1rem;
font-weight: 600;
color: #1e293b;
}
@keyframes fadeInDown {
from {
opacity: 0;
transform: translateY(-20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* Override Bootstrap modal styles */
.modal-content {
border-radius: 16px;
border: none;
box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}
.modal-header {
background: linear-gradient(135deg, #f8f9ff 0%, #f0f1ff 100%);
border-radius: 16px 16px 0 0;
padding: 1.5rem;
border-bottom: 1px solid #e8e9ff;
}
.modal-title {
font-size: 1.25rem;
font-weight: 600;
color: #1e293b;
}
.modal-body {
padding: 2rem;
}
/* Number input styling */
input[type="number"] {
width: 100px;
padding: 0.875rem 1rem;
border: 1px solid #e8e9ff;
border-radius: 10px;
font-size: 0.875rem;
transition: all 0.3s ease;
background: #fff;
}
input[type="number"]:focus {
outline: none;
border-color: #5b5fcf;
box-shadow: 0 0 0 3px rgba(91, 95, 207, 0.1);
}
@media (max-width: 768px) {
.page-title {
font-size: 2rem;
}
.form-row {
flex-direction: column;
align-items: flex-start;
}
.form-label {
flex: none;
width: 100%;
margin-bottom: 0.5rem;
}
}
</style>
<div class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "Create New Backup Schedule" %} <img ng-hide="cyberPanelLoading"
src="{% static 'images/loading.gif' %}"
alt="cyberPanelLoading">
</h3>
<div class="example-box-wrapper">
<form action="/" class="form-horizontal bordered-row">
<div class="form-group" style="display: none">
<label class="col-sm-3 control-label">{% trans "Name" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="selectedAccountAdd"
ng-init="selectedAccountAdd='{{ destination }}'" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Name" %}</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="name" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Backup Frequency" %}</label>
<div class="col-sm-6">
<select ng-model="backupFrequency" class="form-control">
<option>Never</option>
<option>Daily</option>
<option>Weekly</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Backup Retention. Leave 0 for no limit" %}</label>
<div class="col-sm-9">
<div class="number">
<label>
<input ng-model="backupRetention" type="number" value="0">
</label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="addSchedule()"
class="btn btn-primary btn-lg btn-block">{% trans "Add Schedule" %}</button>
</div>
</div>
</form>
</div>
<div class="modern-container">
<!-- Page header -->
<div class="page-header">
<h1 class="page-title">
<i class="fas fa-clock"></i>
{% trans "Schedule Backup" %}
</h1>
<p class="page-subtitle">{% trans "Schedule automated backups to protect your data on localhost or remote server" %}</p>
<div class="header-actions">
<a href="https://cyberpanel.net/KnowledgeBase/home/schedule-backups-local-or-sftp/"
target="_blank"
class="btn-secondary">
<i class="fas fa-book"></i>
{% trans "Documentation" %}
</a>
</div>
</div>
<div class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "Manage Existing Backup Schedules" %} <img ng-hide="cyberPanelLoading"
src="{% static 'images/loading.gif' %}"
alt="cyberPanelLoading">
</h3>
<div class="example-box-wrapper">
<div ng-controller="scheduleBackup">
<!-- Create New Schedule Card -->
<div class="main-card">
<div class="card-header">
<h2 class="card-title">
<i class="fas fa-plus-circle"></i>
{% trans "Create New Backup Schedule" %}
<img ng-hide="cyberPanelLoading" src="{% static 'images/loading.gif' %}" style="width: 24px; margin-left: 10px;">
</h2>
</div>
<div class="card-body">
<form action="/">
<div style="display: none">
<input type="text" ng-model="selectedAccountAdd" ng-init="selectedAccountAdd='{{ destination }}'" required>
</div>
<div class="form-row">
<label class="form-label">{% trans "Name" %}</label>
<input type="text" class="form-control" ng-model="name" placeholder="{% trans 'Enter schedule name' %}" required>
</div>
<form action="/" class="form-horizontal bordered-row">
<div class="form-row">
<label class="form-label">{% trans "Select Backup Frequency" %}</label>
<select ng-model="backupFrequency" class="form-control">
<option>Never</option>
<option>Daily</option>
<option>Weekly</option>
</select>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Destination" %}</label>
<div class="col-sm-6">
<select ng-change="fetchJobs()" ng-model="selectedAccount" class="form-control">
<option>{{ destination }}</option>
</select>
<div class="form-row">
<label class="form-label">{% trans "Backup Retention" %}</label>
<div style="display: flex; align-items: center; gap: 1rem;">
<input ng-model="backupRetention" type="number" value="0" min="0">
<span style="color: #64748b; font-size: 0.875rem;">{% trans "days (0 for no limit)" %}</span>
</div>
</div>
<div ng-hide="jobsHidden" class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Job" %}</label>
<div class="col-sm-6">
<div style="text-align: center; margin-top: 2rem;">
<button type="button" ng-click="addSchedule()" class="btn-primary">
<i class="fas fa-plus"></i>
{% trans "Add Schedule" %}
</button>
</div>
</form>
</div>
</div>
<!-- Manage Existing Schedules Card -->
<div class="main-card">
<div class="card-header">
<h2 class="card-title">
<i class="fas fa-list"></i>
{% trans "Manage Existing Backup Schedules" %}
<img ng-hide="cyberPanelLoading" src="{% static 'images/loading.gif' %}" style="width: 24px; margin-left: 10px;">
</h2>
</div>
<div class="card-body">
<form action="/">
<div class="form-row">
<label class="form-label">{% trans "Select Destination" %}</label>
<select ng-change="fetchJobs()" ng-model="selectedAccount" class="form-control">
<option>{{ destination }}</option>
</select>
</div>
<div ng-hide="jobsHidden" class="form-row">
<label class="form-label">{% trans "Select Job" %}</label>
<div style="flex: 1; display: flex; gap: 1rem;">
<select ng-change="fetchWebsites()" ng-model="selectedJob" class="form-control">
<option ng-repeat="job in jobs track by $index">{$ job $}</option>
</select>
<button ng-hide="driveHidden" type="button" ng-click="deleteAccount()" class="btn-danger">
<i class="fas fa-trash"></i>
{% trans "Delete" %}
</button>
</div>
<button ng-hide="driveHidden" type="button" ng-click="deleteAccount()"
class="btn btn-danger">{% trans "Delete" %}</button>
</div>
<div ng-hide="driveHidden" class="form-group">
<label class="col-sm-3 control-label">{% trans "Add Sites for Backup" %}</label>
<div class="col-sm-6">
<div ng-hide="driveHidden" class="form-row">
<label class="form-label">{% trans "Add Sites for Backup" %}</label>
<div style="flex: 1; display: flex; gap: 1rem;">
<select ng-model="selectedWebsite" class="form-control">
{% for items in websites %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
<button type="button" ng-click="addSite('one')"
class="btn btn-primary">{% trans "Add Site" %}</button>
<button type="button" ng-click="addSite('all')"
class="btn btn-primary">{% trans "Add All" %}</button>
</div>
<div ng-hide="driveHidden" class="form-group">
<div style="border: 1px solid green;" class="col-sm-12">
<table style="margin-top: 2%" class="table">
<thead>
<tr>
<th>Last Run</th>
<th>All Sites</th>
<th>Frequency ({$ currently $})</th>
<th>Retention ({$ currently $})</th>
<th>Current Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>{$ lastRun $}</td>
<td>{$ allSites $}</td>
<td>
<select ng-change="changeFrequency()" ng-model="backupFrequency"
class="form-control">
<option>Never</option>
<option>Daily</option>
<option>Weekly</option>
</select>
</td>
<td>{$ currentStatus $}</td>
</tr>
</tbody>
</table>
<button type="button" ng-click="addSite('one')" class="btn-primary" style="padding: 0.5rem 1rem;">
<i class="fas fa-plus"></i>
{% trans "Add Site" %}
</button>
<button type="button" ng-click="addSite('all')" class="btn-secondary" style="padding: 0.5rem 1rem;">
<i class="fas fa-plus-circle"></i>
{% trans "Add All" %}
</button>
</div>
</div>
<div style="border: 1px solid green;" ng-hide="driveHidden" class="form-group">
<div class="row">
<div style="margin-left: 2%" class="col-sm-3">
<button data-toggle="modal" data-target="#backupLogs" ng-hide="driveHidden"
type="button" ng-click="fetchLogs()"
class="btn btn-gray">{% trans "View Logs" %}</button>
<div id="backupLogs" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;
</button>
<h4 class="modal-title">{% trans "Backup logs" %} <img
ng-hide="cyberPanelLoading"
src="{% static 'images/loading.gif' %}">
</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-9">
</div>
<div class="col-sm-2">
<div class="form-group">
<select ng-model="recordsToShowLogs"
ng-change="fetchLogs()"
class="form-control" id="example-select">
<option>10</option>
<option>50</option>
<option>100</option>
</select>
</div>
</div>
</div>
<table style="margin: 0px; padding-bottom: 2%" class="table">
<thead>
<tr>
<th>Type</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="log in logs track by $index">
<td ng-bind="log.type"></td>
<td ng-bind="log.message"></td>
</tr>
</tbody>
</table>
<div style="margin-top: 2%" class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-8">
</div>
<div class="col-md-3">
<div class="form-group">
<select ng-model="currentPageLogs"
class="form-control"
ng-change="fetchLogs()">
<option ng-repeat="page in paginationLogs">
{$
$index + 1
$}
</option>
</select>
</div>
</div>
</div> <!-- end row -->
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Schedule Info Box -->
<div ng-hide="driveHidden" class="info-box">
<div class="info-box-content">
<div class="info-item">
<span class="info-label">{% trans "Last Run" %}</span>
<span class="info-value">{$ lastRun $}</span>
</div>
<div class="col-sm-6">
<div class="info-item">
<span class="info-label">{% trans "All Sites" %}</span>
<span class="info-value">{$ allSites $}</span>
</div>
<div class="col-sm-2">
<div class="form-group">
<select ng-model="recordsToShow"
ng-change="fetchWebsites()"
class="form-control" id="example-select">
<option>10</option>
<option>50</option>
<option>100</option>
</select>
</div>
<div class="info-item">
<span class="info-label">{% trans "Frequency" %} ({$ currently $})</span>
<select ng-change="changeFrequency()" ng-model="backupFrequency" class="form-control" style="width: 150px;">
<option>Never</option>
<option>Daily</option>
<option>Weekly</option>
</select>
</div>
<div class="info-item">
<span class="info-label">{% trans "Current Status" %}</span>
<span class="info-value">{$ currentStatus $}</span>
</div>
</div>
</div>
<!-- Sites Table Section -->
<div ng-hide="driveHidden" class="sites-section">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;">
<h3 class="section-title">
<i class="fas fa-globe"></i>
{% trans "Backed Up Sites" %}
</h3>
<div style="display: flex; gap: 1rem; align-items: center;">
<button data-toggle="modal" data-target="#backupLogs" type="button" ng-click="fetchLogs()" class="btn-gray">
<i class="fas fa-file-alt"></i>
{% trans "View Logs" %}
</button>
<select ng-model="recordsToShow" ng-change="fetchWebsites()" class="form-control" style="width: 100px;">
<option>10</option>
<option>50</option>
<option>100</option>
</select>
</div>
</div>
<table style="margin-top: 2%" class="table">
<table class="data-table">
<thead>
<tr>
<th>Sites</th>
<th>Action</th>
</tr>
<tr>
<th>{% trans "Sites" %}</th>
<th style="width: 150px;">{% trans "Actions" %}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="website in websites track by $index">
<td ng-bind="website.name"></td>
<td>
<button type="button" ng-click="deleteSite(website.name)"
class="btn btn-danger">{% trans "Delete" %}</button>
</td>
</tr>
<tr ng-repeat="website in websites track by $index">
<td ng-bind="website.name"></td>
<td>
<button type="button" ng-click="deleteSite(website.name)" class="btn-danger">
<i class="fas fa-trash"></i>
{% trans "Delete" %}
</button>
</td>
</tr>
</tbody>
</table>
<div style="margin-top: 2%" class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-8">
</div>
<div class="col-md-3">
<div class="form-group">
<select ng-model="currentPage" class="form-control"
ng-change="fetchWebsites()">
<option ng-repeat="page in pagination">{$ $index + 1
$}
</option>
</select>
</div>
</div>
</div> <!-- end row -->
<div style="margin-top: 1.5rem; text-align: right;">
<div style="display: inline-flex; align-items: center; gap: 1rem;">
<span style="color: #64748b; font-size: 0.875rem;">{% trans "Page" %}</span>
<select ng-model="currentPage" class="form-control" ng-change="fetchWebsites()" style="width: 80px;">
<option ng-repeat="page in pagination">{$ $index + 1 $}</option>
</select>
</div>
</div>
</div>
</form>
</div>
</div>
<!-- Logs Modal -->
<div id="backupLogs" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">
<i class="fas fa-file-alt" style="margin-right: 0.5rem;"></i>
{% trans "Backup Logs" %}
<img ng-hide="cyberPanelLoading" src="{% static 'images/loading.gif' %}" style="width: 20px; margin-left: 10px;">
</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<div style="display: flex; justify-content: flex-end; margin-bottom: 1rem;">
<select ng-model="recordsToShowLogs" ng-change="fetchLogs()" class="form-control" style="width: 100px;">
<option>10</option>
<option>50</option>
<option>100</option>
</select>
</div>
<table class="data-table">
<thead>
<tr>
<th style="width: 100px;">{% trans "Type" %}</th>
<th>{% trans "Message" %}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="log in logs track by $index">
<td ng-bind="log.type"></td>
<td ng-bind="log.message"></td>
</tr>
</tbody>
</table>
<div style="margin-top: 1.5rem; text-align: right;">
<div style="display: inline-flex; align-items: center; gap: 1rem;">
<span style="color: #64748b; font-size: 0.875rem;">{% trans "Page" %}</span>
<select ng-model="currentPageLogs" class="form-control" ng-change="fetchLogs()" style="width: 80px;">
<option ng-repeat="page in paginationLogs">{$ $index + 1 $}</option>
</select>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% endblock %}

View File

@@ -4,111 +4,413 @@
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<style>
.modern-container {
max-width: 1400px;
margin: 0 auto;
padding: 2rem;
}
.page-header {
text-align: center;
margin-bottom: 3rem;
padding: 3rem 0;
background: linear-gradient(135deg, #f8f9ff 0%, #f0f1ff 100%);
border-radius: 20px;
animation: fadeInDown 0.5s ease-out;
}
.page-title {
font-size: 3rem;
font-weight: 700;
color: #1e293b;
margin-bottom: 1rem;
display: flex;
align-items: center;
justify-content: center;
gap: 1rem;
}
.page-subtitle {
font-size: 1.25rem;
color: #64748b;
margin-bottom: 1.5rem;
max-width: 700px;
margin-left: auto;
margin-right: auto;
line-height: 1.6;
}
.page-subtitle strong {
color: #5b5fcf;
font-weight: 600;
}
.header-actions {
display: flex;
gap: 1rem;
justify-content: center;
flex-wrap: wrap;
}
.btn-primary {
background: #5b5fcf;
color: white;
border: none;
padding: 0.75rem 2rem;
border-radius: 10px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
display: inline-flex;
align-items: center;
gap: 0.5rem;
text-decoration: none;
font-size: 0.875rem;
}
.btn-primary:hover {
background: #4547a9;
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(91, 95, 207, 0.4);
color: white;
}
.btn-primary:disabled {
background: #d1d5db;
cursor: not-allowed;
transform: none;
box-shadow: none;
}
.btn-secondary {
background: #fff;
color: #5b5fcf;
border: 1px solid #e8e9ff;
padding: 0.75rem 2rem;
border-radius: 10px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
display: inline-flex;
align-items: center;
gap: 0.5rem;
text-decoration: none;
font-size: 0.875rem;
}
.btn-secondary:hover {
background: #f8f9ff;
border-color: #5b5fcf;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(91, 95, 207, 0.2);
}
.main-card {
background: white;
border-radius: 16px;
box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 10px 40px rgba(0,0,0,0.08);
border: 1px solid #e8e9ff;
overflow: hidden;
margin-bottom: 2rem;
animation: fadeInUp 0.5s ease-out;
max-width: 800px;
margin-left: auto;
margin-right: auto;
}
.card-header {
background: linear-gradient(135deg, #f8f9ff 0%, #f0f1ff 100%);
padding: 1.5rem 2rem;
border-bottom: 1px solid #e8e9ff;
}
.card-title {
font-size: 1.25rem;
font-weight: 600;
color: #1e293b;
margin: 0;
display: flex;
align-items: center;
gap: 0.75rem;
}
.card-body {
padding: 2rem;
}
.form-row {
display: flex;
gap: 1rem;
align-items: center;
margin-bottom: 1.5rem;
}
.form-label {
flex: 0 0 150px;
font-weight: 500;
color: #1e293b;
font-size: 0.875rem;
}
.form-control {
flex: 1;
padding: 0.875rem 1rem;
border: 1px solid #e8e9ff;
border-radius: 10px;
font-size: 0.875rem;
transition: all 0.3s ease;
background: #fff;
}
.form-control:focus {
outline: none;
border-color: #5b5fcf;
box-shadow: 0 0 0 3px rgba(91, 95, 207, 0.1);
}
.progress-section {
margin-top: 2rem;
padding: 2rem;
background: #f8f9ff;
border-radius: 12px;
}
.status-message {
background: #e0f2fe;
border: 1px solid #7dd3fc;
color: #0369a1;
padding: 1rem 1.5rem;
border-radius: 10px;
text-align: center;
margin-bottom: 1.5rem;
font-weight: 500;
font-size: 1.125rem;
}
.progress-wrapper {
background: #e2e8f0;
border-radius: 10px;
overflow: hidden;
height: 24px;
margin-bottom: 1.5rem;
}
.progress-bar {
background: linear-gradient(90deg, #5b5fcf 0%, #8187ff 100%);
height: 100%;
border-radius: 10px;
transition: width 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: 500;
font-size: 0.875rem;
}
.alert {
padding: 1rem 1.5rem;
border-radius: 10px;
margin-bottom: 1rem;
display: flex;
align-items: center;
gap: 0.75rem;
animation: slideInRight 0.3s ease-out;
}
.alert-success {
background: #d1fae5;
color: #065f46;
border: 1px solid #a7f3d0;
}
.alert-danger {
background: #fee2e2;
color: #991b1b;
border: 1px solid #fecaca;
}
.alert i {
font-size: 1.25rem;
}
.form-actions {
display: flex;
gap: 1rem;
justify-content: center;
margin-top: 2rem;
}
@keyframes fadeInDown {
from {
opacity: 0;
transform: translateY(-20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes slideInRight {
from {
opacity: 0;
transform: translateX(20px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
@media (max-width: 768px) {
.page-title {
font-size: 2rem;
}
.form-row {
flex-direction: column;
align-items: flex-start;
}
.form-label {
flex: none;
width: 100%;
margin-bottom: 0.5rem;
}
.form-actions {
flex-direction: column;
width: 100%;
}
.form-actions button {
width: 100%;
}
}
</style>
<div class="container">
<div id="page-title">
<h2>{% trans "Restore Website" %} - <a target="_blank" href="http://go.cyberpanel.net/backup"
style="height: 23px;line-height: 21px;"
class="btn btn-border btn-alt border-red btn-link font-red" title=""><span>{% trans "Backup Docs" %}</span></a>
</h2>
<p>{% trans "This page can be used to restore your websites, Backup should be generated from CyberPanel Backup generation tool, it will detect all Backups under <strong>/home/backup</strong>." %}</p>
</div>
<div ng-controller="OneClickrestoreWebsiteControl" class="panel">
<div class="panel-body">
<h3 class="title-hero">
{% trans "Restore Website" %} <img ng-hide="restoreLoading" src="{% static 'images/loading.gif' %}">
</h3>
<div class="example-box-wrapper">
<form action="/" class="form-horizontal bordered-row">
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Folder" %}</label>
<div class="col-sm-6">
<select ng-change="FetchOCSites()" ng-model="ocFolder" class="form-control">
{% for items in directories %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Select Backup" %}</label>
<div class="col-sm-6">
<select ng-model="ocFile" class="form-control">
<option ng-repeat="item in backups">{$ item $}</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-click="StartOCRestore()"
class="btn btn-primary btn-lg">{% trans "Restore Backup" %}</button>
</div>
</div>
<div ng-hide="installationProgress" class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-7">
<div class="alert alert-success text-center">
<h2>{$ currentStatus $}</h2>
</div>
<div class="progress">
<div id="installProgress" class="progress-bar" role="progressbar" aria-valuenow="70"
aria-valuemin="0" aria-valuemax="100" style="width:0%">
<span class="sr-only">70% Complete</span>
</div>
</div>
<div ng-hide="errorMessageBox" class="alert alert-danger">
<p>{% trans "Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="success" class="alert alert-success">
<p>{% trans "Backup restored successfully." %}</p>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
</div>
</div>
</div>
<div ng-hide="installationProgress" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-disabled="goBackDisable" ng-click="goBack()"
class="btn btn-primary btn-lg">{% trans "Go Back" %}</button>
</div>
</div>
</form>
</div>
<div class="modern-container">
<!-- Page header -->
<div class="page-header">
<h1 class="page-title">
<i class="fas fa-undo-alt"></i>
{% trans "Restore Website" %}
</h1>
<p class="page-subtitle">
{% trans "Restore your websites from backups. Backups are automatically detected from" %} <strong>/home/backup</strong>
{% trans "directory. Select a backup folder and file to begin the restoration process." %}
</p>
<div class="header-actions">
<a href="http://go.cyberpanel.net/backup"
target="_blank"
class="btn-secondary">
<i class="fas fa-book"></i>
{% trans "Backup Documentation" %}
</a>
</div>
</div>
<div ng-controller="OneClickrestoreWebsiteControl">
<!-- Restore Form Card -->
<div class="main-card">
<div class="card-header">
<h2 class="card-title">
<i class="fas fa-folder-open"></i>
{% trans "Select Backup to Restore" %}
<img ng-hide="restoreLoading" src="{% static 'images/loading.gif' %}" style="width: 24px; margin-left: 10px;">
</h2>
</div>
<div class="card-body">
<form action="/">
<div class="form-row">
<label class="form-label">{% trans "Select Folder" %}</label>
<select ng-change="FetchOCSites()" ng-model="ocFolder" class="form-control">
{% for items in directories %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
<div class="form-row">
<label class="form-label">{% trans "Select Backup" %}</label>
<select ng-model="ocFile" class="form-control">
<option ng-repeat="item in backups">{$ item $}</option>
</select>
</div>
<div class="form-actions">
<button type="button" ng-click="StartOCRestore()" class="btn-primary">
<i class="fas fa-download"></i>
{% trans "Restore Backup" %}
</button>
</div>
<!-- Progress Section -->
<div ng-hide="installationProgress" class="progress-section">
<div class="status-message">
<i class="fas fa-info-circle"></i>
{$ currentStatus $}
</div>
<div class="progress-wrapper">
<div id="installProgress" class="progress-bar" role="progressbar"
aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"
style="width:0%">
<span>{$ installPercentage $}%</span>
</div>
</div>
<div ng-hide="errorMessageBox" class="alert alert-danger">
<i class="fas fa-exclamation-circle"></i>
<div>
<strong>{% trans "Error occurred:" %}</strong><br>
{$ errorMessage $}
</div>
</div>
<div ng-hide="success" class="alert alert-success">
<i class="fas fa-check-circle"></i>
<div>
<strong>{% trans "Success!" %}</strong><br>
{% trans "Backup has been restored successfully." %}
</div>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<i class="fas fa-wifi"></i>
<div>
<strong>{% trans "Connection Error" %}</strong><br>
{% trans "Could not connect to server. Please refresh this page and try again." %}
</div>
</div>
<div class="form-actions">
<button type="button" ng-disabled="goBackDisable" ng-click="goBack()" class="btn-secondary">
<i class="fas fa-arrow-left"></i>
{% trans "Go Back" %}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -131,6 +131,11 @@ def getSystemStatus(request):
try:
val = request.session['userID']
currentACL = ACLManager.loadedACL(val)
# Only admins should see system-wide information
if not currentACL.get('admin', 0):
return HttpResponse(json.dumps({'status': 0, 'error_message': 'Admin access required'}), content_type='application/json', status=403)
HTTPData = SystemInformation.getSystemInformation()
json_data = json.dumps(HTTPData)
return HttpResponse(json_data)
@@ -142,6 +147,11 @@ def getLoadAverage(request):
try:
val = request.session['userID']
currentACL = ACLManager.loadedACL(val)
# Only admins should see system load averages
if not currentACL.get('admin', 0):
return HttpResponse(json.dumps({'status': 0, 'error_message': 'Admin access required'}), content_type='application/json', status=403)
loadAverage = SystemInformation.cpuLoad()
loadAverage = list(loadAverage)
one = loadAverage[0]
@@ -495,6 +505,11 @@ def getTrafficStats(request):
try:
val = request.session['userID']
currentACL = ACLManager.loadedACL(val)
# Only admins should see system-wide network stats
if not currentACL.get('admin', 0):
return HttpResponse(json.dumps({'status': 0, 'error_message': 'Admin access required'}), content_type='application/json', status=403)
# Get network stats from /proc/net/dev (Linux)
rx = tx = 0
with open('/proc/net/dev', 'r') as f:
@@ -518,6 +533,11 @@ def getDiskIOStats(request):
try:
val = request.session['userID']
currentACL = ACLManager.loadedACL(val)
# Only admins should see system-wide disk I/O stats
if not currentACL.get('admin', 0):
return HttpResponse(json.dumps({'status': 0, 'error_message': 'Admin access required'}), content_type='application/json', status=403)
# Parse /proc/diskstats for all disks
read_sectors = 0
write_sectors = 0
@@ -547,6 +567,11 @@ def getCPULoadGraph(request):
try:
val = request.session['userID']
currentACL = ACLManager.loadedACL(val)
# Only admins should see system-wide CPU stats
if not currentACL.get('admin', 0):
return HttpResponse(json.dumps({'status': 0, 'error_message': 'Admin access required'}), content_type='application/json', status=403)
# Parse /proc/stat for the 'cpu' line
with open('/proc/stat', 'r') as f:
for line in f:

View File

@@ -1245,7 +1245,7 @@
<i class="fas fa-external-link-alt"></i>
{% trans "Preview Website" %}
</a>
<a href="/fileManager/websiteFunctions/{{ domain }}" class="hero-btn">
<a href="/filemanager/{{ domain }}" class="hero-btn">
<i class="fas fa-folder"></i>
{% trans "File Manager" %}
</a>