initial commit
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
import streamlit as st
|
||||
|
||||
from webapp.task_list import render_task_list
|
||||
|
||||
|
||||
def render_home(container,
|
||||
app_config: dict,
|
||||
authenticator):
|
||||
"""
|
||||
Render the home page
|
||||
:param container: container object to place the content in
|
||||
:param app_config: app configuration
|
||||
:return: None
|
||||
"""
|
||||
|
||||
with container.container():
|
||||
st.title('Annescribe Home')
|
||||
st.write("Welcome to AnneScribe!")
|
||||
authenticator.logout()
|
||||
|
||||
# render task list
|
||||
render_task_list(container, app_config)
|
||||
@@ -0,0 +1,9 @@
|
||||
import os
|
||||
import yaml
|
||||
|
||||
import streamlit as st
|
||||
import streamlit_authenticator as st_auth
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
from functools import partial
|
||||
|
||||
import streamlit as st
|
||||
from streamlit_autorefresh import st_autorefresh
|
||||
|
||||
|
||||
from transcription.job_utils import get_existing_jobs
|
||||
|
||||
def show_results(job_data: dict):
|
||||
"""
|
||||
Show the results of a job
|
||||
:param job_data: job data
|
||||
:return: None
|
||||
"""
|
||||
if job_data is None:
|
||||
return
|
||||
else:
|
||||
st.session_state[f"results_button_{job_data['name']}"] = True
|
||||
st.write(f"Transcription Results for job {job_data['name']}")
|
||||
st.write(f"Output: {job_data['output']}")
|
||||
|
||||
def hide_results(job_data: dict):
|
||||
"""
|
||||
Hide the results of a job
|
||||
:param job_data: job data
|
||||
:return: None
|
||||
"""
|
||||
st.session_state[f"results_button_{job_data['name']}"] = False
|
||||
|
||||
def results_button(job_data: dict, app_config: dict):
|
||||
"""
|
||||
Show the results of a job
|
||||
:param job_data: job data
|
||||
:param app_config: app configuration
|
||||
:return: None
|
||||
"""
|
||||
is_toggled = st.session_state.get(f"results_button_{job_data['name']}")
|
||||
other_toggled = any([st.session_state.get(f"results_button_{job['name']}") for job in get_existing_jobs(app_config)])
|
||||
|
||||
if other_toggled:
|
||||
for job in get_existing_jobs(app_config):
|
||||
st.session_state[f"results_button_{job['name']}"] = False
|
||||
if is_toggled:
|
||||
return st.button("Show Results", on_click=partial(show_results, job_data))
|
||||
else:
|
||||
return st.button("Hide Results", on_click=partial(hide_results, job_data))
|
||||
|
||||
|
||||
def render_task_list(container, app_config: dict):
|
||||
"""
|
||||
Render the task list page
|
||||
:param container: container object to place the content in
|
||||
:param app_config: app configuration
|
||||
:return: None
|
||||
"""
|
||||
|
||||
# disable all results
|
||||
for job in get_existing_jobs(app_config):
|
||||
st.session_state[f"results_button_{job['name']}"] = False
|
||||
|
||||
with container.container():
|
||||
st.subheader('Task List')
|
||||
|
||||
existing_jobs = get_existing_jobs(app_config)
|
||||
|
||||
column_config = [
|
||||
{
|
||||
"name": "Name",
|
||||
"render_func": lambda x: st.markdown(f"**{x['name']}**")
|
||||
},
|
||||
{
|
||||
"name": "Progress",
|
||||
"render_func": lambda x: st.progress(x["progress"]) if x["progress"] < 100 else st.markdown(" -- ")
|
||||
},
|
||||
{
|
||||
"name": "Status",
|
||||
"render_func": lambda x: st.markdown("Completed") if x["completed"] else st.markdown("Processing" if x["processing"] else "Pending")
|
||||
},
|
||||
{
|
||||
"name": "Output",
|
||||
"render_func": lambda x: results_button(x, app_config)
|
||||
}
|
||||
]
|
||||
|
||||
if len(existing_jobs) == 0:
|
||||
st.write("No tasks available.")
|
||||
else:
|
||||
for i, job in enumerate(existing_jobs):
|
||||
cols = st.columns(len(column_config))
|
||||
for j, col in enumerate(column_config):
|
||||
cols[j].write(col["name"])
|
||||
with cols[j]:
|
||||
col["render_func"](job)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user