feat: "Abrir e conferir", the print file full screen, in pieces (item 7)
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 4m28s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m17s
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 4m28s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m17s
The card's "Abrir e conferir" opens the order's print file full screen (Dropstar's third round, item 7): zoom up to 100% real (one file pixel, one screen pixel), the position in cm, the order's files one after the other without closing, and the background behind the transparency light, dark or checkered, remembered (Dropstar, 2026-10-30). Closed in Arte recebida, it asks "Está OK?": the class of each item, prefilled with the measure, then "Mover para Arte conferida" (the final approved, the class kept, the card moved) or "Tratar a arte". A 15 m film is loaded like a map: while the PNG is written, its strips of 512 rows go to storage at 100% and at each halving (app/printtiles.py, originals/tiles/<upload>/), and the viewer (web/kanban-viewer.js) fetches only those on screen. They go when their file expires. Storing a print file that fails is now an attempt like a failed render, not a claim held for an hour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
143
web/kanban-viewer.js
Normal file
143
web/kanban-viewer.js
Normal file
@@ -0,0 +1,143 @@
|
||||
/* Kanban DTF — "Abrir e conferir" (Dropstar's third round, item 7).
|
||||
|
||||
The print file in the browser, full screen: zoom up to 100% real (one file
|
||||
pixel, one screen pixel), the position in cm, the order's files one after
|
||||
the other without closing, and a background behind the transparency (light,
|
||||
dark or checkered, remembered: white art vanishes on light, black on dark).
|
||||
A 57 cm x 15 m film is loaded in pieces, like a map: strips of the film's
|
||||
width at the zoom shown (app/printtiles.py), only those on screen.
|
||||
|
||||
openViewer(files, {title, onClose}): files are [{name, label, manifest,
|
||||
picture}], each with its strips' manifest (and their urls), or only a
|
||||
picture when it has none. */
|
||||
(function(){
|
||||
const BG_KEY='dtf-viewer-bg';
|
||||
const BACKGROUNDS=[['light','Claro'],['dark','Escuro'],['check','Xadrez']];
|
||||
const PX_PER_CM=300/2.54;
|
||||
// Decoded strips kept, the least recently drawn going first.
|
||||
const KEEP=24;
|
||||
const el=(tag,text,cls)=>{const n=document.createElement(tag);if(text!=null)n.textContent=text;if(cls)n.className=cls;return n;};
|
||||
const cm=px=>(px/PX_PER_CM).toFixed(1).replace('.',',');
|
||||
let bg='check';try{bg=localStorage.getItem(BG_KEY)||'check';}catch(_){}
|
||||
|
||||
window.openViewer=function(files,{title='',onClose}={}){
|
||||
const dlg=el('dialog',null,'viewer');dlg.setAttribute('aria-label','Abrir e conferir');
|
||||
const top=el('div',null,'vtop'), name=el('b',title,'vname');
|
||||
const tabs=el('div',null,'vtabs'), tools=el('div',null,'vtools');
|
||||
const where=el('span','','vwhere');
|
||||
const zoomOut=el('button','−','vbtn'), zoomText=el('span','','vzoom'), zoomIn=el('button','+','vbtn');
|
||||
const fit=el('button','Inteira','vbtn'), real=el('button','100%','vbtn');
|
||||
const bgBox=el('div',null,'vbg');
|
||||
const close=el('button','Fechar','vbtn pri');
|
||||
for(const b of [zoomOut,zoomIn,fit,real,close])b.type='button';
|
||||
zoomOut.setAttribute('aria-label','Diminuir');zoomIn.setAttribute('aria-label','Aumentar');
|
||||
for(const [key,label] of BACKGROUNDS){const b=el('button',label,'vbtn');b.type='button';b.dataset.bg=key;
|
||||
b.onclick=()=>{bg=key;try{localStorage.setItem(BG_KEY,key);}catch(_){}paintBg();draw();};bgBox.append(b);}
|
||||
tools.append(where,zoomOut,zoomText,zoomIn,fit,real,bgBox,close);
|
||||
top.append(name,tabs,tools);
|
||||
const stage=el('div',null,'vstage'), canvas=el('canvas'), note=el('p','','vnote');
|
||||
stage.append(canvas,note);dlg.append(top,stage);document.body.append(dlg);
|
||||
|
||||
let file=null, zoom=1, x=0, y=0, cache=new Map(), loading=new Set(), picture=null, raf=0;
|
||||
const paintBg=()=>{for(const b of bgBox.children)b.setAttribute('aria-pressed',String(b.dataset.bg===bg));stage.dataset.bg=bg;};
|
||||
const size=()=>file?.manifest?{w:file.manifest.width,h:file.manifest.height}:picture?{w:picture.width,h:picture.height}:{w:1,h:1};
|
||||
const fitZoom=()=>{const {w,h}=size();return Math.min(stage.clientWidth/w,stage.clientHeight/h,1);};
|
||||
const clamp=()=>{const {w,h}=size(), vw=stage.clientWidth/zoom, vh=stage.clientHeight/zoom;
|
||||
x=w<=vw?(w-vw)/2:Math.max(0,Math.min(w-vw,x));y=h<=vh?(h-vh)/2:Math.max(0,Math.min(h-vh,y));};
|
||||
function setZoom(z,cx=stage.clientWidth/2,cy=stage.clientHeight/2){
|
||||
const fx=x+cx/zoom, fy=y+cy/zoom;
|
||||
zoom=Math.max(Math.min(fitZoom(),0.02),Math.min(4,z));
|
||||
x=fx-cx/zoom;y=fy-cy/zoom;clamp();
|
||||
zoomText.textContent=Math.round(zoom*100)+'%';draw();
|
||||
}
|
||||
// The level whose detail is at least what the zoom shows.
|
||||
function level(){
|
||||
const levels=file.manifest.levels;let k=0;
|
||||
while(k+1<levels.length&&levels[k+1].scale>=zoom)k++;
|
||||
return k;
|
||||
}
|
||||
async function strip(k,i){
|
||||
const key=k+':'+i;
|
||||
if(cache.has(key)){const v=cache.get(key);cache.delete(key);cache.set(key,v);return v;}
|
||||
if(loading.has(key))return null;
|
||||
loading.add(key);
|
||||
try{
|
||||
const url=file.manifest.urls[k][i];
|
||||
const res=await fetch(url,{referrerPolicy:'no-referrer'});
|
||||
if(!res.ok)throw new Error('erro '+res.status);
|
||||
const bmp=await createImageBitmap(await res.blob());
|
||||
if(closed||file?.manifest?.urls[k]?.[i]!==url){bmp.close();return null;}
|
||||
cache.set(key,bmp);
|
||||
while(cache.size>KEEP){const [old,v]=cache.entries().next().value;v.close?.();cache.delete(old);}
|
||||
draw();
|
||||
}catch(e){note.textContent='Não foi possível carregar um pedaço do arquivo ('+e.message+').';}
|
||||
finally{loading.delete(key);}
|
||||
return null;
|
||||
}
|
||||
function draw(){cancelAnimationFrame(raf);raf=requestAnimationFrame(paint);}
|
||||
function paint(){
|
||||
if(closed)return;
|
||||
const ratio=devicePixelRatio||1, W=stage.clientWidth, H=stage.clientHeight;
|
||||
canvas.width=Math.round(W*ratio);canvas.height=Math.round(H*ratio);canvas.style.width=W+'px';canvas.style.height=H+'px';
|
||||
const g=canvas.getContext('2d');g.setTransform(ratio,0,0,ratio,0,0);g.clearRect(0,0,W,H);
|
||||
g.imageSmoothingEnabled=zoom<1;
|
||||
if(picture){g.drawImage(picture,-x*zoom,-y*zoom,picture.width*zoom,picture.height*zoom);return;}
|
||||
if(!file?.manifest)return;
|
||||
const k=level(), L=file.manifest.levels[k], s=L.scale, rows=file.manifest.strip_rows;
|
||||
const first=Math.max(0,Math.floor(y*s/rows)), last=Math.min(L.strips-1,Math.floor((y+H/zoom)*s/rows));
|
||||
for(let i=first;i<=last;i++){
|
||||
let bmp=cache.get(k+':'+i);
|
||||
if(!bmp){strip(k,i);
|
||||
// Meanwhile, a coarser level that is already here.
|
||||
for(let c=k+1;c<file.manifest.levels.length&&!bmp;c++){
|
||||
const C=file.manifest.levels[c], j=Math.floor(i*rows/s*C.scale/rows), have=cache.get(c+':'+j);
|
||||
if(have){const top=j*rows/C.scale;g.drawImage(have,-x*zoom,(top-y)*zoom,have.width/C.scale*zoom,have.height/C.scale*zoom);bmp=null;break;}
|
||||
}
|
||||
continue;}
|
||||
const top=i*rows/s;
|
||||
g.drawImage(bmp,-x*zoom,(top-y)*zoom,bmp.width/s*zoom,bmp.height/s*zoom);
|
||||
}
|
||||
}
|
||||
async function show(f,tab){
|
||||
file=f;picture=null;cache.forEach(v=>v.close?.());cache=new Map();note.textContent='';
|
||||
for(const b of tabs.children)b.setAttribute('aria-pressed',String(b===tab));
|
||||
name.textContent=title?title+' · '+f.name:f.name;
|
||||
if(!f.manifest){
|
||||
note.textContent=f.picture?'Este arquivo não tem os pedaços para 100%: veja a prévia ou baixe o arquivo.':'Este arquivo não tem prévia: baixe para conferir.';
|
||||
if(f.picture){try{const r=await fetch(f.picture);picture=await createImageBitmap(await r.blob());}catch(_){}}
|
||||
}
|
||||
zoom=fitZoom();x=0;y=0;clamp();zoomText.textContent=Math.round(zoom*100)+'%';draw();
|
||||
}
|
||||
files.forEach((f,i)=>{const b=el('button',f.label||f.name,'vtab');b.type='button';b.onclick=()=>show(f,b);tabs.append(b);});
|
||||
tabs.hidden=files.length<2;
|
||||
|
||||
// Drag to move, wheel or pinch to zoom, keys for the rest.
|
||||
let drag=null;
|
||||
stage.onpointerdown=e=>{drag={x:e.clientX,y:e.clientY,ox:x,oy:y};stage.setPointerCapture(e.pointerId);};
|
||||
stage.onpointermove=e=>{
|
||||
const r=stage.getBoundingClientRect(), fx=x+(e.clientX-r.left)/zoom, fy=y+(e.clientY-r.top)/zoom;
|
||||
where.textContent=cm(Math.max(0,fx))+' × '+cm(Math.max(0,fy))+' cm';
|
||||
if(!drag)return;x=drag.ox-(e.clientX-drag.x)/zoom;y=drag.oy-(e.clientY-drag.y)/zoom;clamp();draw();};
|
||||
stage.onpointerup=()=>{drag=null;};
|
||||
// As on a map: the wheel zooms where the pointer is.
|
||||
stage.onwheel=e=>{e.preventDefault();const r=stage.getBoundingClientRect();
|
||||
setZoom(zoom*Math.exp(-e.deltaY*(e.deltaMode?40:1)/400),e.clientX-r.left,e.clientY-r.top);};
|
||||
zoomIn.onclick=()=>setZoom(zoom*1.5);zoomOut.onclick=()=>setZoom(zoom/1.5);
|
||||
fit.onclick=()=>setZoom(fitZoom());real.onclick=()=>setZoom(1);
|
||||
dlg.onkeydown=e=>{if(e.key==='+'||e.key==='=')setZoom(zoom*1.5);else if(e.key==='-')setZoom(zoom/1.5);
|
||||
else if(e.key==='0')setZoom(fitZoom());else if(e.key==='1')setZoom(1);};
|
||||
const resize=()=>{clamp();draw();};addEventListener('resize',resize);
|
||||
// Closed by its button or Escape, and by the dialog's own close as well,
|
||||
// once: some browsers never send that event.
|
||||
let closed=false;
|
||||
const finish=()=>{if(closed)return;closed=true;cancelAnimationFrame(raf);removeEventListener('resize',resize);
|
||||
const strips=[...cache.values()];cache=new Map();strips.forEach(v=>v.close?.());
|
||||
if(dlg.open)dlg.close();dlg.remove();onClose?.();};
|
||||
close.onclick=finish;
|
||||
dlg.addEventListener('cancel',e=>{e.preventDefault();finish();});
|
||||
dlg.onclose=finish;
|
||||
paintBg();dlg.showModal();
|
||||
if(files.length)show(files[0],tabs.children[0]);
|
||||
return {close:finish};
|
||||
};
|
||||
})();
|
||||
@@ -1118,3 +1118,33 @@ select.inp{appearance:none;-webkit-appearance:none;padding-right:32px;background
|
||||
}
|
||||
@keyframes pageIn{from{transform:translateX(30px);opacity:.3}}
|
||||
@keyframes sheetUp{from{transform:translateY(40%);opacity:.3}}
|
||||
|
||||
/* "Abrir e conferir" (item 7): the print file full screen, in pieces. */
|
||||
dialog.viewer{position:fixed;inset:0;width:100vw;height:100vh;max-width:none;max-height:none;margin:0;padding:0;border:0;
|
||||
background:var(--bg);color:var(--tx);display:flex;flex-direction:column}
|
||||
dialog.viewer:not([open]){display:none}
|
||||
dialog.viewer::backdrop{background:var(--scrim)}
|
||||
.vtop{display:flex;align-items:center;gap:12px;flex-wrap:wrap;padding:10px 14px;border-bottom:1px solid var(--ln);background:var(--top)}
|
||||
.vname{font-size:14.5px;font-weight:700;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:32ch}
|
||||
.vtabs{display:flex;gap:6px;overflow-x:auto;flex:1;min-width:0}
|
||||
.vtools{display:flex;align-items:center;gap:6px;margin-left:auto;flex-wrap:wrap}
|
||||
.vbtn,.vtab{height:32px;padding:0 11px;border-radius:8px;border:1px solid var(--ln2);background:var(--sf);color:var(--tx);
|
||||
font-size:13px;font-weight:600;white-space:nowrap;cursor:pointer}
|
||||
.vbtn.pri{background:var(--acc);border-color:var(--acc);color:var(--onacc)}
|
||||
.vtab[aria-pressed="true"],.vbg .vbtn[aria-pressed="true"]{background:var(--ink);border-color:var(--ink);color:var(--onink)}
|
||||
.vbg{display:flex;gap:4px}
|
||||
.vzoom{min-width:48px;text-align:center;font-family:var(--code);font-size:12.5px;color:var(--tx2)}
|
||||
.vwhere{min-width:120px;font-family:var(--code);font-size:12.5px;color:var(--tx2)}
|
||||
.vstage{position:relative;flex:1;min-height:0;overflow:hidden;cursor:grab;touch-action:none}
|
||||
.vstage:active{cursor:grabbing}
|
||||
.vstage canvas{position:absolute;inset:0;display:block}
|
||||
.vstage[data-bg="light"]{background:#FFFFFF}
|
||||
.vstage[data-bg="dark"]{background:#0A0A0A}
|
||||
.vstage[data-bg="check"]{background-color:#FFFFFF;
|
||||
background-image:linear-gradient(45deg,#D9D9D9 25%,transparent 25%),linear-gradient(-45deg,#D9D9D9 25%,transparent 25%),
|
||||
linear-gradient(45deg,transparent 75%,#D9D9D9 75%),linear-gradient(-45deg,transparent 75%,#D9D9D9 75%);
|
||||
background-size:20px 20px;background-position:0 0,0 10px,10px -10px,-10px 0}
|
||||
.vnote{position:absolute;left:50%;bottom:16px;transform:translateX(-50%);margin:0;padding:8px 12px;border-radius:9px;
|
||||
background:var(--sf);border:1px solid var(--ln2);font-size:13px;color:var(--tx2);max-width:min(560px,calc(100% - 32px))}
|
||||
.vnote:empty{display:none}
|
||||
@media(max-width:700px){.vname{max-width:100%;flex-basis:100%}.vwhere{display:none}}
|
||||
|
||||
@@ -175,4 +175,4 @@
|
||||
<div class="scrim" id="scrim"></div>
|
||||
<aside class="drawer" id="panel" aria-label="Pedido"></aside>
|
||||
</div>
|
||||
<script src="/upload.js"></script><script src="/kanban.js"></script></body></html>
|
||||
<script src="/upload.js"></script><script src="/kanban-viewer.js"></script><script src="/kanban.js"></script></body></html>
|
||||
|
||||
@@ -1520,6 +1520,8 @@ function nextBox(order){
|
||||
if(!may('produce')){note('O Designer confere e aprova o arquivo final.');body.push(contractionList(order));}
|
||||
else{
|
||||
const lead=st==='rec'||fixed, a=approveParts(order,lead);
|
||||
// Item 7: open the file, then say whether it is OK.
|
||||
if(st==='rec'){a.approve.classList.remove('pri');main.push(checkButton(order,'btn pri lg'));}
|
||||
if(lead){if(a.files)body.push(a.files);note(a.text);body.push(contractionList(order));main.push(a.approve,...a.extra);}
|
||||
else more.push(a.approve,...a.extra);
|
||||
}
|
||||
@@ -1711,6 +1713,52 @@ function finalDialog(order,ready,{replace=false}={}){
|
||||
// where the folder is, to copy the whole path.
|
||||
const TREAT_NOTE='Arte tratada';
|
||||
const FOLDER_PATH_KEY='folder-path';
|
||||
// ---- Abrir e conferir (item 7) ----------------------------------------------
|
||||
|
||||
// The print file full screen, in pieces (web/kanban-viewer.js); closed in
|
||||
// Arte recebida, it asks whether the art is OK.
|
||||
function checkButton(order,className='btn'){
|
||||
const b=button('Abrir e conferir',()=>openCheck(order),className);b.prepend(svgIcon(IC.eye||IC.file,'i m'));return b;
|
||||
}
|
||||
async function openCheck(order){
|
||||
const {files}=await api('/orders/'+order.id+'/view');
|
||||
if(!files.length){say('Ainda não há arquivo para abrir.',true);return;}
|
||||
openViewer(files,{title:'#'+order.number,onClose:()=>{
|
||||
const now=board.orders.find(o=>o.id===order.id)||order;
|
||||
if(now.state==='rec'&&!now.cancelled_at&&may('produce')&&mayMove('rec','tra'))isOk(now);}});
|
||||
}
|
||||
// "Está OK?" (Dropstar, 2026-10-29): the class of each item, prefilled with
|
||||
// the measure, and the art either goes on to Arte conferida, its final
|
||||
// approved and its class kept, or is treated (item 8).
|
||||
function isOk(order){
|
||||
const items=order.snapshot.items, ready=readyFinals(order);
|
||||
const selects=items.map((item,index)=>{
|
||||
const select=node('select');select.required=true;
|
||||
const none=node('option','Escolha');none.value='';none.disabled=true;select.append(none);
|
||||
for(const c of ['C1','C2','C3']){const o=node('option',c+', '+CLASS_NOTE[c]);o.value=c;select.append(o);}
|
||||
select.value=contractionOf(order,index)||'';return select;});
|
||||
const fields=selects.map((select,index)=>{const item=items[index];
|
||||
return field(items.length>1?'Item '+(index+1)+', contração':'Contração',select,
|
||||
item.stroke_class?'O site mediu '+item.stroke_class+', traço de '+item.stroke_px+' px':'O site não mediu esta arte');});
|
||||
const missing=!finalDone(order)&&!ready.every(Boolean);
|
||||
const treat=button('Tratar a arte',()=>{m.close();treatDialog(order);},'btn');
|
||||
const m=formDialog('Está OK?',{host:$('drawer'),fields,left:[treat],label:'Mover para Arte conferida',
|
||||
text:missing?'Falta o arquivo final de um item: trate a arte e envie o arquivo preparado.'
|
||||
:'A arte chegou boa? Confira a contração e mova para Arte conferida.',
|
||||
onsave:async()=>{
|
||||
if(missing)throw new Error('Falta o arquivo final de um item.');
|
||||
for(const [index,select] of selects.entries())
|
||||
if(select.value!==contractionOf(order,index))
|
||||
await api('/orders/'+order.id+'/contraction',{item_index:index,value:select.value});
|
||||
if(!finalDone(order))
|
||||
await api('/orders/'+order.id+'/final-files',{version:order.version,
|
||||
files:ready.flatMap((r,i)=>r.files.map(f=>({item_index:i,upload_id:f.upload_id}))),note:'Conferido em Abrir e conferir'});
|
||||
await load();
|
||||
await move(board.orders.find(o=>o.id===order.id)||order,'tra');
|
||||
say('Pedido #'+order.number+' em Arte conferida.');
|
||||
}});
|
||||
if(missing)m.box.querySelector('button.pri')?.setAttribute('disabled','');
|
||||
}
|
||||
function treatDialog(order){
|
||||
const base=node('input');base.placeholder='Ex.: D:\\'+(FOLDER.handle?.name||'Pedidos');
|
||||
const names={};
|
||||
@@ -1868,6 +1916,7 @@ function itemCard(order,item,index){
|
||||
}
|
||||
item.uploads.forEach((uid,i)=>links.append(dl_(item.uploads.length>1?'Original '+(i+1):'Arquivo original',uid)));
|
||||
if(spec?.placements){const m=button('Manifesto',()=>manifest(spec,contractionRecord(item,order.contraction?.[index])),'btn');m.prepend(svgIcon(IC.file,'i m'));links.append(m);}
|
||||
if(row?.status==='ready')links.prepend(checkButton(order));
|
||||
if(may('produce')&&!fix&&['rec','tra'].includes(order.state)&&(!row||row.status==='manual'||row.status==='failed')){
|
||||
const again=button('Gerar de novo',async()=>{await api('/orders/'+order.id+'/print-files',{});await load();},'btn');again.prepend(svgIcon(IC.refresh,'i m'));links.append(again);}
|
||||
info.append(links);
|
||||
|
||||
Reference in New Issue
Block a user