ui improvements
This commit is contained in:
@@ -86,6 +86,9 @@ def show_announcement_status(group_id: int):
|
||||
while state_name not in ["COMPLETED", "IDLE", "ERROR"]:
|
||||
# Check for timeout
|
||||
elapsed_time = time.time() - start_tracking_time
|
||||
# Refresh state
|
||||
state_name, state_value = get_group_state(group_id)
|
||||
|
||||
if elapsed_time > max_wait_time:
|
||||
st.warning(f"Status tracking timed out after {max_wait_time} seconds")
|
||||
break
|
||||
@@ -110,50 +113,58 @@ def show_announcement_status(group_id: int):
|
||||
# Update progress bar directly from state value
|
||||
progress = min(state_value / max_state_value, 1.0)
|
||||
progress_bar.progress(progress)
|
||||
|
||||
|
||||
# Add a small delay between requests to avoid hammering the API
|
||||
time.sleep(0.5)
|
||||
|
||||
# Refresh state
|
||||
state_name, state_value = get_group_state(group_id)
|
||||
|
||||
# Final update to progress bar
|
||||
progress = min(state_value / max_state_value, 1.0)
|
||||
progress_bar.progress(progress)
|
||||
|
||||
# Final update to stage display - this ensures we see the COMPLETED state
|
||||
stage_col.write(f"**Stage:** {state_name}")
|
||||
|
||||
# Final update to elapsed time display
|
||||
if "announcement_start_time" in st.session_state:
|
||||
start_time = st.session_state.announcement_start_time
|
||||
final_elapsed_seconds = time.time() - start_time
|
||||
time_col.write(f"⏱️ {final_elapsed_seconds:.1f}s")
|
||||
else:
|
||||
final_elapsed_seconds = time.time() - start_tracking_time
|
||||
time_col.write(f"⏱️ {final_elapsed_seconds:.1f}s")
|
||||
# Final update to stage display and time only if the state isn't already shown
|
||||
if last_state is None or last_state[0] != state_name:
|
||||
stage_col.write(f"**Stage:** {state_name}")
|
||||
|
||||
# Only update time when we update the stage
|
||||
if "announcement_start_time" in st.session_state:
|
||||
start_time = st.session_state.announcement_start_time
|
||||
final_elapsed_seconds = time.time() - start_time
|
||||
time_col.write(f"⏱️ {final_elapsed_seconds:.1f}s")
|
||||
else:
|
||||
final_elapsed_seconds = time.time() - start_tracking_time
|
||||
time_col.write(f"⏱️ {final_elapsed_seconds:.1f}s")
|
||||
|
||||
# Final state
|
||||
if state_name == "COMPLETED":
|
||||
st.success("✅ Announcement completed successfully")
|
||||
|
||||
# Display group information
|
||||
st.write(f"📢 Announcement made to group {group.name}")
|
||||
|
||||
# Display endpoints if available
|
||||
endpoints = group.endpoints
|
||||
if endpoints:
|
||||
endpoint_names = [ep.name for ep in endpoints]
|
||||
st.write(f"📡 Endpoints: {', '.join(endpoint_names)}")
|
||||
|
||||
# Display languages if available
|
||||
languages = group.languages
|
||||
if languages:
|
||||
st.write(f"🌐 Languages: {', '.join(languages)}")
|
||||
|
||||
# Clear the success message when announcement completes
|
||||
st.session_state.show_success_message = False
|
||||
# Only display success message if we haven't shown one for this announcement yet
|
||||
if st.session_state.show_success_message:
|
||||
st.success("✅ Announcement completed successfully")
|
||||
|
||||
# Display group information
|
||||
st.write(f"📢 Announcement made to group {group.name}")
|
||||
|
||||
# Display endpoints if available
|
||||
endpoints = group.endpoints
|
||||
if endpoints:
|
||||
endpoint_names = [ep.name for ep in endpoints]
|
||||
st.write(f"📡 Endpoints: {', '.join(endpoint_names)}")
|
||||
|
||||
# Display languages if available
|
||||
languages = group.languages
|
||||
if languages:
|
||||
st.write(f"🌐 Languages: {', '.join(languages)}")
|
||||
|
||||
# Clear the success message to prevent showing the status again
|
||||
st.session_state.show_success_message = False # Clear success message after announcement completion
|
||||
|
||||
if state_name == "ERROR":
|
||||
st.error("❌ Announcement encountered an error")
|
||||
st.session_state.show_success_message = False # Clear success message on error
|
||||
|
||||
# Increment announcement ID to ensure a fresh status container
|
||||
st.session_state.announcement_id += 1
|
||||
st.session_state.status_container_key = st.session_state.announcement_id
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
st.error(f"Failed to get announcement status: {str(e)}")
|
||||
|
||||
@@ -203,14 +214,12 @@ with st.container():
|
||||
# Update session state with the current message
|
||||
st.session_state.announcement_text = message
|
||||
|
||||
start_announcement(message, selected_group_id)
|
||||
|
||||
# Set flag to show success message
|
||||
st.session_state.show_success_message = True
|
||||
|
||||
# Increment announcement ID to ensure a fresh status container
|
||||
st.session_state.announcement_id += 1
|
||||
st.session_state.status_container_key = st.session_state.announcement_id
|
||||
# Start the announcement
|
||||
start_announcement(message, selected_group_id)
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
st.error(f"Failed to start announcement: {str(e)}")
|
||||
|
||||
Reference in New Issue
Block a user