Merge review photo checks (DTF-WEB-B, C)
All checks were successful
Build and deploy / Validate source (push) Successful in 9s
Build and deploy / Integration suite on a real stack (push) Successful in 7m11s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m10s

This commit is contained in:
Cauê Faleiros
2026-11-16 10:37:44 -03:00
2 changed files with 30 additions and 4 deletions

View File

@@ -265,6 +265,13 @@ function renderBoard(){
const order=board.orders.find(o=>o.id===e.dataTransfer.getData('text/plain'));
const machine=state==='imp'?laneAt(column,e.clientY):null;markLane(column,null);
if(!order)return;
// Above 1 m Finalizado needs the review photo: the drop opens Revisão
// instead of a refused move (Sentry DTF-WEB-B).
if(state==='fin'&&order.state==='rev'&&needsReviewPhoto(order)){
if(may('inspect')){say('Pedido acima de 1 m: tire a foto da revisão antes de finalizar.');reviewDialog(order);}
else say('Pedido acima de 1 m: falta a foto da revisão antes de finalizar.',true);
clearDrop();return;
}
try{
if(order.state!==state)await (state==='imp'?pullTo(order,machine):move(order,state,'',machine));
else if(state!=='fin')await reorder(order,column,e.clientY);

View File

@@ -374,8 +374,7 @@ function nextBox(order){
}else{
// Above 1 m the photo is required to finish (app/reviews.py): the main
// button takes it instead of releasing the order.
const hasPhoto=(order.reviews||[]).some(review=>review.kind==='photo');
if(!order.proof_parent&&orderMetres(order)>1&&!hasPhoto){
if(needsReviewPhoto(order)){
title='Tire a foto da revisão';
note('Pedido acima de 1 m: tire a foto da revisão antes de finalizar.');
if(may('inspect'))main.push(button('Revisar',()=>reviewDialog(order),'btn pri lg'));else cannot();
@@ -595,6 +594,18 @@ function cardOpenAction(order){
// recorded. The server names it DTF-<n>-revisao-<seq> and keeps it 180 days.
const REVIEW_VIDEO_MAX=30;
const reviewClock=s=>Math.floor(s/60)+':'+String(s%60).padStart(2,'0');
// Above 1 m the order finishes only with a review photo (app/reviews.py), of
// at least REVIEW_PHOTO_MIN px on its longer side so the footer can be read.
const REVIEW_PHOTO_MIN=1600;
const needsReviewPhoto=order=>!order.proof_parent&&orderMetres(order)>1&&
!(order.reviews||[]).some(review=>review.kind==='photo');
const smallPhoto=(width,height)=>'A foto tem '+width+'×'+height+' px; a revisão precisa de pelo menos '+
REVIEW_PHOTO_MIN+' px no lado maior para ler o rodapé.';
// The photo's size, read in the browser before the upload (Sentry DTF-WEB-C).
async function photoSize(file){
try{const bitmap=await createImageBitmap(file);const size=[bitmap.width,bitmap.height];bitmap.close?.();return size;}
catch(_){return null;}
}
function reviewDialog(order){
const host=dialogHost();
const video=node('video');video.className='reviewcam';video.muted=true;video.playsInline=true;video.autoplay=true;
@@ -659,6 +670,8 @@ function reviewDialog(order){
clear();
const width=video.videoWidth,height=video.videoHeight;
if(!width||!height){fail('A câmera ainda não está pronta. Espere um instante.');return;}
if(Math.max(width,height)<REVIEW_PHOTO_MIN){
fail(smallPhoto(width,height)+' Esta câmera não chega a isso: grave um vídeo, use o celular ou envie um arquivo.');return;}
const canvas=document.createElement('canvas');canvas.width=width;canvas.height=height;
canvas.getContext('2d').drawImage(video,0,0,width,height);
canvas.toBlob(blob=>{
@@ -704,7 +717,12 @@ function reviewDialog(order){
try{await checkDuration(file);}catch(error){input.value='';fail(error.message);return;}
if(closed)return;
showReady(file,'video');
}else showReady(file,'photo');
}else{
const size=await photoSize(file);
if(closed)return;
if(size&&Math.max(...size)<REVIEW_PHOTO_MIN){input.value='';fail(smallPhoto(size[0],size[1]));return;}
showReady(file,'photo');
}
};
fileLabel.onkeydown=event=>{if(event.key==='Enter'||event.key===' '){event.preventDefault();input.click();}};
cancel.onclick=()=>m.close();
@@ -725,7 +743,8 @@ function reviewDialog(order){
}
};
const m=modal('Revisão do #'+order.number,{host,width:640,
text:'Tire uma foto ou grave um vídeo de até 30 s da folha impressa, ou envie um arquivo.',
text:'Tire uma foto ou grave um vídeo de até 30 s da folha impressa, ou envie um arquivo. '+
'A foto precisa de pelo menos '+REVIEW_PHOTO_MIN+' px no lado maior.',
body:[video,controls,timer,preview],foot:[status,cancel,save],onclose:cleanup});
(async()=>{
try{