Spaces:
Running
Running
sedrick-keh-tri
commited on
Commit
·
bccb934
1
Parent(s):
939b4b0
support datasets table
Browse files
app.py
CHANGED
|
@@ -229,14 +229,27 @@ with gr.Blocks(title="VLA Foundry Database Viewer", css=css) as demo:
|
|
| 229 |
return gr.update(value=filtered_df, column_widths=col_width_list if col_width_list else None), info
|
| 230 |
|
| 231 |
# Update columns when table changes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
table_selector.change(
|
| 233 |
-
fn=
|
| 234 |
inputs=[table_selector],
|
| 235 |
-
outputs=[column_filter, sort_column]
|
| 236 |
-
).then(
|
| 237 |
-
fn=update_table,
|
| 238 |
-
inputs=[table_selector, search_box, column_filter, sort_column, sort_order],
|
| 239 |
-
outputs=[data_table, table_info]
|
| 240 |
)
|
| 241 |
|
| 242 |
# Update table when filters/sorting change
|
|
|
|
| 229 |
return gr.update(value=filtered_df, column_widths=col_width_list if col_width_list else None), info
|
| 230 |
|
| 231 |
# Update columns when table changes
|
| 232 |
+
def on_table_change(table_name):
|
| 233 |
+
# Reset filters and update column choices
|
| 234 |
+
col_filter_update, sort_col_update = update_column_choices(table_name)
|
| 235 |
+
# Get the updated table with reset filters
|
| 236 |
+
filtered_df = get_filtered_data(table_name, "", "All", "", "Ascending")
|
| 237 |
+
info = get_table_info(table_name)
|
| 238 |
+
|
| 239 |
+
# Build column widths for the new table
|
| 240 |
+
col_width_list = []
|
| 241 |
+
if not filtered_df.empty:
|
| 242 |
+
for col in filtered_df.columns:
|
| 243 |
+
col_width_list.append(column_widths.get(col, 300))
|
| 244 |
+
|
| 245 |
+
table_update = gr.update(value=filtered_df, column_widths=col_width_list if col_width_list else None)
|
| 246 |
+
|
| 247 |
+
return col_filter_update, sort_col_update, table_update, info, "", "Ascending"
|
| 248 |
+
|
| 249 |
table_selector.change(
|
| 250 |
+
fn=on_table_change,
|
| 251 |
inputs=[table_selector],
|
| 252 |
+
outputs=[column_filter, sort_column, data_table, table_info, search_box, sort_order]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
)
|
| 254 |
|
| 255 |
# Update table when filters/sorting change
|