83 lines
2.6 KiB
Python
83 lines
2.6 KiB
Python
import streamlit as st
|
|
|
|
def render():
|
|
st.sidebar.title("IaaS Management")
|
|
|
|
# Set default API key if not already set
|
|
if 'api_key' not in st.session_state or st.session_state.api_key == "":
|
|
st.session_state.api_key = "xxx"
|
|
print("Providing xxx as api key")
|
|
|
|
# Display the API key input with the default value
|
|
api_key = st.sidebar.text_input("API Key", type="password", value=st.session_state.get('api_key'))
|
|
if api_key:
|
|
st.session_state.api_key = api_key
|
|
|
|
# Define views with appropriate icons
|
|
views = {
|
|
"Universes": "🌌",
|
|
"Projects": "📂",
|
|
"Virtual Data Centers": "🏢",
|
|
"Networks": "🔌",
|
|
"Regions": "🌎",
|
|
"Hosts": "💻",
|
|
"Images": "🖼️",
|
|
"Containers": "📦",
|
|
"Websocket": "🔄",
|
|
"Virtual Machines": "⚙️"
|
|
}
|
|
|
|
# Style the sidebar navigation
|
|
st.sidebar.markdown("""
|
|
<style>
|
|
/* Reduce spacing between items */
|
|
div.row-widget.stSelectbox > div {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
/* Style for the navbar */
|
|
.streamlit-expanderHeader {
|
|
font-size: 1em;
|
|
padding: 0.5rem;
|
|
}
|
|
|
|
/* Make the select box more compact */
|
|
.stSelectbox div:first-child {
|
|
padding-bottom: 0;
|
|
}
|
|
</style>
|
|
""", unsafe_allow_html=True)
|
|
|
|
st.sidebar.header("Navigation")
|
|
|
|
# Initialize current view in session state if not present
|
|
if 'current_view' not in st.session_state:
|
|
st.session_state.current_view = list(views.keys())[0]
|
|
|
|
# Format the options with icons
|
|
format_func = lambda x: f"{views[x]} {x}"
|
|
|
|
# Use selectbox for navigation
|
|
if st.session_state.view_type == 'list':
|
|
selected_view = st.sidebar.selectbox(
|
|
"Select Resource Type",
|
|
options=list(views.keys()),
|
|
format_func=format_func,
|
|
index=list(views.keys()).index(st.session_state.current_view),
|
|
label_visibility="collapsed"
|
|
)
|
|
|
|
# Handle navigation
|
|
if selected_view != st.session_state.current_view:
|
|
st.session_state.current_view = selected_view
|
|
st.session_state.selected_resource = None
|
|
st.session_state.view_type = 'list'
|
|
st.session_state.selected_resource_type = None
|
|
st.rerun()
|
|
|
|
if st.session_state.view_type == 'detail':
|
|
if st.sidebar.button("← Back to List View"):
|
|
st.session_state.view_type = 'list'
|
|
st.session_state.selected_resource = None
|
|
st.session_state.selected_resource_type = None
|
|
st.rerun() |