You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.8 KiB
62 lines
2.8 KiB
from nicegui import ui |
|
from contextlib import contextmanager |
|
|
|
class AdminLayout: |
|
def __init__(self): |
|
self.sidebar_open = True |
|
|
|
@contextmanager |
|
def render_layout(self): |
|
"""Render the main admin layout""" |
|
with ui.column().classes('min-h-screen bg-gray-50'): |
|
self._render_header() |
|
with ui.row().classes('flex-1 w-full'): |
|
self._render_sidebar() |
|
with ui.column().classes('flex-1 p-6'): |
|
yield |
|
|
|
def _render_header(self): |
|
"""Render top navigation header""" |
|
with ui.header().classes('bg-green-600 text-white shadow-lg'): |
|
with ui.row().classes('w-full justify-between items-center px-4'): |
|
with ui.row().classes('items-center gap-4'): |
|
ui.button(icon='menu', on_click=self._toggle_sidebar).props('flat round') |
|
ui.label('Simple Mensa Admin').classes('text-xl font-bold') |
|
|
|
with ui.row().classes('items-center gap-2'): |
|
ui.button(icon='notifications', on_click=lambda: ui.notify('Nessuna notifica')).props('flat round') |
|
with ui.dropdown_button('Admin', icon='account_circle').props('flat'): |
|
ui.item('Profilo', on_click=lambda: ui.notify('Profilo')) |
|
ui.item('Impostazioni', on_click=lambda: ui.notify('Impostazioni')) |
|
ui.separator() |
|
ui.item('Logout', on_click=self._logout) |
|
|
|
def _render_sidebar(self): |
|
"""Render navigation sidebar""" |
|
with ui.column().classes('w-64 bg-white shadow-lg border-r min-h-full' if self.sidebar_open else 'w-0 overflow-hidden'): |
|
with ui.column().classes('p-4 space-y-2'): |
|
self._nav_item('Dashboard', '/', 'dashboard', active=True) |
|
self._nav_item('Pietanze', '/pietanze', 'restaurant_menu') |
|
self._nav_item('Menu Giornalieri', '/pasti', 'calendar_today') |
|
self._nav_item('Prenotazioni', '/prenotazioni', 'book_online') |
|
self._nav_item('Analytics', '/analytics', 'analytics') |
|
|
|
def _nav_item(self, label: str, path: str, icon: str, active: bool = False): |
|
"""Render navigation item""" |
|
classes = 'w-full justify-start gap-3 p-3 rounded-lg' |
|
if active: |
|
classes += ' bg-green-100 text-green-700' |
|
else: |
|
classes += ' hover:bg-gray-100' |
|
|
|
ui.button(label, icon=icon, on_click=lambda: ui.navigate.to(path)).classes(classes) |
|
|
|
def _toggle_sidebar(self): |
|
"""Toggle sidebar visibility""" |
|
self.sidebar_open = not self.sidebar_open |
|
ui.update() |
|
|
|
def _logout(self): |
|
"""Handle logout""" |
|
ui.navigate.to('/login') |
|
ui.notify('Disconnesso con successo')
|
|
|