Skip to content

Commit

Permalink
proper multipage app
Browse files Browse the repository at this point in the history
  • Loading branch information
entorb committed Dec 26, 2024
1 parent a9545e9 commit bcb4dba
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ extend-ignore = [
"T201", # print
"TD002", # missing-todo-author
"TD003", # missing-todo-link
"INP001", # missing __init__.py in streamlit reports dir
"S101", # use of asserts
]


Expand Down
21 changes: 18 additions & 3 deletions src/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
"""Streamlit UI."""

from pathlib import Path

import streamlit as st

from helper import delete_cache
# from helper import delete_cache

st.set_page_config(page_title="RTM Report", page_icon=None, layout="wide")
st.title("RTM")

delete_cache()

def create_navigation_menu() -> None:
"""Create and populate navigation menu."""
lst = []
for p in sorted(Path("src/reports").glob("*.py")):
f = p.stem
t = f[3:]
lst.append(st.Page(page=f"reports/{f}.py", title=t))
pg = st.navigation(lst)
pg.run()


create_navigation_menu()

# delete_cache()
3 changes: 1 addition & 2 deletions src/pages/Completed.py → src/reports/01_Completed.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""Completed Tasks.""" # noqa: INP001
"""Completed Tasks."""

import altair as alt
import streamlit as st

from tasks_completed import completed_week, get_tasks_completed

st.set_page_config(page_title="RTM Completed", page_icon=None, layout="wide")
st.title("Completed")

df = get_tasks_completed()
Expand Down
9 changes: 5 additions & 4 deletions src/pages/Overdue.py → src/reports/02_Overdue.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"""Completed Tasks.""" # noqa: INP001
"""Completed Tasks."""

import altair as alt
import streamlit as st

from tasks_overdue import get_tasks_overdue, group_by_list

st.set_page_config(page_title="RTM Overdue", page_icon=None, layout="wide")
st.title("Overdue")

df = get_tasks_overdue().sort_values(by=["overdue"], ascending=[True])
lists = sorted(set(df["list"].to_list()))

sel_list = st.selectbox(label="List", index=None, options=lists)
col1, _ = st.columns((1, 5))
sel_list = col1.selectbox(label="List", index=None, options=lists)

st.dataframe(
df.query(f"list == '{sel_list}'") if sel_list else df,
Expand All @@ -24,7 +24,8 @@
df = df.reset_index()


sel_list = st.selectbox(
col1, _ = st.columns((1, 5))
sel_list = col1.selectbox(
label="Parameter",
options=("count", "sum_prio", "sum_overdue_prio", "sum_estimate"),
)
Expand Down

0 comments on commit bcb4dba

Please sign in to comment.