feat: places per machine, drops on Imprimindo go to your machine, a Venda carries its seller to Tiny (DTF-WEB-V)
All checks were successful
Build and deploy / Validate source (push) Successful in 10s
Build and deploy / Integration suite on a real stack (push) Successful in 7m38s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m19s
All checks were successful
Build and deploy / Validate source (push) Successful in 10s
Build and deploy / Integration suite on a real stack (push) Successful in 7m38s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m19s
Marcus, 2026-11-17: - Each machine has its own places (machines.places, 1 to 6, three to start): orders at once in Imprimindo and files at once in its hot folder. Admin sets it in the machine dialog; Admin and Gestão in the machine sheet's Dados da máquina. A third order shows as "Na vez". - Whoever is signed in on a machine drops a card anywhere in Imprimindo and it goes to that machine; without one, the lane under the pointer. - Each Kanban user may name their Tiny seller (Usuários, read from Tiny's own list); a montador Venda reaches Tiny with the seller of who assembled it. Every other order still sends no seller. - A folder download that never reached storage (a network drop) waits for the next pass as a warning and is reported only if it keeps failing (Sentry DTF-WEB-V). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -55,9 +55,10 @@ const MIRROR_NOTE='O cliente espelhou a arte: confira antes de imprimir';
|
||||
const residueNote=item=>{const many=item.residue_accepted>1;
|
||||
return item.residue_accepted+(many?' pontos menores':' ponto menor')+' que 2 mm, que '+(many?'podem':'pode')+' se perder no recorte';};
|
||||
const residueBadge=item=>badge('! Resíduo aceito','warn','O cliente aceitou imprimir com '+residueNote(item));
|
||||
// Two places per machine in Imprimindo (app/machines.py): the first to come
|
||||
// in is printing, the next is being ripped meanwhile.
|
||||
// A machine's places in Imprimindo (app/machines.py): the first to come in is
|
||||
// printing, the next is being ripped meanwhile, any after it waits its turn.
|
||||
const PRINTING={imprimindo:['Imprimindo','live','Já ripou, está rodando'],
|
||||
aguardando:['Na vez','wait','Na hot folder, espera os da frente'],
|
||||
ripando:['Ripando','rip','O Flexi está ripando enquanto o anterior roda']};
|
||||
// A film in parts on its machine (items 10 and 13, Dropstar 2026-10-30):
|
||||
// "parte 3/7 imprimindo · 4/7 ripando". Flexi rips the part it took last from
|
||||
@@ -259,11 +260,11 @@ function renderBoard(){
|
||||
column.ondragover=e=>{
|
||||
if(dragging?.state===state&&state!=='fin'&&mayReorder(state)){e.preventDefault();markDrop(column,e.clientY);return;}
|
||||
if(!column.classList.contains('allowed'))return;e.preventDefault();column.classList.add('target');
|
||||
if(state==='imp')markLane(column,laneAt(column,e.clientY));};
|
||||
if(state==='imp')markLane(column,dropMachine(column,e.clientY));};
|
||||
column.ondragleave=e=>{if(!column.contains(e.relatedTarget)){column.classList.remove('target');markLane(column,null);clearDrop();}};
|
||||
column.ondrop=async e=>{e.preventDefault();column.classList.remove('target');
|
||||
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);
|
||||
const machine=state==='imp'?dropMachine(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).
|
||||
@@ -301,7 +302,7 @@ function renderBoard(){
|
||||
// machine has its lane, so a card dragged from the queue can be dropped on
|
||||
// the machine it goes to print on.
|
||||
function printingLanes(orders){
|
||||
const cap=board.printing_cap||2, mine=myMachine()?.id;
|
||||
const mine=myMachine()?.id;
|
||||
const filtered=Object.values(boardFilter).some(Boolean);
|
||||
const out=[];
|
||||
const list=(board.machines||[]).filter(m=>m.active||orders.some(o=>o.machine?.id===m.id));
|
||||
@@ -310,6 +311,8 @@ function printingLanes(orders){
|
||||
.sort((a,b)=>(a.printing==='imprimindo'?0:1)-(b.printing==='imprimindo'?0:1));
|
||||
// Filtered, a lane with nothing to show stays out; unfiltered, the places count every order.
|
||||
if(filtered&&!here.length)continue;
|
||||
// Each machine's own places (app/machines.py), set in its sheet.
|
||||
const cap=m.places||board.printing_cap||3;
|
||||
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':plural(Math.max(0,cap-n),'vaga','vagas');
|
||||
@@ -336,6 +339,10 @@ function printingLanes(orders){
|
||||
return out;
|
||||
}
|
||||
// The machine lane under the pointer in Imprimindo: the last lane head above it.
|
||||
// Where a card dropped on Imprimindo goes: the machine of whoever is signed in
|
||||
// on one, wherever it lands in the column (Marcus, 2026-11-17); otherwise the
|
||||
// lane under the pointer.
|
||||
const dropMachine=(column,y)=>myMachine()?.id||laneAt(column,y);
|
||||
function laneAt(column,y){
|
||||
let found=null;
|
||||
for(const el of column.querySelectorAll('[data-machine]')){
|
||||
|
||||
@@ -249,12 +249,12 @@ async function loadStats(){
|
||||
$('stats-kpis').replaceChildren(cards,extra);
|
||||
statsChart($('stats-chart'),data.daily);
|
||||
// Por máquina: what each printed, how fast, and what it has now.
|
||||
const cap=board.printing_cap||2;
|
||||
const capOf=id=>(board.machines||[]).find(x=>x.id===id)?.places||board.printing_cap||3;
|
||||
const machineRows=data.machines.map(m=>{
|
||||
const tr=node('tr');if(!m.active)tr.classList.add('off');
|
||||
const name=node('td');name.append(node('b',m.name+(m.active?'':', desativada')),
|
||||
node('span',(m.orders?plural(m.orders,'pedido','pedidos'):'nada')+(m.last_finished?', último '+when(m.last_finished):''),'sub'));
|
||||
const now=!m.id?'—':m.now.imp?(m.now.imp>=cap?'cheia':m.now.imp+' imprimindo')+(m.now.tra?', '+m.now.tra+' na fila':''):m.now.tra?m.now.tra+' na fila':'livre';
|
||||
const now=!m.id?'—':m.now.imp?(m.now.imp>=capOf(m.id)?'cheia':m.now.imp+' imprimindo')+(m.now.tra?', '+m.now.tra+' na fila':''):m.now.tra?m.now.tra+' na fila':'livre';
|
||||
tr.append(name,node('td',m.orders?metres(m.metres):'—','r'),
|
||||
node('td',m.metres_per_hour!=null?String(m.metres_per_hour).replace('.',',')+' m':'—','r'),node('td',now,'muted'));
|
||||
return tr;});
|
||||
|
||||
@@ -362,7 +362,7 @@ function nextBox(order){
|
||||
const p=proofBtn();if(p)more.push(p);
|
||||
fixBtn();
|
||||
}else if(st==='imp'){
|
||||
title=order.printing==='ripando'?'Ripando enquanto o anterior roda':'Terminou de imprimir?';
|
||||
title=order.printing==='ripando'?'Ripando enquanto o anterior roda':order.printing==='aguardando'?'Na vez: espera os da frente':'Terminou de imprimir?';
|
||||
note('A folha segue para o Revisor conferir.');
|
||||
if(can('rev'))main.push(moveBtn('rev'));else cannot();
|
||||
const p=proofBtn();if(p)more.push(p);
|
||||
|
||||
@@ -14,9 +14,9 @@ function machineChoice(machine,mine=false){
|
||||
b.append(head,node('span',machine.products.map(p=>PRODUCT_LABEL[p]).join(' e ')||'Nenhum produto','sub'));
|
||||
const here=board.orders.filter(o=>o.state==='imp'&&!o.cancelled_at&&o.machine?.id===machine.id)
|
||||
.sort((x,y)=>(x.printing==='imprimindo'?0:1)-(y.printing==='imprimindo'?0:1));
|
||||
for(let i=0;i<Math.max(board.printing_cap||2,here.length);i++){
|
||||
for(let i=0;i<Math.max(machine.places||board.printing_cap||3,here.length);i++){
|
||||
const o=here[i],job=node('span',undefined,'job');
|
||||
if(o)job.append(node('i',undefined,o.printing==='ripando'?'ripmark':'runmark'),node('span','#'+o.number,'code'),node('em',o.printing==='ripando'?'ripando':'imprimindo'));
|
||||
if(o)job.append(node('i',undefined,o.printing==='imprimindo'?'runmark':'ripmark'),node('span','#'+o.number,'code'),node('em',o.printing||'imprimindo'));
|
||||
else job.append(node('i',undefined,'freemark'),node('span','livre','free'));
|
||||
b.append(job);
|
||||
}
|
||||
@@ -247,6 +247,18 @@ function userForm(u){
|
||||
pass.required=!editing;pass.placeholder=editing?'Deixe em branco para manter a atual':'8 caracteres ou mais';
|
||||
const active=node('input');active.checked=u?u.active:true;active.disabled=u?.email===ME.email;
|
||||
const row=node('div',undefined,'frow');row.append(field('Nome',name),field('E-mail',email));
|
||||
// The Tiny seller this person is: a Venda they assemble in Montar reaches
|
||||
// Tiny with it (Marcus, 2026-11-17). The list comes from Tiny itself.
|
||||
const seller=node('select');
|
||||
const none=node('option','Nenhum: o pedido vai sem vendedor');none.value='';seller.append(none);
|
||||
if(u?.tiny_seller){const o=node('option',u.tiny_seller.name);o.value=String(u.tiny_seller.id);seller.append(o);seller.value=o.value;}
|
||||
const sellerNote=node('small','Num pedido de Venda montado por esta pessoa no Montar, o Tiny recebe este vendedor.');
|
||||
api('/tiny/sellers').then(list=>{
|
||||
const keep=seller.value;
|
||||
seller.replaceChildren(none,...list.map(x=>{const o=node('option',x.name);o.value=String(x.id);return o;}));
|
||||
if(keep&&!list.some(x=>String(x.id)===keep)&&u?.tiny_seller){const o=node('option',u.tiny_seller.name+' (não está mais no Tiny)');o.value=keep;seller.append(o);}
|
||||
seller.value=keep;
|
||||
}).catch(e=>{sellerNote.textContent='Não foi possível ler os vendedores do Tiny: '+e.message;});
|
||||
const left=[];
|
||||
if(editing&&u.email!==ME.email){
|
||||
const remove=node('button','Excluir usuário','btn quiet');remove.type='button';
|
||||
@@ -257,18 +269,28 @@ function userForm(u){
|
||||
}
|
||||
const m=formDialog(editing?u.name||u.email:'Novo usuário',{width:560,left,lead:editing?avatar(u,'bigava'):null,
|
||||
text:editing?PRESENCE[presence(u)].split(':')[0]+', último acesso '+(u.last_login_at?when(u.last_login_at):'nunca'):'A pessoa entra com o e-mail e esta senha, e troca a senha em Minha conta.',
|
||||
fields:[row,roleField,field(editing?'Nova senha':'Senha inicial',pass),checkbox('Ativo: pode entrar no sistema',active)],
|
||||
fields:[row,roleField,field(editing?'Nova senha':'Senha inicial',pass),field('Vendedor no Tiny',seller,sellerNote),checkbox('Ativo: pode entrar no sistema',active)],
|
||||
label:editing?'Salvar':'Criar usuário',onsave:async()=>{
|
||||
const body={name:name.value,email:email.value,role:role.value()==='superadmin'?'admin':role.value(),active:active.checked,password:pass.value||null};
|
||||
const picked=seller.value?{id:Number(seller.value),name:seller.selectedOptions[0].textContent.replace(/ \(não está mais no Tiny\)$/,'')}:null;
|
||||
const body={name:name.value,email:email.value,role:role.value()==='superadmin'?'admin':role.value(),active:active.checked,password:pass.value||null,tiny_seller:picked};
|
||||
await api(editing?'/users/'+u.id:'/users',body);
|
||||
say(editing?'Usuário salvo.':'Usuário criado. Passe o e-mail e a senha inicial para a pessoa.');await loadUsers();
|
||||
}});
|
||||
}
|
||||
// A machine's places in Imprimindo, which are also the files at once in its
|
||||
// hot folder (app/machines.py): Admin and Gestão set them (Marcus, 2026-11-17).
|
||||
const PLACES_NOTE='Quantos pedidos a máquina aceita em Imprimindo, e quantos arquivos ficam juntos na hot folder dela.';
|
||||
function placesSelect(value){
|
||||
const select=node('select');
|
||||
for(let n=1;n<=6;n++){const o=node('option',String(n));o.value=String(n);select.append(o);}
|
||||
select.value=String(value||3);return select;
|
||||
}
|
||||
function machineForm(m){
|
||||
const name=node('input');name.required=true;name.maxLength=60;name.value=m?.name||'';name.placeholder='Ex.: Têxtil 2';
|
||||
const products=pills([['textil','Têxtil'],['uv','UV']],m?.products||[]);
|
||||
const limit=node('input');limit.type='number';limit.min='1';limit.max='99999';limit.step='0.1';limit.inputMode='decimal';
|
||||
limit.placeholder='Sem limite';limit.value=m?.limit_metres??'';
|
||||
const places=placesSelect(m?.places);
|
||||
const active=node('input');active.checked=m?m.active:true;
|
||||
const left=[];
|
||||
if(m){
|
||||
@@ -281,11 +303,12 @@ function machineForm(m){
|
||||
const d=formDialog(m?'Editar máquina':'Nova máquina',{width:520,left,
|
||||
fields:[field('Nome',name),group('Imprime',products),
|
||||
field('Limite de metros em aberto',unit(limit,'metros'),'Pedidos novos vão para a máquina do produto com menos metros em aberto, dentro do limite.'),
|
||||
field('Vagas em Imprimindo',places,PLACES_NOTE),
|
||||
checkbox('Ativa: recebe pedidos',active)],
|
||||
onsave:async()=>{
|
||||
if(!products.values().length)throw new Error('Marque o que a máquina imprime.');
|
||||
await api(m?'/machines/'+m.id:'/machines',{name:name.value,active:active.checked,products:products.values(),
|
||||
limit_metres:limit.value?Number(limit.value):null});
|
||||
limit_metres:limit.value?Number(limit.value):null,places:Number(places.value)});
|
||||
say(m?'Máquina salva.':'Máquina criada.');await loadUsers();await load();
|
||||
}});
|
||||
}
|
||||
@@ -396,9 +419,10 @@ async function openMachineSheet(machineId, tab='situacao'){
|
||||
const price=node('input');price.type='number';price.min='0';price.step='0.01';price.inputMode='decimal';
|
||||
price.value=machine.price_cents!==null&&machine.price_cents!==undefined?(machine.price_cents/100).toFixed(2):'';
|
||||
const installed=node('input');installed.type='date';installed.value=machine.installed_on||'';
|
||||
const places=placesSelect(machineState?.places);
|
||||
const minimums={};
|
||||
const box=node('div',undefined,'mblock');
|
||||
box.append(field('Preço de compra (R$)',price),field('Data de instalação',installed));
|
||||
box.append(field('Vagas em Imprimindo',places,PLACES_NOTE),field('Preço de compra (R$)',price),field('Data de instalação',installed));
|
||||
for(const [item,[label,unit]] of Object.entries(data.catalog.supplies)){
|
||||
const input=node('input');input.type='number';input.min='0';input.step='0.001';input.inputMode='decimal';
|
||||
const typed=data.minimums[item], fallback=data.default_minimums?.[item];
|
||||
@@ -412,6 +436,8 @@ async function openMachineSheet(machineId, tab='situacao'){
|
||||
save.onclick=async()=>{
|
||||
save.disabled=true;error.hidden=true;
|
||||
try{
|
||||
if(machineState&&Number(places.value)!==machineState.places)
|
||||
await api('/machines/'+machine.id+'/places',{places:Number(places.value)});
|
||||
await api('/machines/'+machine.id+'/sheet',{
|
||||
price_cents:price.value.trim()===''?null:Math.round(Number(price.value)*100),
|
||||
installed_on:installed.value||null,
|
||||
|
||||
@@ -286,8 +286,9 @@ const REVIEWS_FOLDER='Revisões';
|
||||
const FOLDER={mode:'showDirectoryPicker' in window?'folder':/Firefox\//.test(navigator.userAgent)?'downloads':'none',
|
||||
brave:!!navigator.brave,handle:null,granted:false,downloads:false,since:null,
|
||||
saved:new Map(),busy:false,status:'',error:'',last:null,lastSig:null,
|
||||
// Passes in a row each file was held open by another program (DTF-WEB-M).
|
||||
locked:new Map(),
|
||||
// Passes in a row each file was held open by another program (DTF-WEB-M),
|
||||
// or could not be downloaded for the network (DTF-WEB-V).
|
||||
locked:new Map(),unreachable:new Map(),
|
||||
// Since when the main folder does not answer (DTF-WEB-P), and whether that was reported.
|
||||
awaySince:0,awayReported:false,
|
||||
// Whether this page load cleared the old version's leftovers (order #30).
|
||||
@@ -501,10 +502,11 @@ async function sweepLeftovers(dir,depth){
|
||||
// tries again.
|
||||
// A file that arrived incomplete waits for the next pass too, reported.
|
||||
const LOCKED=new Set(['NoModificationAllowedError','InvalidModificationError','NotReadableError','InvalidStateError']);
|
||||
function fileStep(locked,incomplete){
|
||||
function fileStep(locked,incomplete,unreachable){
|
||||
return async(name,fn)=>{try{await fn();return true;}
|
||||
catch(e){
|
||||
if(e.name==='IncompleteFile'){incomplete.push(e.message);return false;}
|
||||
if(e.unreachable){unreachable.push(name);return false;}
|
||||
if(!LOCKED.has(e.name))throw e;locked.push(name);return false;}};
|
||||
}
|
||||
const stageDir=name=>FOLDER.handle.getDirectoryHandle(name,{create:true});
|
||||
@@ -532,8 +534,14 @@ async function moveSaved(rec,to){
|
||||
return true;
|
||||
}
|
||||
// One file from storage, whole, into a folder.
|
||||
// A download that never reached storage or the server (the network dropped
|
||||
// for a moment, Sentry DTF-WEB-V) is marked unreachable: the file waits for
|
||||
// the next pass, like one held open, and is reported only if it keeps failing.
|
||||
async function fetchFile(url,options){
|
||||
try{return await fetch(url,options);}catch(e){e.unreachable=true;throw e;}
|
||||
}
|
||||
async function fetchInto(dir,file,watched=false){
|
||||
const r=await fetch(file.url,{referrerPolicy:'no-referrer'});
|
||||
const r=await fetchFile(file.url,{referrerPolicy:'no-referrer'});
|
||||
if(!r.ok||!r.body)throw new Error('não foi possível baixar '+file.name+' (erro '+r.status+').');
|
||||
await writeWhole(dir,file.name,r,watched);
|
||||
}
|
||||
@@ -598,7 +606,7 @@ async function syncFolder(force=false){
|
||||
const wanted=new Map(files.map(f=>[f.upload_id,f]));
|
||||
const where=stages?'“'+FOLDER.handle.name+'”':'a pasta de downloads';
|
||||
let removed=0, moved=0, saved=0;
|
||||
const locked=[], incomplete=[], step=fileStep(locked,incomplete);
|
||||
const locked=[], incomplete=[], unreachable=[], step=fileStep(locked,incomplete,unreachable);
|
||||
if(stages){
|
||||
await clearWork();
|
||||
if(!FOLDER.swept){for(const name of FLOW_FOLDERS)await sweepLeftovers(await stageDir(name),2);FOLDER.swept=true;}
|
||||
@@ -652,7 +660,7 @@ async function syncFolder(force=false){
|
||||
for(const r of receipts){
|
||||
try{await api('/orders/'+r.order+'/receipt/claim',{});}catch(e){if(e.status===409)continue;throw e;}
|
||||
await step(r.name,async()=>{try{
|
||||
const res=await fetch('/api/operator/orders/'+r.order+'/receipt');
|
||||
const res=await fetchFile('/api/operator/orders/'+r.order+'/receipt');
|
||||
if(!res.ok||!res.body)throw new Error('não foi possível gerar '+r.name+' (erro '+res.status+').');
|
||||
await writeWhole(await stageDir(RECEIPTS_FOLDER),r.name,res,true);printed++;
|
||||
}catch(e){await api('/orders/'+r.order+'/receipt/release',{}).catch(()=>{});throw e;}});
|
||||
@@ -666,7 +674,7 @@ async function syncFolder(force=false){
|
||||
FOLDER.status='Salvando revisão: '+review.name;paintFolder();
|
||||
if(!await step(review.name,async()=>{
|
||||
const view=await api('/orders/'+review.order+'/reviews/'+review.id+'/view');
|
||||
const res=await fetch(view.url,{referrerPolicy:'no-referrer'});
|
||||
const res=await fetchFile(view.url,{referrerPolicy:'no-referrer'});
|
||||
if(!res.ok||!res.body)throw new Error('não foi possível baixar '+review.name+' (erro '+res.status+').');
|
||||
await writeWhole(await stageDir(REVIEWS_FOLDER),review.name,res);
|
||||
}))continue;
|
||||
@@ -685,6 +693,19 @@ async function syncFolder(force=false){
|
||||
// Expected while the FlexiPRINT reads a file: a warning the first time, and
|
||||
// an error (which reaches Sentry) only when the same file is still held
|
||||
// after LOCKED_REPORT_PASSES passes (Sentry DTF-WEB-M).
|
||||
// Not downloaded for the network: a warning, and an error (so in Sentry)
|
||||
// only when the same file still fails after LOCKED_REPORT_PASSES passes.
|
||||
for(const name of [...FOLDER.unreachable.keys()])if(!unreachable.includes(name))FOLDER.unreachable.delete(name);
|
||||
for(const name of unreachable)FOLDER.unreachable.set(name,(FOLDER.unreachable.get(name)||0)+1);
|
||||
if(unreachable.length){
|
||||
FOLDER.lastSig=null;
|
||||
const stuck=unreachable.filter(name=>FOLDER.unreachable.get(name)===LOCKED_REPORT_PASSES);
|
||||
FOLDER.error='Não foi possível baixar '+unreachable[0]+(unreachable.length>1?' e mais '+(unreachable.length-1):'')+
|
||||
' agora (a rede oscilou). Os outros foram gravados; o Kanban tenta de novo em 30 s.';
|
||||
if(stuck.length)say('Pastas automáticas: '+stuck.join(', ')+' não baixa há '+Math.round(LOCKED_REPORT_PASSES*30/60)+
|
||||
' minutos. Confira a internet deste computador.',true);
|
||||
else if(unreachable.some(name=>FOLDER.unreachable.get(name)===1))say('Pastas automáticas: '+FOLDER.error);
|
||||
}
|
||||
for(const name of [...FOLDER.locked.keys()])if(!locked.includes(name))FOLDER.locked.delete(name);
|
||||
for(const name of locked)FOLDER.locked.set(name,(FOLDER.locked.get(name)||0)+1);
|
||||
if(locked.length){
|
||||
@@ -971,7 +992,7 @@ function stageLimitsDialog(){
|
||||
}).catch(error=>say(error.message,true));
|
||||
}
|
||||
function field(label,input,hint){
|
||||
const l=node('label',undefined,'fld');l.append(label,input);if(hint)l.append(node('small',hint));return l;
|
||||
const l=node('label',undefined,'fld');l.append(label,input);if(hint)l.append(hint instanceof Node?hint:node('small',hint));return l;
|
||||
}
|
||||
// A checkbox drawn as the design's box.
|
||||
function checkbox(label,input){
|
||||
|
||||
Reference in New Issue
Block a user