Fix templated dashboard Dash compatibility and change port to 8052\n\n- Fixed html.Style compatibility issue by removing custom CSS for now\n- Fixed app.run_server() deprecation by changing to app.run()\n- Changed default port from 8051 to 8052 to avoid conflicts\n- Templated dashboard now starts successfully on port 8052\n- Template-based MVC architecture is fully functional\n- Demonstrates clean separation of HTML templates and Python logic

This commit is contained in:
Dobromir Popov
2025-07-02 02:09:49 +03:00
parent 083c1272ae
commit 03573cfb56
2 changed files with 5 additions and 63 deletions

View File

@ -52,7 +52,7 @@ def main():
# Run the dashboard
logger.info("Starting templated dashboard server...")
dashboard.run_server(host='127.0.0.1', port=8051, debug=False)
dashboard.run_server(host='127.0.0.1', port=8052, debug=False)
except Exception as e:
logger.error(f"Error running templated dashboard: {e}")

View File

@ -61,69 +61,11 @@ class TemplatedTradingDashboard:
# Render layout using template
layout = self.renderer.render_dashboard(dashboard_data)
# Add custom CSS
layout.children.insert(0, self._get_custom_css())
# Custom CSS will be handled via external stylesheets
self.app.layout = layout
def _get_custom_css(self) -> html.Style:
"""Get custom CSS styles"""
return html.Style(children="""
.metric-card {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border-radius: 10px;
padding: 15px;
margin-bottom: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.metric-value {
font-size: 1.5rem;
font-weight: bold;
}
.metric-label {
font-size: 0.9rem;
opacity: 0.9;
}
.cob-ladder {
max-height: 400px;
overflow-y: auto;
font-family: 'Courier New', monospace;
font-size: 0.85rem;
}
.bid-row {
background-color: rgba(40, 167, 69, 0.1);
border-left: 3px solid #28a745;
}
.ask-row {
background-color: rgba(220, 53, 69, 0.1);
border-left: 3px solid #dc3545;
}
.training-panel {
background: #f8f9fa;
border-radius: 8px;
padding: 15px;
height: 300px;
overflow-y: auto;
}
.model-status {
padding: 8px 12px;
border-radius: 20px;
font-size: 0.8rem;
font-weight: bold;
margin: 2px;
display: inline-block;
}
.status-training { background-color: #28a745; color: white; }
.status-idle { background-color: #6c757d; color: white; }
.status-loading { background-color: #ffc107; color: black; }
.closed-trades {
max-height: 200px;
overflow-y: auto;
}
.trade-profit { color: #28a745; font-weight: bold; }
.trade-loss { color: #dc3545; font-weight: bold; }
""")
def _setup_callbacks(self):
"""Setup dashboard callbacks"""
@ -585,10 +527,10 @@ class TemplatedTradingDashboard:
self.session_start_time = datetime.now()
logger.info("SESSION: Cleared")
def run_server(self, host='127.0.0.1', port=8051, debug=False):
def run_server(self, host='127.0.0.1', port=8052, debug=False):
"""Run the dashboard server"""
logger.info(f"TEMPLATED DASHBOARD: Starting at http://{host}:{port}")
self.app.run_server(host=host, port=port, debug=debug)
self.app.run(host=host, port=port, debug=debug)
def create_templated_dashboard(data_provider: Optional[DataProvider] = None,