Download app/dashboard/index.html from CJR61/papi_cc: direct link, hf CLI and curl.
- Browser
- Download file 10.6 kB
-
https://huggingface.co/spaces/CJR61/papi_cc/resolve/main/app/dashboard/index.html
- Command line
-
hf download hf://spaces/CJR61/papi_cc/app/dashboard/index.html
-
curl -L -o index.html https://huggingface.co/spaces/CJR61/papi_cc/resolve/main/app/dashboard/index.html
10.6 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>papi_cc Dashboard</title> | |
| <style> | |
| *{box-sizing:border-box;margin:0;padding:0} | |
| body{font-family:system-ui,-apple-system,sans-serif;background:#f0f2f5;color:#333;min-height:100vh} | |
| /* Header */ | |
| header{background:#1a1a2e;color:#fff;padding:.9rem 2rem;display:flex;justify-content:space-between;align-items:center;box-shadow:0 2px 8px rgba(0,0,0,.3)} | |
| header h1{font-size:1.25rem;letter-spacing:.5px} | |
| .running-badge{font-size:.72rem;background:#4ade80;color:#14532d;padding:3px 10px;border-radius:20px;font-weight:700;letter-spacing:.5px} | |
| /* Layout */ | |
| .container{max-width:1200px;margin:0 auto;padding:1.5rem} | |
| /* Status cards */ | |
| .cards{display:grid;grid-template-columns:repeat(3,1fr);gap:1rem;margin-bottom:1.5rem} | |
| @media(max-width:640px){.cards{grid-template-columns:1fr}} | |
| .card{background:#fff;border-radius:10px;padding:1.2rem 1.4rem;box-shadow:0 1px 4px rgba(0,0,0,.08)} | |
| .card-label{font-size:.72rem;text-transform:uppercase;letter-spacing:.8px;color:#9ca3af;margin-bottom:.5rem} | |
| .card-value{font-size:2rem;font-weight:700;line-height:1} | |
| .card-sub{font-size:.76rem;color:#6b7280;margin-top:.35rem} | |
| .bar-track{height:6px;background:#e5e7eb;border-radius:3px;margin-top:.8rem;overflow:hidden} | |
| .bar-fill{height:100%;border-radius:3px;transition:width .6s ease} | |
| .bar-green{background:#22c55e}.bar-yellow{background:#eab308}.bar-red{background:#ef4444} | |
| /* Tabs */ | |
| .tab-header{display:flex;gap:0;border-bottom:2px solid #e5e7eb;margin-bottom:1.2rem} | |
| .tab-btn{padding:.55rem 1.3rem;cursor:pointer;font-size:.875rem;color:#6b7280;border-bottom:2px solid transparent;margin-bottom:-2px;user-select:none;transition:color .2s} | |
| .tab-btn:hover{color:#1a1a2e} | |
| .tab-btn.active{color:#1a1a2e;border-bottom-color:#1a1a2e;font-weight:600} | |
| .tab-pane{display:none}.tab-pane.active{display:block} | |
| /* Log box */ | |
| .log-box{background:#0f172a;color:#cbd5e1;font-family:'Courier New',monospace;font-size:.78rem;padding:1rem;border-radius:10px;height:460px;overflow-y:auto;line-height:1.55} | |
| .log-box .l{padding:1px 0} | |
| .log-box .l.err{color:#f87171}.log-box .l.inf{color:#86efac}.log-box .l.wrn{color:#fde047} | |
| /* Table */ | |
| .tbl-wrap{background:#fff;border-radius:10px;box-shadow:0 1px 4px rgba(0,0,0,.08);overflow:hidden} | |
| .tbl-meta{padding:.7rem 1.1rem;font-size:.8rem;color:#6b7280;border-bottom:1px solid #f3f4f6} | |
| table{width:100%;border-collapse:collapse;font-size:.86rem} | |
| th{background:#f9fafb;padding:.75rem 1rem;text-align:left;font-size:.76rem;font-weight:600;text-transform:uppercase;letter-spacing:.5px;color:#6b7280;border-bottom:1px solid #e5e7eb} | |
| td{padding:.65rem 1rem;border-bottom:1px solid #f3f4f6} | |
| tr:last-child td{border-bottom:none} | |
| tr:hover td{background:#fafafa} | |
| .pill{display:inline-block;padding:2px 9px;border-radius:20px;font-size:.72rem;font-weight:600} | |
| .pill-b{background:#fef9c3;color:#854d0e} | |
| .pill-v{background:#fee2e2;color:#991b1b} | |
| .pill-n{background:#f3f4f6;color:#6b7280} | |
| /* Image grid */ | |
| .img-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(160px,1fr));gap:1rem} | |
| .img-card{background:#fff;border-radius:10px;overflow:hidden;box-shadow:0 1px 4px rgba(0,0,0,.08);transition:transform .15s} | |
| .img-card:hover{transform:translateY(-2px)} | |
| .img-card img{width:100%;height:130px;object-fit:cover;display:block;background:#f3f4f6} | |
| .img-meta{padding:.5rem .7rem;font-size:.72rem;color:#6b7280;word-break:break-all;line-height:1.4} | |
| .img-meta strong{display:block;color:#374151;font-weight:500} | |
| /* Misc */ | |
| .footer{font-size:.73rem;color:#9ca3af;text-align:right;margin-top:1rem} | |
| .empty{text-align:center;color:#9ca3af;padding:3rem 1rem;font-size:.9rem} | |
| .section-title{font-size:.8rem;color:#6b7280;margin-bottom:.8rem} | |
| </style> | |
| </head> | |
| <body> | |
| <header> | |
| <h1>🐷 papi_cc Dashboard</h1> | |
| <span class="running-badge">● RUNNING</span> | |
| </header> | |
| <div class="container"> | |
| <!-- Status Cards --> | |
| <div class="cards"> | |
| <div class="card"> | |
| <div class="card-label">CPU Usage</div> | |
| <div class="card-value" id="cpu-val">—</div> | |
| <div class="card-sub">utilization</div> | |
| <div class="bar-track"><div class="bar-fill bar-green" id="cpu-bar" style="width:0%"></div></div> | |
| </div> | |
| <div class="card"> | |
| <div class="card-label">RAM</div> | |
| <div class="card-value" id="ram-val">—</div> | |
| <div class="card-sub" id="ram-sub">—</div> | |
| <div class="bar-track"><div class="bar-fill bar-green" id="ram-bar" style="width:0%"></div></div> | |
| </div> | |
| <div class="card"> | |
| <div class="card-label">Disk</div> | |
| <div class="card-value" id="disk-val">—</div> | |
| <div class="card-sub" id="disk-sub">—</div> | |
| <div class="bar-track"><div class="bar-fill bar-green" id="disk-bar" style="width:0%"></div></div> | |
| </div> | |
| </div> | |
| <!-- Tabs --> | |
| <div class="tab-header"> | |
| <div class="tab-btn active" onclick="switchTab('logs',this)">Logs</div> | |
| <div class="tab-btn" onclick="switchTab('records',this)">Inference Records</div> | |
| <div class="tab-btn" onclick="switchTab('images',this)">Uploaded Images</div> | |
| </div> | |
| <!-- Logs --> | |
| <div class="tab-pane active" id="tab-logs"> | |
| <div class="section-title" id="log-meta">Loading…</div> | |
| <div class="log-box" id="log-box"></div> | |
| </div> | |
| <!-- Records --> | |
| <div class="tab-pane" id="tab-records"> | |
| <div class="tbl-wrap"> | |
| <div class="tbl-meta" id="db-meta">Loading…</div> | |
| <table> | |
| <thead><tr><th>ID / Timestamp</th><th>Prediction</th><th>Probability</th><th>Similarity</th></tr></thead> | |
| <tbody id="db-body"><tr><td colspan="4" class="empty">Loading…</td></tr></tbody> | |
| </table> | |
| </div> | |
| </div> | |
| <!-- Images --> | |
| <div class="tab-pane" id="tab-images"> | |
| <div class="section-title" id="img-meta">Loading…</div> | |
| <div class="img-grid" id="img-grid"></div> | |
| </div> | |
| <div class="footer">Auto-refresh every 5s · Last updated: <span id="last-update">—</span></div> | |
| </div> | |
| <script> | |
| // Extract key from current URL and append to all API calls | |
| const _key = new URLSearchParams(location.search).get('key') || ''; | |
| function api(path) { | |
| return path + (path.includes('?') ? '&' : '?') + 'key=' + encodeURIComponent(_key); | |
| } | |
| let activeTab = 'logs'; | |
| function switchTab(tab, el) { | |
| document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active')); | |
| document.querySelectorAll('.tab-pane').forEach(p => p.classList.remove('active')); | |
| el.classList.add('active'); | |
| document.getElementById('tab-' + tab).classList.add('active'); | |
| activeTab = tab; | |
| loadTab(tab); | |
| } | |
| function barColor(pct) { | |
| return pct > 80 ? 'bar-red' : pct > 60 ? 'bar-yellow' : 'bar-green'; | |
| } | |
| function setBar(id, pct) { | |
| const el = document.getElementById(id); | |
| el.style.width = pct + '%'; | |
| el.className = 'bar-fill ' + barColor(pct); | |
| } | |
| async function loadStatus() { | |
| try { | |
| const d = await fetch(api('/dashboard/status/')).then(r => r.json()); | |
| document.getElementById('cpu-val').textContent = d.cpu_percent + '%'; | |
| setBar('cpu-bar', d.cpu_percent); | |
| document.getElementById('ram-val').textContent = d.ram_used_mb + ' MB'; | |
| document.getElementById('ram-sub').textContent = | |
| `Available: ${d.ram_available_mb} MB / Total: ${d.ram_total_mb} MB`; | |
| setBar('ram-bar', d.ram_percent); | |
| document.getElementById('disk-val').textContent = d.disk_used_gb + ' GB'; | |
| document.getElementById('disk-sub').textContent = | |
| `Free: ${d.disk_free_gb} GB / Total: ${d.disk_total_gb} GB`; | |
| setBar('disk-bar', d.disk_percent); | |
| document.getElementById('last-update').textContent = new Date().toLocaleTimeString(); | |
| } catch(e) { console.error(e); } | |
| } | |
| async function loadLogs() { | |
| try { | |
| const d = await fetch(api('/dashboard/logs/?lines=150')).then(r => r.json()); | |
| document.getElementById('log-meta').textContent = | |
| `Showing last ${d.lines.length} of ${d.total} total lines`; | |
| const box = document.getElementById('log-box'); | |
| if (!d.lines.length) { | |
| box.innerHTML = '<div class="empty">No logs yet</div>'; | |
| return; | |
| } | |
| box.innerHTML = d.lines.map(line => { | |
| const cls = line.includes('[ERROR]') ? 'err' : line.includes('[INFO]') ? 'inf' : | |
| line.includes('[WARNING]') ? 'wrn' : ''; | |
| return `<div class="l ${cls}">${line.replace(/&/g,'&').replace(/</g,'<')}</div>`; | |
| }).join(''); | |
| box.scrollTop = box.scrollHeight; | |
| } catch(e) { console.error(e); } | |
| } | |
| async function loadRecords() { | |
| try { | |
| const d = await fetch(api('/dashboard/database/')).then(r => r.json()); | |
| document.getElementById('db-meta').textContent = `Total records: ${d.total}`; | |
| const tbody = document.getElementById('db-body'); | |
| if (!d.records.length) { | |
| tbody.innerHTML = '<tr><td colspan="4" class="empty">No inference records yet</td></tr>'; | |
| return; | |
| } | |
| tbody.innerHTML = d.records.map(rec => { | |
| const pillCls = rec.Prediction === 'bacteria' ? 'pill-b' : | |
| rec.Prediction === 'virus' ? 'pill-v' : 'pill-n'; | |
| const prob = isNaN(rec.Probability) ? '—' : | |
| (parseFloat(rec.Probability) * 100).toFixed(0) + '%'; | |
| return `<tr> | |
| <td style="font-family:monospace;font-size:.8rem">${rec.ID}</td> | |
| <td><span class="pill ${pillCls}">${rec.Prediction}</span></td> | |
| <td>${prob}</td> | |
| <td>${rec.Similarity ?? '—'}</td> | |
| </tr>`; | |
| }).join(''); | |
| } catch(e) { console.error(e); } | |
| } | |
| async function loadImages() { | |
| try { | |
| const d = await fetch(api('/dashboard/uploads/')).then(r => r.json()); | |
| document.getElementById('img-meta').textContent = `Total uploads: ${d.total}`; | |
| const grid = document.getElementById('img-grid'); | |
| if (!d.files.length) { | |
| grid.innerHTML = '<div class="empty">No uploaded images yet</div>'; | |
| return; | |
| } | |
| grid.innerHTML = d.files.map(f => ` | |
| <div class="img-card"> | |
| <img src="${api(f.url)}" alt="${f.name}" loading="lazy" | |
| onerror="this.parentElement.style.display='none'"> | |
| <div class="img-meta"> | |
| <strong>${f.name}</strong> | |
| ${f.size_kb} KB | |
| </div> | |
| </div>`).join(''); | |
| } catch(e) { console.error(e); } | |
| } | |
| function loadTab(tab) { | |
| if (tab === 'logs') loadLogs(); | |
| else if (tab === 'records') loadRecords(); | |
| else if (tab === 'images') loadImages(); | |
| } | |
| // Init | |
| loadStatus(); | |
| loadLogs(); | |
| // Auto-refresh every 5s | |
| setInterval(() => { | |
| loadStatus(); | |
| loadTab(activeTab); | |
| }, 5000); | |
| </script> | |
| </body> | |
| </html> | |