ui: sortable processing-date column
This commit is contained in:
+13
-7
@@ -65,7 +65,7 @@ const pgo=new Set();
|
|||||||
function togPg(name){pgo.has(name)?pgo.delete(name):pgo.add(name);tick()}
|
function togPg(name){pgo.has(name)?pgo.delete(name):pgo.add(name);tick()}
|
||||||
// Speakers panel: diarization label -> person mapping, with a datalist of candidate names.
|
// Speakers panel: diarization label -> person mapping, with a datalist of candidate names.
|
||||||
async function panel(name){const data=await (await fetch("/speakers?name="+name)).json();
|
async function panel(name){const data=await (await fetch("/speakers?name="+name)).json();
|
||||||
return `<tr class=sp><td colspan=6><datalist id="cand-${name}">${data.candidates.map(candidate=>`<option value="${E(candidate)}">`).join("")}</datalist>`+
|
return `<tr class=sp><td colspan=7><datalist id="cand-${name}">${data.candidates.map(candidate=>`<option value="${E(candidate)}">`).join("")}</datalist>`+
|
||||||
data.rows.map(row=>`<div><b>${E(row.label)}</b> ${fmt(row.talk_s)} <input data-n="${name}" data-l="${E(row.label)}" list="cand-${name}" value="${E(row.person)}"> ${row.source}${row.source==="auto"&&row.overlap_s!=null?" "+Math.round(row.overlap_s)+"s":""}<br><small>${row.samples.map(E).join(" | ")}</small></div>`).join("")+
|
data.rows.map(row=>`<div><b>${E(row.label)}</b> ${fmt(row.talk_s)} <input data-n="${name}" data-l="${E(row.label)}" list="cand-${name}" value="${E(row.person)}"> ${row.source}${row.source==="auto"&&row.overlap_s!=null?" "+Math.round(row.overlap_s)+"s":""}<br><small>${row.samples.map(E).join(" | ")}</small></div>`).join("")+
|
||||||
`<div class=sa><button class=pri onclick="saveSpk('${name}')">✓ Salva nomi</button><button onclick="spk('${name}')">✕ Chiudi</button></div>`}
|
`<div class=sa><button class=pri onclick="saveSpk('${name}')">✓ Salva nomi</button><button onclick="spk('${name}')">✕ Chiudi</button></div>`}
|
||||||
// Read the label -> person inputs and save them (/speaker_map).
|
// Read the label -> person inputs and save them (/speaker_map).
|
||||||
@@ -156,9 +156,9 @@ return `<div class="live ${cls}"><span class=dot></span><span>${txt?txt+" — ":
|
|||||||
// Progress panel for a recording: boot, queued, or running pipeline.
|
// Progress panel for a recording: boot, queued, or running pipeline.
|
||||||
function progPanel(row){const prog=row.prog,stop=`<span class=acts>${row.flow_run_id?`<a class=btn href="http://127.0.0.1:4200/runs/flow-run/${row.flow_run_id}" target=_blank>prefect</a>`:""}<button class=del onclick="stopRun('${row.name}')">■ stop</button></span>`;
|
function progPanel(row){const prog=row.prog,stop=`<span class=acts>${row.flow_run_id?`<a class=btn href="http://127.0.0.1:4200/runs/flow-run/${row.flow_run_id}" target=_blank>prefect</a>`:""}<button class=del onclick="stopRun('${row.name}')">■ stop</button></span>`;
|
||||||
// Pipeline starting: the Python environment can take minutes on the first run.
|
// Pipeline starting: the Python environment can take minutes on the first run.
|
||||||
if(!prog&&row.running)return `<tr><td colspan=6><div class=pg><div class=pgh><span><span class=big>…</span> <b>Avvio della pipeline</b> <span class=n>— preparazione dell'ambiente Python (la prima volta scarica le dipendenze: qualche minuto)</span></span>${stop}</div><div class="bar ind"><i></i></div><div class="live"><span class=dot></span><span>${E(row.boot||"in avvio…")}</span></div></div>`;
|
if(!prog&&row.running)return `<tr><td colspan=7><div class=pg><div class=pgh><span><span class=big>…</span> <b>Avvio della pipeline</b> <span class=n>— preparazione dell'ambiente Python (la prima volta scarica le dipendenze: qualche minuto)</span></span>${stop}</div><div class="bar ind"><i></i></div><div class="live"><span class=dot></span><span>${E(row.boot||"in avvio…")}</span></div></div>`;
|
||||||
// Queued behind another run, or nothing to show.
|
// Queued behind another run, or nothing to show.
|
||||||
if(!prog)return row.status==="queued"?`<tr><td colspan=6><div class=pg><div class=pgh><b>In coda</b><span><span class=eta>parte appena finisce l'elaborazione in corso</span> ${stop}</span></div><div class="bar ind"><i></i></div></div>`:"";
|
if(!prog)return row.status==="queued"?`<tr><td colspan=7><div class=pg><div class=pgh><b>In coda</b><span><span class=eta>parte appena finisce l'elaborazione in corso</span> ${stop}</span></div><div class="bar ind"><i></i></div></div>`:"";
|
||||||
// Overall percent (null if unknown) and the running step.
|
// Overall percent (null if unknown) and the running step.
|
||||||
const pct=prog.pct!=null?Math.round(prog.pct*100):null,cur=prog.plan.find(stage=>stage.state==="run");
|
const pct=prog.pct!=null?Math.round(prog.pct*100):null,cur=prog.plan.find(stage=>stage.state==="run");
|
||||||
// Step chips: skipped / done with duration / running with fraction / pending with estimate.
|
// Step chips: skipped / done with duration / running with fraction / pending with estimate.
|
||||||
@@ -166,7 +166,7 @@ const chips=prog.plan.map(stage=>stage.state==="skip"?`<span class="st skip" tit
|
|||||||
// Done-of-total counter and step label.
|
// Done-of-total counter and step label.
|
||||||
const cnt=prog.total?`${prog.done} di ${prog.total}`:"",step=LBL[prog.step]||prog.step;
|
const cnt=prog.total?`${prog.done} di ${prog.total}`:"",step=LBL[prog.step]||prog.step;
|
||||||
// Panel markup: header, progress bars, step chips and live status.
|
// Panel markup: header, progress bars, step chips and live status.
|
||||||
return `<tr><td colspan=6><div class=pg>
|
return `<tr><td colspan=7><div class=pg>
|
||||||
<div class=pgh><span><span class=big>${pct!=null?pct+"%":"…"}</span> <b>${step}</b> <span class=n>— ${E(prog.note||HOW[prog.step]||"")}</span></span>
|
<div class=pgh><span><span class=big>${pct!=null?pct+"%":"…"}</span> <b>${step}</b> <span class=n>— ${E(prog.note||HOW[prog.step]||"")}</span></span>
|
||||||
<span><span class=eta>${prog.eta!=null?`fine prevista <b>~${clock(prog.eta)}</b> · mancano <b>${dur(prog.eta)}</b> · `:""}trascorso ${dur(prog.elapsed)}</span> ${stop}</span></div>
|
<span><span class=eta>${prog.eta!=null?`fine prevista <b>~${clock(prog.eta)}</b> · mancano <b>${dur(prog.eta)}</b> · `:""}trascorso ${dur(prog.elapsed)}</span> ${stop}</span></div>
|
||||||
<div class="bar${pct==null?" ind":""}"><i style="width:${pct||0}%"></i></div>
|
<div class="bar${pct==null?" ind":""}"><i style="width:${pct||0}%"></i></div>
|
||||||
@@ -203,6 +203,10 @@ addEventListener("drop",event=>{event.preventDefault();document.body.classList.r
|
|||||||
// Meetings per page and current page index (0-based); goPg changes page and re-renders.
|
// Meetings per page and current page index (0-based); goPg changes page and re-renders.
|
||||||
const PS=100;let pg_=0;
|
const PS=100;let pg_=0;
|
||||||
function goPg(delta){pg_+=delta;tick()}
|
function goPg(delta){pg_+=delta;tick()}
|
||||||
|
// Sort by processing date (updated_at): 0 = default (newest name first), -1 = newest first, 1 = oldest first.
|
||||||
|
let srt=0;function sortDt(){srt=srt<0?1:-1;pg_=0;tick()}
|
||||||
|
// SQLite UTC "YYYY-MM-DD HH:MM:SS" shown in local time.
|
||||||
|
const dt=value=>value?new Date(value.replace(" ","T")+"Z").toLocaleString("it-IT",{dateStyle:"short",timeStyle:"short"}):"";
|
||||||
// Refresh the whole UI from /status: header, LLM pickers, table.
|
// Refresh the whole UI from /status: header, LLM pickers, table.
|
||||||
async function tick(){try{const data=await (await fetch("/status")).json();ab.disabled=data.ask_blocked;ab.title=data.ask_blocked?"pipeline in corso":"";
|
async function tick(){try{const data=await (await fetch("/status")).json();ab.disabled=data.ask_blocked;ab.title=data.ask_blocked?"pipeline in corso":"";
|
||||||
// Browser tab title shows the progress of the first running pipeline.
|
// Browser tab title shows the progress of the first running pipeline.
|
||||||
@@ -218,16 +222,18 @@ qs.textContent=data.queue?`rielaborazione: ${data.queue} da completare`:"";
|
|||||||
// Remember step-select values so they survive the re-render.
|
// Remember step-select values so they survive the re-render.
|
||||||
document.querySelectorAll("select[id^=f-]").forEach(select=>sel[select.id]=select.value);
|
document.querySelectorAll("select[id^=f-]").forEach(select=>sel[select.id]=select.value);
|
||||||
// Table header.
|
// Table header.
|
||||||
let html="<thead><tr><th>riunione<th>stato<th>durata<th>speaker<th>dimensione<th>azioni</tr></thead>";
|
let html=`<thead><tr><th>riunione<th>stato<th style="cursor:pointer;user-select:none;white-space:nowrap" onclick=sortDt() title="ordina per data di elaborazione">elaborazione ${srt<0?"▼":srt>0?"▲":"↕"}<th>durata<th>speaker<th>dimensione<th>azioni</tr></thead>`;
|
||||||
|
// Apply the date sort before paging (ISO strings sort lexicographically).
|
||||||
|
const recs=srt?[...data.recs].sort((a,b)=>srt*(a.updated_at||"").localeCompare(b.updated_at||"")):data.recs;
|
||||||
// Pagination: PS meetings per page; clamp the page if recordings were removed, then draw the pager.
|
// Pagination: PS meetings per page; clamp the page if recordings were removed, then draw the pager.
|
||||||
const pages=Math.max(1,Math.ceil(data.recs.length/PS));if(pg_>=pages)pg_=pages-1;
|
const pages=Math.max(1,Math.ceil(data.recs.length/PS));if(pg_>=pages)pg_=pages-1;
|
||||||
pgr.innerHTML=pages>1?`<button ${pg_?"":"disabled"} onclick="goPg(-1)">‹</button><span>pagina ${pg_+1} di ${pages} (${data.recs.length} riunioni)</span><button ${pg_<pages-1?"":"disabled"} onclick="goPg(1)">›</button>`:"";
|
pgr.innerHTML=pages>1?`<button ${pg_?"":"disabled"} onclick="goPg(-1)">‹</button><span>pagina ${pg_+1} di ${pages} (${data.recs.length} riunioni)</span><button ${pg_<pages-1?"":"disabled"} onclick="goPg(1)">›</button>`:"";
|
||||||
// One tbody per recording on the current page; "running" when the status is done but the process is still alive.
|
// One tbody per recording on the current page; "running" when the status is done but the process is still alive.
|
||||||
for(const row of data.recs.slice(pg_*PS,(pg_+1)*PS)){
|
for(const row of recs.slice(pg_*PS,(pg_+1)*PS)){
|
||||||
// Display title, falling back to the upload name.
|
// Display title, falling back to the upload name.
|
||||||
const nm=row.title||row.upload,act=!!(row.prog||row.running||row.status==="queued");
|
const nm=row.title||row.upload,act=!!(row.prog||row.running||row.status==="queued");
|
||||||
// Main row: checkbox, title and rename buttons; status badge with error text and time since last data.
|
// Main row: checkbox, title and rename buttons; status badge with error text and time since last data.
|
||||||
html+=`<tbody class=rec><tr class=main><td><input type=checkbox class=mg value="${row.name}"><span class="ttl${act?" act":""}"${act?` onclick="togPg('${row.name}')" title="mostra/nascondi avanzamento"`:""}>${nm?`<b>${E(nm)}</b>${act?"<span class=spin></span>":""}<br><small>${row.name}</small>`:row.name+(act?"<span class=spin></span>":"")}</span><td><span class="b ${row.status}" title="${E(row.error)}">${row.status}</span>${row.receiving_age_s!=null&&row.status==="recording"?` <small>${row.receiving_age_s}s ago</small>`:""}${row.error?`<br><small>${E(row.error)}</small>`:""}<td>${row.duration_s?fmt(row.duration_s):""}<td>${row.speakers??""}<td>${row.mb?row.mb+" MB":""}
|
html+=`<tbody class=rec><tr class=main><td><input type=checkbox class=mg value="${row.name}"><span class="ttl${act?" act":""}"${act?` onclick="togPg('${row.name}')" title="mostra/nascondi avanzamento"`:""}>${nm?`<b>${E(nm)}</b>${act?"<span class=spin></span>":""}<br><small>${row.name}</small>`:row.name+(act?"<span class=spin></span>":"")}</span><td><span class="b ${row.status}" title="${E(row.error)}">${row.status}</span>${row.receiving_age_s!=null&&row.status==="recording"?` <small>${row.receiving_age_s}s ago</small>`:""}${row.error?`<br><small>${E(row.error)}</small>`:""}<td>${dt(row.updated_at)}<td>${row.duration_s?fmt(row.duration_s):""}<td>${row.speakers??""}<td>${row.mb?row.mb+" MB":""}
|
||||||
<td><div class=acts><a class="btn pri"${row.files.includes("report.html")?` href="/report?name=${row.name}" target=_blank`:""}>📄 report</a><a class=btn${row.files.includes("report.html")?` href="/pdf?name=${row.name}" target=_blank`:""}>pdf</a><button title="anteprima e ritaglio" ${row.mb?"":"disabled"} onclick="play('${row.name}',${row.duration_s||0},'${E(nm||row.name).replace(/'/g,"")}')">▶ video</button><button title="altre azioni" onclick="more('${row.name}',${row.mb||0},'${E(nm||row.name).replace(/'/g,"")}',${!!(row.mb&&row.status==="done"&&!row.running)},'${E(row.title||row.upload||"").replace(/'/g,"")}',${!!row.files.includes("report.html")},${!!(row.running||row.status==="queued"||row.status==="recording")})">⋯</button></div>`;
|
<td><div class=acts><a class="btn pri"${row.files.includes("report.html")?` href="/report?name=${row.name}" target=_blank`:""}>📄 report</a><a class=btn${row.files.includes("report.html")?` href="/pdf?name=${row.name}" target=_blank`:""}>pdf</a><button title="anteprima e ritaglio" ${row.mb?"":"disabled"} onclick="play('${row.name}',${row.duration_s||0},'${E(nm||row.name).replace(/'/g,"")}')">▶ video</button><button title="altre azioni" onclick="more('${row.name}',${row.mb||0},'${E(nm||row.name).replace(/'/g,"")}',${!!(row.mb&&row.status==="done"&&!row.running)},'${E(row.title||row.upload||"").replace(/'/g,"")}',${!!row.files.includes("report.html")},${!!(row.running||row.status==="queued"||row.status==="recording")})">⋯</button></div>`;
|
||||||
html+=pgo.has(row.name)?progPanel(row):"";
|
html+=pgo.has(row.name)?progPanel(row):"";
|
||||||
if(open_.has(row.name))html+=await panel(row.name);html+="</tbody>"}
|
if(open_.has(row.name))html+=await panel(row.name);html+="</tbody>"}
|
||||||
|
|||||||
Reference in New Issue
Block a user