| <!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 = [];
|
|
|
|
|
| function getAPIEndpoint() {
|
| const host = window.location.hostname;
|
| const port = window.location.port;
|
| const protocol = window.location.protocol;
|
|
|
|
|
| if (host.includes('hf.space') || host.includes('huggingface')) {
|
| return `${protocol}//${host}/api/providers`;
|
| }
|
|
|
|
|
| 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();
|
| }
|
|
|
|
|
| fetchProviders();
|
|
|
|
|
| setInterval(fetchProviders, 30000);
|
| </script>
|
| </body>
|
| </html>
|
|
|