Files
stand/stand.py
2022-05-27 20:23:03 +02:00

54 lines
1.0 KiB
Python

import streamlit as st
import hacks
from aggrid import aggrid
from download import download
from restapi import restapi
from utils.st_utils import get_session_id, hide_UI_elements
print(">>> start of streamlit run")
st.set_page_config(
page_title="stand",
page_icon="icon.png",
layout="wide"
)
hide_UI_elements()
restapi.sid = get_session_id() # rest api needs current session ID to trigger the next rerun
changed = restapi.changed
df = restapi.data
download(df)
# if df in restapi changed, we need to reload it into aggrid.
# if df in restapi did not change, we do not reload to ensure changes in the browser persist.
response = aggrid(
df,
reload_data=changed
)
# if we reloaded, aggrid returns the df from before (why?), thus we do not update the restapi.
# if we did not reload, aggrid may return an updated df from an edit in the browser,
# and thus we need to update the restapi.
new_df = response["data"]
if not new_df.equals(df) and not changed:
restapi.data = new_df
print(">>> end of streamlit run")