feat: 失败任务汇总 - /api/summary + 监控页异常面板
- 新增 /api/summary:各状态计数 + 异常设备列表(last_error/任务/重试次数/时间) - 监控页新增"异常汇总"面板:显示失败/异常设备及错误信息,方便长期运行观察健康度
This commit is contained in:
@@ -364,6 +364,43 @@ async function loadMonitor(){
|
||||
updateSelCount();
|
||||
// 加载任务卡片
|
||||
loadJobsForMonitor();
|
||||
// 加载异常汇总
|
||||
loadSummary();
|
||||
}catch(e){console.error(e);}
|
||||
}
|
||||
|
||||
// ===== 异常设备汇总 =====
|
||||
async function loadSummary(){
|
||||
try{
|
||||
const r=await apiGet('/api/summary');
|
||||
if(!r||!r.ok)return;
|
||||
const counts=r.counts||{};
|
||||
const errors=r.errors||[];
|
||||
const errCount=(counts.error||0)+(counts.failed||0);
|
||||
const badge=document.getElementById('summary-badge');
|
||||
const panel=document.getElementById('summary-panel');
|
||||
const empty=document.getElementById('summary-empty');
|
||||
if(badge)badge.textContent='· 异常 '+errCount+' · 运行 '+counts.running+' · 完成 '+counts.done;
|
||||
if(!panel||!empty)return;
|
||||
if(!errors.length){
|
||||
panel.style.display='none';
|
||||
empty.style.display='block';
|
||||
return;
|
||||
}
|
||||
panel.style.display='block';
|
||||
empty.style.display='none';
|
||||
const tb=document.getElementById('tb-summary');
|
||||
tb.innerHTML=errors.map(e=>{
|
||||
const st=e.status==='failed'?'<span class="label label-danger">失败</span>':'<span class="label label-warning">异常</span>';
|
||||
const up=e.updated?new Date(e.updated*1000).toLocaleTimeString():'';
|
||||
return '<tr>'+
|
||||
'<td><strong>'+esc(e.serial)+'</strong>'+(e.model?' <span style="font-size:11px;color:#94a3b8">'+esc(e.model)+'</span>':'')+'</td>'+
|
||||
'<td>'+st+'</td>'+
|
||||
'<td>'+esc(e.task||'-')+'</td>'+
|
||||
'<td>'+(e.attempt>0?e.attempt+'次':'<span class="text-muted">-</span>')+'</td>'+
|
||||
'<td class="err-text" title="'+esc(e.last_error||'')+'">'+esc(e.last_error||'-')+'</td>'+
|
||||
'</tr>';
|
||||
}).join('');
|
||||
}catch(e){console.error(e);}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user