fix: align proof, treatment, metrics and site videos with PDF
All checks were successful
Build and deploy / Validate source (push) Successful in 11s
Build and deploy / Integration suite on a real stack (push) Successful in 5m44s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m22s
All checks were successful
Build and deploy / Validate source (push) Successful in 11s
Build and deploy / Integration suite on a real stack (push) Successful in 5m44s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m22s
This commit is contained in:
@@ -684,7 +684,7 @@ const contactWho=order=>(order.contact_by||'')+' em '+when(order.contact_since);
|
||||
// The print proof (app/proof.py): asked for at checkout, or an order above 10 m.
|
||||
// The room marks "Prova OK" once it is checked; without it, no Finalizado.
|
||||
const PROOF_ABOVE_METRES=10;
|
||||
const PROOF_RULE='Até 30 cm, do trecho de traço mais fino, um pedaço de cada arte diferente; no máximo 3 provas por pedido, sem cobrança.';
|
||||
const PROOF_RULE='Até 15 cm por classe, do trecho de traço mais fino; no máximo 3 provas por pedido, sem cobrança.';
|
||||
const needsProof=order=>!!order.snapshot.proof||order.snapshot.items.reduce((t,i)=>t+Number(i.billed_metres),0)>PROOF_ABOVE_METRES;
|
||||
const proofPending=order=>needsProof(order)&&!order.proof_ok_at&&order.state!=='fin'&&!order.cancelled_at&&!order.proof_parent;
|
||||
// The proof card (app/proof.py): the order's own card waits outside the queue
|
||||
@@ -1549,6 +1549,12 @@ function contractionList(order){
|
||||
return box;
|
||||
}
|
||||
function approveParts(order,main=true){
|
||||
if(order.snapshot.treatment){
|
||||
const approve=button('Enviar arte tratada',()=>treatDialog(order),'btn lg'+(main?' pri':''));
|
||||
approve.dataset.treat='';
|
||||
return {text:'Tratamento pago: o designer precisa enviar o PNG tratado de cada item antes da fila.',
|
||||
files:null,approve,extra:[]};
|
||||
}
|
||||
const ready=readyFinals(order), all=ready.every(Boolean), many=ready.length>1;
|
||||
const files=node('div',undefined,'files');
|
||||
if(all)ready.forEach((r,i)=>r.files.forEach((f,k)=>files.append(fileRow(f.name,(many?'Item '+(i+1)+', ':'')+FINAL_TITLE[r.source]+
|
||||
@@ -1576,7 +1582,10 @@ function nextBox(order){
|
||||
const moveBtn=(to,label,className='btn pri lg')=>{const b=button(label||'Mover para '+board.states[to],()=>move(order,to),className);b.dataset.move=to;return b;};
|
||||
if(waitingProof(order)){
|
||||
title='Aguardando prova do #'+order.proof_card.number;
|
||||
note('O pedido segue para Arte conferida após Prova OK no card da prova. Você pode abrir o arquivo para consultar.');
|
||||
const manual=(board.orders.find(o=>o.id===order.proof_card.id)?.print_files||[]).some(r=>r.status==='manual');
|
||||
note(manual?'O Prumo não abriu o original. Prepare o PNG completo deste pedido; a prova será gerada automaticamente a partir dele.'
|
||||
:'O pedido segue para Arte conferida após Prova OK no card da prova. Você pode abrir o arquivo para consultar.');
|
||||
if(manual&&may('produce'))main.push(button('Preparar arquivo para a prova',()=>finalDialog(order,readyFinals(order)),'btn pri lg'));
|
||||
return composeNext(title,body,main,more);
|
||||
}
|
||||
// A proof card in Revisão waits for its answer (Dropstar, 2026-11-03).
|
||||
@@ -1614,13 +1623,23 @@ function nextBox(order){
|
||||
}
|
||||
if(st==='rec'&&order.proof_parent){
|
||||
title=finalDone(order)?'Conferir a prova':'Gerando a prova';
|
||||
note(finalDone(order)?'Abra o PNG gerado pelo Prumo e confirme a contração.':'O Prumo prepara até 15 cm por classe e aprova o PNG final automaticamente.');
|
||||
const manual=(order.print_files||[]).some(r=>r.status==='manual');
|
||||
note(finalDone(order)?'Abra o PNG gerado pelo Prumo e confirme a contração.':manual
|
||||
?'O original exige preparo manual. Abra o pedido pai, envie o PNG completo e depois gere a prova de novo.'
|
||||
:'O Prumo prepara até 15 cm por classe e aprova o PNG final automaticamente.');
|
||||
if(manual&&may('produce'))more.push(button('Abrir pedido pai',()=>openPanel(order.proof_parent.id),'btn lg'));
|
||||
if(finalDone(order)&&may('produce'))main.push(checkButton(order,'btn pri lg'));
|
||||
if((order.print_files||[]).some(r=>r.status==='failed'||r.status==='manual'||r.timed_out)&&may('produce'))
|
||||
more.push(button('Gerar de novo',async()=>{await api('/orders/'+order.id+'/print-files',{});await load();},'btn lg'));
|
||||
return composeNext(title,body,main,more);
|
||||
}
|
||||
if(st==='rec'||st==='cor'){
|
||||
if(st==='rec'&&order.snapshot.treatment&&!treatmentDone(order)&&finalDone(order)){
|
||||
title='Enviar a arte tratada';
|
||||
note('O tratamento foi pago. Envie o PNG tratado de cada item antes de colocar o pedido na fila.');
|
||||
if(may('produce'))main.push(button('Tratar a arte',()=>treatDialog(order),'btn pri lg'));
|
||||
return composeNext(title,body,main,more);
|
||||
}
|
||||
if(!finalDone(order)&&trans.includes('tra')){
|
||||
if(st==='rec')title='Aprovar o arquivo final';
|
||||
// The designer approves every file (D-16); the others see it waiting.
|
||||
@@ -1750,6 +1769,7 @@ function pickupDialog(order){
|
||||
const isPickup=order=>order.snapshot.freight?.service==='pickup';
|
||||
// ---- Final files: the file each item is printed from, approved by an operator.
|
||||
const finalDone=order=>order.snapshot.items.every((_,index)=>(order.final_items||[]).includes(index));
|
||||
const treatmentDone=order=>order.snapshot.items.every((_,index)=>order.treated?.items?.includes(index));
|
||||
const FINAL_SOURCE={correction:'correção do cliente',generated:'arquivo gerado',original:'original'};
|
||||
const FINAL_TITLE={correction:'Correção do cliente',generated:'Gerado pelo sistema',original:'Original do cliente'};
|
||||
// What the system generated for an item: one PNG, or the parts of a film
|
||||
@@ -1917,11 +1937,13 @@ function treatDialog(order){
|
||||
const file=row.input.files[0];
|
||||
if(file)return {file};
|
||||
const kept=(order.finals||[]).filter(f=>f.item_index===index).map(f=>f.upload_id);
|
||||
return {ids:kept.length?kept:ready[index]?[ready[index].upload_id]:[]};
|
||||
const treated=order.treated?.items?.includes(index);
|
||||
return {ids:order.snapshot.treatment&&!treated?[]:
|
||||
kept.length?kept:ready[index]?ready[index].files.map(f=>f.upload_id):[]};
|
||||
});
|
||||
if(!plan.some(p=>p.file))throw new Error('Escolha o arquivo tratado.');
|
||||
const empty=plan.findIndex(p=>!p.file&&!p.ids.length);
|
||||
if(empty>=0)throw new Error('O item '+(empty+1)+' ainda não tem arquivo: suba a arte tratada dele também.');
|
||||
if(empty>=0)throw new Error('O item '+(empty+1)+' ainda não tem arte tratada: envie o PNG dele também.');
|
||||
const refs=[];
|
||||
for(const [index,p] of plan.entries()){
|
||||
if(!p.file){refs.push(...p.ids.map(upload_id=>({item_index:index,upload_id})));continue;}
|
||||
@@ -2621,15 +2643,15 @@ async function loadStats(){
|
||||
// Orders; when some came back to the stage, how many times it was entered.
|
||||
const passed=st?plural(st.orders,'pedido','pedidos')+(st.passages>st.orders?', '+st.passages+' passagens':''):'nenhum';
|
||||
name.append(node('span',passed,'sub'));
|
||||
tr.append(name,node('td',st?duration(st.median_hours):'—','r strong'),
|
||||
tr.append(name,node('td',st?duration(st.average_hours):'—','r strong'),
|
||||
node('td',limit?duration(limit.hours):'—','r'),
|
||||
node('td',late.count?String(late.count)+(late.today?' · '+late.today+' hoje':''):'—','r'),
|
||||
node('td',now?plural(now.orders,'pedido','pedidos')+', o mais antigo há '+duration(now.oldest_hours):'nenhum','muted'));
|
||||
return tr;}));
|
||||
// Speed (item 0.12): average and p95 of what the customer feels.
|
||||
const secs=v=>v==null?'—':v<60?Math.max(1,Math.round(v))+' s':Math.round(v/60)+' min';
|
||||
const speedFmt=s=>s.unit==='MB/s'
|
||||
? (v=>v==null?'—':v.toFixed(1).replace('.',',')+' MB/s')
|
||||
const speedFmt=s=>s.unit==='s/MB'
|
||||
? (v=>v==null?'—':v.toFixed(1).replace('.',',')+' s/MB')
|
||||
: (v=>s.unit==='s'?secs(v):String(v));
|
||||
$('stats-speed').replaceChildren(...(data.speed||[]).map(s=>{
|
||||
const tr=node('tr'),fmt=speedFmt(s);
|
||||
@@ -3208,7 +3230,53 @@ function renderEvents(){
|
||||
|
||||
// Integrações: the print room's folder for whoever produces, what is on and off
|
||||
// for the managers, and the buttons, details and the Tiny log for the superadmin.
|
||||
const eventsIfAllowed=async()=>{if(may('integrations'))await loadEvents();};
|
||||
const eventsIfAllowed=async()=>{if(may('integrations'))await loadEvents();if(may('manage'))await loadSiteVideos();};
|
||||
|
||||
async function loadSiteVideos(){
|
||||
const host=$('site-videos-list'),panel=$('site-videos-panel');
|
||||
panel.hidden=!may('manage');
|
||||
if(panel.hidden)return;
|
||||
const data=await api('/site-videos');
|
||||
host.replaceChildren(...data.videos.map(video=>{
|
||||
const row=node('div',undefined,'siteVideoRow');
|
||||
const heading=node('div',undefined,'siteVideoHeading');
|
||||
heading.append(node('b',video.title),node('span',video.enabled?'Publicado':'Rascunho','pill'+(video.enabled?' ok':'')));
|
||||
const videoInput=node('input');videoInput.type='file';videoInput.accept='.mp4,.webm,video/mp4,video/webm';
|
||||
const captionsInput=node('input');captionsInput.type='file';captionsInput.accept='.vtt,text/vtt';
|
||||
const videoLabel=node('label',undefined,'siteVideoField');
|
||||
videoLabel.append(node('span','Vídeo · '+(video.video_name||'nenhum arquivo')),videoInput);
|
||||
const captionsLabel=node('label',undefined,'siteVideoField');
|
||||
captionsLabel.append(node('span','Legenda · '+(video.captions_name||'nenhuma legenda')),captionsInput);
|
||||
const product=node('select');product.setAttribute('aria-label','Produto do vídeo '+video.title);
|
||||
for(const [value,title] of [['','Só na categoria DTF'],['file','Arquivo por metro'],
|
||||
['avulsa','Artes avulsas'],['uvfile','Arquivo por metro UV'],['uv','Artes avulsas UV']]){
|
||||
const option=node('option',title);option.value=value;product.append(option);
|
||||
}
|
||||
product.value=video.product||'';
|
||||
const productLabel=node('label',undefined,'siteVideoField');productLabel.append(node('span','Vídeo flutuante'),product);
|
||||
const enabled=node('input');enabled.type='checkbox';enabled.checked=video.enabled;
|
||||
const publish=node('label',undefined,'siteVideoToggle');publish.append(enabled,node('span','Publicado no Site'));
|
||||
const errorMessage=node('p',undefined,'siteVideoError');errorMessage.setAttribute('role','alert');
|
||||
const save=button('Salvar vídeo',async()=>{
|
||||
save.disabled=true;
|
||||
errorMessage.textContent='';
|
||||
try{
|
||||
let uploadId=video.upload_id,captionsId=video.captions_id;
|
||||
if(videoInput.files[0])uploadId=await dtfUpload(videoInput.files[0],{api,startPath:'/site-videos/uploads',
|
||||
scope:'site-video:'+video.id+':video',progress:text=>say(text)});
|
||||
if(captionsInput.files[0])captionsId=await dtfUpload(captionsInput.files[0],{api,startPath:'/site-videos/uploads',
|
||||
scope:'site-video:'+video.id+':captions',progress:text=>say(text)});
|
||||
await api('/site-videos/'+video.id,{upload_id:uploadId,captions_id:captionsId,
|
||||
product:product.value||null,enabled:enabled.checked});
|
||||
say('Vídeo salvo. O Site mostrará a nova versão na próxima abertura.');
|
||||
await loadSiteVideos();
|
||||
}catch(error){errorMessage.textContent=error.message;save.disabled=false;}
|
||||
},'btn');
|
||||
const fields=node('div',undefined,'siteVideoFields');
|
||||
fields.append(videoLabel,captionsLabel,productLabel,publish,save,errorMessage);
|
||||
row.append(heading,fields);return row;
|
||||
}));
|
||||
}
|
||||
// A row with only its name, state and summary, for whoever may not change it.
|
||||
const integRow=o=>may('integrations')?integration(o):integration({name:o.name,state:o.state,tone:o.tone,summary:o.summary});
|
||||
let mpCheck=null;
|
||||
|
||||
Reference in New Issue
Block a user