GuglielmoTor commited on
Commit
0c06300
Β·
verified Β·
1 Parent(s): f6e1ce4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -3
app.py CHANGED
@@ -4,6 +4,7 @@ import gradio as gr
4
  import pandas as pd
5
  import os
6
  import logging
 
7
 
8
  # --- Module Imports ---
9
  # Functions from your existing/provided custom modules
@@ -65,6 +66,19 @@ def guarded_fetch_analytics(token_state):
65
  logging.error(f"Error in guarded_fetch_analytics calling fetch_and_render_analytics: {e}", exc_info=True)
66
  return (f"❌ Error fetching analytics: {e}", None, None, None, None, None, None, None)
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  # --- Gradio UI Blocks ---
70
  with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
@@ -97,9 +111,11 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
97
  with gr.Tabs():
98
  with gr.TabItem("1️⃣ Dashboard & Sync"):
99
  gr.Markdown("System checks for existing data from Bubble. The 'Sync' button activates if new data needs to be fetched from LinkedIn based on the last sync times and data availability.")
100
- sync_data_btn = gr.Button("πŸ”„ Sync LinkedIn Data", variant="primary", visible=False, interactive=False)
101
 
102
- # MODIFIED: Removed the 'height' argument as it's not supported directly
 
 
 
103
  sync_status_html_output = gr.HTML("<p style='text-align:center;'>Sync status will appear here.</p>")
104
 
105
  dashboard_display_html = gr.HTML("<p style='text-align:center;'>Dashboard loading...</p>")
@@ -111,6 +127,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
111
  show_progress="full"
112
  )
113
 
 
114
  sync_data_btn.click(
115
  fn=lambda: get_sync_animation_html(),
116
  inputs=None,
@@ -120,7 +137,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
120
  fn=sync_all_linkedin_data_orchestrator,
121
  inputs=[token_state],
122
  outputs=[sync_status_html_output, token_state],
123
- show_progress=False
124
  ).then(
125
  fn=process_and_store_bubble_token,
126
  inputs=[url_user_token_display, org_urn_display, token_state],
@@ -133,6 +150,20 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
133
  show_progress=False
134
  )
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  with gr.TabItem("2️⃣ Analytics"):
137
  fetch_analytics_btn = gr.Button("πŸ“ˆ Fetch/Refresh Full Analytics", variant="primary")
138
  follower_count_md = gr.Markdown("Analytics data will load here...")
 
4
  import pandas as pd
5
  import os
6
  import logging
7
+ import time # Added for simulating delay
8
 
9
  # --- Module Imports ---
10
  # Functions from your existing/provided custom modules
 
66
  logging.error(f"Error in guarded_fetch_analytics calling fetch_and_render_analytics: {e}", exc_info=True)
67
  return (f"❌ Error fetching analytics: {e}", None, None, None, None, None, None, None)
68
 
69
+ # --- Animation Test Functions ---
70
+ def show_animation_for_test():
71
+ """Returns the animation HTML for the test button."""
72
+ logging.info("TEST BUTTON: Showing animation.")
73
+ return get_sync_animation_html()
74
+
75
+ def simulate_processing_after_animation():
76
+ """Simulates a delay and then returns a completion message."""
77
+ logging.info("TEST BUTTON: Simulating processing after animation.")
78
+ time.sleep(5) # Simulate a 5-second process
79
+ logging.info("TEST BUTTON: Simulation complete.")
80
+ return "<p style='text-align:center; color: green; font-size: 1.2em;'>βœ… Animation Test Complete!</p>"
81
+
82
 
83
  # --- Gradio UI Blocks ---
84
  with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
 
111
  with gr.Tabs():
112
  with gr.TabItem("1️⃣ Dashboard & Sync"):
113
  gr.Markdown("System checks for existing data from Bubble. The 'Sync' button activates if new data needs to be fetched from LinkedIn based on the last sync times and data availability.")
 
114
 
115
+ with gr.Row(): # To place buttons side-by-side or in a sequence
116
+ sync_data_btn = gr.Button("πŸ”„ Sync LinkedIn Data", variant="primary", visible=False, interactive=False)
117
+ test_animation_btn = gr.Button("πŸ§ͺ Test Animation Display", variant="secondary") # New Test Button
118
+
119
  sync_status_html_output = gr.HTML("<p style='text-align:center;'>Sync status will appear here.</p>")
120
 
121
  dashboard_display_html = gr.HTML("<p style='text-align:center;'>Dashboard loading...</p>")
 
127
  show_progress="full"
128
  )
129
 
130
+ # Original Sync Button Logic
131
  sync_data_btn.click(
132
  fn=lambda: get_sync_animation_html(),
133
  inputs=None,
 
137
  fn=sync_all_linkedin_data_orchestrator,
138
  inputs=[token_state],
139
  outputs=[sync_status_html_output, token_state],
140
+ show_progress=False # Animation is the progress
141
  ).then(
142
  fn=process_and_store_bubble_token,
143
  inputs=[url_user_token_display, org_urn_display, token_state],
 
150
  show_progress=False
151
  )
152
 
153
+ # New Test Animation Button Logic
154
+ test_animation_btn.click(
155
+ fn=show_animation_for_test,
156
+ inputs=None,
157
+ outputs=[sync_status_html_output],
158
+ show_progress=False # Animation is the progress
159
+ ).then(
160
+ fn=simulate_processing_after_animation,
161
+ inputs=None,
162
+ outputs=[sync_status_html_output],
163
+ show_progress=False # Message indicates completion
164
+ )
165
+
166
+
167
  with gr.TabItem("2️⃣ Analytics"):
168
  fetch_analytics_btn = gr.Button("πŸ“ˆ Fetch/Refresh Full Analytics", variant="primary")
169
  follower_count_md = gr.Markdown("Analytics data will load here...")