initial ui
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/venv/
|
||||
107
frontend.py
Normal file
107
frontend.py
Normal file
@@ -0,0 +1,107 @@
|
||||
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 ✈️")
|
||||
|
||||
# Predefined announcements section
|
||||
st.header("Predefined Announcements")
|
||||
col1, col2, col3 = st.columns(3)
|
||||
with col1:
|
||||
if st.button("Final Boarding Call"):
|
||||
announce("This is the final boarding call for flight LX-380 to New York", "Gate1")
|
||||
with col2:
|
||||
if st.button("Security Reminder"):
|
||||
announce("Please keep your luggage with you at all times", "Gate2")
|
||||
with col3:
|
||||
if st.button("Delay Notice"):
|
||||
announce("We regret to inform you of a 30-minute delay", "Gate1")
|
||||
|
||||
st.markdown("---")
|
||||
|
||||
# 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()
|
||||
})
|
||||
|
||||
# Custom announcement section
|
||||
st.header("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"):
|
||||
announce(message, selected_group)
|
||||
Reference in New Issue
Block a user