Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -113,7 +113,7 @@ def filter_and_visualize(selected_lab, selected_type, selected_date_range):
|
|
| 113 |
else:
|
| 114 |
anomaly_text = "Anomalies Detected:\n" + anomalies[['DeviceID', 'Lab', 'Type', 'Status', 'UsageCount']].to_string(index=False)
|
| 115 |
|
| 116 |
-
return device_cards, buf1, buf2, anomaly_text, ""
|
| 117 |
|
| 118 |
def download_pdf(selected_lab, selected_type, selected_date_range):
|
| 119 |
global df
|
|
@@ -161,6 +161,9 @@ with gr.Blocks() as demo:
|
|
| 161 |
type_dropdown = gr.Dropdown(label="Filter by Equipment Type", choices=["All"], value="All")
|
| 162 |
date_dropdown = gr.Dropdown(label="Filter by Date Range", choices=["All"], value="All")
|
| 163 |
|
|
|
|
|
|
|
|
|
|
| 164 |
with gr.Row():
|
| 165 |
device_table = gr.DataFrame(label="Device Cards (Usage, Last Log)")
|
| 166 |
plot_daily = gr.Image(label="Daily Log Trends")
|
|
@@ -176,21 +179,14 @@ with gr.Blocks() as demo:
|
|
| 176 |
inputs=csv_input,
|
| 177 |
outputs=[lab_dropdown, type_dropdown, date_dropdown, error_box, lab_dropdown, type_dropdown, date_dropdown]
|
| 178 |
)
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
outputs=[device_table, plot_daily, plot_uptime, anomaly_output, error_box]
|
| 183 |
-
)
|
| 184 |
-
type_dropdown.change(
|
| 185 |
-
fn=filter_and_visualize,
|
| 186 |
-
inputs=[lab_dropdown, type_dropdown, date_dropdown],
|
| 187 |
-
outputs=[device_table, plot_daily, plot_uptime, anomaly_output, error_box]
|
| 188 |
-
)
|
| 189 |
-
date_dropdown.change(
|
| 190 |
fn=filter_and_visualize,
|
| 191 |
inputs=[lab_dropdown, type_dropdown, date_dropdown],
|
| 192 |
outputs=[device_table, plot_daily, plot_uptime, anomaly_output, error_box]
|
| 193 |
)
|
|
|
|
| 194 |
download_btn.click(
|
| 195 |
fn=download_pdf,
|
| 196 |
inputs=[lab_dropdown, type_dropdown, date_dropdown],
|
|
|
|
| 113 |
else:
|
| 114 |
anomaly_text = "Anomalies Detected:\n" + anomalies[['DeviceID', 'Lab', 'Type', 'Status', 'UsageCount']].to_string(index=False)
|
| 115 |
|
| 116 |
+
return device_cards, buf1, buf2, anomaly_text, "Filters applied successfully."
|
| 117 |
|
| 118 |
def download_pdf(selected_lab, selected_type, selected_date_range):
|
| 119 |
global df
|
|
|
|
| 161 |
type_dropdown = gr.Dropdown(label="Filter by Equipment Type", choices=["All"], value="All")
|
| 162 |
date_dropdown = gr.Dropdown(label="Filter by Date Range", choices=["All"], value="All")
|
| 163 |
|
| 164 |
+
with gr.Row():
|
| 165 |
+
submit_btn = gr.Button("Submit") # Added Submit button
|
| 166 |
+
|
| 167 |
with gr.Row():
|
| 168 |
device_table = gr.DataFrame(label="Device Cards (Usage, Last Log)")
|
| 169 |
plot_daily = gr.Image(label="Daily Log Trends")
|
|
|
|
| 179 |
inputs=csv_input,
|
| 180 |
outputs=[lab_dropdown, type_dropdown, date_dropdown, error_box, lab_dropdown, type_dropdown, date_dropdown]
|
| 181 |
)
|
| 182 |
+
|
| 183 |
+
# Bind filter_and_visualize to the Submit button
|
| 184 |
+
submit_btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
fn=filter_and_visualize,
|
| 186 |
inputs=[lab_dropdown, type_dropdown, date_dropdown],
|
| 187 |
outputs=[device_table, plot_daily, plot_uptime, anomaly_output, error_box]
|
| 188 |
)
|
| 189 |
+
|
| 190 |
download_btn.click(
|
| 191 |
fn=download_pdf,
|
| 192 |
inputs=[lab_dropdown, type_dropdown, date_dropdown],
|