diff --git a/app/ui/index.html b/app/ui/index.html index 2ff209e..1b59668 100644 --- a/app/ui/index.html +++ b/app/ui/index.html @@ -14,12 +14,6 @@ - -
Trascina qui un video o un audio di una riunione per elaborarlo.
@@ -28,8 +22,14 @@
+ + -
+
diff --git a/app/ui/ui.js b/app/ui/ui.js index c431fed..61913a8 100644 --- a/app/ui/ui.js +++ b/app/ui/ui.js @@ -7,16 +7,18 @@ const fmt=s=>{s=Math.round(s);return String(Math.floor(s/60)).padStart(2,"0")+": q.onkeydown=e=>{if(e.key=="Enter")srch()}; // Enter in the Q&A box asks the question. qa.onkeydown=e=>{if(e.key=="Enter")ask()}; +// Close button appended after results: clears the input and the result box. +const CLOSE=(i,o)=>`
`; // Q&A: /ask answers from the meeting data. The model may take minutes to load on first use. async function ask(){if(!qa.value)return;ar.innerHTML="…avvio modelli / risposta (può richiedere qualche minuto)"; const r=await fetch("/ask?q="+encodeURIComponent(qa.value));if(!r.ok){ar.textContent=await r.text();return}const j=await r.json(); // Turn citation markers [n] into links to the matching report section; keep the marker if the source is missing. ar.innerHTML="
"+E(j.answer).replace(/\[(\d+)\]/g,(m,n)=>{const s=j.sources[n-1];return s?`[${n}]`:m})+"
"+ -j.sources.map(s=>`
[${s.n}] ${E(s.date)} ${E(s.meeting)} — ${E(s.topic)} ${fmt(s.t)} (${s.kind}): ${E(s.text)}
`).join("")} +j.sources.map(s=>`
[${s.n}] ${E(s.date)} ${E(s.meeting)} — ${E(s.topic)} ${fmt(s.t)} (${s.kind}): ${E(s.text)}
`).join("")+CLOSE("qa","ar")} // Search over speech and screen text (/search). async function srch(){if(!q.value){sr.innerHTML="";return}const j=await (await fetch("/search?q="+encodeURIComponent(q.value))).json(); // Speech hits: [meeting, seconds, speaker, text]. Screen hits: [meeting, seconds, speaker, text, shot file] and link to the screenshot. -sr.innerHTML=j.speech.map(r=>`
${E(r[0])} ${fmt(r[1])} ${E(r[2]||"")}: ${E(r[3])}
`).join("")+j.screen.map(r=>`
🖥 ${E(r[0])} ${fmt(r[1])} ${E(r[2]||"")}: ${E(r[3])}
`).join("")} +sr.innerHTML=j.speech.map(r=>`
${E(r[0])} ${fmt(r[1])} ${E(r[2]||"")}: ${E(r[3])}
`).join("")+j.screen.map(r=>`
🖥 ${E(r[0])} ${fmt(r[1])} ${E(r[2]||"")}: ${E(r[3])}
`).join("")+CLOSE("q","sr")} // Start a pipeline run from the chosen step (/run); 409 means it is already running. async function run(n){const f=document.getElementById("f-"+n).value;const r=await fetch(`/run?name=${n}&from=${f}`,{method:"POST"});if(r.status==409)alert("già in esecuzione");tick()} // Names of the checked recording rows (.mg checkboxes). @@ -166,6 +168,9 @@ addEventListener("dragover",e=>{e.preventDefault();document.body.classList.add(" addEventListener("dragleave",e=>{if(!e.relatedTarget)document.body.classList.remove("drag")}); // Drop anywhere on the page: upload the first file. addEventListener("drop",e=>{e.preventDefault();document.body.classList.remove("drag");const f=e.dataTransfer.files[0];if(f)send(f)}); +// Meetings per page and current page index (0-based); goPg changes page and re-renders. +const PS=100;let pg_=0; +function goPg(d){pg_+=d;tick()} // Refresh the whole UI from /status: header, LLM pickers, table. async function tick(){try{const j=await (await fetch("/status")).json();ab.disabled=j.ask_blocked;ab.title=j.ask_blocked?"pipeline in corso":""; // Browser tab title shows the progress of the first running pipeline. @@ -182,8 +187,11 @@ qs.textContent=j.queue?`rielaborazione: ${j.queue} da completare`:""; document.querySelectorAll("select[id^=f-]").forEach(s=>sel[s.id]=s.value); // Table header. let h="recordingstatusdurationspeakersMBlinksactions"; -// One tbody per recording; "running" when the status is done but the process is still alive. -for(const r of j.recs){const st=r.running&&r.status=="done"?"running":r.status; +// Pagination: PS meetings per page; clamp the page if recordings were removed, then draw the pager. +const np=Math.max(1,Math.ceil(j.recs.length/PS));if(pg_>=np)pg_=np-1; +pgr.innerHTML=np>1?`pagina ${pg_+1} di ${np} (${j.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 r of j.recs.slice(pg_*PS,(pg_+1)*PS)){const st=r.running&&r.status=="done"?"running":r.status; // Display title, falling back to the upload name. const nm=r.title||r.upload; // Main row: checkbox, title and rename buttons; status badge with error text and time since last data.