import streamlit as st from .enums import Page from .utils import artist_select from ..assets.models import Asset, GlobalParticipant def display_results_rows( artist_name: str, assets: list[Asset], clips_by_asset: dict[str, int] ): """ Displays the rows of the search results dataframe with a navigation button. """ # --- Results Table Header --- header_cols = st.columns([3, 3, 1, 2, 1]) header_cols[0].markdown("**Artist Name**") header_cols[1].markdown("**Song Name**") header_cols[2].markdown("**Clips**") header_cols[3].markdown("**Preview**") header_cols[4].markdown("**Action**") st.markdown("---") # --- Results Table Rows --- for index, asset in enumerate(assets): res_cols = st.columns([2, 3, 1, 2, 1]) with res_cols[0]: st.write(artist_name) with res_cols[1]: st.write(asset.asset_meta_data.asset_name) with res_cols[2]: # Display number of generated clips st.write(clips_by_asset.get(asset.id, 0)) with res_cols[3]: # Display the local video file st.video(asset.s3_key) with res_cols[4]: # Button to navigate to the "Clip It" page if st.button("Clip It", key=f"clip_it{index}"): st.session_state.page = Page.CLIP_IT st.session_state.asset = asset st.session_state.artist_name = artist_name st.session_state.artist_selection_index = index st.rerun() # Rerun the app to navigate to the new page def render_search_page(): clips_by_asset: dict[str, int] = st.session_state.clips_by_asset artists_by_name: dict[str, GlobalParticipant] = st.session_state.artist_by_name artists_name = artist_select(list(artists_by_name.keys())) if st.button("Add New Song", key="add_song_button", use_container_width=True): st.session_state.page = Page.ADD_SONG st.rerun() # Rerun the app to navigate to the new page if artists_name: assets = artists_by_name[artists_name].assets display_results_rows( artist_name=artists_name, assets=assets, clips_by_asset=clips_by_asset )