Files
gkachele-saas/backups/backup-20260114-085602/local/demo/templates/client_admin.html
2026-01-17 11:40:17 +01:00

312 lines
11 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Admin - Cliente</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
background: #f0f0f1;
padding: 20px;
}
.header {
background: white;
padding: 20px 30px;
border-radius: 8px;
margin-bottom: 20px;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
display: flex;
justify-content: space-between;
align-items: center;
}
.header h1 {
color: #1d2327;
font-size: 24px;
}
.tabs {
display: flex;
gap: 10px;
margin-bottom: 20px;
background: white;
padding: 10px;
border-radius: 8px;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.tab {
padding: 10px 20px;
background: transparent;
border: none;
cursor: pointer;
border-bottom: 2px solid transparent;
font-size: 14px;
color: #50575e;
}
.tab.active {
color: #2271b1;
border-bottom-color: #2271b1;
}
.tab-content {
display: none;
background: white;
padding: 30px;
border-radius: 8px;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.tab-content.active {
display: block;
}
.btn {
padding: 8px 16px;
background: #2271b1;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
text-decoration: none;
display: inline-block;
}
.btn:hover { background: #135e96; }
.btn-danger { background: #d63638; }
.btn-danger:hover { background: #b32d2e; }
.btn-success { background: #00a32a; }
.btn-success:hover { background: #008a20; }
.upload-area {
border: 2px dashed #c3c4c7;
border-radius: 4px;
padding: 40px;
text-align: center;
margin: 20px 0;
background: #f6f7f7;
}
.upload-area:hover {
border-color: #2271b1;
background: #f0f6fc;
}
.media-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
gap: 15px;
margin-top: 20px;
}
.media-item {
position: relative;
border: 1px solid #c3c4c7;
border-radius: 4px;
overflow: hidden;
background: #fff;
}
.media-item img {
width: 100%;
height: 150px;
object-fit: cover;
}
.media-item .actions {
padding: 8px;
display: flex;
gap: 5px;
background: #f6f7f7;
}
.media-item .actions button {
flex: 1;
padding: 5px;
font-size: 12px;
}
input[type="file"] {
display: none;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: 600;
color: #1d2327;
}
.form-group input,
.form-group textarea {
width: 100%;
padding: 8px 12px;
border: 1px solid #8c8f94;
border-radius: 4px;
font-size: 14px;
}
.form-group input:focus,
.form-group textarea:focus {
border-color: #2271b1;
outline: none;
box-shadow: 0 0 0 1px #2271b1;
}
</style>
</head>
<body>
<div class="header">
<h1>⚙️ Panel de Administración</h1>
<div>
<a href="/dashboard" class="btn">← Volver al Dashboard</a>
<a href="/logout" class="btn btn-danger">Salir</a>
</div>
</div>
<div class="tabs">
<button class="tab active" onclick="showTab('media')">📷 Media</button>
<button class="tab" onclick="showTab('settings')">⚙️ Configuración</button>
<button class="tab" onclick="showTab('sites')">🌐 Mis Sitios</button>
</div>
<!-- Tab Media -->
<div id="tab-media" class="tab-content active">
<h2>Gestionar Imágenes</h2>
<div class="upload-area" onclick="document.getElementById('fileInput').click()">
<p style="font-size: 18px; color: #50575e; margin-bottom: 10px;">📤 Arrastra imágenes aquí o haz clic para subir</p>
<p style="font-size: 12px; color: #8c8f94;">Formatos: JPG, PNG, GIF (máx. 5MB)</p>
<input type="file" id="fileInput" multiple accept="image/*" onchange="uploadFiles(this.files)">
</div>
<div id="mediaGrid" class="media-grid">
<!-- Las imágenes se cargarán aquí -->
</div>
</div>
<!-- Tab Configuración -->
<div id="tab-settings" class="tab-content">
<h2>Configuración de Cuenta</h2>
<form id="settingsForm">
<div class="form-group">
<label>Email</label>
<input type="email" id="user_email" value="{{ user_email }}" readonly>
</div>
<div class="form-group">
<label>Plan</label>
<input type="text" id="user_plan" value="{{ user_plan }}" readonly>
</div>
<div class="form-group">
<label>Cambiar Contraseña</label>
<input type="password" id="new_password" placeholder="Nueva contraseña">
</div>
<button type="submit" class="btn btn-success">💾 Guardar Cambios</button>
</form>
</div>
<!-- Tab Sitios -->
<div id="tab-sites" class="tab-content">
<h2>Mis Sitios</h2>
<div style="display: grid; gap: 15px; margin-top: 20px;">
{% for site in sites %}
<div style="background: #f6f7f7; padding: 15px; border-radius: 4px; border: 1px solid #c3c4c7;">
<div style="display: flex; justify-content: space-between; align-items: center;">
<div>
<h3 style="margin-bottom: 5px;">{{ site.slug }}</h3>
<p style="color: #50575e; font-size: 14px;">Tema: {{ site.theme }} | Estado: <span style="padding: 3px 8px; background: {% if site.status == 'published' %}#00a32a{% elif site.status == 'pending' %}#dba617{% else %}#d63638{% endif %}; color: white; border-radius: 3px; font-size: 12px;">{{ site.status }}</span></p>
</div>
<div>
<a href="/customizer/{{ site.id }}" class="btn">✏️ Editar</a>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
<script>
function showTab(tabName) {
// Ocultar todos los tabs
document.querySelectorAll('.tab-content').forEach(tab => {
tab.classList.remove('active');
});
document.querySelectorAll('.tab').forEach(btn => {
btn.classList.remove('active');
});
// Mostrar el tab seleccionado
document.getElementById('tab-' + tabName).classList.add('active');
event.target.classList.add('active');
}
function uploadFiles(files) {
const formData = new FormData();
for (let file of files) {
formData.append('files', file);
}
fetch('/api/admin/upload', {
method: 'POST',
body: formData
})
.then(r => r.json())
.then(data => {
if (data.success) {
alert('✅ Imágenes subidas correctamente');
loadMedia();
} else {
alert('❌ Error: ' + data.error);
}
});
}
function loadMedia() {
fetch('/api/admin/media')
.then(r => r.json())
.then(data => {
const grid = document.getElementById('mediaGrid');
grid.innerHTML = '';
data.media.forEach(item => {
const div = document.createElement('div');
div.className = 'media-item';
div.innerHTML = `
<img src="/uploads/${item.filename}" alt="${item.filename}">
<div class="actions">
<button class="btn" onclick="copyUrl('${item.filename}')">📋 URL</button>
<button class="btn btn-danger" onclick="deleteMedia(${item.id})">🗑️</button>
</div>
`;
grid.appendChild(div);
});
});
}
function copyUrl(filename) {
const url = window.location.origin + '/uploads/' + filename;
navigator.clipboard.writeText(url);
alert('✅ URL copiada: ' + url);
}
function deleteMedia(id) {
if (confirm('¿Eliminar esta imagen?')) {
fetch(`/api/admin/media/${id}`, {method: 'DELETE'})
.then(r => r.json())
.then(data => {
if (data.success) {
loadMedia();
}
});
}
}
// Cargar media al iniciar
loadMedia();
// Guardar configuración
document.getElementById('settingsForm').addEventListener('submit', (e) => {
e.preventDefault();
const password = document.getElementById('new_password').value;
if (password) {
fetch('/api/admin/settings', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({password: password})
})
.then(r => r.json())
.then(data => {
if (data.success) {
alert('✅ Contraseña actualizada');
document.getElementById('new_password').value = '';
}
});
}
});
</script>
</body>
</html>