Modularización de GKACHELE SaaS
This commit is contained in:
178
demo/templates/admin.html
Normal file
178
demo/templates/admin.html
Normal file
@@ -0,0 +1,178 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Admin - Demo</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background: #f5f5f5;
|
||||
padding: 20px;
|
||||
}
|
||||
.header {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
background: white;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
th, td {
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
th {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
}
|
||||
.btn {
|
||||
padding: 5px 15px;
|
||||
background: #4caf50;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h1>🔧 Panel Admin</h1>
|
||||
</div>
|
||||
|
||||
<h2>Solicitudes Pendientes</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Slug</th>
|
||||
<th>Email Cliente</th>
|
||||
<th>Fecha</th>
|
||||
<th>Acción</th>
|
||||
</tr>
|
||||
{% for req in requests %}
|
||||
<tr>
|
||||
<td>{{ req.id }}</td>
|
||||
<td>{{ req.slug }}</td>
|
||||
<td>{{ req.email }}</td>
|
||||
<td>{{ req.created_at }}</td>
|
||||
<td>
|
||||
<button class="btn" onclick="approve({{ req.id }})">✅ Aprobar</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if not requests %}
|
||||
<tr><td colspan="5">No hay solicitudes pendientes</td></tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
|
||||
<h2>👥 Usuarios Registrados</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Email</th>
|
||||
<th>Plan</th>
|
||||
<th>Rubro</th>
|
||||
<th>Sitios</th>
|
||||
<th>Publicados</th>
|
||||
<th>Solicitudes</th>
|
||||
<th>Fecha</th>
|
||||
<th>Acción</th>
|
||||
</tr>
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td>{{ user.id }}</td>
|
||||
<td>{{ user.email }}</td>
|
||||
<td>{{ user.plan }}</td>
|
||||
<td>{{ user.rubro }}</td>
|
||||
<td>{{ user.num_sitios }}</td>
|
||||
<td>{{ user.sitios_publicados }}</td>
|
||||
<td>{{ user.num_solicitudes }}</td>
|
||||
<td>{{ user.created_at[:10] if user.created_at else 'N/A' }}</td>
|
||||
<td>
|
||||
{% if user.id != 1 %}
|
||||
<button class="btn-danger" onclick="deleteUser({{ user.id }}, '{{ user.email }}')">🗑️ Eliminar</button>
|
||||
{% else %}
|
||||
<span style="color: #999;">Admin Principal</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if not users %}
|
||||
<tr><td colspan="9">No hay usuarios registrados</td></tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
|
||||
<h2>🌐 Todos los Sitios</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Slug</th>
|
||||
<th>Tema</th>
|
||||
<th>Status</th>
|
||||
<th>Ver</th>
|
||||
</tr>
|
||||
{% for site in sites %}
|
||||
<tr>
|
||||
<td>{{ site.id }}</td>
|
||||
<td>{{ site.slug }}</td>
|
||||
<td>{{ site.theme }}</td>
|
||||
<td>{{ site.status }}</td>
|
||||
<td>
|
||||
{% if site.status == 'published' %}
|
||||
<a href="/site/{{ site.slug }}" target="_blank">Ver</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<style>
|
||||
.btn-danger {
|
||||
background: #d63638;
|
||||
color: white;
|
||||
}
|
||||
.btn-danger:hover {
|
||||
background: #b32d2e;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
function approve(requestId) {
|
||||
if (confirm('¿Aprobar este sitio?')) {
|
||||
fetch(`/admin/approve/${requestId}`, {method: 'POST'})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('✅ Sitio aprobado');
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function deleteUser(userId, email) {
|
||||
if (confirm(`⚠️ ¿Eliminar usuario ${userId} (${email})?\n\nEsto eliminará TODOS sus datos:\n- Sitios\n- Menús\n- Widgets\n- Media\n- Solicitudes\n\nEsta acción NO se puede deshacer.`)) {
|
||||
fetch(`/admin/users/delete/${userId}`, {method: 'POST'})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('✅ Usuario eliminado exitosamente');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('❌ Error: ' + (data.error || 'Error al eliminar'));
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
alert('❌ Error: ' + err);
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user