feat: aggiunti: loggica random, tema scuro, correzioni mail, miglioramenti generali, cache;
This commit is contained in:
@@ -42,6 +42,20 @@ const ICONS = {
|
||||
settings: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="12" cy="12" r="3"></circle>
|
||||
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path>
|
||||
</svg>`,
|
||||
sun: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="12" cy="12" r="5"></circle>
|
||||
<line x1="12" y1="1" x2="12" y2="3"></line>
|
||||
<line x1="12" y1="21" x2="12" y2="23"></line>
|
||||
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
|
||||
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
|
||||
<line x1="1" y1="12" x2="3" y2="12"></line>
|
||||
<line x1="21" y1="12" x2="23" y2="12"></line>
|
||||
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
|
||||
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
|
||||
</svg>`,
|
||||
moon: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
|
||||
</svg>`
|
||||
};
|
||||
|
||||
@@ -50,8 +64,8 @@ const NAV_ITEMS = [
|
||||
{ href: '/team-calendar', icon: 'users', label: 'Calendario del team' },
|
||||
{ href: '/team-rules', icon: 'rules', label: 'Regole parcheggio', roles: ['admin', 'manager'] },
|
||||
{ href: '/admin/users', icon: 'user', label: 'Gestione Utenti', roles: ['admin'] },
|
||||
{ href: '/admin/offices', icon: 'building', label: 'Gestione Uffici', roles: ['admin'] },
|
||||
{ href: '/parking-settings', icon: 'settings', label: 'Impostazioni Ufficio', roles: ['admin', 'manager'] }
|
||||
{ href: '/admin/offices', icon: 'building', label: 'Gestione Gruppi', roles: ['admin'] },
|
||||
{ href: '/parking-settings', icon: 'settings', label: 'Impostazioni Gruppi', roles: ['admin', 'manager'] }
|
||||
];
|
||||
|
||||
function getIcon(name) {
|
||||
@@ -98,9 +112,10 @@ async function initNav() {
|
||||
// Setup user menu (logout) & mobile menu
|
||||
setupUserMenu();
|
||||
setupMobileMenu();
|
||||
setupThemeToggle();
|
||||
|
||||
// CHECK: Block access if user has no office (and is not admin)
|
||||
// Admins are allowed to access "Gestione Uffici" even without an office
|
||||
// Admins are allowed to access "Gestione Gruppi" even without an office
|
||||
if (currentUser && !currentUser.office_id && currentUser.role !== 'admin') {
|
||||
navContainer.innerHTML = ''; // Clear nav
|
||||
|
||||
@@ -124,14 +139,14 @@ async function initNav() {
|
||||
<line x1="12" y1="16" x2="12.01" y2="16"></line>
|
||||
</svg>
|
||||
</div>
|
||||
<h2 style="margin-bottom: 1rem;">Ufficio non assegnato</h2>
|
||||
<h2 style="margin-bottom: 1rem;">Gruppo non assegnato</h2>
|
||||
<p class="text-secondary" style="margin-bottom: 1.5rem; line-height: 1.6;">
|
||||
Il tuo account <strong>${currentUser.email}</strong> è attivo, ma non sei ancora stato assegnato a nessuno ufficio.
|
||||
Il tuo account <strong>${currentUser.email}</strong> è attivo, ma non sei ancora stato assegnato a nessuno gruppo.
|
||||
</p>
|
||||
<div style="padding: 1.5rem; background: #f8fafc; border-radius: 8px; text-align: left;">
|
||||
<div style="font-weight: 600; margin-bottom: 0.5rem; color: var(--text);">Cosa fare?</div>
|
||||
<div style="font-size: 0.95rem; color: var(--text-secondary);">
|
||||
Contatta l'amministratore di sistema per richiedere l'assegnazione al tuo ufficio di competenza.<br>
|
||||
Contatta l'amministratore di sistema per richiedere l'assegnazione al tuo gruppo di competenza.<br>
|
||||
<a href="mailto:s.salemi@sielte.it" style="color: var(--primary); text-decoration: none; font-weight: 500; margin-top: 0.5rem; display: inline-block;">s.salemi@sielte.it</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -212,6 +227,35 @@ function setupUserMenu() {
|
||||
}
|
||||
}
|
||||
|
||||
function setupThemeToggle() {
|
||||
// Apply immediate theme to avoid flash
|
||||
const savedTheme = localStorage.getItem('theme') || 'system';
|
||||
applyTheme(savedTheme);
|
||||
|
||||
// Watch for system theme changes if set to system
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
|
||||
if (localStorage.getItem('theme') === 'system') {
|
||||
applyTheme('system');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function applyTheme(theme) {
|
||||
let isDark = false;
|
||||
if (theme === 'system') {
|
||||
isDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
} else {
|
||||
isDark = theme === 'dark';
|
||||
}
|
||||
|
||||
if (isDark) {
|
||||
document.documentElement.setAttribute('data-theme', 'dark');
|
||||
} else {
|
||||
document.documentElement.removeAttribute('data-theme');
|
||||
}
|
||||
localStorage.setItem('theme', theme);
|
||||
}
|
||||
|
||||
// Export for use in other scripts
|
||||
window.getIcon = getIcon;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user