-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_generator.html
More file actions
355 lines (312 loc) · 17 KB
/
admin_generator.html
File metadata and controls
355 lines (312 loc) · 17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Administrador de Proyectos - Andecorp</title>
<!-- Bootstrap -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
<!-- Font Awesome -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet" />
<style>
body {
background-color: #f0f2f5;
font-family: 'Segoe UI', system-ui, sans-serif;
}
.container {
max-width: 950px;
}
.preview-img {
width: 80px;
height: 60px;
object-fit: cover;
border-radius: 4px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.card {
border: none;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
border-radius: 12px;
}
.card-header {
background: white;
border-bottom: 1px solid #eee;
padding: 1.5rem;
border-radius: 12px 12px 0 0 !important;
}
.nav-tabs .nav-link {
color: #6c757d;
border: none;
font-weight: 500;
}
.nav-tabs .nav-link.active {
color: #0d6efd;
border-bottom: 2px solid #0d6efd;
background: none;
}
.form-label {
font-size: 0.9rem;
font-weight: 600;
color: #344767;
}
.form-control:focus {
box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
border-color: #0d6efd;
}
</style>
</head>
<body class="py-5">
<div class="container">
<div class="text-center mb-5">
<h2 class="fw-bold text-dark">Panel de Gestión Andecorp</h2>
<p class="text-muted">Generador de archivo de datos para proyectos</p>
</div>
<div id="alertContainer"></div>
<div class="row">
<!-- Columna Formulario -->
<div class="col-lg-8">
<div class="card mb-4">
<div class="card-header d-flex justify-content-between align-items-center">
<h5 class="mb-0 text-primary fw-bold"><i class="fas fa-plus-circle me-2"></i>Nuevo Proyecto</h5>
<button type="button" id="clearForm"
class="btn btn-outline-secondary btn-sm rounded-pill px-3">Limpiar</button>
</div>
<div class="card-body">
<form id="projectForm">
<!-- Navegación Pasos -->
<ul class="nav nav-tabs mb-4" id="formTabs" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="basic-tab" data-bs-toggle="tab"
data-bs-target="#basic" type="button" role="tab">Básico</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="details-tab" data-bs-toggle="tab"
data-bs-target="#details" type="button" role="tab">Detalles</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="media-tab" data-bs-toggle="tab" data-bs-target="#media"
type="button" role="tab">Imágenes</button>
</li>
</ul>
<div class="tab-content" id="formTabsContent">
<!-- TAB 1: BÁSICO -->
<div class="tab-pane fade show active" id="basic" role="tabpanel">
<div class="row">
<div class="col-md-8 mb-3">
<label for="title" class="form-label">Título del Proyecto</label>
<input type="text" class="form-control" id="title" required
placeholder="Ej: Condominio Alto Bosque">
</div>
<div class="col-md-4 mb-3">
<label for="date" class="form-label">Fecha</label>
<input type="text" class="form-control" id="date" required
placeholder="Ej: Marzo 2025">
</div>
</div>
<div class="mb-3">
<label for="shortDescription" class="form-label">Descripción Corta
(Tarjeta)</label>
<textarea class="form-control" id="shortDescription" rows="3" required
placeholder="Breve resumen que aparece en la tarjeta del proyecto..."></textarea>
<div class="form-text">Máximo recomendado: 150 caracteres.</div>
</div>
</div>
<!-- TAB 2: DETALLES -->
<div class="tab-pane fade" id="details" role="tabpanel">
<div class="row">
<div class="col-md-6 mb-3">
<label for="client" class="form-label">Empresa Mandante</label>
<div class="input-group">
<span class="input-group-text bg-white"><i
class="fas fa-building text-muted"></i></span>
<input type="text" class="form-control" id="client"
placeholder="Ej: Constructora XYZ">
</div>
</div>
<div class="col-md-6 mb-3">
<label for="timeline" class="form-label">Plazo de Ejecución</label>
<div class="input-group">
<span class="input-group-text bg-white"><i
class="fas fa-clock text-muted"></i></span>
<input type="text" class="form-control" id="timeline"
placeholder="Ej: 12 Meses">
</div>
</div>
</div>
<div class="mb-3">
<label for="fullDescription" class="form-label">Descripción Completa</label>
<textarea class="form-control" id="fullDescription" rows="5"
placeholder="Historia completa del proyecto. Puede usar HTML básico como <br> para saltos de línea."></textarea>
</div>
<div class="mb-3">
<label for="solution" class="form-label">Solución Andecorp</label>
<textarea class="form-control" id="solution" rows="3"
placeholder="Detalles técnicos de la solución implementada (Andamios Front, Multifront, etc.)"></textarea>
</div>
</div>
<!-- TAB 3: MEDIA -->
<div class="tab-pane fade" id="media" role="tabpanel">
<div class="alert alert-info py-2 small">
<i class="fas fa-info-circle me-1"></i> Rutas relativas a:
<code>./img/10_proyectos/[zona]/[proyecto]/</code>
</div>
<div class="mb-4">
<label for="image" class="form-label">Imagen de Portada (Principal)</label>
<input type="text" class="form-control" id="image" required
value="./img/10_proyectos/zona/proyecto/portada.webp">
</div>
<div class="mb-3">
<label for="gallery" class="form-label">Galería de Imágenes</label>
<textarea class="form-control" id="gallery" rows="4"
placeholder="./img/10_proyectos/zona/proyecto/1.webp, ./img/10_proyectos/zona/proyecto/2.webp"></textarea>
<div class="form-text">Ingrese una ruta por línea o separadas por comas.</div>
</div>
</div>
</div>
<div class="d-grid gap-2 d-md-flex justify-content-md-end mt-4 pt-3 border-top">
<button type="submit" class="btn btn-primary px-4 rounded-pill fw-bold">
<i class="fas fa-plus me-2"></i>Agregar Proyecto
</button>
</div>
</form>
</div>
</div>
</div>
<!-- Columna Lista -->
<div class="col-lg-4">
<div class="card h-100">
<div class="card-header bg-dark text-white d-flex justify-content-between align-items-center">
<span class="fw-bold">Lista Actual</span>
<span class="badge bg-primary rounded-pill" id="projCount">0</span>
</div>
<div class="card-body p-0 d-flex flex-column">
<div class="table-responsive flex-grow-1" style="max-height: 500px; overflow-y: auto;">
<table class="table table-hover mb-0 align-middle small">
<tbody id="projectsTableBody">
<!-- JS Injection -->
</tbody>
</table>
</div>
<div class="p-3 border-top bg-light mt-auto">
<button id="downloadBtn" class="btn btn-success w-100 fw-bold shadow-sm">
<i class="fas fa-download me-2"></i>Descargar JS
</button>
<small class="d-block text-center text-muted mt-2" style="font-size: 0.75rem;">
Reemplazar archivo en <code>js/projectsData.js</code>
</small>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Logic -->
<script type="module">
import { projectsData as initialData } from './js/projectsData.js';
let currentProjects = [...initialData];
const form = document.getElementById('projectForm');
const tableBody = document.getElementById('projectsTableBody');
const downloadBtn = document.getElementById('downloadBtn');
const alertContainer = document.getElementById('alertContainer');
const countBadge = document.getElementById('projCount');
// Render Table
function renderTable() {
tableBody.innerHTML = '';
countBadge.textContent = currentProjects.length;
if (currentProjects.length === 0) {
tableBody.innerHTML = '<tr><td class="text-center text-muted py-4">Sin proyectos</td></tr>';
return;
}
currentProjects.forEach((proj, index) => {
const tr = document.createElement('tr');
tr.innerHTML = `
<td style="width: 60px;"><img src="${proj.image}" class="preview-img" alt="img" onerror="this.src='https://via.placeholder.com/80?text=Error'"></td>
<td>
<div class="fw-bold text-truncate" style="max-width: 150px;">${proj.title}</div>
<div class="text-muted" style="font-size: 0.75rem;">${proj.date}</div>
</td>
<td class="text-end">
<button class="btn btn-link text-danger p-0 delete-btn" data-index="${index}" title="Eliminar">
<i class="fas fa-trash-alt"></i>
</button>
</td>
`;
tableBody.appendChild(tr);
});
// Delete Event Listeners
document.querySelectorAll('.delete-btn').forEach(btn => {
btn.addEventListener('click', (e) => {
const idx = e.target.closest('button').dataset.index;
if (confirm("¿Eliminar este proyecto de la lista?")) {
currentProjects.splice(idx, 1);
renderTable();
}
});
});
}
// Add Project
form.addEventListener('submit', (e) => {
e.preventDefault();
// Proceso Galeria (soporta saltos de linea o comas)
const galleryRaw = document.getElementById('gallery').value;
const galleryArray = galleryRaw
.split(/[\n,]/) // Split by newline or comma
.map(s => s.trim())
.filter(s => s.length > 0);
const newProject = {
id: 'proj-' + Date.now(),
title: document.getElementById('title').value,
date: document.getElementById('date').value,
shortDescription: document.getElementById('shortDescription').value,
fullDescription: document.getElementById('fullDescription').value,
client: document.getElementById('client').value,
timeline: document.getElementById('timeline').value,
solution: document.getElementById('solution').value,
image: document.getElementById('image').value,
gallery: galleryArray
};
// Add to beginning of array (LIFO)
currentProjects.unshift(newProject);
renderTable();
form.reset();
// Show success alert
showAlert('Proyecto agreado exitosamente.', 'success');
// Reset tabs to first one
const firstTab = new bootstrap.Tab(document.querySelector('#formTabs button:first-child'));
firstTab.show();
});
// Download File
downloadBtn.addEventListener('click', () => {
const fileContent = `export const projectsData = ${JSON.stringify(currentProjects, null, 4)};\n`;
const blob = new Blob([fileContent], { type: 'text/javascript' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'projectsData.js';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
showAlert('Archivo generado. Recuerde subirlo al servidor.', 'info');
});
// Helper Alert
function showAlert(msg, type) {
alertContainer.innerHTML = `
<div class="alert alert-${type} alert-dismissible fade show shadow-sm" role="alert">
<i class="fas fa-check-circle me-2"></i>${msg}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
`;
setTimeout(() => {
const alert = bootstrap.Alert.getInstance(alertContainer.querySelector('.alert'));
if (alert) alert.close();
}, 4000);
}
document.getElementById('clearForm').addEventListener('click', () => form.reset());
// Initial Render
renderTable();
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>