AIdeaText commited on
Commit
c53c31f
verified
1 Parent(s): f6bbcfd

Update modules/ui/ui.py

Browse files
Files changed (1) hide show
  1. modules/ui/ui.py +68 -51
modules/ui/ui.py CHANGED
@@ -75,31 +75,52 @@ def main():
75
  #############################################################
76
  #############################################################
77
  def login_register_page(lang_code, t):
78
- # st.title("AIdeaText")
79
- # st.write(t.get("welcome_message", "Bienvenido. Por favor, inicie sesi贸n o reg铆strese."))
80
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  left_column, right_column = st.columns([1, 3])
82
 
83
  with left_column:
84
- tab1, tab2 = st.tabs([t.get("login", "Iniciar Sesi贸n"),
85
- t.get("register", "Registrarse")])
86
 
87
  with tab1:
88
- login_form(lang_code, t)
89
 
90
  with tab2:
91
- register_form(lang_code, t)
92
 
93
  with right_column:
94
- display_videos_and_info(lang_code, t)
95
 
96
  #############################################################
97
  #############################################################
98
- def login_form(lang_code, t):
99
  with st.form("login_form"):
100
- username = st.text_input(t.get("email", "Correo electr贸nico"))
101
- password = st.text_input(t.get("password", "Contrase帽a"), type="password")
102
- submit_button = st.form_submit_button(t.get("login", "Iniciar Sesi贸n"))
103
 
104
  if submit_button:
105
  success, role = authenticate_user(username, password)
@@ -114,44 +135,43 @@ def login_form(lang_code, t):
114
  logger.info(f"Usuario autenticado: {username}, Rol: {role}")
115
  st.rerun()
116
  else:
117
- st.error(t.get("invalid_credentials", "Credenciales incorrectas"))
118
 
119
 
120
  #############################################################
121
  #############################################################
122
- def register_form(lang_code, t):
123
- # st.header(t.get("request_trial", "Solicitar prueba de la aplicaci贸n"))
124
- name = st.text_input(t.get("name", "Nombre"))
125
- lastname = st.text_input(t.get("lastname", "Apellidos"))
126
- institution = st.text_input(t.get("institution", "Instituci贸n"))
127
- current_role = st.selectbox(t.get("current_role", "Rol en la instituci贸n donde labora"),
128
- [t.get("professor", "Profesor"), t.get("student", "Estudiante"), t.get("administrative", "Administrativo")])
129
 
130
  # Definimos el rol por defecto como estudiante
131
- desired_role = t.get("student", "Estudiante")
132
 
133
- email = st.text_input(t.get("institutional_email", "Correo electr贸nico de su instituci贸n"))
134
- reason = st.text_area(t.get("interest_reason", "驴Por qu茅 est谩s interesado en probar AIdeaText?"))
135
 
136
- if st.button(t.get("submit_application", "Enviar solicitud")):
137
- logger.info(f"Attempting to submit application for {email}")
138
- logger.debug(f"Form data: name={name}, lastname={lastname}, email={email}, institution={institution}, current_role={current_role}, desired_role={desired_role}, reason={reason}")
139
 
140
  if not name or not lastname or not email or not institution or not reason:
141
- logger.warning("Incomplete form submission")
142
- st.error(t.get("complete_all_fields", "Por favor, completa todos los campos."))
143
  elif not is_institutional_email(email):
144
- logger.warning(f"Non-institutional email used: {email}")
145
- st.error(t.get("use_institutional_email", "Por favor, utiliza un correo electr贸nico institucional."))
146
  else:
147
- logger.info(f"Attempting to store application for {email}")
148
  success = store_application_request(name, lastname, email, institution, current_role, desired_role, reason)
149
  if success:
150
- st.success(t.get("application_sent", "Tu solicitud ha sido enviada. Te contactaremos pronto."))
151
- logger.info(f"Application request stored successfully for {email}")
152
  else:
153
- st.error(t.get("application_error", "Hubo un problema al enviar tu solicitud. Por favor, intenta de nuevo m谩s tarde."))
154
- logger.error(f"Failed to store application request for {email}")
155
 
156
 
