GuglielmoTor commited on
Commit
b8db252
·
verified ·
1 Parent(s): 82011d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -70
app.py CHANGED
@@ -20,8 +20,8 @@ from config import (
20
  # UPDATED: Using the new data loading function from the refactored state manager
21
  from services.state_manager import load_data_from_bubble
22
  from ui.ui_generators import (
23
- # display_main_dashboard, # Removed: Dashboard content is now in app.py directly
24
  build_analytics_tab_plot_area,
 
25
  BOMB_ICON, EXPLORE_ICON, FORMULA_ICON, ACTIVE_ICON
26
  )
27
  from ui.analytics_plot_generator import update_analytics_plots_figures, create_placeholder_plot
@@ -117,8 +117,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
117
  No longer generates dashboard HTML as the Home tab is now static.
118
  """
119
  status_msg, new_state = load_data_from_bubble(url_token, org_urn_val, current_state)
120
- # dashboard_content = display_main_dashboard(new_state) # Removed this line
121
- return status_msg, new_state # Removed dashboard_content from outputs
122
 
123
  analytics_icons = {'bomb': BOMB_ICON, 'explore': EXPLORE_ICON, 'formula': FORMULA_ICON, 'active': ACTIVE_ICON}
124
  analytics_tab_instance = AnalyticsTab(
@@ -136,7 +135,6 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
136
  fn_generate_llm_response=generate_llm_response
137
  )
138
 
139
- # --- FIXED: New handler only updates the report display ---
140
  def update_report_display(selected_report_id: str, current_token_state: dict):
141
  """
142
  Updates only the report display markdown when a new report is selected.
@@ -153,7 +151,6 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
153
  if selected_report_series_df.empty:
154
  return gr.update(value=f"*Error: Report with ID '{selected_report_id}' not found.*")
155
 
156
- # Extract the report data and format it for display
157
  selected_report_series = selected_report_series_df.iloc[0]
158
  report_markdown = format_report_for_display(selected_report_series)
159
 
@@ -162,73 +159,14 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
162
  with gr.Tabs() as tabs:
163
  # --- NEW HOME TAB ---
164
  with gr.TabItem("1️⃣ Home", id="tab_home"):
165
- gr.Markdown("""
166
- <div style="text-align: center; padding: 20px; background-color: #f0f8ff; border-radius: 10px; margin-bottom: 20px; box-shadow: 0 4px 8px rgba(0,0,0,0.1);">
167
- <h2 style="color: #2c3e50; margin-bottom: 15px;">Welcome to your LinkedIn Employer Brand Analytics Dashboard!</h2>
168
- <p style="font-size: 1.1em; color: #34495e; line-height: 1.6;">
169
- This powerful tool is designed to help you **measure and enhance your employer brand** on LinkedIn.
170
- By leveraging comprehensive analytics, you can dive into your data to understand trends, track performance,
171
- and gain actionable insights to improve your presence and attractiveness as an employer.
172
- </p>
173
- <p style="font-size: 1.0em; color: #555; margin-top: 15px;">
174
- Explore the sections below to get a comprehensive overview of your LinkedIn presence and
175
- unlock the full potential of your employer branding efforts.
176
- </p>
177
- </div>
178
- """)
179
-
180
- with gr.Row():
181
- with gr.Column():
182
- gr.Markdown("""
183
- <div style="background-color: #e8f5e9; padding: 20px; border-radius: 8px; min-height: 180px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 2px 4px rgba(0,0,0,0.08);">
184
- <h3 style="color: #2e7d32; margin-bottom: 10px;">📈 Graphs</h3>
185
- <p style="color: #4caf50; flex-grow: 1;">
186
- Dive into detailed visualizations of your LinkedIn data. This section provides dynamic charts and
187
- interactive plots that help you understand trends and variations in posts, mentions, and
188
- follower statistics over time. Identify patterns and make data-driven decisions.
189
- </p>
190
- <div style="text-align: center; margin-top: 15px;">
191
- <img src="https://placehold.co/100x60/4CAF50/ffffff?text=Charts" alt="Graphs Icon" style="margin-bottom: 10px; border-radius: 5px;">
192
- </div>
193
- </div>
194
- """)
195
- btn_graphs = gr.Button("Go to Graphs", variant="primary", size="lg")
196
- with gr.Column():
197
- gr.Markdown("""
198
- <div style="background-color: #e3f2fd; padding: 20px; border-radius: 8px; min-height: 180px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 2px 4px rgba(0,0,0,0.08);">
199
- <h3 style="color: #1976d2; margin-bottom: 10px;">📊 Reports</h3>
200
- <p style="color: #2196f3; flex-grow: 1;">
201
- Access comprehensive quarterly and weekly reports of your employer brand performance.
202
- These pre-generated reports offer in-depth summaries and insights, providing a clear
203
- snapshot of your progress over specific periods.
204
- </p>
205
- <div style="text-align: center; margin-top: 15px;">
206
- <img src="https://placehold.co/100x60/2196F3/ffffff?text=Reports" alt="Reports Icon" style="margin-bottom: 10px; border-radius: 5px;">
207
- </div>
208
- </div>
209
- """)
210
- btn_reports = gr.Button("Go to Reports", variant="primary", size="lg")
211
- with gr.Row():
212
- with gr.Column():
213
- gr.Markdown("""
214
- <div style="background-color: #fff3e0; padding: 20px; border-radius: 8px; min-height: 180px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 2px 4px rgba(0,0,0,0.08);">
215
- <h3 style="color: #ef6c00; margin-bottom: 10px;">🎯 OKR Table</h3>
216
- <p style="color: #ff9800; flex-grow: 1;">
217
- Discover Objectives and Key Results (OKRs) generated by AI, along with actionable tasks.
218
- This section provides concrete recommendations tailored to improve your employer brand,
219
- helping you translate insights into measurable actions.
220
- </p>
221
- <div style="text-align: center; margin-top: 15px;">
222
- <img src="https://placehold.co/100x60/FF9800/ffffff?text=OKRs" alt="OKR Icon" style="margin-bottom: 10px; border-radius: 5px;">
223
- </div>
224
- </div>
225
- """)
226
- btn_okr = gr.Button("Go to OKR Table", variant="primary", size="lg")
227
 
228
  # Link buttons to tab selection
229
  btn_graphs.click(fn=lambda: gr.update(selected="tab_analytics"), outputs=tabs)
230
  btn_reports.click(fn=lambda: gr.update(selected="tab_agentic_report"), outputs=tabs)
231
  btn_okr.click(fn=lambda: gr.update(selected="tab_agentic_okrs"), outputs=tabs)
 
232
 
233
 
234
  analytics_tab_instance.create_tab_ui() # This is the "Graphs" tab, assuming its ID is "tab_analytics"
@@ -287,8 +225,6 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
287
  )
