fix: the Kanban says the proof machine before a pull, folder downloads cut by the network wait for the next pass, expected refusals stay out of Sentry (DTF-WEB-16..1K, DTF-API-C)
All checks were successful
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 7m37s
Build and deploy / Secret scan and release gate (push) Successful in 9s
Build and deploy / Publish images (push) Successful in 1m25s
All checks were successful
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 7m37s
Build and deploy / Secret scan and release gate (push) Successful in 9s
Build and deploy / Publish images (push) Successful in 1m25s
- 19/1F: the board carries the approved proof's machine; the pull and the order's machine field keep to it and say why. - 17/1E: a network drop while a download or an answer arrives counts as unreachable/offline, warned first like the others. - 16: no folder picker (Safari): said in a line. - 1A, 1J/1K, 1D, 18: guidance and expected refusals (pull to another machine, someone already on the machine, e-mail in use, coupon) are not errors. - 1B: an empty file is refused on the page. - API-C: the Tiny's rate limit reaches Sentry only if it repeats. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -56,8 +56,9 @@
|
||||
const retry=response.headers.get('Retry-After');
|
||||
if(retry!=null)error.retryAfter=retry;
|
||||
// A status the caller expects (a resumed upload that expired) is handled
|
||||
// there, not reported.
|
||||
if(!(options.expected||[]).includes(response.status))
|
||||
// there, not reported. `expected` may also be a test of status and text.
|
||||
const expected=options.expected;
|
||||
if(!(typeof expected==='function'?expected(response.status,error.message):(expected||[]).includes(response.status)))
|
||||
window.dtfObservability?.apiError?.(path,response.status,error.message,data.detail);
|
||||
throw error;
|
||||
}
|
||||
@@ -152,6 +153,9 @@
|
||||
// One message line under the steps. Its tone says what it is: a refusal or
|
||||
// a missing field is an error (red), a cart that changed a warning, a
|
||||
// created order a confirmation, the rest information.
|
||||
// A code the customer typed wrong, or one no longer valid (app/coupons.py):
|
||||
// they fix it, it is no error (Sentry DTF-WEB-18).
|
||||
const couponRefusal=(status,text)=>status===422&&/^(Cupom |Este cupom |Você já usou este cupom)/.test(text||'');
|
||||
function message(text, tone='info') {
|
||||
status.textContent = text; status.dataset.tone = text ? tone : '';
|
||||
if (tone === 'error' && text) window.dtfObservability?.uiError?.(text, 'site');
|
||||
@@ -553,11 +557,11 @@
|
||||
localStorage.setItem('dtf-request-key',requestKey);
|
||||
localStorage.setItem('dtf-request-body',requestBody);
|
||||
}
|
||||
const quote = await api('/quotes',{request_key:requestKey,...content,timings});
|
||||
const quote = await api('/quotes',{request_key:requestKey,...content,timings},{expected:couponRefusal});
|
||||
quotedCart=initialCart;localStorage.setItem('dtf-quote-cart',quotedCart);
|
||||
draftId=quote.id; localStorage.setItem('dtf-quote',draftId);
|
||||
await refresh(true);
|
||||
} catch(error) { message(error.message,'error'); }
|
||||
} catch(error) { message(error.message,couponRefusal(error.status,error.message)?'warn':'error'); }
|
||||
finally { busy=false; pintaEntrega(); }
|
||||
};
|
||||
// `go`: the customer asked to pay, so the cart page moves to the payment page.
|
||||
|
||||
@@ -36,7 +36,8 @@ function askMachine(again=false){
|
||||
const required=ME.machine_question==='required', current=myMachine();
|
||||
let m=null;
|
||||
const choose=async(id,confirm=false)=>{
|
||||
try{await api('/me/machine',{machine_id:id,confirm});m.close();await load(true);}
|
||||
// Someone else on the machine is a question, not an error (Sentry DTF-WEB-1J).
|
||||
try{await api('/me/machine',{machine_id:id,confirm},{expected:confirm?[]:[409]});m.close();await load(true);}
|
||||
catch(e){
|
||||
if(e.status===409&&!confirm&&await ask('Outra pessoa está nesta máquina',e.message,'Continuar mesmo assim'))return choose(id,true);
|
||||
say(e.message,true);}};
|
||||
@@ -69,6 +70,12 @@ function paintMyMachine(){
|
||||
for(const id of ['my-machine','rail-machine'])$(id).onclick=()=>askMachine(true);
|
||||
$('account-machine').onclick=()=>{$('account-menu').hidden=true;askMachine(true);};
|
||||
|
||||
// The machine that printed the order's approved proof: the order prints
|
||||
// there too, and the server refuses any other (Sentry DTF-WEB-19, 1F).
|
||||
function proofMachine(order){
|
||||
const card=order.proof_card;
|
||||
return card?.proof_result==='ok'&&card.machine_id?(board.machines||[]).find(m=>m.id===card.machine_id)||{id:card.machine_id,name:'máquina da prova'}:null;
|
||||
}
|
||||
// The machine is recorded when the card is pulled into Imprimindo.
|
||||
function machineCard(order){
|
||||
const box=node('div',undefined,'fact');box.append(node('span','Máquina','lbl'));
|
||||
@@ -80,6 +87,11 @@ function machineCard(order){
|
||||
box.append(node('b',current?current.name:'Aguardando máquina'),node('span',detail));
|
||||
return box;
|
||||
}
|
||||
const proofAt=proofMachine(order);
|
||||
if(proofAt){
|
||||
box.append(node('b',proofAt.name),node('span','A máquina que imprimiu a prova #'+order.proof_card.number));
|
||||
return box;
|
||||
}
|
||||
const select=node('select');select.setAttribute('aria-label','Máquina do pedido');
|
||||
const auto=node('option','Sem máquina');auto.value='';select.append(auto);
|
||||
const family=order.snapshot.items.some(i=>i.mode==='uvfile'||i.mode==='uv')?'uv':'textil';
|
||||
@@ -273,7 +285,8 @@ function userForm(u){
|
||||
label:editing?'Salvar':'Criar usuário',onsave:async()=>{
|
||||
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);
|
||||
// An e-mail already in use is said in the form, not an error (Sentry DTF-WEB-1D).
|
||||
await api(editing?'/users/'+u.id:'/users',body,{expected:[409]});
|
||||
say(editing?'Usuário salvo.':'Usuário criado. Passe o e-mail e a senha inicial para a pessoa.');await loadUsers();
|
||||
}});
|
||||
}
|
||||
@@ -647,17 +660,22 @@ async function pullTo(order, machineId){
|
||||
if(ME?.role==='operador'){
|
||||
const mine=myMachine();
|
||||
if(!mine){askMachine(true);return;}
|
||||
// Guidance, not an error: the pull goes to the session's machine (Sentry DTF-WEB-1A).
|
||||
if(machineId&&machineId!==mine.id){
|
||||
say('Você está na '+mine.name+': o que você puxa vai para ela.',true);return;
|
||||
say('Você está na '+mine.name+': o que você puxa vai para ela.');return;
|
||||
}
|
||||
target=mine.id;
|
||||
}else{
|
||||
target=machineId||order.machine?.id||myMachine()?.id||null;
|
||||
target=machineId||proofMachine(order)?.id||order.machine?.id||myMachine()?.id||null;
|
||||
if(!target){
|
||||
target=await choosePullMachine(order);
|
||||
if(!target)return;
|
||||
}
|
||||
}
|
||||
const proofAt=proofMachine(order);
|
||||
if(proofAt&&target!==proofAt.id){
|
||||
say('O #'+order.number+' imprime na '+proofAt.name+', a máquina que imprimiu a prova #'+order.proof_card.number+'.');return;
|
||||
}
|
||||
const machine=(board.machines||[]).find(row=>row.id===target);
|
||||
// A lane drop, or a machine chosen before, may be one that does not print
|
||||
// this product (by its first item, as app/machines.py product_family): said
|
||||
|
||||
@@ -228,12 +228,14 @@ function freightWeight(fr){
|
||||
}
|
||||
// A download button: the arrow, then its label.
|
||||
function downloadButton(text,fn,className){const b=button(text,fn,className);b.prepend(svgIcon(IC.download,'i m'));return b;}
|
||||
async function api(path,body){
|
||||
async function api(path,body,options={}){
|
||||
// A fetch that never reached the server (no network) is marked offline.
|
||||
let r;
|
||||
try{r=await fetch('/api/operator'+path,{headers:{'Content-Type':'application/json'},...(body===undefined?{}:{method:'POST',body:JSON.stringify(body)})});}
|
||||
catch(e){e.offline=true;throw e;}
|
||||
const d=await r.json();
|
||||
// The network can also drop while the answer arrives (Sentry DTF-WEB-1E).
|
||||
let d;
|
||||
try{d=await r.json();}catch(e){if(e instanceof TypeError)e.offline=true;throw e;}
|
||||
if(!r.ok){
|
||||
// A validation error is a list: name its first field and what was wrong
|
||||
// instead of the bare status (Sentry DTF-WEB-E).
|
||||
@@ -242,7 +244,8 @@ async function api(path,body){
|
||||
const error=new Error(typeof d.detail==='string'?d.detail:
|
||||
'Confira os campos ('+r.status+')'+(first?': '+(field?field+', ':'')+first.msg:'.'));
|
||||
error.status=r.status;
|
||||
window.dtfObservability?.apiError?.(path,r.status,error.message,d.detail);
|
||||
// A status the caller expects and answers itself is not reported.
|
||||
if(!(options.expected||[]).includes(r.status))window.dtfObservability?.apiError?.(path,r.status,error.message,d.detail);
|
||||
throw error;
|
||||
}
|
||||
return d;
|
||||
@@ -403,6 +406,8 @@ function paintFolder(){
|
||||
$('badge-integrations').textContent=attention?'!':'';
|
||||
}
|
||||
async function chooseFolder(){
|
||||
// Safari and the phones have no folder picker (Sentry DTF-WEB-16).
|
||||
if(!('showDirectoryPicker' in window)){say('Este navegador não grava em pastas. Use o Chrome ou o Edge no computador da fábrica.');return;}
|
||||
let handle;
|
||||
try{handle=await window.showDirectoryPicker({id:'dtf-fila',mode:'readwrite'});}
|
||||
catch(e){if(e.name==='AbortError')return;throw e;}
|
||||
@@ -461,7 +466,13 @@ async function writeWhole(dir,name,source,watched=false){
|
||||
try{
|
||||
const out=await temp.createWritable();
|
||||
try{if(blob){await out.write(source);await out.close();}else await source.body.pipeTo(out);}
|
||||
catch(e){await out.abort().catch(()=>{});throw e;}
|
||||
catch(e){
|
||||
await out.abort().catch(()=>{});
|
||||
// A download the network cut halfway waits for the next pass, as one
|
||||
// that never started (Sentry DTF-WEB-17).
|
||||
if(!blob&&e instanceof TypeError)e.unreachable=true;
|
||||
throw e;
|
||||
}
|
||||
const size=(await temp.getFile()).size;
|
||||
if(!size||expected&&size!==expected)
|
||||
throw new IncompleteFile('O arquivo '+name+' chegou incompleto ('+fileSize(size)+(expected?' de '+fileSize(expected):'')+') e foi descartado.');
|
||||
|
||||
@@ -174,6 +174,16 @@ async function sel(fs){
|
||||
' GB.</b> Divida a folha em partes menores antes de enviar.';
|
||||
fs=fs.filter(f=>f.size<=max);
|
||||
}
|
||||
// A file of 0 bytes (a copy that failed, a cloud placeholder): said here,
|
||||
// never sent (Sentry DTF-WEB-1B).
|
||||
const vazios=fs.filter(f=>!f.size);
|
||||
if(vazios.length){
|
||||
const el=$('recusa');
|
||||
el.style.display='block';
|
||||
el.innerHTML='<b>'+escapeHTML(vazios.map(f=>f.name).join(', '))+(vazios.length>1?' estão vazios':' está vazio')+
|
||||
' (0 bytes).</b> Abra o arquivo no seu computador para conferir e escolha de novo.';
|
||||
fs=fs.filter(f=>f.size);
|
||||
}
|
||||
if(!fs.length) return;
|
||||
// On their way at once; a JPG is refused at the order anyway.
|
||||
fs.filter(f=>!/\.jpe?g$/i.test(f.name)).forEach(f=>window.dtfEnvio?.enviar(f));
|
||||
|
||||
Reference in New Issue
Block a user