157
  #############################################################
@@ -163,17 +183,17 @@ def is_institutional_email(email):
163
 
164
  #############################################################
165
  #############################################################
166
- def display_videos_and_info(lang_code, t):
167
  # Crear tabs para cada secci贸n
168
  tab_use_case, tab_videos, tab_events, tab_gallery, tab_news = st.tabs([
169
- "Casos de uso",
170
- "Videos de presentaciones",
171
- "Ponencias acad茅micas",
172
- "Fotos de eventos",
173
- "Control de versiones"
174
  ])
175
 
176
- # Tab de Casos de uso
177
  with tab_use_case:
178
  use_case_videos = {
179
  "English - Radar use chart": "https://youtu.be/fFbbtlIewgs",
@@ -187,7 +207,7 @@ def display_videos_and_info(lang_code, t):
187
  "Espa帽ol - Uso del bot para buscar respuestas" : "https://www.youtube.com/watch?v=GFKDS0K2s7E"
188
  }
189
 
190
- selected_title = st.selectbox("Selecciona un caso de uso en espa帽ol o en ingl茅s:", list(use_case_videos.keys()))
191
  if selected_title in use_case_videos:
192
  try:
193
  st_player(use_case_videos[selected_title])
@@ -206,7 +226,7 @@ def display_videos_and_info(lang_code, t):
206
  "Demo de la versi贸n de escritorio.": "https://www.youtube.com/watch?v=nP6eXbog-ZY"
207
  }
208
 
209
- selected_title = st.selectbox("Selecciona una conferencia:", list(videos.keys()))
210
  if selected_title in videos:
211
  try:
212
  st_player(videos[selected_title])
@@ -297,14 +317,11 @@ def display_videos_and_info(lang_code, t):
297
 
298
 
299
  # Tab de Novedades
 
300
  with tab_news:
301
- st.markdown("""
302
- ### Novedades de la versi贸n actual
303
- - Interfaz mejorada para una mejor experiencia de usuario
304
- - Optimizaci贸n del an谩lisis morfosint谩ctico
305
- - Soporte para m煤ltiples idiomas
306
- - Nuevo m贸dulo de an谩lisis del discurso
307
- - Sistema de chat integrado para soporte
308
  """)
309
 
310
  # Definici贸n de __all__ para especificar qu茅 se exporta
 
75
  #############################################################
76
  #############################################################
77
  def login_register_page(lang_code, t):
78
+ # Obtener traducciones espec铆ficas para landing page
79
+ from landing_translations import get_landing_translations
80
+ landing_t = get_landing_translations(lang_code)
81
+
82
+ # Language selection dropdown at the top
83
+ languages = {'Espa帽ol': 'es', 'English': 'en', 'Fran莽ais': 'fr', 'Portugu锚s': 'pt'}
84
+
85
+ # Create a container for the language selector with styling
86
+ with st.container():
87
+ col1, col2 = st.columns([3, 1])
88
+ with col1:
89
+ st.title("AIdeaText")
90
+ with col2:
91
+ selected_lang = st.selectbox(
92
+ landing_t['select_language'],
93
+ list(languages.keys()),
94
+ index=list(languages.values()).index(lang_code),
95
+ key=f"landing_language_selector_{lang_code}"
96
+ )
97
+ new_lang_code = languages[selected_lang]
98
+ if lang_code != new_lang_code:
99
+ st.session_state.lang_code = new_lang_code
100
+ st.rerun()
101
+
102
+ # Main content with columns
103
  left_column, right_column = st.columns([1, 3])
104
 
105
  with left_column:
106
+ tab1, tab2 = st.tabs([landing_t['login'], landing_t['register']])
 
107
 
108
  with tab1:
109
+ login_form(lang_code, landing_t)
110
 
111
  with tab2:
112
+ register_form(lang_code, landing_t)
113
 
114
  with right_column:
115
+ display_videos_and_info(lang_code, landing_t)
116
 
117
  #############################################################
118
  #############################################################
119
+ def login_form(lang_code, landing_t):
120
  with st.form("login_form"):