288
 
289
  if AGENTIC_MODULES_LOADED:
290
- # FIXED: The change event for the report selector now only updates the report display markdown.
291
- # The OKR visualization is not affected and remains static after the initial load.
292
  report_selector_dd.change(
293
  fn=update_report_display,
294
  inputs=[report_selector_dd, token_state],
@@ -305,7 +241,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
305
  initial_load_event = org_urn_display.change(
306
  fn=initial_data_load_sequence,
307
  inputs=[url_user_token_display, org_urn_display, token_state],
308
- outputs=[status_box, token_state], # dashboard_display_html removed
309
  show_progress="full"
310
  )
311
 
 
20
  # UPDATED: Using the new data loading function from the refactored state manager
21
  from services.state_manager import load_data_from_bubble
22
  from ui.ui_generators import (
 
23
  build_analytics_tab_plot_area,
24
+ build_home_tab_ui, # NEW: Import the function to build the Home tab UI
25
  BOMB_ICON, EXPLORE_ICON, FORMULA_ICON, ACTIVE_ICON
26
  )
27
  from ui.analytics_plot_generator import update_analytics_plots_figures, create_placeholder_plot
 
117
  No longer generates dashboard HTML as the Home tab is now static.
118
  """
119
  status_msg, new_state = load_data_from_bubble(url_token, org_urn_val, current_state)
120
+ return status_msg, new_state
 
121
 
122
  analytics_icons = {'bomb': BOMB_ICON, 'explore': EXPLORE_ICON, 'formula': FORMULA_ICON, 'active': ACTIVE_ICON}
123
  analytics_tab_instance = AnalyticsTab(
 
135
  fn_generate_llm_response=generate_llm_response
136
  )
137
 
 
138
  def update_report_display(selected_report_id: str, current_token_state: dict):
139
  """
140
  Updates only the report display markdown when a new report is selected.
 
151
  if selected_report_series_df.empty:
152
  return gr.update(value=f"*Error: Report with ID '{selected_report_id}' not found.*")
153
 
 
154
  selected_report_series = selected_report_series_df.iloc[0]
155
  report_markdown = format_report_for_display(selected_report_series)
156
 
 
159
  with gr.Tabs() as tabs:
160
  # --- NEW HOME TAB ---
161
  with gr.TabItem("1️⃣ Home", id="tab_home"):
162
+ # Call the new function from ui_generators to build the Home tab content
163
+ btn_graphs, btn_reports, btn_okr, btn_help = build_home_tab_ui()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
  # Link buttons to tab selection
166
  btn_graphs.click(fn=lambda: gr.update(selected="tab_analytics"), outputs=tabs)
167
  btn_reports.click(fn=lambda: gr.update(selected="tab_agentic_report"), outputs=tabs)
168
  btn_okr.click(fn=lambda: gr.update(selected="tab_agentic_okrs"), outputs=tabs)
169
+ # btn_help.click(fn=lambda: gr.update(selected="tab_help"), outputs=tabs) # Uncomment if you add a help tab
170
 
171
 
172
  analytics_tab_instance.create_tab_ui() # This is the "Graphs" tab, assuming its ID is "tab_analytics"
 
225
  )
226
 
227
  if AGENTIC_MODULES_LOADED:
 
 
228
  report_selector_dd.change(
229
  fn=update_report_display,
230
  inputs=[report_selector_dd, token_state],
 
241
  initial_load_event = org_urn_display.change(
242
  fn=initial_data_load_sequence,
243
  inputs=[url_user_token_display, org_urn_display, token_state],
244
+ outputs=[status_box, token_state],
245
  show_progress="full"
246
  )
247