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.
 

80 lines
2.1 KiB

from nicegui import ui, app
import yaml
from pathlib import Path
from services.auth_service import AuthService
from services.api_client import APIClient
from pages.login import LoginPage
from pages.dashboard import DashboardPage
from pages.pietanze import PietanzePage
from components.layout import AdminLayout
# Load configuration
config_path = Path(__file__).parent / "config.yaml"
with open(config_path, 'r', encoding='utf-8') as f:
config = yaml.safe_load(f)
# Initialize services
auth_service = AuthService(config['auth'])
api_client = APIClient(config['api']['base_url'])
# Global layout instance
admin_layout = AdminLayout()
@ui.page('/')
def index():
"""Main dashboard page"""
if not auth_service.is_authenticated():
ui.navigate.to('/login')
return
with admin_layout.render_layout():
dashboard = DashboardPage(api_client)
dashboard.render()
@ui.page('/login')
def login():
"""Login page"""
login_page = LoginPage(auth_service)
login_page.render()
@ui.page('/pietanze')
def pietanze():
"""Pietanze management page"""
if not auth_service.is_authenticated():
ui.navigate.to('/login')
return
with admin_layout.render_layout():
pietanze_page = PietanzePage(api_client)
pietanze_page.render()
@ui.page('/pasti')
def pasti():
"""Pasti management page (placeholder)"""
if not auth_service.is_authenticated():
ui.navigate.to('/login')
return
with admin_layout.render_layout():
ui.label('Gestione Pasti - In sviluppo')
@ui.page('/prenotazioni')
def prenotazioni():
"""Prenotazioni management page (placeholder)"""
if not auth_service.is_authenticated():
ui.navigate.to('/login')
return
with admin_layout.render_layout():
ui.label('Gestione Prenotazioni - In sviluppo')
if __name__ in {"__main__", "__mp_main__"}:
# Configure app
app.add_static_files('/static', Path(__file__).parent / 'static')
ui.run(
title=config['app']['title'],
port=config['app']['port'],
reload=config['app']['debug'],
show=config['app']['debug']
)