James McCool
commited on
Commit
Β·
53f8288
1
Parent(s):
655c1a7
Refactor player selection and pagination in app.py for enhanced usability
Browse files- Updated player selection logic to allow filtering by specific players or all players, improving user interaction.
- Adjusted pagination layout for better alignment and spacing, enhancing the overall user experience.
- Ensured that the contest data is filtered based on player selection, maintaining accurate data representation.
app.py
CHANGED
@@ -88,11 +88,8 @@ with tab2:
|
|
88 |
with col1:
|
89 |
with st.form(key='filter_form'):
|
90 |
type_var = st.selectbox("Select Game Type", ['Classic', 'Showdown'])
|
91 |
-
|
92 |
-
|
93 |
-
player_names = st.multiselect("Select players", options=st.session_state['entry_list'])
|
94 |
-
else:
|
95 |
-
player_names = st.session_state['entry_list']
|
96 |
submitted = st.form_submit_button("Submit")
|
97 |
|
98 |
|
@@ -108,6 +105,11 @@ with tab2:
|
|
108 |
'cpt_own_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['captain ownership']))
|
109 |
}
|
110 |
|
|
|
|
|
|
|
|
|
|
|
111 |
if type_var == 'Classic':
|
112 |
st.session_state['Contest']['salary'] = st.session_state['Contest'].apply(lambda row: sum(map_dict['salary_map'].get(player, 0) for player in row), axis=1)
|
113 |
st.session_state['Contest']['median'] = st.session_state['Contest'].apply(lambda row: sum(map_dict['proj_map'].get(player, 0) for player in row), axis=1)
|
@@ -146,13 +148,13 @@ with tab2:
|
|
146 |
total_pages = (total_rows + rows_per_page - 1) // rows_per_page
|
147 |
|
148 |
# Create pagination controls in a single row
|
149 |
-
pagination_cols = st.columns([1, 1, 1,
|
150 |
-
with pagination_cols[
|
151 |
if st.button("β Previous", disabled=st.session_state.current_page == 0):
|
152 |
st.session_state.current_page -= 1
|
153 |
-
with pagination_cols[1]:
|
154 |
-
st.markdown(f"**Page {st.session_state.current_page + 1} of {total_pages}**", unsafe_allow_html=True)
|
155 |
with pagination_cols[2]:
|
|
|
|
|
156 |
if st.button("Next β", disabled=st.session_state.current_page == total_pages - 1):
|
157 |
st.session_state.current_page += 1
|
158 |
|
|
|
88 |
with col1:
|
89 |
with st.form(key='filter_form'):
|
90 |
type_var = st.selectbox("Select Game Type", ['Classic', 'Showdown'])
|
91 |
+
entry_parse_var = st.selectbox("Do you want to view a specific player(s) or a group of players?", ['All', 'Specific'])
|
92 |
+
entry_names = st.multiselect("Select players", options=st.session_state['entry_list'], default=[])
|
|
|
|
|
|
|
93 |
submitted = st.form_submit_button("Submit")
|
94 |
|
95 |
|
|
|
105 |
'cpt_own_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['captain ownership']))
|
106 |
}
|
107 |
|
108 |
+
if entry_parse_var == 'Specific':
|
109 |
+
st.session_state['Contest'] = st.session_state['Contest'][st.session_state['Contest']['BaseName'].isin(entry_names)]
|
110 |
+
else:
|
111 |
+
st.session_state['Contest'] = st.session_state['Contest']
|
112 |
+
|
113 |
if type_var == 'Classic':
|
114 |
st.session_state['Contest']['salary'] = st.session_state['Contest'].apply(lambda row: sum(map_dict['salary_map'].get(player, 0) for player in row), axis=1)
|
115 |
st.session_state['Contest']['median'] = st.session_state['Contest'].apply(lambda row: sum(map_dict['proj_map'].get(player, 0) for player in row), axis=1)
|
|
|
148 |
total_pages = (total_rows + rows_per_page - 1) // rows_per_page
|
149 |
|
150 |
# Create pagination controls in a single row
|
151 |
+
pagination_cols = st.columns([4, 1, 1, 1, 4]) # Last column for spacing
|
152 |
+
with pagination_cols[1]:
|
153 |
if st.button("β Previous", disabled=st.session_state.current_page == 0):
|
154 |
st.session_state.current_page -= 1
|
|
|
|
|
155 |
with pagination_cols[2]:
|
156 |
+
st.markdown(f"**Page {st.session_state.current_page + 1} of {total_pages}**", unsafe_allow_html=True)
|
157 |
+
with pagination_cols[3]:
|
158 |
if st.button("Next β", disabled=st.session_state.current_page == total_pages - 1):
|
159 |
st.session_state.current_page += 1
|
160 |
|