Update modules/ui/router.py
Browse files- modules/ui/router.py +11 -6
modules/ui/router.py
CHANGED
|
@@ -25,28 +25,33 @@ def create_router():
|
|
| 25 |
with gr.Blocks(css="footer {display: none}") as app:
|
| 26 |
# Contenedores para cada vista
|
| 27 |
with gr.Group(visible=True) as landing_container:
|
| 28 |
-
landing_view = create_landing_view()
|
| 29 |
|
| 30 |
with gr.Group(visible=False) as login_container:
|
| 31 |
-
login_view = create_login_view()
|
| 32 |
|
| 33 |
with gr.Group(visible=False) as dashboard_container:
|
| 34 |
-
dashboard_view = create_dashboard_view()
|
| 35 |
|
| 36 |
# Configurar navegaci贸n
|
| 37 |
def handle_navigation(view_name, **kwargs):
|
| 38 |
return router.switch_view(view_name, **kwargs)
|
| 39 |
|
| 40 |
# Conectar eventos de navegaci贸n
|
| 41 |
-
|
| 42 |
fn=lambda: handle_navigation("login"),
|
| 43 |
outputs=[landing_container, login_container, dashboard_container]
|
| 44 |
)
|
| 45 |
|
| 46 |
-
|
| 47 |
fn=lambda username, role: handle_navigation("dashboard", username=username, role=role),
|
| 48 |
inputs=[login_view.username, login_view.role],
|
| 49 |
outputs=[landing_container, login_container, dashboard_container]
|
| 50 |
)
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
with gr.Blocks(css="footer {display: none}") as app:
|
| 26 |
# Contenedores para cada vista
|
| 27 |
with gr.Group(visible=True) as landing_container:
|
| 28 |
+
landing_view, start_button = create_landing_view()
|
| 29 |
|
| 30 |
with gr.Group(visible=False) as login_container:
|
| 31 |
+
login_view, login_button = create_login_view()
|
| 32 |
|
| 33 |
with gr.Group(visible=False) as dashboard_container:
|
| 34 |
+
dashboard_view, logout_button = create_dashboard_view()
|
| 35 |
|
| 36 |
# Configurar navegaci贸n
|
| 37 |
def handle_navigation(view_name, **kwargs):
|
| 38 |
return router.switch_view(view_name, **kwargs)
|
| 39 |
|
| 40 |
# Conectar eventos de navegaci贸n
|
| 41 |
+
start_button.click(
|
| 42 |
fn=lambda: handle_navigation("login"),
|
| 43 |
outputs=[landing_container, login_container, dashboard_container]
|
| 44 |
)
|
| 45 |
|
| 46 |
+
login_button.click(
|
| 47 |
fn=lambda username, role: handle_navigation("dashboard", username=username, role=role),
|
| 48 |
inputs=[login_view.username, login_view.role],
|
| 49 |
outputs=[landing_container, login_container, dashboard_container]
|
| 50 |
)
|
| 51 |
|
| 52 |
+
logout_button.click(
|
| 53 |
+
fn=lambda: handle_navigation("landing"),
|
| 54 |
+
outputs=[landing_container, login_container, dashboard_container]
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
return app
|