Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -467,16 +467,24 @@ def show_fetch_data_button(webproperty, search_type, start_date, end_date, selec
|
|
467 |
|
468 |
|
469 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
470 |
# -------------
|
471 |
# Main Streamlit App Function
|
472 |
# -------------
|
473 |
|
474 |
-
# Main Streamlit App Function
|
475 |
def main():
|
476 |
-
"""
|
477 |
-
The main function for the Streamlit application.
|
478 |
-
Handles the app setup, authentication, UI components, and data fetching logic.
|
479 |
-
"""
|
480 |
setup_streamlit()
|
481 |
client_config = load_config()
|
482 |
st.session_state.auth_flow, st.session_state.auth_url = google_auth(client_config)
|
@@ -507,13 +515,12 @@ def main():
|
|
507 |
start_date, end_date = calc_date_range(date_range_selection)
|
508 |
|
509 |
selected_dimensions = show_dimensions_selector(search_type)
|
510 |
-
|
511 |
-
if st.button("Fetch Data and
|
512 |
report = fetch_data_loading(webproperty, search_type, start_date, end_date, selected_dimensions)
|
513 |
|
514 |
if report is not None and not report.empty:
|
515 |
-
|
516 |
-
download_csv_link(report)
|
517 |
else:
|
518 |
st.warning("No data found for the selected criteria.")
|
519 |
|
|
|
467 |
|
468 |
|
469 |
|
470 |
+
def show_paginated_dataframe(report, rows_per_page=20):
|
471 |
+
"""
|
472 |
+
Displays the DataFrame with custom pagination.
|
473 |
+
"""
|
474 |
+
total_rows = len(report)
|
475 |
+
total_pages = (total_rows - 1) // rows_per_page + 1
|
476 |
+
|
477 |
+
page = st.number_input("Page", min_value=1, max_value=total_pages, step=1)
|
478 |
+
|
479 |
+
start_idx = (page - 1) * rows_per_page
|
480 |
+
end_idx = start_idx + rows_per_page
|
481 |
+
st.dataframe(report.iloc[start_idx:end_idx])
|
482 |
+
|
483 |
# -------------
|
484 |
# Main Streamlit App Function
|
485 |
# -------------
|
486 |
|
|
|
487 |
def main():
|
|
|
|
|
|
|
|
|
488 |
setup_streamlit()
|
489 |
client_config = load_config()
|
490 |
st.session_state.auth_flow, st.session_state.auth_url = google_auth(client_config)
|
|
|
515 |
start_date, end_date = calc_date_range(date_range_selection)
|
516 |
|
517 |
selected_dimensions = show_dimensions_selector(search_type)
|
518 |
+
|
519 |
+
if st.button("Fetch Data and Display"):
|
520 |
report = fetch_data_loading(webproperty, search_type, start_date, end_date, selected_dimensions)
|
521 |
|
522 |
if report is not None and not report.empty:
|
523 |
+
show_paginated_dataframe(report)
|
|
|
524 |
else:
|
525 |
st.warning("No data found for the selected criteria.")
|
526 |
|