- Added `psutil` dependency for system performance metrics. - Implemented a new layout in `dashboard/layouts/system_health.py` using Mantine components for real-time monitoring of data collection services, database health, Redis status, and system performance. - Enhanced callbacks in `dashboard/callbacks/system_health.py` for detailed status updates and error handling. - Introduced quick status indicators for data collection, database, Redis, and performance metrics with auto-refresh functionality. - Created modals for viewing detailed data collection information and service logs. - Updated documentation to reflect the new features and usage guidelines.
76 lines
2.4 KiB
Python
76 lines
2.4 KiB
Python
"""
|
|
Main dashboard application module.
|
|
"""
|
|
|
|
import dash
|
|
from dash import html, dcc
|
|
import dash_mantine_components as dmc
|
|
from utils.logger import get_logger
|
|
from dashboard.layouts import (
|
|
get_market_data_layout,
|
|
get_bot_management_layout,
|
|
get_performance_layout,
|
|
get_system_health_layout
|
|
)
|
|
from dashboard.components import create_indicator_modal
|
|
|
|
logger = get_logger("dashboard_app")
|
|
|
|
|
|
def create_app():
|
|
"""Create and configure the Dash application."""
|
|
# Initialize Dash app
|
|
app = dash.Dash(__name__, suppress_callback_exceptions=True)
|
|
|
|
# Define the main layout wrapped in MantineProvider
|
|
app.layout = dmc.MantineProvider([
|
|
html.Div([
|
|
# Page title
|
|
html.H1("🚀 Crypto Trading Bot Dashboard",
|
|
style={'text-align': 'center', 'color': '#2c3e50', 'margin-bottom': '30px'}),
|
|
|
|
# Navigation tabs
|
|
dcc.Tabs(id='main-tabs', value='market-data', children=[
|
|
dcc.Tab(label='📊 Market Data', value='market-data'),
|
|
dcc.Tab(label='🤖 Bot Management', value='bot-management'),
|
|
dcc.Tab(label='📈 Performance', value='performance'),
|
|
dcc.Tab(label='⚙️ System Health', value='system-health'),
|
|
], style={'margin-bottom': '20px'}),
|
|
|
|
# Tab content container
|
|
html.Div(id='tab-content'),
|
|
|
|
# Hidden button for callback compatibility (real button is in market data layout)
|
|
html.Button(id='add-indicator-btn', style={'display': 'none'}),
|
|
|
|
# Add Indicator Modal
|
|
create_indicator_modal(),
|
|
|
|
# Auto-refresh interval
|
|
dcc.Interval(
|
|
id='interval-component',
|
|
interval=30*1000, # Update every 30 seconds
|
|
n_intervals=0
|
|
)
|
|
])
|
|
])
|
|
|
|
return app
|
|
|
|
|
|
def register_callbacks(app):
|
|
"""Register all dashboard callbacks."""
|
|
from dashboard.callbacks import (
|
|
register_navigation_callbacks,
|
|
register_chart_callbacks,
|
|
register_indicator_callbacks,
|
|
register_system_health_callbacks
|
|
)
|
|
|
|
# Register all callback modules
|
|
register_navigation_callbacks(app)
|
|
register_chart_callbacks(app)
|
|
register_indicator_callbacks(app)
|
|
register_system_health_callbacks(app)
|
|
|
|
logger.info("All dashboard callbacks registered successfully") |