Compare commits

...

4 Commits

Author SHA1 Message Date
Cauê Faleiros
040ef46f94 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
2026-11-16 10:37:44 -03:00
Cauê Faleiros
9e5811d58f Merge new layout phase D (production board, stage times) 2026-11-16 10:37:44 -03:00
Cauê Faleiros
92ffb679d6 fix: the review photo is measured before sending, and a drag to Finalizado without it opens Revisão
Sentry DTF-WEB-C and DTF-WEB-B (order #24, 16/11): a review photo under
1600 px on its longer side was refused only after the upload (a 1280x720
webcam always is), and dragging the card to Finalizado without the photo
got the server's 409. The dialog now says the minimum, the camera shot
and a chosen photo are measured in the browser with the same message,
and the drop opens Revisão instead of a refused move.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-16 10:37:44 -03:00
Cauê Faleiros
2c740da4c1 feat: new layout phase D, the production board and stage times as on the canvas
Roadmap Novo Layout, phase D step 2 (canvas A1, D1): a late card gets
the red border and red time (warn colour for a warn late) instead of the
Atrasados strip, which is no longer shown (renderLatebar kept for later);
machine lanes with name, blocking-alert dot, free places and dashed free
slots; compact Finalizado cards; the phone stage chips fade at the edge.
"Tempo aceitável de cada etapa" is a table (Etapa, Aceitável, Responde
pela etapa) with the same API. Built by Prensa.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-16 10:17:20 -03:00
5 changed files with 91 additions and 25 deletions

View File

@@ -354,6 +354,12 @@ try{
await kanban.click('[data-tab="stats"]');
await waitFor(()=>kanban.eval(`document.querySelector('#stats-kpis').children.length>0
&& document.querySelector('#stats-machine-body').children.length>0`),'Números tab and machines by month');
// The stage-times dialog (D1) opens from Números and keeps its five rows.
await kanban.click('#edit-stage-limits');
await waitFor(()=>kanban.eval('!!document.querySelector(".modal.limitsDialog")'),'stage-times dialog');
assert.equal(await kanban.eval('document.querySelectorAll(".modal.limitsDialog tbody tr").length'),5);
await kanban.eval('document.querySelector(".modal .dlghead .btn.sq").click()');
await waitFor(()=>kanban.eval('!document.querySelector(".modal")'),'stage-times dialog closed');
// Cotações lives in its own file now: the list and the review panel load too.
await kanban.click('[data-tab="quotes"]');
await waitFor(()=>kanban.eval(`document.querySelector('#quote-filters').children.length>0

View File

@@ -211,7 +211,6 @@ function renderLatebar(){
if(may('manage'))bar.append(button('Editar tempos',()=>stageLimitsDialog(),'btn ghost'));
}
function renderBoard(){
renderLatebar();
renderFilters();
const active=board.orders.filter(o=>['rec','tra','imp'].includes(o.state)&&!o.cancelled_at);
const open=board.orders.filter(o=>o.state!=='fin'&&!o.cancelled_at).length;
@@ -266,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);
@@ -299,10 +305,10 @@ function printingLanes(orders){
if(filtered&&!here.length)continue;
const n=filtered?here.length:Math.max(m.states?.imp||0,here.length);
const lane=node('div',undefined,'lanehead'+(m.id===mine?' mine':''));lane.dataset.machine=m.id;
const load=n>cap?'acima do limite':n>=cap?'cheia':plural(cap-n,'vaga','vagas');
lane.append(svgIcon(IC.printer,'i s'),node('b',m.name));
// The machine's sheet opens here; an alert due shows a warning dot with its text.
const alerts=m.alerts||[];
const load=n>cap?'acima do limite':plural(Math.max(0,cap-n),'vaga','vagas');
lane.append(node('b',m.name));
// The machine's sheet opens here; a blocking alert shows a warning dot with its text.
const alerts=(m.alerts||[]).filter(a=>a.blocking);
if(alerts.length){const mark=node('i',undefined,'lanealert');mark.title=alerts.map(a=>a.text).join(' · ');
mark.setAttribute('aria-hidden','true');lane.append(mark);}
lane.append(node('span',(m.id===mine?'sua máquina · ':'')+load));
@@ -314,7 +320,7 @@ function printingLanes(orders){
out.push(lane,...here.map(o=>{const c=card(o);c.dataset.machine=m.id;return c;}));
if(!filtered&&n<cap){
const slot=node('div',undefined,'freeslot');slot.dataset.machine=m.id;
slot.append(node('i',undefined,'freemark'),cap-n>1?plural(cap-n,'vaga livre','vagas livres')+' na '+m.name:'Vaga livre na '+m.name);out.push(slot);
slot.append(plural(cap-n,'vaga livre','vagas livres')+' na '+m.name);out.push(slot);
}
}
// An order whose machine is gone or off still shows.
@@ -435,14 +441,15 @@ function draggable(c,order){
function card(order,place){
const s=order.snapshot, mine=isMine(order)&&order.state!=='fin'&&!order.cancelled_at;
const [step,tone]=nextStep(order,place);
const c=node('div',undefined,'card'+(mine?' mine':'')+(tone==='live'?' live':'')+(order.id===openOrder?' open':'')+(order.cancelled_at?' off':''));
const late=!!order.late&&!order.cancelled_at;
const c=node('div',undefined,'card'+(mine?' mine':'')+(tone==='live'?' live':'')+(order.id===openOrder?' open':'')+(order.cancelled_at?' off':'')+
(late?' islate':'')+(late&&order.late==='warn'?' islate-warn':''));
c.tabIndex=0;c.setAttribute('role','button');c.dataset.card=order.id;
const who=buyer(s);
c.setAttribute('aria-label','Pedido #'+order.number+', '+who.title+': '+step);
const top=node('span',undefined,'ctop'), info=node('span',undefined,'cinfo');
const row=node('span',undefined,'crow');
const late=!!order.late&&!order.cancelled_at;
const age=node('span',shortAgo(order.state_since||order.updated_at),'age'+(late?' late tip-l'+(order.late==='bad'?' late2':''):''));
const age=node('span',shortAgo(order.state_since||order.updated_at),'age'+(late?' late tip-l'+(order.late==='warn'?' warnlate':''):''));
if(late)age.dataset.tip='Fora do tempo: '+(order.state_hours??'?')+' h nesta etapa · limite '+
(order.limit_hours??'?')+' h · responsável: '+(order.limit_by||'—');
row.append(node('span','#'+order.number,'num'),originTag(order),age);

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{

View File

@@ -230,8 +230,8 @@ main{padding:0}
.lbl{font-size:12.5px;font-weight:500;color:var(--tx3)}
.right{margin-left:auto}
.board{display:grid;grid-template-columns:repeat(5,minmax(228px,1fr)) 232px;gap:10px;padding:16px 20px 28px;align-items:start;overflow-x:auto}
.col{display:flex;flex-direction:column;gap:8px;min-width:0;min-height:240px;background:var(--lane);border-radius:14px;padding:8px;transition:background .15s,box-shadow .15s}
.board{display:grid;grid-template-columns:repeat(5,minmax(0,1fr)) 232px;gap:10px;padding:16px 20px 0;align-items:start;overflow-x:auto}
.col{display:flex;flex-direction:column;gap:8px;min-width:0;min-height:240px;background:var(--lane);border-radius:14px 14px 0 0;padding:8px;transition:background .15s,box-shadow .15s}
.col.allowed{box-shadow:inset 0 0 0 1.5px color-mix(in srgb,var(--acc) 40%,transparent)}
.col.target{box-shadow:inset 0 0 0 2px var(--acc);background:color-mix(in srgb,var(--acc) 5%,var(--lane))}
.latebar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:0 0 10px;padding:9px 12px;border:1px solid var(--ln2);border-radius:9px;background:var(--sf);font-size:12px}
@@ -270,6 +270,8 @@ main{padding:0}
.card{display:flex;flex-direction:column;gap:10px;width:100%;padding:10px;border:1px solid var(--ln);border-radius:11px;background:var(--sf);text-align:left;color:inherit;transition:border-color .15s,transform .25s cubic-bezier(.2,.8,.2,1),box-shadow .25s}
.card:hover{border-color:var(--ln3);transform:translateY(-1px);box-shadow:var(--lift)}
.card.mine{border-color:color-mix(in srgb,var(--mine) 55%,transparent)}
.card.islate{border-color:color-mix(in srgb,var(--bad) 45%,transparent)}
.card.islate.islate-warn{border-color:color-mix(in srgb,var(--warn) 45%,transparent)}
.card.open,.mini.open{border-color:var(--ink);box-shadow:0 0 0 1px var(--ink)}
.card.off{opacity:.7}
.card[draggable=true]{cursor:grab}
@@ -302,6 +304,7 @@ main{padding:0}
.origin{font-size:12px;color:var(--tx3);min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.age{margin-left:auto;font-size:12px;color:var(--tx3);white-space:nowrap}
.age.late{color:var(--bad);font-weight:600}
.age.late.warnlate{color:var(--warn)}
.cname{display:block;font-size:14px;font-weight:600;color:var(--tx);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.35}
.cmeta{display:flex;align-items:baseline;gap:8px;color:var(--tx2);font-size:12.5px;white-space:nowrap;min-width:0;margin-top:1px}
.cmeta>span{overflow:hidden;text-overflow:ellipsis}
@@ -310,7 +313,7 @@ main{padding:0}
.mach.mine{color:var(--mine);font-weight:600}
.creason{display:block;color:var(--tx2);font-size:12.5px;line-height:1.45}
.creason b{color:var(--bad);font-weight:600}
.cfoot{display:flex;align-items:center;gap:8px;padding-top:9px;border-top:1px solid var(--ln);min-height:32px}
.cfoot{display:flex;align-items:center;gap:8px;min-height:28px}
.next{display:flex;align-items:center;gap:7px;font-size:13px;font-weight:600;color:var(--tx);min-width:0}
.next .stx{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.25}
.next.wait{color:var(--tx2);font-weight:550}
@@ -327,17 +330,27 @@ main{padding:0}
.flag.warn{background:transparent;color:var(--warn);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--warn) 50%,transparent)}
.flag.bad{background:transparent;color:var(--bad);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--bad) 50%,transparent)}
.flag .plus{font-weight:500;opacity:.8}
.mini{display:flex;flex-direction:column;gap:4px;width:100%;padding:11px 12px;border:1px solid var(--ln);border-radius:11px;background:var(--sf);text-align:left;color:inherit;transition:border-color .15s}
.mini{display:flex;flex-direction:column;gap:6px;width:100%;padding:12px;border:1px solid var(--ln);border-radius:11px;background:var(--sf);text-align:left;color:inherit;transition:border-color .15s}
.mini:hover{border-color:var(--ln3)}
.mini .cname{font-size:13.5px}
.mini .done{display:flex;align-items:center;gap:6px;font-size:12.5px;color:var(--tx2);min-width:0}
.mini .done.warn{color:var(--warn);font-weight:600}
.moreold{height:38px;border:0;border-radius:10px;background:transparent;color:var(--tx2);font-size:13px;font-weight:550}
.moreold:hover{color:var(--tx);background:var(--sf3)}
/* Tempo aceitável de cada etapa (D1): the small table inside the dialog. */
.limitsDialog .dtable th:first-child,.limitsDialog .dtable td:first-child{padding-left:24px}
.limitsDialog .limitStage{display:inline-flex;align-items:center;gap:10px;font-weight:600}
.limitsDialog .limitStage .i{color:var(--tx2)}
.limitsDialog .inp{display:flex;align-items:center;gap:8px;padding:0 10px;height:38px}
.limitsDialog .limitHours{width:96px}
.limitsDialog .limitWho{width:190px}
.limitsDialog .limitInp{border:0;background:transparent;height:auto;padding:0;min-width:0;flex:1;font:inherit;color:inherit;outline:none;width:100%;box-shadow:none}
.limitsDialog .limitInp:focus{box-shadow:none}
.limitsDialog .limitHint{margin-left:8px;font-size:12.5px;color:var(--tx3)}
/* Smaller screens (1366): narrower lanes, a smaller picture, and the machine
left to the lanes of Imprimindo and the green border. */
@media (max-width:1500px){
.board{grid-template-columns:repeat(5,minmax(196px,1fr)) 200px;gap:8px;padding:14px 16px 24px}
.board{grid-template-columns:repeat(5,minmax(196px,1fr)) 200px;gap:8px;padding:14px 16px 0}
.tools{padding:14px 16px 0}
.ctop{grid-template-columns:40px minmax(0,1fr);gap:10px}
.thumb{width:40px;height:40px;padding:3px}
@@ -1023,7 +1036,7 @@ select.inp{appearance:none;-webkit-appearance:none;padding-right:32px;background
.phone,.mtabs,.msum,.mdl,.mbtns,.mhead.phone,.mlist.phone,.mscrim,.msheet{display:none}
@media (max-width:700px){
/* Touch targets: buttons, chips and inputs at least 44 px tall. */
.btn,.chip,.inp,.mic,.mtab,#quote-filters button,.pagetools .seg button,input:not([type=checkbox]):not([type=radio]):not(.vh),select,textarea{min-height:44px}
.btn,.chip,.inp,.mic,.mtab,#quote-filters button,.pagetools .seg button,.card-open,input:not([type=checkbox]):not([type=radio]):not(.vh),select,textarea{min-height:44px}
.phone{display:flex}
.mlist.phone{display:flex}
#app:not([hidden]){display:block}
@@ -1060,7 +1073,7 @@ select.inp{appearance:none;-webkit-appearance:none;padding-right:32px;background
/* Produção: the stages as chips, one at a time */
#tab-board:not([hidden]){display:block;height:auto}
#tab-board .tools{display:none}
.mtabs{display:flex;gap:6px;overflow-x:auto;padding:10px 12px;border-bottom:1px solid var(--ln);background:var(--top);scrollbar-width:none;position:sticky;top:58px;z-index:4}
.mtabs{display:flex;gap:6px;overflow-x:auto;padding:10px 12px;border-bottom:1px solid var(--ln);background:var(--top);scrollbar-width:none;position:sticky;top:58px;z-index:4;-webkit-mask-image:linear-gradient(90deg,#000 calc(100% - 40px),transparent);mask-image:linear-gradient(90deg,#000 calc(100% - 40px),transparent)}
.mtab,#quote-filters button,#stats-period button,#stats-range .btn,.pagetools .seg button{flex:none;height:36px;padding:0 13px 0 10px;border-radius:999px;border:1px solid var(--ln2);background:transparent;color:var(--tx2);font-size:13px;font-weight:600;display:flex;align-items:center;gap:7px;white-space:nowrap;box-shadow:none}
.mtab .sg{width:16px;height:16px}
.mtab .n,#quote-filters .n,.pagetools .seg .n{font-size:12px;font-weight:600;color:var(--tx3)}

View File

@@ -754,17 +754,38 @@ const STAGE_LABELS={rec:'Arte recebida',tra:'Arte conferida',imp:'Imprimindo',re
function stageLimitsDialog(){
api('/stage-limits').then(({limits})=>{
const current=Object.fromEntries((limits||[]).map(limit=>[limit.state,limit]));
const inputs={},fields=[];
const inputs={};
const table=node('table',undefined,'dtable stageLimits');
const thead=node('thead'),headRow=node('tr');
for(const title of ['Etapa','Aceitável','Responde pela etapa'])headRow.append(node('th',title));
thead.append(headRow);
const tbody=node('tbody');
for(const state of ['rec','tra','imp','rev','fin']){
const limit=current[state]||{hours:2,responsible:''};
const tr=node('tr');
const stage=node('td');
const name=node('span',undefined,'limitStage');
name.append(svgIcon(GLYPH[state],'i m'),node('b',STAGE_LABELS[state]));
stage.append(name);
const hoursCell=node('td');
const hoursBox=node('span',undefined,'inp limitHours');
const hours=node('input');hours.type='number';hours.min='0.1';hours.step='0.5';hours.value=limit.hours;
hours.className='limitInp';hours.setAttribute('aria-label','Horas aceitáveis em '+STAGE_LABELS[state]);
hoursBox.append(hours,node('span','h','pre'));
hoursCell.append(hoursBox);
if(state==='fin')hoursCell.append(node('span','3 dias','limitHint'));
const whoCell=node('td');
const whoBox=node('span',undefined,'inp limitWho');
const who=node('input');who.value=limit.responsible||'';who.maxLength=80;
who.className='limitInp';who.setAttribute('aria-label','Quem responde por '+STAGE_LABELS[state]);
whoBox.append(who);
whoCell.append(whoBox);
inputs[state]={hours,who};
fields.push(field(STAGE_LABELS[state]+' (horas)',hours,state==='fin'?'Use 72 para 3 dias.':''));
fields.push(field('Responsável por '+STAGE_LABELS[state].toLowerCase(),who));
tr.append(stage,hoursCell,whoCell);tbody.append(tr);
}
formDialog('Tempos aceitáveis por etapa',{host:dialogHost(),width:640,fields,
note:'Amarelo ao passar do limite; vermelho no dobro.',
table.append(thead,tbody);
formDialog('Tempo aceitável de cada etapa',{host:dialogHost(),width:680,className:'limitsDialog',
text:'Passou disso, o horário do card fica vermelho.',fields:[table],label:'Salvar tempos',
onsave:async()=>{
const limits=Object.entries(inputs).map(([state,{hours,who}])=>({
state,hours:Number(hours.value),responsible:who.value.trim()}));