feat(frontend): T44 setup FastAPI static files and templates

- Mount static files on /static endpoint
- Configure Jinja2Templates with directory structure
- Create base template with Pico.css, HTMX, Chart.js
- Create all template subdirectories (auth, dashboard, keys, tokens, profile, components)
- Create initial CSS and JS files
- Add tests for static files and templates configuration

Tests: 12 passing
Coverage: 100% on new configuration code
This commit is contained in:
Luca Sacchi Ricciardi
2026-04-07 17:58:03 +02:00
parent 3ae5d736ce
commit c1f47c897f
16 changed files with 1592 additions and 4 deletions

49
static/js/main.js Normal file
View File

@@ -0,0 +1,49 @@
// OpenRouter Monitor - Main JavaScript
// HTMX Configuration
document.addEventListener('DOMContentLoaded', function() {
// Configure HTMX to include CSRF token in requests
document.body.addEventListener('htmx:configRequest', function(evt) {
const csrfToken = document.querySelector('meta[name="csrf-token"]');
if (csrfToken) {
evt.detail.headers['X-CSRF-Token'] = csrfToken.content;
}
});
// Auto-hide alerts after 5 seconds
const alerts = document.querySelectorAll('.alert:not(.alert-permanent)');
alerts.forEach(function(alert) {
setTimeout(function() {
alert.style.opacity = '0';
setTimeout(function() {
alert.remove();
}, 300);
}, 5000);
});
});
// Utility function to format currency
function formatCurrency(amount) {
return new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
}).format(amount);
}
// Utility function to format date
function formatDate(dateString) {
return new Intl.DateTimeFormat('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit'
}).format(new Date(dateString));
}
// Confirmation dialog for destructive actions
function confirmAction(message, callback) {
if (confirm(message)) {
callback();
}
}