diff --git a/app/ui/ui.js b/app/ui/ui.js index fdbb955..f73bb68 100644 --- a/app/ui/ui.js +++ b/app/ui/ui.js @@ -65,7 +65,7 @@ const pgo=new Set(); 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. async function panel(name){const data=await (await fetch("/speakers?name="+name)).json(); -return `${data.candidates.map(candidate=>``+ +return `${data.candidates.map(candidate=>``+ data.rows.map(row=>`
${E(row.label)} ${fmt(row.talk_s)} ${row.source}${row.source==="auto"&&row.overlap_s!=null?" "+Math.round(row.overlap_s)+"s":""}
${row.samples.map(E).join(" | ")}
`).join("")+ `
`} // Read the label -> person inputs and save them (/speaker_map). @@ -156,9 +156,9 @@ return `
${txt?txt+" — ": // Progress panel for a recording: boot, queued, or running pipeline. function progPanel(row){const prog=row.prog,stop=`${row.flow_run_id?`prefect`:""}`; // Pipeline starting: the Python environment can take minutes on the first run. -if(!prog&&row.running)return `
…  Avvio della pipeline — preparazione dell'ambiente Python (la prima volta scarica le dipendenze: qualche minuto)${stop}
${E(row.boot||"in avvio…")}
`; +if(!prog&&row.running)return `
…  Avvio della pipeline — preparazione dell'ambiente Python (la prima volta scarica le dipendenze: qualche minuto)${stop}
${E(row.boot||"in avvio…")}
`; // Queued behind another run, or nothing to show. -if(!prog)return row.status==="queued"?`
In codaparte appena finisce l'elaborazione in corso ${stop}
`:""; +if(!prog)return row.status==="queued"?`
In codaparte appena finisce l'elaborazione in corso ${stop}
`:""; // 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"); // 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"?`
+return `
${pct!=null?pct+"%":"…"}  ${step} — ${E(prog.note||HOW[prog.step]||"")} ${prog.eta!=null?`fine prevista ~${clock(prog.eta)} · mancano ${dur(prog.eta)} · `:""}trascorso ${dur(prog.elapsed)} ${stop}
@@ -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. const PS=100;let pg_=0; 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. 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. @@ -218,16 +222,18 @@ qs.textContent=data.queue?`rielaborazione: ${data.queue} da completare`:""; // Remember step-select values so they survive the re-render. document.querySelectorAll("select[id^=f-]").forEach(select=>sel[select.id]=select.value); // Table header. -let html="riunionestatodurataspeakerdimensioneazioni"; +let html=`riunionestatoelaborazione ${srt<0?"▼":srt>0?"▲":"↕"}durataspeakerdimensioneazioni`; +// 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. const pages=Math.max(1,Math.ceil(data.recs.length/PS));if(pg_>=pages)pg_=pages-1; pgr.innerHTML=pages>1?`pagina ${pg_+1} di ${pages} (${data.recs.length} riunioni)`:""; // 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. 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. -html+=`${nm?`${E(nm)}${act?"":""}
${row.name}`:row.name+(act?"":"")}
${row.status}${row.receiving_age_s!=null&&row.status==="recording"?` ${row.receiving_age_s}s ago`:""}${row.error?`
${E(row.error)}`:""}${row.duration_s?fmt(row.duration_s):""}${row.speakers??""}${row.mb?row.mb+" MB":""} +html+=`${nm?`${E(nm)}${act?"":""}
${row.name}`:row.name+(act?"":"")}
${row.status}${row.receiving_age_s!=null&&row.status==="recording"?` ${row.receiving_age_s}s ago`:""}${row.error?`
${E(row.error)}`:""}${dt(row.updated_at)}${row.duration_s?fmt(row.duration_s):""}${row.speakers??""}${row.mb?row.mb+" MB":""}
📄 reportpdf
`; html+=pgo.has(row.name)?progPanel(row):""; if(open_.has(row.name))html+=await panel(row.name);html+=""}