// history.js — история тестов let historyOpen=false; async function toggleHistory(){ const body=document.getElementById('history-body'); historyOpen=!historyOpen; body.style.display=historyOpen?'block':'none'; if(historyOpen) await loadHistory(); } async function loadHistory(){ const body=document.getElementById('history-body'); if(!body||body.style.display==='none') return; try{ const r=await fetch('/api/history'); const rows=await r.json(); if(!rows||!rows.length){body.innerHTML='Нет записей'; return;} let html=''; html+=''; rows.forEach(r=>{ const time=r.created_at?r.created_at.replace('T',' ').substring(0,19):'?'; const cls=r.status==='OK'?'badge-success':''; html+=``; }); html+='
ВремяОперацияИнстансСтатусДлит.
${time} ${_esc(r.op_name||'?')} ${_esc(r.display_name||r.instance_uid||'?')} ${_esc(r.status||'?')} ${r.duration_sec!=null?r.duration_sec.toFixed(1)+'s':'-'}
'; body.innerHTML=html; }catch(e){body.innerHTML='Ошибка загрузки';} }