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:
TenerifeProp Dev
2026-04-06 01:24:37 +01:00
parent 659b749a61
commit 1dd901dd4f
5 changed files with 3569 additions and 3195 deletions

Binary file not shown.

3251
public/admin-old.html Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -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.')

View File

@@ -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 }