Spaces:
Sleeping
Sleeping
Update modules/ui/ui.py
Browse files- modules/ui/ui.py +36 -21
modules/ui/ui.py
CHANGED
|
@@ -19,6 +19,8 @@ from translations import get_translations
|
|
| 19 |
|
| 20 |
from ..studentact.student_activities_v2 import display_student_activities
|
| 21 |
|
|
|
|
|
|
|
| 22 |
from ..auth.auth import authenticate_user, authenticate_student, authenticate_admin
|
| 23 |
|
| 24 |
from ..admin.admin_ui import admin_page
|
|
@@ -408,6 +410,7 @@ def user_page(lang_code, t):
|
|
| 408 |
# Inicializar estados para todos los tabs
|
| 409 |
if 'tab_states' not in st.session_state:
|
| 410 |
st.session_state.tab_states = {
|
|
|
|
| 411 |
'morpho_active': False,
|
| 412 |
'semantic_live_active': False,
|
| 413 |
'semantic_active': False,
|
|
@@ -419,6 +422,7 @@ def user_page(lang_code, t):
|
|
| 419 |
|
| 420 |
# Sistema de tabs
|
| 421 |
tab_names = [
|
|
|
|
| 422 |
t.get('morpho_tab', 'Análisis Morfosintáctico'),
|
| 423 |
t.get('semantic_live_tab', 'Análisis Semántico Vivo'),
|
| 424 |
t.get('semantic_tab', 'Análisis Semántico'),
|
|
@@ -444,7 +448,15 @@ def user_page(lang_code, t):
|
|
| 444 |
if can_switch:
|
| 445 |
st.session_state.selected_tab = index
|
| 446 |
|
| 447 |
-
if index == 0: #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 448 |
st.session_state.tab_states['morpho_active'] = True
|
| 449 |
display_morphosyntax_interface(
|
| 450 |
st.session_state.lang_code,
|
|
@@ -452,7 +464,8 @@ def user_page(lang_code, t):
|
|
| 452 |
t.get('TRANSLATIONS', {})
|
| 453 |
)
|
| 454 |
|
| 455 |
-
|
|
|
|
| 456 |
st.session_state.tab_states['semantic_live_active'] = True
|
| 457 |
display_semantic_live_interface(
|
| 458 |
st.session_state.lang_code,
|
|
@@ -460,7 +473,7 @@ def user_page(lang_code, t):
|
|
| 460 |
t.get('TRANSLATIONS', {})
|
| 461 |
)
|
| 462 |
|
| 463 |
-
elif index ==
|
| 464 |
st.session_state.tab_states['semantic_active'] = True
|
| 465 |
display_semantic_interface(
|
| 466 |
st.session_state.lang_code,
|
|
@@ -468,7 +481,7 @@ def user_page(lang_code, t):
|
|
| 468 |
t.get('TRANSLATIONS', {})
|
| 469 |
)
|
| 470 |
|
| 471 |
-
elif index ==
|
| 472 |
st.session_state.tab_states['discourse_live_active'] = True
|
| 473 |
display_discourse_live_interface(
|
| 474 |
st.session_state.lang_code,
|
|
@@ -477,7 +490,7 @@ def user_page(lang_code, t):
|
|
| 477 |
)
|
| 478 |
|
| 479 |
|
| 480 |
-
elif index ==
|
| 481 |
st.session_state.tab_states['discourse_active'] = True
|
| 482 |
display_discourse_interface(
|
| 483 |
st.session_state.lang_code,
|
|
@@ -485,7 +498,7 @@ def user_page(lang_code, t):
|
|
| 485 |
t.get('TRANSLATIONS', {})
|
| 486 |
)
|
| 487 |
|
| 488 |
-
elif index ==
|
| 489 |
st.session_state.tab_states['activities_active'] = True
|
| 490 |
display_student_activities(
|
| 491 |
username=st.session_state.username,
|
|
@@ -493,7 +506,7 @@ def user_page(lang_code, t):
|
|
| 493 |
t=t.get('ACTIVITIES_TRANSLATIONS', {})
|
| 494 |
)
|
| 495 |
|
| 496 |
-
elif index ==
|
| 497 |
st.session_state.tab_states['feedback_active'] = True
|
| 498 |
display_feedback_form(
|
| 499 |
st.session_state.lang_code,
|
|
@@ -512,26 +525,28 @@ def user_page(lang_code, t):
|
|
| 512 |
def get_tab_index(state_key):
|
| 513 |
"""Obtiene el índice del tab basado en la clave de estado"""
|
| 514 |
index_map = {
|
| 515 |
-
'
|
| 516 |
-
'
|
| 517 |
-
'
|
| 518 |
-
'
|
| 519 |
-
'
|
| 520 |
-
'
|
| 521 |
-
'
|
|
|
|
| 522 |
}
|
| 523 |
return index_map.get(state_key, -1)
|
| 524 |
|
| 525 |
def get_state_key_for_index(index):
|
| 526 |
"""Obtiene la clave de estado basada en el índice del tab"""
|
| 527 |
state_map = {
|
| 528 |
-
0: '
|
| 529 |
-
1: '
|
| 530 |
-
2: '
|
| 531 |
-
3: '
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
|
|
|
| 535 |
}
|
| 536 |
return state_map.get(index)
|
| 537 |
|
|
|
|
| 19 |
|
| 20 |
from ..studentact.student_activities_v2 import display_student_activities
|
| 21 |
|
| 22 |
+
from ..studentact.current_situation_interface import display_current_situation_interface
|
| 23 |
+
|
| 24 |
from ..auth.auth import authenticate_user, authenticate_student, authenticate_admin
|
| 25 |
|
| 26 |
from ..admin.admin_ui import admin_page
|
|
|
|
| 410 |
# Inicializar estados para todos los tabs
|
| 411 |
if 'tab_states' not in st.session_state:
|
| 412 |
st.session_state.tab_states = {
|
| 413 |
+
'current_situation_active': False,
|
| 414 |
'morpho_active': False,
|
| 415 |
'semantic_live_active': False,
|
| 416 |
'semantic_active': False,
|
|
|
|
| 422 |
|
| 423 |
# Sistema de tabs
|
| 424 |
tab_names = [
|
| 425 |
+
t.get('current_situation_tab', "Mi Situación Actual"),
|
| 426 |
t.get('morpho_tab', 'Análisis Morfosintáctico'),
|
| 427 |
t.get('semantic_live_tab', 'Análisis Semántico Vivo'),
|
| 428 |
t.get('semantic_tab', 'Análisis Semántico'),
|
|
|
|
| 448 |
if can_switch:
|
| 449 |
st.session_state.selected_tab = index
|
| 450 |
|
| 451 |
+
if index == 0: # Situación actual
|
| 452 |
+
st.session_state.tab_states['current_situation_active'] = True
|
| 453 |
+
display_current_situation_interface(
|
| 454 |
+
st.session_state.lang_code,
|
| 455 |
+
st.session_state.nlp_models,
|
| 456 |
+
t.get('TRANSLATIONS', {})
|
| 457 |
+
)
|
| 458 |
+
|
| 459 |
+
elif index == 1: # Morfosintáctico
|
| 460 |
st.session_state.tab_states['morpho_active'] = True
|
| 461 |
display_morphosyntax_interface(
|
| 462 |
st.session_state.lang_code,
|
|
|
|
| 464 |
t.get('TRANSLATIONS', {})
|
| 465 |
)
|
| 466 |
|
| 467 |
+
|
| 468 |
+
elif index == 2: # Semántico Vivo
|
| 469 |
st.session_state.tab_states['semantic_live_active'] = True
|
| 470 |
display_semantic_live_interface(
|
| 471 |
st.session_state.lang_code,
|
|
|
|
| 473 |
t.get('TRANSLATIONS', {})
|
| 474 |
)
|
| 475 |
|
| 476 |
+
elif index == 3: # Semántico
|
| 477 |
st.session_state.tab_states['semantic_active'] = True
|
| 478 |
display_semantic_interface(
|
| 479 |
st.session_state.lang_code,
|
|
|
|
| 481 |
t.get('TRANSLATIONS', {})
|
| 482 |
)
|
| 483 |
|
| 484 |
+
elif index == 4: # Discurso Vivo
|
| 485 |
st.session_state.tab_states['discourse_live_active'] = True
|
| 486 |
display_discourse_live_interface(
|
| 487 |
st.session_state.lang_code,
|
|
|
|
| 490 |
)
|
| 491 |
|
| 492 |
|
| 493 |
+
elif index == 5: # Discurso
|
| 494 |
st.session_state.tab_states['discourse_active'] = True
|
| 495 |
display_discourse_interface(
|
| 496 |
st.session_state.lang_code,
|
|
|
|
| 498 |
t.get('TRANSLATIONS', {})
|
| 499 |
)
|
| 500 |
|
| 501 |
+
elif index == 6: # Actividades
|
| 502 |
st.session_state.tab_states['activities_active'] = True
|
| 503 |
display_student_activities(
|
| 504 |
username=st.session_state.username,
|
|
|
|
| 506 |
t=t.get('ACTIVITIES_TRANSLATIONS', {})
|
| 507 |
)
|
| 508 |
|
| 509 |
+
elif index == 7: # Feedback
|
| 510 |
st.session_state.tab_states['feedback_active'] = True
|
| 511 |
display_feedback_form(
|
| 512 |
st.session_state.lang_code,
|
|
|
|
| 525 |
def get_tab_index(state_key):
|
| 526 |
"""Obtiene el índice del tab basado en la clave de estado"""
|
| 527 |
index_map = {
|
| 528 |
+
'current_situation_active': 0,
|
| 529 |
+
'morpho_active': 1,
|
| 530 |
+
'semantic_live_active': 2,
|
| 531 |
+
'semantic_active': 3,
|
| 532 |
+
'discourse_live_active': 4,
|
| 533 |
+
'discourse_active': 5,
|
| 534 |
+
'activities_active': 6,
|
| 535 |
+
'feedback_active': 7
|
| 536 |
}
|
| 537 |
return index_map.get(state_key, -1)
|
| 538 |
|
| 539 |
def get_state_key_for_index(index):
|
| 540 |
"""Obtiene la clave de estado basada en el índice del tab"""
|
| 541 |
state_map = {
|
| 542 |
+
0: 'current_situation_active'
|
| 543 |
+
1: 'morpho_active',
|
| 544 |
+
2: 'semantic_live_active',
|
| 545 |
+
3: 'semantic_active',
|
| 546 |
+
4: 'discourse_live_active',
|
| 547 |
+
5: 'discourse_active',
|
| 548 |
+
6: 'activities_active',
|
| 549 |
+
7: 'feedback_active'
|
| 550 |
}
|
| 551 |
return state_map.get(index)
|
| 552 |
|