mirror of
https://github.com/aljazceru/hummingbot-dashboard.git
synced 2026-01-04 14:04:26 +01:00
(feat) refactor bot performance card
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user