Files
auracaster-webui/frontend.py
2025-03-10 12:35:43 +01:00

127 lines
4.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import streamlit as st
# Configuration defaults
DEFAULT_LANGUAGES = ["German", "English"]
OPTIONAL_LANGUAGES = ["French", "Spanish"]
# Initialize session state for configuration
if "endpoint_groups" not in st.session_state:
st.session_state.endpoint_groups = [
{
"name": "Gate1",
"endpoints": ["endpoint1", "endpoint2"],
"languages": DEFAULT_LANGUAGES.copy()
},
{
"name": "Gate2",
"endpoints": ["endpoint3"],
"languages": DEFAULT_LANGUAGES.copy()
}
]
# Mock API call function
def announce(text: str, gate: str):
"""Mock function that would make an API call"""
# Find the selected group
group = next(g for g in st.session_state.endpoint_groups if g["name"] == gate)
st.write(f"📢 Announcement made to group {gate}:")
st.write(f"📡 Endpoints: {', '.join(group['endpoints'])}")
st.write(f"🗣️ '{text}'")
st.write(f"🌐 Languages: {', '.join(group['languages'])}")
st.write("(This is a mock - real implementation would:")
st.write("- Call airport PA system API")
st.write(f"- Make announcements in {len(group['languages'])} languages")
st.write("- Handle endpoint group routing)")
# Page setup
st.set_page_config(page_title="Airport Announcement System", page_icon="✈️")
# Main interface
st.title("Airport Announcement System ✈️")
# Announcements section
with st.container():
st.header("Announcements")
# Predefined announcements
col1, col2, col3 = st.columns(3)
with col1:
if st.button("Final Boarding Call"):
st.session_state.last_announcement = {
"message": "This is the final boarding call for flight LX-380 to New York",
"group": "Gate1"
}
with col2:
if st.button("Security Reminder"):
st.session_state.last_announcement = {
"message": "Please keep your luggage with you at all times",
"group": "Gate2"
}
with col3:
if st.button("Delay Notice"):
st.session_state.last_announcement = {
"message": "We regret to inform you of a 30-minute delay",
"group": "Gate1"
}
# Custom announcement
with st.form("custom_announcement"):
# Get all groups
groups = [group["name"] for group in st.session_state.endpoint_groups]
selected_group = st.selectbox("Select announcement area", groups)
message = st.text_area("Enter announcement text", "")
if st.form_submit_button("Make Announcement"):
st.session_state.last_announcement = {
"message": message,
"group": selected_group
}
# Configuration section in sidebar
with st.sidebar:
st.header("Configuration")
with st.expander("Endpoint Groups"):
for i, group in enumerate(st.session_state.endpoint_groups):
cols = st.columns([4, 1])
with cols[0]:
group["name"] = st.text_input(
f"Group Name {i+1}",
value=group["name"],
key=f"group_name_{i}"
)
group["endpoints"] = st.text_input(
f"Endpoints {i+1}",
value=", ".join(group["endpoints"]),
key=f"endpoints_{i}"
).split(", ")
with cols[1]:
if st.button("", key=f"remove_{i}"):
del st.session_state.endpoint_groups[i]
st.rerun()
group["languages"] = st.multiselect(
f"Languages {i+1}",
options=DEFAULT_LANGUAGES + OPTIONAL_LANGUAGES,
default=group["languages"],
key=f"lang_{i}"
)
st.markdown("---")
if st.button(" Add Group"):
st.session_state.endpoint_groups.append({
"name": f"Group {len(st.session_state.endpoint_groups)+1}",
"endpoints": [],
"languages": DEFAULT_LANGUAGES.copy()
})
# Display announcement feedback at the bottom of the page
if "last_announcement" in st.session_state:
st.write("---")
announce(
st.session_state.last_announcement["message"],
st.session_state.last_announcement["group"]
)