- Deleted `app_new.py`, which was previously the main entry point for the dashboard application, to streamline the codebase. - Consolidated the application initialization and callback registration logic into `main.py`, enhancing modularity and maintainability. - Updated the logging and error handling practices in `main.py` to ensure consistent application behavior and improved debugging capabilities. These changes simplify the application structure, aligning with project standards for modularity and maintainability.
78 lines
2.5 KiB
Python
78 lines
2.5 KiB
Python
"""
|
|
Main dashboard application module.
|
|
"""
|
|
|
|
import dash
|
|
from dash import html, dcc
|
|
import dash_bootstrap_components as dbc
|
|
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, external_stylesheets=[dbc.themes.LUX])
|
|
|
|
# Define the main layout
|
|
app.layout = html.Div([
|
|
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_data_analysis_callbacks
|
|
)
|
|
|
|
# Register all callback modules
|
|
register_navigation_callbacks(app)
|
|
register_chart_callbacks(app)
|
|
register_indicator_callbacks(app)
|
|
register_system_health_callbacks(app)
|
|
register_data_analysis_callbacks(app)
|
|
|
|
logger.info("All dashboard callbacks registered successfully") |