mirror of
https://github.com/aljazceru/hummingbot-dashboard.git
synced 2025-12-20 15:04:21 +01:00
(feat) update st utils
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import os.path
|
||||
|
||||
import streamlit_authenticator as stauth
|
||||
import pandas as pd
|
||||
from pathlib import Path
|
||||
import inspect
|
||||
import os.path
|
||||
from pathlib import Path
|
||||
|
||||
import pandas as pd
|
||||
import streamlit as st
|
||||
import streamlit_authenticator as stauth
|
||||
import yaml
|
||||
from st_pages import add_page_title, show_pages
|
||||
from yaml import SafeLoader
|
||||
@@ -34,23 +33,22 @@ def initialize_st_page(title: str, icon: str, layout="wide", initial_sidebar_sta
|
||||
def download_csv_button(df: pd.DataFrame, filename: str, key: str):
|
||||
csv = df.to_csv(index=False).encode('utf-8')
|
||||
return st.download_button(
|
||||
label="Download CSV",
|
||||
data=csv,
|
||||
file_name=f"{filename}.csv",
|
||||
mime="text/csv",
|
||||
key=key
|
||||
)
|
||||
label="Download CSV",
|
||||
data=csv,
|
||||
file_name=f"{filename}.csv",
|
||||
mime="text/csv",
|
||||
key=key
|
||||
)
|
||||
|
||||
|
||||
def style_metric_cards(
|
||||
background_color: str = "rgba(255, 255, 255, 0)",
|
||||
border_size_px: int = 1,
|
||||
border_color: str = "rgba(255, 255, 255, 0.3)",
|
||||
border_radius_px: int = 5,
|
||||
border_left_color: str = "rgba(255, 255, 255, 0.5)",
|
||||
box_shadow: bool = True,
|
||||
background_color: str = "rgba(255, 255, 255, 0)",
|
||||
border_size_px: int = 1,
|
||||
border_color: str = "rgba(255, 255, 255, 0.3)",
|
||||
border_radius_px: int = 5,
|
||||
border_left_color: str = "rgba(255, 255, 255, 0.5)",
|
||||
box_shadow: bool = True,
|
||||
):
|
||||
|
||||
box_shadow_str = (
|
||||
"box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15) !important;"
|
||||
if box_shadow
|
||||
@@ -74,14 +72,16 @@ def style_metric_cards(
|
||||
|
||||
|
||||
def get_backend_api_client():
|
||||
from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT
|
||||
from backend.services.backend_api_client import BackendAPIClient
|
||||
from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT
|
||||
backend_api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT)
|
||||
is_docker_running = False
|
||||
try:
|
||||
is_docker_running = backend_api_client.is_docker_running()
|
||||
except Exception as e:
|
||||
st.error(f"There was an error trying to connect to the Backend API: \n\n{str(e)} \n\nPlease make sure the Backend API is running.")
|
||||
st.error(
|
||||
f"There was an error trying to connect to the Backend API: "
|
||||
f"\n\n{str(e)} \n\nPlease make sure the Backend API is running.")
|
||||
st.stop()
|
||||
if not is_docker_running:
|
||||
st.error("Docker is not running. Please make sure Docker is running.")
|
||||
|
||||
Reference in New Issue
Block a user