Meshari21 commited on
Commit
c72d516
·
verified ·
1 Parent(s): 839ddf6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -344,7 +344,7 @@ with gr.Blocks(css=open("styles.css", "r").read(), theme="soft") as app:
344
  with gr.Row(elem_id="header") as header_row:
345
  with gr.Column(scale=8):
346
  gr.Markdown("## Mental Health Chatbot")
347
- with gr.Column(scale=4) as profile_container:
348
  profile_button = gr.Button("👤", elem_id="profile_button", variant="secondary")
349
  with gr.Column(visible=False, elem_id="profile_info_box") as profile_info_box:
350
  profile_info = gr.HTML()
@@ -659,10 +659,10 @@ with gr.Blocks(css=open("styles.css", "r").read(), theme="soft") as app:
659
 
660
  # Handle login: update previous patients dropdown
661
  def handle_login(username, password):
 
662
  if login_user(username, password):
663
  user_session.value = username
664
  prev_choices = get_previous_patients()
665
- # Return 27 outputs now: existing 20 plus 7 more for sessions and booking tabs.
666
  return (
667
  f"Welcome, {username}!", # login_output
668
  gr.update(visible=True), # main_panel
@@ -690,10 +690,10 @@ with gr.Blocks(css=open("styles.css", "r").read(), theme="soft") as app:
690
  "", # patient_name_appt (Booking tab field)
691
  "", # appointment_date (Booking tab field)
692
  "", # appointment_time (Booking tab field)
693
- "" # reason (Booking tab field)
 
694
  )
695
  else:
696
- # On failure, clear those fields as well.
697
  return (
698
  "Invalid credentials.", # login_output
699
  gr.update(), # main_panel
@@ -721,7 +721,8 @@ with gr.Blocks(css=open("styles.css", "r").read(), theme="soft") as app:
721
  "", # patient_name_appt
722
  "", # appointment_date
723
  "", # appointment_time
724
- "" # reason
 
725
  )
726
 
727
 
@@ -739,10 +740,12 @@ with gr.Blocks(css=open("styles.css", "r").read(), theme="soft") as app:
739
  therapy_textbox, therapy_conf_html,
740
  summary_textbox, explanation_textbox,
741
  generate_report_btn, report_download, session_data_state,
742
- search_name, search_date, booking_output, patient_name_appt, appointment_date, appointment_time, reason
 
743
  ]
744
  )
745
 
 
746
  def handle_logout():
747
  user_session.value = ""
748
  return (
@@ -759,9 +762,11 @@ with gr.Blocks(css=open("styles.css", "r").read(), theme="soft") as app:
759
  "", # Clear new_username textbox (register page)
760
  "", # Clear new_password textbox (register page)
761
  "", # Clear full_name textbox (register page)
762
- "" # Clear email textbox (register page)
 
763
  )
764
 
 
765
  logout_button.click(
766
  handle_logout,
767
  outputs=[
 
344
  with gr.Row(elem_id="header") as header_row:
345
  with gr.Column(scale=8):
346
  gr.Markdown("## Mental Health Chatbot")
347
+ with gr.Column(visible=False, elem_id="profile_container") as profile_container:
348
  profile_button = gr.Button("👤", elem_id="profile_button", variant="secondary")
349
  with gr.Column(visible=False, elem_id="profile_info_box") as profile_info_box:
350
  profile_info = gr.HTML()
 
659
 
660
  # Handle login: update previous patients dropdown
661
  def handle_login(username, password):
662
+ prev_choices = []
663
  if login_user(username, password):
664
  user_session.value = username
665
  prev_choices = get_previous_patients()
 
666
  return (
667
  f"Welcome, {username}!", # login_output
668
  gr.update(visible=True), # main_panel
 
690
  "", # patient_name_appt (Booking tab field)
691
  "", # appointment_date (Booking tab field)
692
  "", # appointment_time (Booking tab field)
693
+ "", # reason (Booking tab field)
694
+ gr.update(visible=True) # profile_container: show profile icon now
695
  )
696
  else:
 
697
  return (
698
  "Invalid credentials.", # login_output
699
  gr.update(), # main_panel
 
721
  "", # patient_name_appt
722
  "", # appointment_date
723
  "", # appointment_time
724
+ "", # reason
725
+ gr.update(visible=False) # profile_container: hide profile icon on failure
726
  )
727
 
728
 
 
740
  therapy_textbox, therapy_conf_html,
741
  summary_textbox, explanation_textbox,
742
  generate_report_btn, report_download, session_data_state,
743
+ search_name, search_date, booking_output, patient_name_appt, appointment_date, appointment_time, reason,
744
+ profile_container # new output for profile container
745
  ]
746
  )
747
 
748
+
749
  def handle_logout():
750
  user_session.value = ""
751
  return (
 
762
  "", # Clear new_username textbox (register page)
763
  "", # Clear new_password textbox (register page)
764
  "", # Clear full_name textbox (register page)
765
+ "", # Clear email textbox (register page)
766
+ gr.update(visible=False) # profile_container: hide profile icon
767
  )
768
 
769
+
770
  logout_button.click(
771
  handle_logout,
772
  outputs=[