refactor: modular admin panel with clean URLs
## Changes - Removed .html extension from URLs (/login, /admin) - Completely refactored admin.html with modular design - Common sidebar and topbar for all admin sections - Dynamic content loading via AJAX - Modern responsive design with Bootstrap 5 ## Admin Sections - Dashboard (statistics, recent items) - Properties (list with CRUD) - Leads (management) - Testimonials (CRUD) - FAQ (CRUD) - Services (CRUD) - Settings (site configuration) ## Technical - Clean URL routing: /login, /admin instead of .html - Session-based auth check on page load - Universal API client with auth methods - Single-page admin with dynamic sections ## URLs - Login: /login (was /login.html) - Admin: /admin (was /admin.html) - API: /api/auth/login, /api/admin/stats ## Tested ✅ /login returns correct page ✅ /admin returns correct page ✅ Login API works ✅ Session persists ✅ Admin sections load correctly
This commit is contained in:
Binary file not shown.
3251
public/admin-old.html
Normal file
3251
public/admin-old.html
Normal file
File diff suppressed because it is too large
Load Diff
3499
public/admin.html
3499
public/admin.html
File diff suppressed because it is too large
Load Diff
@@ -351,7 +351,7 @@
|
||||
if (res.ok) {
|
||||
const data = await res.json()
|
||||
if (data.success && data.data) {
|
||||
window.location.href = '/admin.html'
|
||||
window.location.href = '/admin'
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -450,7 +450,7 @@
|
||||
|
||||
// Redirect to admin
|
||||
setTimeout(() => {
|
||||
window.location.href = '/admin.html'
|
||||
window.location.href = '/admin'
|
||||
}, 500)
|
||||
} else {
|
||||
showAlert(data.error || 'Error al iniciar sesión. Verifique sus credenciales.')
|
||||
|
||||
@@ -1192,19 +1192,17 @@ app.get('/api/admin/stats', requireAdmin, (c) => {
|
||||
})
|
||||
})
|
||||
|
||||
// Serve static files and SPA routes
|
||||
// Serve static files and SPA routes (clean URLs without .html)
|
||||
app.get('/property/*', serveStatic({ path: './public/property.html' }))
|
||||
app.get('/admin/*', serveStatic({ path: './public/admin.html' }))
|
||||
app.get('/admin.html', serveStatic({ path: './public/admin.html' }))
|
||||
app.get('/login.html', serveStatic({ path: './public/login.html' }))
|
||||
app.get('/admin', serveStatic({ path: './public/admin.html' }))
|
||||
app.get('/login', serveStatic({ path: './public/login.html' }))
|
||||
app.get('/admin', (c) => c.redirect('/admin.html'))
|
||||
|
||||
// Serve index.html for all other routes
|
||||
// Fallback to index.html for all other routes
|
||||
app.get('*', serveStatic({ path: './public/index.html' }))
|
||||
|
||||
// Start server
|
||||
const port = parseInt(process.env.PORT || '8080')
|
||||
console.log(`🚀 Server running at http://localhost:${port}`)
|
||||
|
||||
export default { port, fetch: app.fetch }
|
||||
export default { port, fetch: app.fetch }
|
||||
|
||||
Reference in New Issue
Block a user