Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -55,13 +55,17 @@ def guarded_fetch_dashboard():
|
|
55 |
|
56 |
def guarded_fetch_analytics():
|
57 |
if not token_received["status"]:
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
61 |
token_received["client_id"],
|
62 |
token_received["token"]
|
63 |
)
|
64 |
-
return count_md, plot
|
|
|
65 |
|
66 |
def run_mentions_and_load():
|
67 |
html, fig = generate_mentions_dashboard(
|
@@ -114,16 +118,20 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
|
|
114 |
with gr.TabItem("2️⃣ Analytics"):
|
115 |
gr.Markdown("View follower count and monthly gains for your organization.")
|
116 |
fetch_analytics_btn = gr.Button("📈 Fetch Follower Analytics", variant="primary")
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
|
|
|
|
|
|
121 |
fetch_analytics_btn.click(
|
122 |
fn=guarded_fetch_analytics,
|
123 |
inputs=[],
|
124 |
-
outputs=[follower_count, follower_plot]
|
125 |
)
|
126 |
|
|
|
127 |
with gr.TabItem("3️⃣ Mentions"):
|
128 |
gr.Markdown("Analyze sentiment of recent posts that mention your organization.")
|
129 |
fetch_mentions_btn = gr.Button("🧠 Fetch Mentions & Sentiment", variant="primary")
|
|
|
55 |
|
56 |
def guarded_fetch_analytics():
|
57 |
if not token_received["status"]:
|
58 |
+
return (
|
59 |
+
"<p style='color:red; text-align:center;'>❌ Access denied. No token available.</p>",
|
60 |
+
None,
|
61 |
+
None
|
62 |
+
)
|
63 |
+
count_md, plot, growth_plot = fetch_and_render_analytics(
|
64 |
token_received["client_id"],
|
65 |
token_received["token"]
|
66 |
)
|
67 |
+
return count_md, plot, growth_plot
|
68 |
+
|
69 |
|
70 |
def run_mentions_and_load():
|
71 |
html, fig = generate_mentions_dashboard(
|
|
|
118 |
with gr.TabItem("2️⃣ Analytics"):
|
119 |
gr.Markdown("View follower count and monthly gains for your organization.")
|
120 |
fetch_analytics_btn = gr.Button("📈 Fetch Follower Analytics", variant="primary")
|
121 |
+
|
122 |
+
follower_count = gr.Markdown("<p style='text-align: center; color: #555;'>Waiting for token...</p>")
|
123 |
+
|
124 |
+
with gr.Row(): # Use Row to align the two plots side-by-side
|
125 |
+
follower_plot = gr.Plot(visible=False)
|
126 |
+
growth_rate_plot = gr.Plot(visible=False)
|
127 |
+
|
128 |
fetch_analytics_btn.click(
|
129 |
fn=guarded_fetch_analytics,
|
130 |
inputs=[],
|
131 |
+
outputs=[follower_count, follower_plot, growth_rate_plot]
|
132 |
)
|
133 |
|
134 |
+
|
135 |
with gr.TabItem("3️⃣ Mentions"):
|
136 |
gr.Markdown("Analyze sentiment of recent posts that mention your organization.")
|
137 |
fetch_mentions_btn = gr.Button("🧠 Fetch Mentions & Sentiment", variant="primary")
|