452 lines
No EOL
11 KiB
HTML
452 lines
No EOL
11 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}Configuración{% endblock %}
|
|
|
|
{% block content %}
|
|
<div id="backup-overlay"
|
|
style="display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.9); z-index:9999; flex-direction:column; justify-content:center; align-items:center; color:white; padding: 2rem; text-align: center;">
|
|
<i class="fas fa-database fa-spin fa-3x" style="margin-bottom:20px; color: var(--accent-color);"></i>
|
|
<h2 id="backup-title">Preparando backup...</h2>
|
|
<div
|
|
style="width: 100%; max-width: 400px; background: #333; border-radius: 10px; height: 10px; margin: 20px 0; overflow: hidden;">
|
|
<div id="backup-progress-bar"
|
|
style="width: 0%; height: 100%; background: var(--accent-color); transition: width 0.3s;"></div>
|
|
</div>
|
|
<p id="backup-status-text">Calculando noticias...</p>
|
|
<button id="btn-close-backup" onclick="hideBackupLoading()" class="btn btn-secondary"
|
|
style="margin-top:20px; display: none;">Cerrar</button>
|
|
</div>
|
|
|
|
<script>
|
|
let isBackupRunning = false;
|
|
let autoReloadTimer = null;
|
|
|
|
function startAutoReload() {
|
|
if (!isBackupRunning) {
|
|
autoReloadTimer = setTimeout(() => location.reload(), 30000);
|
|
}
|
|
}
|
|
|
|
function stopAutoReload() {
|
|
if (autoReloadTimer) clearTimeout(autoReloadTimer);
|
|
}
|
|
|
|
function startBackup() {
|
|
isBackupRunning = true;
|
|
stopAutoReload();
|
|
document.getElementById('backup-overlay').style.display = 'flex';
|
|
document.getElementById('backup-title').innerText = "Iniciando Backup...";
|
|
document.getElementById('backup-progress-bar').style.width = '0%';
|
|
document.getElementById('btn-close-backup').style.display = 'none';
|
|
|
|
fetch('/config/backup/start')
|
|
.then(r => r.json())
|
|
.then(data => {
|
|
pollBackupStatus(data.task_id);
|
|
})
|
|
.catch(err => {
|
|
alert("Error al iniciar backup");
|
|
hideBackupLoading();
|
|
});
|
|
}
|
|
|
|
function pollBackupStatus(taskId) {
|
|
fetch(`/config/backup/status/${taskId}`)
|
|
.then(r => r.json())
|
|
.then(data => {
|
|
if (data.status === 'processing' || data.status === 'initializing') {
|
|
updateBackupUI(data);
|
|
setTimeout(() => pollBackupStatus(taskId), 2000);
|
|
} else if (data.status === 'completed') {
|
|
updateBackupUI(data);
|
|
document.getElementById('backup-title').innerText = "¡Backup Completado!";
|
|
document.getElementById('backup-status-text').innerText = "Iniciando descarga...";
|
|
window.location.href = `/config/backup/download/${taskId}`;
|
|
document.getElementById('btn-close-backup').style.display = 'block';
|
|
isBackupRunning = false;
|
|
startAutoReload();
|
|
} else if (data.status === 'error') {
|
|
alert("Error: " + data.error);
|
|
hideBackupLoading();
|
|
}
|
|
});
|
|
}
|
|
|
|
function updateBackupUI(data) {
|
|
if (data.total > 0) {
|
|
const percent = Math.round((data.progress / data.total) * 100);
|
|
document.getElementById('backup-progress-bar').style.width = percent + '%';
|
|
document.getElementById('backup-status-text').innerText = `Procesando: ${data.progress.toLocaleString()} / ${data.total.toLocaleString()} (${percent}%)`;
|
|
document.getElementById('backup-title').innerText = "Generando archivo ZIP...";
|
|
}
|
|
}
|
|
|
|
function hideBackupLoading() {
|
|
document.getElementById('backup-overlay').style.display = 'none';
|
|
isBackupRunning = false;
|
|
startAutoReload();
|
|
}
|
|
|
|
// Initialize auto-reload
|
|
startAutoReload();
|
|
</script>
|
|
<div class="config-page">
|
|
<h2><i class="fas fa-cog"></i> Configuración</h2>
|
|
|
|
|
|
|
|
<div class="config-grid">
|
|
<!-- Translator Card -->
|
|
<div class="config-card card-wide"
|
|
style="display: flex; align-items: center; justify-content: center; min-height: 120px;">
|
|
<a href="{{ url_for('config.translator_config') }}" class="btn btn-dark-outline"
|
|
style="font-size: 1.1rem; padding: 1rem 2rem;">
|
|
<i class="fas fa-robot"></i> Configurar Modelo
|
|
</a>
|
|
</div>
|
|
|
|
<!-- Backup Card -->
|
|
<div class="config-card">
|
|
<div class="card-header">
|
|
<div class="card-icon"><i class="fas fa-file-archive"></i></div>
|
|
</div>
|
|
<h3>Backup (ZIP)</h3>
|
|
<p>Exporta todas las noticias y traducciones en un archivo comprimido (ZIP) para ahorrar espacio.</p>
|
|
<button onclick="startBackup()" class="btn btn-dark" id="btn-start-backup">
|
|
<i class="fas fa-file-download"></i> Descargar ZIP (con progreso)
|
|
</button>
|
|
|
|
<div style="margin-top:10px; padding-top:10px; border-top:1px solid #eee;">
|
|
<small style="display:block; margin-bottom:5px; color:#666;">Metadatos:</small>
|
|
<div style="display:flex; gap:10px;">
|
|
<a href="{{ url_for('backup.export_paises') }}" class="btn btn-small btn-secondary_outline"
|
|
style="font-size:0.8em; padding:5px 10px;">
|
|
<i class="fas fa-file-csv"></i> Países
|
|
</a>
|
|
<a href="{{ url_for('backup.export_categorias') }}" class="btn btn-small btn-secondary_outline"
|
|
style="font-size:0.8em; padding:5px 10px;">
|
|
<i class="fas fa-file-csv"></i> Categorías
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Restore Card -->
|
|
<div class="config-card">
|
|
<div class="card-header">
|
|
<div class="card-icon"><i class="fas fa-upload"></i></div>
|
|
</div>
|
|
<h3>Restaurar</h3>
|
|
<p>Importa datos desde un backup en formato <strong>JSON</strong> o <strong>ZIP</strong>.</p>
|
|
<a href="{{ url_for('config.restore_noticias') }}" class="btn btn-dark-outline">
|
|
<i class="fas fa-upload"></i> Subir Backup
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.config-page h2 {
|
|
margin-bottom: 1.5rem;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
font-family: 'Playfair Display', 'Times New Roman', serif;
|
|
font-weight: 700;
|
|
letter-spacing: -0.02em;
|
|
}
|
|
|
|
/* Stats Banner */
|
|
.stats-banner {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 1.5rem;
|
|
padding: 1rem 1.5rem;
|
|
background: #111;
|
|
border-radius: 8px;
|
|
margin-bottom: 2rem;
|
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
|
|
}
|
|
|
|
.stat-item {
|
|
text-align: center;
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: 1.75rem;
|
|
font-weight: 700;
|
|
color: #fff;
|
|
font-family: 'Poppins', sans-serif;
|
|
line-height: 1;
|
|
}
|
|
|
|
.stat-value.stat-warning {
|
|
color: #ffc107;
|
|
}
|
|
|
|
.stat-value.stat-processing {
|
|
color: #17a2b8;
|
|
}
|
|
|
|
.stat-value.stat-error {
|
|
color: #dc3545;
|
|
}
|
|
|
|
.stat-label {
|
|
font-size: 0.7rem;
|
|
color: rgba(255, 255, 255, 0.6);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
margin-top: 0.25rem;
|
|
}
|
|
|
|
.stat-divider {
|
|
width: 1px;
|
|
height: 40px;
|
|
background: rgba(255, 255, 255, 0.15);
|
|
}
|
|
|
|
/* Cards Grid */
|
|
.config-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
|
gap: 1.5rem;
|
|
}
|
|
|
|
.config-card {
|
|
background: var(--card-bg, #fff);
|
|
border-radius: 12px;
|
|
padding: 1.5rem;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.75rem;
|
|
transition: transform 0.2s, box-shadow 0.2s;
|
|
border-top: 3px solid #111;
|
|
}
|
|
|
|
.config-card.card-wide {
|
|
grid-column: span 2;
|
|
}
|
|
|
|
@media (max-width: 700px) {
|
|
.config-card.card-wide {
|
|
grid-column: span 1;
|
|
}
|
|
}
|
|
|
|
.config-card:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
|
|
}
|
|
|
|
.card-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: flex-start;
|
|
}
|
|
|
|
.card-icon {
|
|
font-size: 1.75rem;
|
|
color: #111;
|
|
}
|
|
|
|
.card-status {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.35rem;
|
|
font-size: 0.7rem;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
color: #28a745;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.card-status .pulse {
|
|
width: 8px;
|
|
height: 8px;
|
|
background: #28a745;
|
|
border-radius: 50%;
|
|
animation: pulse 2s infinite;
|
|
}
|
|
|
|
@keyframes pulse {
|
|
|
|
0%,
|
|
100% {
|
|
opacity: 1;
|
|
transform: scale(1);
|
|
}
|
|
|
|
50% {
|
|
opacity: 0.5;
|
|
transform: scale(1.2);
|
|
}
|
|
}
|
|
|
|
.config-card h3 {
|
|
margin: 0;
|
|
font-size: 1.25rem;
|
|
font-family: 'Playfair Display', 'Times New Roman', serif;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.config-card p {
|
|
color: var(--text-muted, #666);
|
|
font-size: 0.9rem;
|
|
margin: 0;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
/* Big Stats */
|
|
.big-stats {
|
|
display: flex;
|
|
gap: 2rem;
|
|
margin: 1rem 0;
|
|
padding: 1rem 0;
|
|
border-top: 1px solid var(--border-color, #eee);
|
|
border-bottom: 1px solid var(--border-color, #eee);
|
|
}
|
|
|
|
.big-stat {
|
|
text-align: center;
|
|
flex: 1;
|
|
}
|
|
|
|
.big-stat .big-number {
|
|
font-size: 2.5rem;
|
|
font-weight: 800;
|
|
color: #111;
|
|
font-family: 'Poppins', sans-serif;
|
|
line-height: 1;
|
|
}
|
|
|
|
.big-stat .big-label {
|
|
font-size: 0.75rem;
|
|
color: var(--text-muted, #666);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
margin-top: 0.35rem;
|
|
}
|
|
|
|
.big-stat.highlight .big-number {
|
|
color: #28a745;
|
|
}
|
|
|
|
.card-values {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.card-values code {
|
|
background: #f4f4f4;
|
|
padding: 0.25rem 0.5rem;
|
|
border-radius: 4px;
|
|
font-size: 0.75rem;
|
|
font-family: 'JetBrains Mono', monospace;
|
|
}
|
|
|
|
/* Buttons - Black Theme */
|
|
.btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 0.5rem;
|
|
padding: 0.75rem 1.5rem;
|
|
border: none;
|
|
border-radius: 6px;
|
|
font-size: 0.85rem;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
text-decoration: none;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.03em;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.btn:hover {
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
|
}
|
|
|
|
.btn-dark {
|
|
background: #111;
|
|
color: #fff;
|
|
}
|
|
|
|
.btn-dark:hover {
|
|
background: #333;
|
|
}
|
|
|
|
.btn-dark-outline {
|
|
background: transparent;
|
|
color: #111;
|
|
border: 2px solid #111;
|
|
}
|
|
|
|
.btn-dark-outline:hover {
|
|
background: #111;
|
|
color: #fff;
|
|
}
|
|
|
|
/* Dark Mode */
|
|
.dark-mode .config-card {
|
|
background: var(--card-bg-dark, #1e1e1e);
|
|
border-top-color: #fff;
|
|
}
|
|
|
|
.dark-mode .card-icon {
|
|
color: #fff;
|
|
}
|
|
|
|
.dark-mode .big-stat .big-number {
|
|
color: #fff;
|
|
}
|
|
|
|
.dark-mode .card-values code {
|
|
background: #333;
|
|
}
|
|
|
|
.dark-mode .stats-banner {
|
|
background: #000;
|
|
}
|
|
|
|
.dark-mode .btn-dark {
|
|
background: #fff;
|
|
color: #111;
|
|
}
|
|
|
|
.dark-mode .btn-dark-outline {
|
|
border-color: #fff;
|
|
color: #fff;
|
|
}
|
|
|
|
.dark-mode .btn-dark-outline:hover {
|
|
background: #fff;
|
|
color: #111;
|
|
}
|
|
|
|
/* Responsive */
|
|
@media (max-width: 600px) {
|
|
.stats-banner {
|
|
flex-wrap: wrap;
|
|
gap: 1rem;
|
|
}
|
|
|
|
.stat-divider {
|
|
display: none;
|
|
}
|
|
|
|
.stat-item {
|
|
flex: 0 0 45%;
|
|
}
|
|
|
|
.big-stats {
|
|
flex-direction: column;
|
|
gap: 1rem;
|
|
}
|
|
}
|
|
</style>
|
|
|
|
{% endblock %} |