Files
hummingbot-dashboard/pages/file_manager/app.py
2023-08-23 12:49:32 -07:00

41 lines
1.3 KiB
Python

from types import SimpleNamespace
import streamlit as st
from streamlit_elements import elements, mui
from ui_components.bots_file_explorer import BotsFileExplorer
from ui_components.dashboard import Dashboard
from ui_components.editor import Editor
from utils.st_utils import initialize_st_page
initialize_st_page(title="Strategy Configs", icon="🗂️", initial_sidebar_state="collapsed")
if "fe_board" not in st.session_state:
board = Dashboard()
fe_board = SimpleNamespace(
dashboard=board,
file_explorer=BotsFileExplorer(board, 0, 0, 3, 7),
editor=Editor(board, 4, 0, 9, 7),
)
st.session_state.fe_board = fe_board
else:
fe_board = st.session_state.fe_board
# Add new tabs
for tab_name, content in fe_board.file_explorer.tabs.items():
if tab_name not in fe_board.editor.tabs:
fe_board.editor.add_tab(tab_name, content["content"], content["language"])
# Remove deleted tabs
for tab_name in list(fe_board.editor.tabs.keys()):
if tab_name not in fe_board.file_explorer.tabs:
fe_board.editor.remove_tab(tab_name)
with elements("file_manager"):
with mui.Paper(elevation=3, style={"padding": "2rem"}, spacing=[2, 2], container=True):
with fe_board.dashboard():
fe_board.file_explorer()
fe_board.editor()