32 lines
5.5 KiB
HTML
32 lines
5.5 KiB
HTML
<!doctype html>
|
||
<html lang="zh-CN"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||
<title>Bench · SFT 采集</title>
|
||
<style>
|
||
:root{font:15px/1.55 system-ui,sans-serif;color:#183344;background:#edf2f4}body{max-width:1440px;margin:auto;padding:28px}h1{font-size:28px;margin:0}header{display:flex;justify-content:space-between;align-items:center}small,.muted{color:#607783}input,select,button{font:inherit;padding:7px 10px;border:1px solid #b9c9d0;border-radius:6px;background:white}button{cursor:pointer}.cards{display:grid;grid-template-columns:repeat(5,1fr);gap:12px;margin:22px 0}.card,section{background:#fff;border:1px solid #d6e0e5;border-radius:10px;padding:18px}.number{font-size:30px;font-weight:650}section{margin-bottom:16px;overflow:auto}h2{font-size:17px;margin:0 0 12px}table{width:100%;border-collapse:collapse;text-align:left;font-size:13px}td,th{border-bottom:1px solid #e3eaf0;padding:10px;vertical-align:top}tr[data-row]{cursor:pointer}tr[data-row]:hover{background:#f2f7fa}pre{white-space:pre-wrap;overflow-wrap:anywhere;font:12px/1.6 ui-monospace,monospace;margin:0}.warn{color:#a45813}.good{color:#1c7057}.panels{display:grid;grid-template-columns:1fr 1fr;gap:16px}#detail{display:none}#health{font-weight:600}@media(max-width:800px){.cards{grid-template-columns:repeat(2,1fr)}.panels{grid-template-columns:1fr}header{display:block}body{padding:16px}}
|
||
</style>
|
||
<header><div><small>BENCH / COLLECTION</small><h1>SFT 采集状态</h1><div id="stamp" class="muted">正在读取快照</div></div><div><input id="run" placeholder="批次 ID"><button id="apply">查看</button> <span id="health">UNKNOWN</span></div></header>
|
||
<div class="cards" id="cards"></div>
|
||
<div class="panels"><section><h2>共享配额与等待</h2><pre id="quota">UNKNOWN</pre></section><section><h2>数据与发布版本</h2><pre id="data">UNKNOWN</pre></section></div>
|
||
<section><h2>资源租约与排队</h2><pre id="resources">UNKNOWN</pre></section>
|
||
<section><h2>任务与执行 <select id="filter"><option value="">全部状态</option><option>RUNNING</option><option>VERIFYING</option><option>QUEUED</option><option>PAUSED_INFRA</option><option>CLEANING</option><option>PASS</option><option>FAIL</option><option>UNVERIFIED</option></select></h2><p class="muted">Agent、阶段进程与数据库状态分别计数;未知值不代表 0。点击任务查看进程身份和硬门证据。</p><table><thead><tr><th>任务 / 尝试</th><th>数据库</th><th>活动 / 等待</th><th>健康</th><th>执行结果</th><th>清理</th></tr></thead><tbody id="rows"></tbody></table><div><button id="previous">上一页</button> <span id="page"></span> <button id="next">下一页</button></div></section>
|
||
<section id="detail"><h2>任务详情 <button id="close">关闭</button></h2><pre id="detailText"></pre></section>
|
||
<script>
|
||
const $=id=>document.getElementById(id);let run='',offset=0,total=0,busy=false;
|
||
const display=v=>v===null||v===undefined?'UNKNOWN':String(v);
|
||
const pretty=v=>JSON.stringify(v??{status:'UNKNOWN'},null,2);
|
||
async function get(path){const r=await fetch(path,{cache:'no-store'});if(!r.ok)throw Error('HTTP '+r.status);return r.json()}
|
||
function element(tag,text){const e=document.createElement(tag);e.textContent=text;return e}
|
||
async function refresh(){if(busy)return;busy=true;try{
|
||
const s=await get(run?'/api/runs/'+encodeURIComponent(run)+'/snapshot':'/api/snapshot');
|
||
if(!run&&s.run_id){run=s.run_id;$('run').value=run}
|
||
$('health').textContent=s.source_status;$('health').className=s.source_status==='FRESH'?'good':'warn';
|
||
$('stamp').textContent='采样时间 '+(s.sampled_at?new Date(s.sampled_at*1000).toLocaleString():'UNKNOWN')+' · 快照年龄 '+display(s.age_s)+' s';
|
||
const labels=[['真实 Agent','agent_processes'],['阶段进程','stage_processes'],['回收监督器','supervisor_processes'],['Collector','collector_processes'],['DB 活跃','db_active'],['尝试总数','attempts']];
|
||
$('cards').replaceChildren(...labels.map(([name,key])=>{const e=element('div','');e.className='card';e.append(element('small',name));const n=element('div',display(s.counts?.[key]));n.className='number';e.append(n);return e}));
|
||
$('quota').textContent=pretty(s.quota);$('data').textContent=pretty({materialized:s.data,published:s.final_dataset});$('resources').textContent=pretty(s.resources);
|
||
if(run){const response=await get('/api/runs/'+encodeURIComponent(run)+'/rollouts?cursor='+offset+'&state='+encodeURIComponent($('filter').value));total=response.total;
|
||
$('rows').replaceChildren(...response.items.map(r=>{const tr=document.createElement('tr');tr.dataset.row='1';[r.job_id+' / '+r.kk,r.state,r.activity,r.health,r.execution_outcome||r.execution_state,r.cleanup_state].forEach(v=>tr.append(element('td',display(v))));tr.onclick=async()=>{try{$('detailText').textContent=pretty(await get('/api/runs/'+encodeURIComponent(run)+'/rollouts/'+encodeURIComponent(r.job_id)+'/'+r.kk));$('detail').style.display='block'}catch(e){$('detailText').textContent=String(e)}};return tr}));$('page').textContent=offset+'–'+Math.min(offset+100,total)+' / '+total;}
|
||
}catch(e){$('health').textContent='UNAVAILABLE';$('health').className='warn';$('stamp').textContent='连接不可用,保留上次快照 · '+e.message}finally{busy=false}}
|
||
$('apply').onclick=()=>{run=$('run').value.trim();offset=0;refresh()};$('filter').onchange=()=>{offset=0;refresh()};$('previous').onclick=()=>{offset=Math.max(0,offset-100);refresh()};$('next').onclick=()=>{if(offset+100<total){offset+=100;refresh()}};$('close').onclick=()=>{$('detail').style.display='none'};refresh();setInterval(refresh,5000);
|
||
</script></html>
|