File size: 14,270 Bytes
b068b76 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Crypto Monitor - Provider Dashboard</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--primary: #6366f1;
--primary-dark: #4f46e5;
--success: #10b981;
--warning: #f59e0b;
--danger: #ef4444;
--info: #3b82f6;
--bg-dark: #0f172a;
--bg-card: #1e293b;
--bg-hover: #334155;
--text-light: #f1f5f9;
--text-muted: #94a3b8;
--border: #334155;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
color: var(--text-light);
line-height: 1.6;
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1600px;
margin: 0 auto;
}
header {
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
padding: 30px;
border-radius: 16px;
margin-bottom: 30px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
text-align: center;
}
header h1 {
font-size: 32px;
font-weight: 700;
margin-bottom: 8px;
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
}
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
margin-bottom: 30px;
}
.stat-card {
background: var(--bg-card);
padding: 24px;
border-radius: 12px;
border: 1px solid var(--border);
border-top: 4px solid var(--primary);
}
.stat-card:hover {
transform: translateY(-4px);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
transition: all 0.3s;
}
.stat-card .label {
color: var(--text-muted);
font-size: 13px;
text-transform: uppercase;
letter-spacing: 0.5px;
font-weight: 600;
margin-bottom: 8px;
}
.stat-card .value {
font-size: 36px;
font-weight: 700;
margin: 8px 0;
}
.filters {
background: var(--bg-card);
padding: 20px;
border-radius: 12px;
margin-bottom: 20px;
border: 1px solid var(--border);
display: flex;
gap: 15px;
flex-wrap: wrap;
}
.search-box input, .filters select, .filters button {
padding: 10px 16px;
background: var(--bg-dark);
border: 1px solid var(--border);
border-radius: 8px;
color: var(--text-light);
font-size: 14px;
}
.filters button {
background: var(--primary);
border-color: var(--primary);
cursor: pointer;
font-weight: 600;
}
.filters button:hover {
background: var(--primary-dark);
}
.table-container {
background: var(--bg-card);
border-radius: 12px;
border: 1px solid var(--border);
overflow: hidden;
}
table {
width: 100%;
border-collapse: collapse;
}
thead {
background: var(--bg-dark);
}
thead th {
text-align: left;
padding: 16px 20px;
font-weight: 600;
font-size: 13px;
text-transform: uppercase;
color: var(--text-muted);
}
tbody tr {
border-bottom: 1px solid var(--border);
}
tbody tr:hover {
background: var(--bg-hover);
}
tbody td {
padding: 16px 20px;
font-size: 14px;
}
.badge {
display: inline-block;
padding: 6px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
text-transform: uppercase;
}
.badge.validated {
background: rgba(16, 185, 129, 0.15);
color: var(--success);
}
.badge.unvalidated {
background: rgba(239, 68, 68, 0.15);
color: var(--danger);
}
.category {
padding: 4px 10px;
border-radius: 6px;
font-size: 12px;
background: rgba(99, 102, 241, 0.1);
color: var(--primary);
}
.type {
padding: 4px 8px;
border-radius: 4px;
font-size: 11px;
background: rgba(59, 130, 246, 0.1);
color: var(--info);
}
.response-time {
font-weight: 600;
}
.response-time.fast { color: var(--success); }
.response-time.medium { color: var(--warning); }
.response-time.slow { color: var(--danger); }
@media (max-width: 768px) {
.stats-grid {
grid-template-columns: 1fr;
}
.filters {
flex-direction: column;
}
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>
<span style="font-size: 40px;">π</span>
Crypto Provider Monitor
</h1>
<p style="color: rgba(255, 255, 255, 0.85);">Real-time API Provider Monitoring Dashboard</p>
</header>
<div class="stats-grid">
<div class="stat-card">
<div class="label">Total Providers</div>
<div class="value" style="color: var(--primary);" id="totalProviders">-</div>
</div>
<div class="stat-card">
<div class="label">β
Validated</div>
<div class="value" style="color: var(--success);" id="validatedCount">-</div>
</div>
<div class="stat-card">
<div class="label">β Unvalidated</div>
<div class="value" style="color: var(--danger);" id="unvalidatedCount">-</div>
</div>
<div class="stat-card">
<div class="label">β‘ Avg Response</div>
<div class="value" style="color: var(--warning); font-size: 28px;" id="avgResponse">- ms</div>
</div>
</div>
<div class="filters">
<select id="categoryFilter" onchange="applyFilters()">
<option value="all">All Categories</option>
</select>
<select id="statusFilter" onchange="applyFilters()">
<option value="all">All Status</option>
<option value="validated">Validated</option>
<option value="unvalidated">Unvalidated</option>
</select>
<div class="search-box" style="flex: 1; min-width: 250px;">
<input type="text" id="searchInput" placeholder="Search providers..." onkeyup="applyFilters()">
</div>
<button onclick="refreshData()">π Refresh</button>
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>Provider ID</th>
<th>Name</th>
<th>Category</th>
<th>Type</th>
<th>Status</th>
<th>Response Time</th>
</tr>
</thead>
<tbody id="providersTable">
<tr><td colspan="6" style="text-align: center; padding: 40px;">Loading...</td></tr>
</tbody>
</table>
</div>
</div>
<script>
let allProviders = [];
// Auto-detect API endpoint
function getAPIEndpoint() {
const host = window.location.hostname;
const port = window.location.port;
const protocol = window.location.protocol;
// For Hugging Face Spaces
if (host.includes('hf.space') || host.includes('huggingface')) {
return `${protocol}//${host}/api/providers`;
}
// For local development
if (port) {
return `${protocol}//${host}:${port}/api/providers`;
}
return '/api/providers';
}
async function fetchProviders() {
try {
const response = await fetch(getAPIEndpoint());
const data = await response.json();
allProviders = data.providers || [];
updateUI();
} catch (error) {
console.error('Error:', error);
document.getElementById('providersTable').innerHTML =
'<tr><td colspan="6" style="text-align: center; padding: 40px; color: var(--danger);">Error loading providers</td></tr>';
}
}
function updateUI() {
updateStats();
populateFilters();
applyFilters();
}
function updateStats() {
const total = allProviders.length;
const validated = allProviders.filter(p => p.status === 'validated').length;
const unvalidated = total - validated;
const responseTimes = allProviders
.filter(p => p.response_time_ms > 0)
.map(p => p.response_time_ms);
const avgResponse = responseTimes.length > 0
? Math.round(responseTimes.reduce((a, b) => a + b) / responseTimes.length)
: 0;
document.getElementById('totalProviders').textContent = total;
document.getElementById('validatedCount').textContent = validated;
document.getElementById('unvalidatedCount').textContent = unvalidated;
document.getElementById('avgResponse').textContent = avgResponse > 0 ? `${avgResponse} ms` : 'N/A';
}
function populateFilters() {
const categories = [...new Set(allProviders.map(p => p.category))].filter(c => c).sort();
const categoryFilter = document.getElementById('categoryFilter');
categoryFilter.innerHTML = '<option value="all">All Categories</option>';
categories.forEach(cat => {
categoryFilter.innerHTML += `<option value="${cat}">${cat.replace(/_/g, ' ').toUpperCase()}</option>`;
});
}
function applyFilters() {
const category = document.getElementById('categoryFilter').value;
const status = document.getElementById('statusFilter').value;
const search = document.getElementById('searchInput').value.toLowerCase();
let filtered = allProviders.filter(p => {
const matchCategory = category === 'all' || p.category === category;
const matchStatus = status === 'all' || p.status === status;
const matchSearch = !search ||
p.name.toLowerCase().includes(search) ||
p.provider_id.toLowerCase().includes(search) ||
(p.category && p.category.toLowerCase().includes(search));
return matchCategory && matchStatus && matchSearch;
});
renderTable(filtered);
}
function renderTable(providers) {
const tbody = document.getElementById('providersTable');
if (providers.length === 0) {
tbody.innerHTML = '<tr><td colspan="6" style="text-align: center; padding: 40px;">No providers found</td></tr>';
return;
}
tbody.innerHTML = providers.map(p => {
const responseTime = p.response_time_ms || 0;
let responseClass = 'fast';
if (responseTime > 500) responseClass = 'slow';
else if (responseTime > 200) responseClass = 'medium';
return `
<tr>
<td><code style="color: var(--text-muted); font-size: 12px;">${p.provider_id}</code></td>
<td><strong>${p.name}</strong></td>
<td><span class="category">${(p.category || 'unknown').replace(/_/g, ' ')}</span></td>
<td><span class="type">${(p.type || 'unknown').replace(/_/g, ' ')}</span></td>
<td><span class="badge ${p.status}">${p.status}</span></td>
<td>${responseTime > 0 ?
`<span class="response-time ${responseClass}">${Math.round(responseTime)} ms</span>` :
'<span style="color: var(--text-muted);">N/A</span>'
}</td>
</tr>
`;
}).join('');
}
function refreshData() {
fetchProviders();
}
// Initial load
fetchProviders();
// Auto-refresh every 30 seconds
setInterval(fetchProviders, 30000);
</script>
</body>
</html>
|