Skip to content

Commit

Permalink
dashboard: Add permalink URLs for year, month filters
Browse files Browse the repository at this point in the history
Closes #16
  • Loading branch information
punchagan committed Oct 2, 2024
1 parent 82c07c8 commit 082bc8a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/pages/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,21 @@ def display_sidebar(
st.caption(f"*Expense data last updated on {updated}*")

months = get_months()
q_year = st.query_params.get("y", None)
q_month = st.query_params.get("m", None)
if q_year is not None:
selection = (int(q_year), int(q_month) if q_month is not None else 13)
index = months.index(selection)
else:
index = min(2, len(months) - 1)
option = st.selectbox(
"Time Period",
months,
format_func=format_month,
index=min(2, len(months) - 1),
index=index,
disabled=disabled,
)
st.query_params.y, st.query_params.m = map(str, option)
start_date, end_date, num_days = daterange_from_year_month(*option)

category_ids = [ALL_CATEGORY, NO_CATEGORY, *sorted(categories.keys())]
Expand Down

0 comments on commit 082bc8a

Please sign in to comment.