From b57dbe53b1084d08076b57dc540cae4cd1e31841 Mon Sep 17 00:00:00 2001 From: cardosofede Date: Fri, 28 Jul 2023 22:17:30 +0200 Subject: [PATCH] (feat) refactor bot performance card --- ui_components/bot_performance_card.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/ui_components/bot_performance_card.py b/ui_components/bot_performance_card.py index 3df2bf6..7424e5b 100644 --- a/ui_components/bot_performance_card.py +++ b/ui_components/bot_performance_card.py @@ -1,5 +1,5 @@ from docker_manager import DockerManager -from streamlit_elements import mui, sync, html, lazy, elements +from streamlit_elements import mui, lazy from ui_components.dashboard import Dashboard import streamlit as st from utils.os_utils import get_python_files_from_directory, get_yml_files_from_directory @@ -32,10 +32,10 @@ class BotPerformanceCard(Dashboard.Item): sx={"display": "flex", "flexDirection": "column", "borderRadius": 3, "overflow": "hidden"}, elevation=2): color = "green" if bot_config["is_running"] else "red" - start_date = bot_config.get("start_date", "Not Available") + subheader_message = "Running" if bot_config["is_running"] else "Stopped" mui.CardHeader( title=bot_config["bot_name"], - subheader=f"Running since {start_date}", + subheader=subheader_message, avatar=mui.Avatar("🤖", sx={"bgcolor": color}), action=mui.IconButton(mui.icon.Stop, onClick=lambda: bot_config["broker_client"].stop()) if bot_config[ "is_running"] else mui.IconButton(mui.icon.BuildCircle), @@ -52,24 +52,17 @@ class BotPerformanceCard(Dashboard.Item): with mui.CardContent(sx={"flex": 1}): with mui.Grid(container=True, spacing=2): with mui.Grid(item=True, xs=12): - mui.Typography("Select a script or strategy to start the bot with:") + mui.Typography("Select a strategy:") with mui.Grid(item=True, xs=8): mui.TextField(label="Script name or config file name", - onChange=lazy(lambda x: self.set_strategy(x, bot_name))) + onChange=lazy(lambda x: self.set_strategy(x, bot_name)), + sx={"width": "100%"},) with mui.Grid(item=True, xs=4): with mui.Button(onClick=lambda: bot_config["broker_client"].start( script=st.session_state.active_bots[bot_name]["selected_strategy"])): mui.icon.PlayCircle() mui.Typography("Start") - with mui.Grid(item=True, xs=12): - with elements("autocomplete"): - mui.Autocomplete( - options=scripts + strategies, - value=st.session_state.active_bots[bot_name]["selected_strategy"], - onChange=lazy(lambda x: self.set_strategy(x, bot_name)), - renderInput=lambda params: mui.TextField(params, label="disableClearable", variant="standard") - ) # with mui.Select(label="Scripts", onChange=lazy(lambda x: self.set_strategy(x, bot_name))): # for script in scripts: