412 lines
14 KiB
HTML
412 lines
14 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>COBY - Multi-Exchange Data Aggregation</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: #333;
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.header {
|
|
background: rgba(255, 255, 255, 0.1);
|
|
backdrop-filter: blur(10px);
|
|
padding: 1rem 2rem;
|
|
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
|
|
}
|
|
|
|
.header h1 {
|
|
color: white;
|
|
font-size: 2rem;
|
|
font-weight: 300;
|
|
}
|
|
|
|
.header p {
|
|
color: rgba(255, 255, 255, 0.8);
|
|
margin-top: 0.5rem;
|
|
}
|
|
|
|
.container {
|
|
flex: 1;
|
|
padding: 2rem;
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
width: 100%;
|
|
}
|
|
|
|
.status-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
|
gap: 1.5rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.status-card {
|
|
background: rgba(255, 255, 255, 0.9);
|
|
border-radius: 12px;
|
|
padding: 1.5rem;
|
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
|
|
backdrop-filter: blur(10px);
|
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
}
|
|
|
|
.status-card h3 {
|
|
color: #333;
|
|
margin-bottom: 1rem;
|
|
font-size: 1.2rem;
|
|
}
|
|
|
|
.status-indicator {
|
|
display: flex;
|
|
align-items: center;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.status-dot {
|
|
width: 12px;
|
|
height: 12px;
|
|
border-radius: 50%;
|
|
margin-right: 0.5rem;
|
|
}
|
|
|
|
.status-dot.healthy {
|
|
background: #4CAF50;
|
|
box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
|
|
}
|
|
|
|
.status-dot.warning {
|
|
background: #FF9800;
|
|
box-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
|
|
}
|
|
|
|
.status-dot.error {
|
|
background: #F44336;
|
|
box-shadow: 0 0 10px rgba(244, 67, 54, 0.5);
|
|
}
|
|
|
|
.status-dot.unknown {
|
|
background: #9E9E9E;
|
|
}
|
|
|
|
.metrics-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
gap: 1rem;
|
|
margin-top: 1rem;
|
|
}
|
|
|
|
.metric-item {
|
|
background: rgba(255, 255, 255, 0.1);
|
|
padding: 0.75rem;
|
|
border-radius: 8px;
|
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
}
|
|
|
|
.metric-label {
|
|
font-size: 0.9rem;
|
|
color: #666;
|
|
margin-bottom: 0.25rem;
|
|
}
|
|
|
|
.metric-value {
|
|
font-size: 1.5rem;
|
|
font-weight: 600;
|
|
color: #333;
|
|
}
|
|
|
|
.loading {
|
|
text-align: center;
|
|
padding: 2rem;
|
|
color: rgba(255, 255, 255, 0.8);
|
|
}
|
|
|
|
.error-message {
|
|
background: rgba(244, 67, 54, 0.1);
|
|
border: 1px solid rgba(244, 67, 54, 0.3);
|
|
color: #F44336;
|
|
padding: 1rem;
|
|
border-radius: 8px;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.refresh-button {
|
|
background: rgba(255, 255, 255, 0.2);
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
color: white;
|
|
padding: 0.5rem 1rem;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
font-size: 0.9rem;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.refresh-button:hover {
|
|
background: rgba(255, 255, 255, 0.3);
|
|
}
|
|
|
|
.footer {
|
|
background: rgba(0, 0, 0, 0.1);
|
|
padding: 1rem 2rem;
|
|
text-align: center;
|
|
color: rgba(255, 255, 255, 0.6);
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.header {
|
|
padding: 1rem;
|
|
}
|
|
|
|
.container {
|
|
padding: 1rem;
|
|
}
|
|
|
|
.status-grid {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="header">
|
|
<h1>COBY Dashboard</h1>
|
|
<p>Multi-Exchange Data Aggregation System</p>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<div id="error-container"></div>
|
|
|
|
<div id="loading" class="loading">
|
|
<p>Loading system status...</p>
|
|
</div>
|
|
|
|
<div id="dashboard" style="display: none;">
|
|
<div class="status-grid">
|
|
<div class="status-card">
|
|
<h3>System Status</h3>
|
|
<div id="system-status">
|
|
<div class="status-indicator">
|
|
<div class="status-dot unknown"></div>
|
|
<span>Checking system health...</span>
|
|
</div>
|
|
</div>
|
|
<button class="refresh-button" onclick="refreshData()">Refresh</button>
|
|
</div>
|
|
|
|
<div class="status-card">
|
|
<h3>Exchange Connections</h3>
|
|
<div id="exchange-status">
|
|
<div class="status-indicator">
|
|
<div class="status-dot unknown"></div>
|
|
<span>Loading exchange status...</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="status-card">
|
|
<h3>Performance Metrics</h3>
|
|
<div class="metrics-grid" id="performance-metrics">
|
|
<div class="metric-item">
|
|
<div class="metric-label">CPU Usage</div>
|
|
<div class="metric-value">--</div>
|
|
</div>
|
|
<div class="metric-item">
|
|
<div class="metric-label">Memory Usage</div>
|
|
<div class="metric-value">--</div>
|
|
</div>
|
|
<div class="metric-item">
|
|
<div class="metric-label">Throughput</div>
|
|
<div class="metric-value">--</div>
|
|
</div>
|
|
<div class="metric-item">
|
|
<div class="metric-label">Latency</div>
|
|
<div class="metric-value">--</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="status-card">
|
|
<h3>Data Processing</h3>
|
|
<div id="processing-status">
|
|
<div class="status-indicator">
|
|
<div class="status-dot unknown"></div>
|
|
<span>Loading processing status...</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="footer">
|
|
<p>© 2024 COBY Multi-Exchange Data Aggregation System</p>
|
|
</div>
|
|
|
|
<script>
|
|
let ws = null;
|
|
let reconnectAttempts = 0;
|
|
const maxReconnectAttempts = 5;
|
|
|
|
// Initialize dashboard
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
loadInitialData();
|
|
connectWebSocket();
|
|
});
|
|
|
|
async function loadInitialData() {
|
|
try {
|
|
const response = await fetch('/api/health');
|
|
if (response.ok) {
|
|
const data = await response.json();
|
|
updateSystemStatus(data);
|
|
document.getElementById('loading').style.display = 'none';
|
|
document.getElementById('dashboard').style.display = 'block';
|
|
} else {
|
|
showError('Failed to load system status');
|
|
}
|
|
} catch (error) {
|
|
showError('Unable to connect to COBY API: ' + error.message);
|
|
}
|
|
}
|
|
|
|
function connectWebSocket() {
|
|
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
const wsUrl = `${protocol}//${window.location.host}/ws/dashboard`;
|
|
|
|
ws = new WebSocket(wsUrl);
|
|
|
|
ws.onopen = function() {
|
|
console.log('WebSocket connected');
|
|
reconnectAttempts = 0;
|
|
};
|
|
|
|
ws.onmessage = function(event) {
|
|
try {
|
|
const data = JSON.parse(event.data);
|
|
updateDashboard(data);
|
|
} catch (error) {
|
|
console.error('Error parsing WebSocket message:', error);
|
|
}
|
|
};
|
|
|
|
ws.onclose = function() {
|
|
console.log('WebSocket disconnected');
|
|
if (reconnectAttempts < maxReconnectAttempts) {
|
|
setTimeout(() => {
|
|
reconnectAttempts++;
|
|
connectWebSocket();
|
|
}, 5000);
|
|
}
|
|
};
|
|
|
|
ws.onerror = function(error) {
|
|
console.error('WebSocket error:', error);
|
|
};
|
|
}
|
|
|
|
function updateSystemStatus(data) {
|
|
const systemStatus = document.getElementById('system-status');
|
|
const status = data.status || 'unknown';
|
|
const healthy = status === 'healthy';
|
|
|
|
systemStatus.innerHTML = `
|
|
<div class="status-indicator">
|
|
<div class="status-dot ${healthy ? 'healthy' : 'error'}"></div>
|
|
<span>System ${healthy ? 'Healthy' : 'Unhealthy'}</span>
|
|
</div>
|
|
<p style="margin-top: 0.5rem; font-size: 0.9rem; color: #666;">
|
|
Last updated: ${new Date(data.timestamp || Date.now()).toLocaleString()}
|
|
</p>
|
|
`;
|
|
}
|
|
|
|
function updateDashboard(data) {
|
|
// Update performance metrics if available
|
|
if (data.performance) {
|
|
updatePerformanceMetrics(data.performance);
|
|
}
|
|
|
|
// Update exchange status if available
|
|
if (data.exchanges) {
|
|
updateExchangeStatus(data.exchanges);
|
|
}
|
|
|
|
// Update processing status if available
|
|
if (data.processing) {
|
|
updateProcessingStatus(data.processing);
|
|
}
|
|
}
|
|
|
|
function updatePerformanceMetrics(performance) {
|
|
const metricsContainer = document.getElementById('performance-metrics');
|
|
const metrics = [
|
|
{ label: 'CPU Usage', value: `${(performance.cpu_usage || 0).toFixed(1)}%` },
|
|
{ label: 'Memory Usage', value: `${(performance.memory_usage || 0).toFixed(1)}%` },
|
|
{ label: 'Throughput', value: `${(performance.throughput || 0).toFixed(0)} ops/s` },
|
|
{ label: 'Latency', value: `${(performance.avg_latency || 0).toFixed(1)}ms` }
|
|
];
|
|
|
|
metricsContainer.innerHTML = metrics.map(metric => `
|
|
<div class="metric-item">
|
|
<div class="metric-label">${metric.label}</div>
|
|
<div class="metric-value">${metric.value}</div>
|
|
</div>
|
|
`).join('');
|
|
}
|
|
|
|
function updateExchangeStatus(exchanges) {
|
|
const exchangeStatus = document.getElementById('exchange-status');
|
|
const connectedCount = Object.values(exchanges).filter(status => status === 'connected').length;
|
|
const totalCount = Object.keys(exchanges).length;
|
|
|
|
exchangeStatus.innerHTML = `
|
|
<div class="status-indicator">
|
|
<div class="status-dot ${connectedCount === totalCount ? 'healthy' : connectedCount > 0 ? 'warning' : 'error'}"></div>
|
|
<span>${connectedCount}/${totalCount} exchanges connected</span>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
function updateProcessingStatus(processing) {
|
|
const processingStatus = document.getElementById('processing-status');
|
|
const isProcessing = processing.active || false;
|
|
|
|
processingStatus.innerHTML = `
|
|
<div class="status-indicator">
|
|
<div class="status-dot ${isProcessing ? 'healthy' : 'warning'}"></div>
|
|
<span>Data processing ${isProcessing ? 'active' : 'inactive'}</span>
|
|
</div>
|
|
<p style="margin-top: 0.5rem; font-size: 0.9rem; color: #666;">
|
|
Processed: ${processing.total_processed || 0} events
|
|
</p>
|
|
`;
|
|
}
|
|
|
|
function showError(message) {
|
|
const errorContainer = document.getElementById('error-container');
|
|
errorContainer.innerHTML = `
|
|
<div class="error-message">
|
|
<strong>Error:</strong> ${message}
|
|
</div>
|
|
`;
|
|
document.getElementById('loading').style.display = 'none';
|
|
}
|
|
|
|
async function refreshData() {
|
|
await loadInitialData();
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |