GuglielmoTor commited on
Commit
11aff8b
·
verified ·
1 Parent(s): aaf319d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +80 -9
app.py CHANGED
@@ -20,7 +20,7 @@ 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,
24
  build_analytics_tab_plot_area,
25
  BOMB_ICON, EXPLORE_ICON, FORMULA_ICON, ACTIVE_ICON
26
  )
@@ -76,7 +76,7 @@ else:
76
 
77
 
78
  with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
79
- title="LinkedIn Organization Dashboard") as app:
80
  # --- STATE MANAGEMENT ---
81
  token_state = gr.State(value={
82
  "token": None, "client_id": None, "org_urn": None,
@@ -112,9 +112,13 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
112
  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)
113
 
114
  def initial_data_load_sequence(url_token, org_urn_val, current_state):
 
 
 
 
115
  status_msg, new_state = load_data_from_bubble(url_token, org_urn_val, current_state)
116
- dashboard_content = display_main_dashboard(new_state)
117
- return status_msg, new_state, dashboard_content
118
 
119
  analytics_icons = {'bomb': BOMB_ICON, 'explore': EXPLORE_ICON, 'formula': FORMULA_ICON, 'active': ACTIVE_ICON}
120
  analytics_tab_instance = AnalyticsTab(
@@ -156,11 +160,78 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
156
  return report_markdown
157
 
158
  with gr.Tabs() as tabs:
159
- with gr.TabItem("1️⃣ Dashboard", id="tab_dashboard"):
160
- gr.Markdown("I dati visualizzati in questo pannello sono caricati direttamente da Bubble.io.")
161
- dashboard_display_html = gr.HTML("<p style='text-align:center;'>Caricamento dashboard...</p>")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
 
163
- analytics_tab_instance.create_tab_ui()
164
 
165
  with gr.TabItem("3️⃣ Agentic Analysis Report", id="tab_agentic_report", visible=AGENTIC_MODULES_LOADED):
166
  gr.Markdown("## 🤖 Comprehensive Analysis Report (from Bubble.io)")
@@ -234,7 +305,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
234
  initial_load_event = org_urn_display.change(
235
  fn=initial_data_load_sequence,
236
  inputs=[url_user_token_display, org_urn_display, token_state],
237
- outputs=[status_box, token_state, dashboard_display_html],
238
  show_progress="full"
239
  )
240
 
 
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
  )
 
76
 
77
 
78
  with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
79
+ title="LinkedIn Organization Dashboard") as app:
80
  # --- STATE MANAGEMENT ---
81
  token_state = gr.State(value={
82
  "token": None, "client_id": None, "org_urn": None,
 
112
  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)
113
 
114
  def initial_data_load_sequence(url_token, org_urn_val, current_state):
115
+ """
116
+ Handles the initial data loading from Bubble.
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(
 
160
  return report_markdown
161
 
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"
235
 
236
  with gr.TabItem("3️⃣ Agentic Analysis Report", id="tab_agentic_report", visible=AGENTIC_MODULES_LOADED):
237
  gr.Markdown("## 🤖 Comprehensive Analysis Report (from Bubble.io)")
 
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