121
+ username = st.text_input(landing_t['email'])
122
+ password = st.text_input(landing_t['password'], type="password")
123
+ submit_button = st.form_submit_button(landing_t['login_button'])
124
 
125
  if submit_button:
126
  success, role = authenticate_user(username, password)
 
135
  logger.info(f"Usuario autenticado: {username}, Rol: {role}")
136
  st.rerun()
137
  else:
138
+ st.error(landing_t['invalid_credentials'])
139
 
140
 
141
  #############################################################
142
  #############################################################
143
+ def register_form(lang_code, landing_t):
144
+ name = st.text_input(landing_t['name'])
145
+ lastname = st.text_input(landing_t['lastname'])
146
+ institution = st.text_input(landing_t['institution'])
147
+ current_role = st.selectbox(landing_t['current_role'],
148
+ [landing_t['professor'], landing_t['student'], landing_t['administrative']])
 
149
 
150
  # Definimos el rol por defecto como estudiante
151
+ desired_role = landing_t['student']
152
 
153
+ email = st.text_input(landing_t['institutional_email'])
154
+ reason = st.text_area(landing_t['interest_reason'])
155
 
156
+ if st.button(landing_t['submit_application']):
157
+ logger.info(f"Intentando enviar solicitud para {email}")
158
+ logger.debug(f"Datos del formulario: name={name}, lastname={lastname}, email={email}, institution={institution}, current_role={current_role}, desired_role={desired_role}, reason={reason}")
159
 
160
  if not name or not lastname or not email or not institution or not reason:
161
+ logger.warning("Env铆o de formulario incompleto")
162
+ st.error(landing_t['complete_all_fields'])
163
  elif not is_institutional_email(email):
164
+ logger.warning(f"Email no institucional utilizado: {email}")
165
+ st.error(landing_t['use_institutional_email'])
166
  else:
167
+ logger.info(f"Intentando almacenar solicitud para {email}")
168
  success = store_application_request(name, lastname, email, institution, current_role, desired_role, reason)
169
  if success:
170
+ st.success(landing_t['application_sent'])
171
+ logger.info(f"Solicitud almacenada exitosamente para {email}")
172
  else:
173
+ st.error(landing_t['application_error'])
174
+ logger.error(f"Error al almacenar solicitud para {email}")
175
 
176
 
177
  #############################################################
 
183
 
184
  #############################################################
185
  #############################################################
186
+ def display_videos_and_info(lang_code, landing_t):
187
  # Crear tabs para cada secci贸n
188
  tab_use_case, tab_videos, tab_events, tab_gallery, tab_news = st.tabs([
189
+ landing_t['use_cases'],
190
+ landing_t['presentation_videos'],
191
+ landing_t['academic_presentations'],
192
+ landing_t['event_photos'],
193
+ landing_t['version_control']
194
  ])
195
 
196
+ # Tab de Casos de uso
197
  with tab_use_case:
198
  use_case_videos = {
199
  "English - Radar use chart": "https://youtu.be/fFbbtlIewgs",
 
207
  "Espa帽ol - Uso del bot para buscar respuestas" : "https://www.youtube.com/watch?v=GFKDS0K2s7E"
208
  }
209
 
210
+ selected_title = st.selectbox(landing_t['select_use_case'], list(use_case_videos.keys()))
211
  if selected_title in use_case_videos:
212
  try:
213
  st_player(use_case_videos[selected_title])
 
226
  "Demo de la versi贸n de escritorio.": "https://www.youtube.com/watch?v=nP6eXbog-ZY"
227
  }
228
 
229
+ selected_title = st.selectbox(landing_t['select_presentation'], list(videos.keys()))
230
  if selected_title in videos:
231
  try:
232
  st_player(videos[selected_title])
 
317
 
318
 
319
  # Tab de Novedades
320
+ # Tab de Novedades - Usar contenido traducido
321
  with tab_news:
322
+ st.markdown(f"### {landing_t['latest_version_title']}")
323
+ for update in landing_t['version_updates']:
324
+ st.markdown(f"- {update}")
 
 
 
 
325
  """)
326
 
327
  # Definici贸n de __all__ para especificar qu茅 se exporta