GuglielmoTor commited on
Commit
11be958
Β·
verified Β·
1 Parent(s): d93d018

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -45
app.py CHANGED
@@ -18,9 +18,6 @@ from config import (
18
  BUBBLE_API_ENDPOINT_ENV_VAR
19
  )
20
 
21
- # analytics_tab_module is now imported locally inside ui/ui_enhancements.py's build_main_app_ui
22
- # from services.analytics_tab_module import AnalyticsTab # REMOVED global import here
23
-
24
  # UPDATED: Using the new data loading function from the refactored state manager
25
  from services.state_manager import load_data_from_bubble
26
 
@@ -116,6 +113,7 @@ def initial_data_load_sequence(url_token, org_urn_val, current_state):
116
  return status_msg, new_state
117
 
118
  # Build the main UI using the function from ui_enhancements
 
119
  (app, url_user_token_display, org_urn_display, status_box,
120
  token_state, reconstruction_cache_st, enhanced_okr_display_html,
121
  tabs, report_selector_dd, agentic_display_outputs,
@@ -136,46 +134,18 @@ def initial_data_load_sequence(url_token, org_urn_val, current_state):
136
  create_enhanced_okr_tab_func=create_enhanced_okr_tab,
137
  format_report_for_display_func=format_report_for_display, # Pass the imported function
138
  AGENTIC_MODULES_LOADED=AGENTIC_MODULES_LOADED, # ADD THIS PARAMETER
139
- get_initial_okr_display_func=get_initial_okr_display if AGENTIC_MODULES_LOADED else None # ADD THIS TOO
140
- )
141
-
142
- # Event handlers (re-establishing them now that components are defined)
143
- app.load(fn=get_url_user_token, inputs=None, outputs=[url_user_token_display, org_urn_display], api_name="get_url_params", show_progress=False)
144
-
145
- if AGENTIC_MODULES_LOADED:
146
- report_selector_dd.change(
147
- fn=lambda sr_id, c_state: update_report_display_enhanced(sr_id, c_state, format_report_for_display),
148
- inputs=[report_selector_dd, token_state],
149
- outputs=[agentic_display_outputs[7], agentic_display_outputs[8]], # report_header_html_display, report_body_markdown_display
150
- show_progress="minimal"
151
  )
152
 
153
- # Initial load sequence with enhanced status updates
154
- initial_load_event = org_urn_display.change(
155
- fn=initial_data_load_sequence,
156
- inputs=[url_user_token_display, org_urn_display, token_state],
157
- outputs=[status_box, token_state],
158
- show_progress="full"
159
- )
160
-
161
- # Chain the loading events
162
- initial_load_event.then(
163
- fn=analytics_tab_instance.refresh_analytics_graphs_ui,
164
- inputs=[token_state, analytics_tab_instance.date_filter_selector, analytics_tab_instance.custom_start_date_picker,
165
- analytics_tab_instance.custom_end_date_picker, chat_histories_st_returned],
166
- outputs=analytics_tab_instance.graph_refresh_outputs_list,
167
- show_progress="full"
168
- ).then(
169
- fn=load_and_display_agentic_results,
170
- inputs=[token_state, reconstruction_cache_st],
171
- outputs=agentic_display_outputs,
172
- show_progress="minimal"
173
- ).then(
174
- fn=format_okrs_for_enhanced_display,
175
- inputs=[reconstruction_cache_st],
176
- outputs=[enhanced_okr_display_html],
177
- show_progress="minimal"
178
- )
179
 
180
  if __name__ == "__main__":
181
  # Enhanced startup logging
@@ -208,10 +178,10 @@ if __name__ == "__main__":
208
 
209
  print("🌐 Launching dashboard on http://0.0.0.0:7860")
210
  print("🎯 Dashboard features:")
211
- print(" β€’ πŸ“Š Advanced LinkedIn Analytics")
212
- print(" β€’ πŸ€– AI-Powered Insights")
213
- print(" β€’ 🎯 OKR Generation & Tracking")
214
- print(" β€’ ☁️ Bubble.io Integration")
215
 
216
  app.launch(
217
  server_name="0.0.0.0",
@@ -221,3 +191,4 @@ if __name__ == "__main__":
221
  show_tips=True,
222
  enable_queue=True
223
  )
 
 
18
  BUBBLE_API_ENDPOINT_ENV_VAR
19
  )
20
 
 
 
 
21
  # UPDATED: Using the new data loading function from the refactored state manager
22
  from services.state_manager import load_data_from_bubble
23
 
 
113
  return status_msg, new_state
114
 
115
  # Build the main UI using the function from ui_enhancements
116
+ # This function now also sets up the main event listeners.
117
  (app, url_user_token_display, org_urn_display, status_box,
118
  token_state, reconstruction_cache_st, enhanced_okr_display_html,
119
  tabs, report_selector_dd, agentic_display_outputs,
 
134
  create_enhanced_okr_tab_func=create_enhanced_okr_tab,
135
  format_report_for_display_func=format_report_for_display, # Pass the imported function
136
  AGENTIC_MODULES_LOADED=AGENTIC_MODULES_LOADED, # ADD THIS PARAMETER
137
+ get_initial_okr_display_func=get_initial_okr_display if AGENTIC_MODULES_LOADED else None, # ADD THIS TOO
138
+ # Pass the initial data load sequence function and others that need to be bound
139
+ # within the Gradio Blocks context.
140
+ initial_data_load_sequence_func=initial_data_load_sequence,
141
+ get_url_user_token_func=get_url_user_token,
142
+ load_and_display_agentic_results_func=load_and_display_agentic_results,
143
+ format_okrs_for_enhanced_display_func=format_okrs_for_enhanced_display,
144
+ update_report_display_enhanced_func=update_report_display_enhanced # Pass this as well
 
 
 
 
145
  )
146
 
147
+ # The event handlers are now set up *inside* build_main_app_ui,
148
+ # so these calls are no longer needed here.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
 
150
  if __name__ == "__main__":
151
  # Enhanced startup logging
 
178
 
179
  print("🌐 Launching dashboard on http://0.0.0.0:7860")
180
  print("🎯 Dashboard features:")
181
+ print(" β€’ πŸ“Š Advanced LinkedIn Analytics")
182
+ print(" β€’ πŸ€– AI-Powered Insights")
183
+ print(" β€’ 🎯 OKR Generation & Tracking")
184
+ print(" β€’ ☁️ Bubble.io Integration")
185
 
186
  app.launch(
187
  server_name="0.0.0.0",
 
191
  show_tips=True,
192
  enable_queue=True
193
  )
194
+