feat: Dropstar's corrections of 21/10 that need no answer from them
All checks were successful
Build and deploy / Validate source (push) Successful in 1m30s
Build and deploy / Integration suite on a real stack (push) Successful in 4m2s
Build and deploy / Secret scan and release gate (push) Successful in 14s
Build and deploy / Publish images (push) Successful in 1m48s
All checks were successful
Build and deploy / Validate source (push) Successful in 1m30s
Build and deploy / Integration suite on a real stack (push) Successful in 4m2s
Build and deploy / Secret scan and release gate (push) Successful in 14s
Build and deploy / Publish images (push) Successful in 1m48s
- the home example priced as the ready sheet it shows (nota 92, R$ 14,90) - opening hours 7h to 18h, and art sent at any time - uploads up to 1 GB, every file scanned - a Designer profile: artwork and corrections on every order, moving only among Arte recebida, Arte conferida and Correção - Números by date range, per machine, and orders apart from passages Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -36,10 +36,13 @@ let quoteQuery='', quoteProduct='', quoteLayout='', quoteFlag='', quoteTimer=nul
|
||||
// The signed-in operator and what their profile allows (app/core/auth.py).
|
||||
let ME=null;
|
||||
const may=cap=>!!ME?.can?.includes(cap);
|
||||
const ROLE_NAMES={superadmin:'Superadmin',admin:'Administrador',gestao:'Gestão',operador:'Operador',vendedor:'Vendedor'};
|
||||
const ROLE_NAMES={superadmin:'Superadmin',admin:'Administrador',gestao:'Gestão',designer:'Designer',operador:'Operador',vendedor:'Vendedor'};
|
||||
// The designer moves cards only among the artwork stages; the queue onwards is the print room's (app/core/auth.py).
|
||||
const DESIGNER_STATES=['rec','tra','cor'];
|
||||
const mayMove=(from,to)=>may('produce')&&(ME?.role!=='designer'||DESIGNER_STATES.includes(from)&&DESIGNER_STATES.includes(to));
|
||||
// Which tabs each capability opens.
|
||||
const TAB_NEEDS={quotes:o=>may('manage')||ME?.role==='vendedor',payments:()=>may('manage'),
|
||||
stats:()=>may('manage')||ME?.role==='vendedor',integrations:()=>may('manage')||may('produce'),users:()=>may('users')};
|
||||
stats:()=>may('manage')||ME?.role==='vendedor',integrations:()=>may('manage')||may('print'),users:()=>may('users')};
|
||||
function applyRole(){
|
||||
for(const b of document.querySelectorAll('[data-tab]')){const need=TAB_NEEDS[b.dataset.tab];b.hidden=!!need&&!need();}
|
||||
if(TAB_NEEDS[tab]&&!TAB_NEEDS[tab]())showTab('board');
|
||||
@@ -300,7 +303,7 @@ function folderCount(){
|
||||
// The folder's row and the tab's warning sign, which shows the folder needs a click.
|
||||
function paintFolder(){
|
||||
$('folder-card')?.replaceWith(folderCard());
|
||||
const attention=may('produce')&&(FOLDER.mode==='folder'&&!!FOLDER.handle&&!FOLDER.granted||folderActive()&&!!FOLDER.error);
|
||||
const attention=may('print')&&(FOLDER.mode==='folder'&&!!FOLDER.handle&&!FOLDER.granted||folderActive()&&!!FOLDER.error);
|
||||
$('badge-integrations').textContent=attention?'!':'';
|
||||
}
|
||||
async function chooseFolder(){
|
||||
@@ -373,7 +376,7 @@ async function moveToQueue(rec){
|
||||
// board load it asks only when something it follows changed; the folder's
|
||||
// own timer always asks, since another computer may have moved the order.
|
||||
async function syncFolder(force=false){
|
||||
if(!folderActive()||FOLDER.busy||!board||!may('produce'))return;
|
||||
if(!folderActive()||FOLDER.busy||!board||!may('print'))return;
|
||||
const follows=early()?['rec','tra','cor','fil']:['fil'];
|
||||
const sig=FOLDER.when+'|'+board.orders.filter(o=>follows.includes(o.state)||o.cancelled_at)
|
||||
.map(o=>o.id+':'+o.version+':'+o.state+(o.cancelled_at?':x':'')).join(',');
|
||||
@@ -600,7 +603,7 @@ function renderBoard(){
|
||||
const count=state==='fin'&&board.finished_total>orders.length?orders.length+' de '+board.finished_total:String(orders.length);
|
||||
line.append(swatch,node('h2',title),node('span',count,'n'));
|
||||
// The print queue's tools need the room: there it says only the metres.
|
||||
const tools=state==='fil'&&may('produce');
|
||||
const tools=state==='fil'&&may('print');
|
||||
const sub=node('div',undefined,'col-sub');sub.append(node('small',orders.length?metres(total)+(tools?'':' no total'):'vazio'));
|
||||
// The print queue's files, all at once, to import into FlexiPRINT.
|
||||
if(tools){
|
||||
@@ -615,7 +618,7 @@ function renderBoard(){
|
||||
// Dragging only goes forward to the next stage. Going back or asking for a
|
||||
// correction needs a reason, so those happen in the order panel.
|
||||
column.ondragover=e=>{
|
||||
if(dragging?.state===state&&state!=='fin'){e.preventDefault();markDrop(column,e.clientY);return;}
|
||||
if(dragging?.state===state&&state!=='fin'&&mayMove(state,state)){e.preventDefault();markDrop(column,e.clientY);return;}
|
||||
if(!column.classList.contains('allowed'))return;e.preventDefault();column.classList.add('target');};
|
||||
column.ondragleave=e=>{if(!column.contains(e.relatedTarget)){column.classList.remove('target');clearDrop();}};
|
||||
column.ondrop=async e=>{e.preventDefault();column.classList.remove('target');
|
||||
@@ -632,7 +635,7 @@ function renderBoard(){
|
||||
// An operator's test order: no payment, no Tiny.
|
||||
const isTest=order=>order.payment?.provider==='teste';
|
||||
function card(order){
|
||||
const c=node('button',undefined,'card');c.type='button';c.dataset.card=order.id;c.draggable=!order.cancelled_at&&may('produce');
|
||||
const c=node('button',undefined,'card');c.type='button';c.dataset.card=order.id;c.draggable=!order.cancelled_at&&mayMove(order.state,order.state);
|
||||
if(order.id===openOrder)c.classList.add('open');
|
||||
const s=order.snapshot;
|
||||
const top=node('div',undefined,'row');
|
||||
@@ -657,7 +660,7 @@ function card(order){
|
||||
c.ondragstart=e=>{
|
||||
dragging=order;
|
||||
e.dataTransfer.setData('text/plain',order.id);
|
||||
const forward=board.transitions[order.state].filter(s=>s!=='cor');
|
||||
const forward=board.transitions[order.state].filter(s=>s!=='cor'&&mayMove(order.state,s));
|
||||
for(const col of document.querySelectorAll('.col[data-state]'))col.classList.toggle('allowed',forward.includes(col.dataset.state));
|
||||
say((forward.length?'Mover para '+forward.map(s=>board.states[s]).join(' ou ')+', ou ':'')+'arraste para cima ou para baixo para mudar a prioridade',false,60000);
|
||||
};
|
||||
@@ -806,6 +809,7 @@ function moves(order){
|
||||
let step=null;
|
||||
for(const next of board.transitions[order.state]){
|
||||
if(next==='cor'){
|
||||
if(!mayMove(order.state,next))continue;
|
||||
const b=node('button','Pedir correção','btn danger');b.type='button';b.dataset.move='cor';
|
||||
b.onclick=()=>toggle(reason);row.append(b);
|
||||
}else if(next==='fil'&&!finalDone(order)){
|
||||
@@ -832,13 +836,13 @@ function moves(order){
|
||||
upload.append(cancel);sync=()=>{actions.hidden=!upload.hidden;};
|
||||
text.append(actions,upload);
|
||||
step=node('div',undefined,'nextstep lead');step.append(node('span','!','nextmark'),text);
|
||||
}else{
|
||||
}else if(mayMove(order.state,next)){
|
||||
const b=button('Mover para '+board.states[next],()=>move(order,next),'btn primary');b.dataset.move=next;row.append(b);
|
||||
}
|
||||
}
|
||||
if(!row.children.length)row.append(node('span','Pedido concluído.','muted'));
|
||||
if(!row.children.length)row.append(node('span',order.state==='fin'?'Pedido concluído.':'Daqui em diante, com a produção.','muted'));
|
||||
// Undo a mistaken move: one stage back, internal reason, no customer message.
|
||||
const previous=board.back?.[order.state];
|
||||
const previous=mayMove(order.state,board.back?.[order.state])?board.back?.[order.state]:null;
|
||||
const sub=node('div',undefined,'subactions');
|
||||
const backForm=node('form',undefined,'reason');backForm.hidden=true;forms.push(backForm);
|
||||
if(previous){
|
||||
@@ -949,7 +953,7 @@ async function approveReady(order,ready){
|
||||
ready.map((r,i)=>(many?'Item '+(i+1)+': ':'')+r.label).join('\n')))return;
|
||||
const note='Aprovado como está: '+[...new Set(ready.map(r=>FINAL_SOURCE[r.source]))].join(', ');
|
||||
await api('/orders/'+order.id+'/final-files',{version:order.version,files:ready.map((r,i)=>({item_index:i,upload_id:r.upload_id})),note});
|
||||
await load();say('Arquivo final aprovado. Agora é só mover para a fila.');
|
||||
await load();say(mayMove(order.state,'fil')?'Arquivo final aprovado. Agora é só mover para a fila.':'Arquivo final aprovado. A produção coloca na fila.');
|
||||
}
|
||||
// The form for a file the operator prepared, or to pick per item; ready
|
||||
// files come ticked.
|
||||
@@ -1078,7 +1082,7 @@ function historySection(order,rows,section){
|
||||
function machineCard(order){
|
||||
const box=node('div',undefined,'fcard');box.append(node('p','Máquina','eyebrow'));
|
||||
const current=order.machine;
|
||||
if(!may('produce')||!board.machines?.length){
|
||||
if(!may('print')||!board.machines?.length){
|
||||
box.append(node('b',current?current.name:'Nenhuma máquina cadastrada'));return box;
|
||||
}
|
||||
const select=node('select',undefined,'machine-select');select.setAttribute('aria-label','Máquina do pedido');
|
||||
@@ -1174,7 +1178,7 @@ function userForm(u){
|
||||
const name=node('input');name.required=true;name.maxLength=80;name.value=u?.name||'';
|
||||
const email=node('input');email.type='email';email.required=true;email.value=u?.email||'';
|
||||
const role=node('select');
|
||||
const roles=u?.role==='superadmin'?['superadmin']:['admin','gestao','operador','vendedor'];
|
||||
const roles=u?.role==='superadmin'?['superadmin']:['admin','gestao','designer','operador','vendedor'];
|
||||
for(const r of roles){const o=node('option',ROLE_NAMES[r]);o.value=r;role.append(o);}
|
||||
role.value=u?.role||'operador';role.disabled=u?.role==='superadmin'||u?.email===ME.email;
|
||||
const pass=node('input');pass.type='password';pass.minLength=8;pass.maxLength=128;pass.autocomplete='new-password';
|
||||
@@ -1228,18 +1232,36 @@ $('new-machine').onclick=()=>machineForm(null);
|
||||
|
||||
// ---- Numbers -------------------------------------------------------------
|
||||
|
||||
let statsDays=30;
|
||||
// The period: the last 7, 30 or 90 days, or two dates the person picks.
|
||||
let statsDays=30, statsRange=null;
|
||||
function duration(hours){
|
||||
if(hours===null||hours===undefined)return '—';
|
||||
if(hours<1)return Math.max(1,Math.round(hours*60))+' min';
|
||||
if(hours<48)return (hours<10?hours.toFixed(1):Math.round(hours).toString()).replace('.',',')+' h';
|
||||
return Math.round(hours/24)+' dias';
|
||||
}
|
||||
const dayLabel=iso=>new Date(iso+'T12:00:00').toLocaleDateString('pt-BR',{day:'2-digit',month:'2-digit',year:'numeric'});
|
||||
function statsPeriod(){
|
||||
const box=$('stats-period');
|
||||
const chips=[[7,'7 dias'],[30,'30 dias'],[90,'90 dias']].map(([days,label])=>{
|
||||
const b=node('button',label,'chip');b.type='button';b.setAttribute('aria-pressed',String(!statsRange&&days===statsDays));
|
||||
b.onclick=()=>{statsDays=days;statsRange=null;loadStats().catch(e=>say(e.message,true));};return b;});
|
||||
const from=node('input');from.type='date';from.setAttribute('aria-label','De');
|
||||
const to=node('input');to.type='date';to.setAttribute('aria-label','Até');
|
||||
const today=new Date(Date.now()-3*3600e3).toISOString().slice(0,10);
|
||||
from.max=to.max=today;
|
||||
if(statsRange){from.value=statsRange.start;to.value=statsRange.end;}
|
||||
const apply=button('Ver',()=>{
|
||||
if(!from.value||!to.value)return say('Escolha a data inicial e a final.',true);
|
||||
if(from.value>to.value)return say('A data inicial é depois da final.',true);
|
||||
statsRange={start:from.value,end:to.value};loadStats().catch(e=>say(e.message,true));},'btn small');
|
||||
const range=node('div',undefined,'daterange');range.append(from,node('span','até','faint'),to,apply);
|
||||
box.replaceChildren(...chips,range);
|
||||
}
|
||||
async function loadStats(){
|
||||
const data=await api('/stats?days='+statsDays);
|
||||
$('stats-period').replaceChildren(...[[7,'7 dias'],[30,'30 dias'],[90,'90 dias']].map(([days,label])=>{
|
||||
const b=node('button',label,'chip');b.type='button';b.setAttribute('aria-pressed',String(days===statsDays));
|
||||
b.onclick=()=>{statsDays=days;loadStats().catch(e=>say(e.message,true));};return b;}));
|
||||
const data=await api('/stats?'+(statsRange?'start='+statsRange.start+'&end='+statsRange.end:'days='+statsDays));
|
||||
statsPeriod();
|
||||
$('stats-note').textContent='Pedidos pagos de '+dayLabel(data.start)+' a '+dayLabel(data.end)+'. Pedidos de teste e cancelados ficam de fora.';
|
||||
const kpi=(label,value,note)=>{const k=node('div',undefined,'kpi');k.append(node('span',label),node('b',value));if(note)k.append(node('small',note));return k;};
|
||||
const pct=data.orders?Math.round(100*data.corrected/data.orders):0;
|
||||
$('stats-kpis').replaceChildren(
|
||||
@@ -1250,11 +1272,24 @@ async function loadStats(){
|
||||
kpi('Pedidos com correção',String(data.corrected),data.orders?pct+'% dos pedidos':null),
|
||||
kpi('Do pagamento ao Finalizado',duration(data.lead.median_hours),data.lead.orders?'mediana de '+data.lead.orders+' pedidos':'nenhum finalizado'));
|
||||
statsChart($('stats-chart'),data.daily);
|
||||
const machineRows=data.machines.map(m=>{
|
||||
const tr=node('tr');if(!m.active)tr.classList.add('off');
|
||||
const now=[m.now.imp?m.now.imp+' imprimindo':'',m.now.fil?m.now.fil+' na fila':''].filter(Boolean).join(' · ');
|
||||
tr.append(node('td',m.name+(m.active?'':' · desativada')),
|
||||
node('td',m.orders?metres(m.metres)+' · '+m.orders+(m.orders>1?' pedidos':' pedido'):'nada'),
|
||||
node('td',m.metres_per_hour!=null?String(m.metres_per_hour).replace('.',',')+' m/h':'—'),
|
||||
node('td',m.last_finished?when(m.last_finished):'nunca','faint'),
|
||||
node('td',m.id?now||'nada na fila':'—'));
|
||||
return tr;});
|
||||
if(!machineRows.length){const tr=node('tr');const td=node('td','Nenhuma máquina cadastrada.','faint');td.colSpan=5;tr.append(td);machineRows.push(tr);}
|
||||
$('stats-machines').replaceChildren(...machineRows);
|
||||
const rows=['rec','tra','fil','imp','cor'].map(state=>{
|
||||
const tr=node('tr'),name=node('td'),sw=node('span',undefined,'swatch');sw.style.setProperty('--c',STAGE_COLORS[state]);
|
||||
name.append(sw,board.states[state]);
|
||||
const st=data.stages[state], now=data.waiting[state];
|
||||
tr.append(name,node('td',st?duration(st.median_hours):'—'),node('td',st?String(st.orders):'0'),
|
||||
// Orders; when some came back to the stage, how many times it was entered.
|
||||
const passed=st?String(st.orders)+(st.passages>st.orders?' · '+st.passages+' passagens':''):'0';
|
||||
tr.append(name,node('td',st?duration(st.median_hours):'—'),node('td',passed),
|
||||
node('td',now?now.orders+(now.orders>1?' pedidos':' pedido')+' · o mais antigo há '+duration(now.oldest_hours):'nenhum'));
|
||||
return tr;});
|
||||
$('stats-stages').replaceChildren(...rows);
|
||||
@@ -1267,7 +1302,7 @@ function statsChart(box,daily){
|
||||
const step=max<=0?1:(()=>{const raw=max/4, p=10**Math.floor(Math.log10(raw)), f=raw/p;return (f<=1?1:f<=2?2:f<=5?5:10)*p;})();
|
||||
const ceiling=step*Math.max(1,Math.ceil(max/step));
|
||||
const svg=document.createElementNS(ns,'svg');svg.setAttribute('viewBox','0 0 '+w+' '+h);svg.setAttribute('role','img');
|
||||
svg.setAttribute('aria-label','Metros vendidos por dia nos últimos '+daily.length+' dias');
|
||||
svg.setAttribute('aria-label','Metros vendidos por dia, '+daily.length+' dias');
|
||||
const el=(tag,attrs)=>{const e=document.createElementNS(ns,tag);for(const [k,v] of Object.entries(attrs))e.setAttribute(k,v);return e;};
|
||||
const y=v=>top+(h-top-bottom)*(1-v/ceiling);
|
||||
for(let v=0;v<=ceiling+1e-9;v+=step){
|
||||
@@ -1673,7 +1708,7 @@ const eventsIfAllowed=async()=>{if(may('integrations'))await loadEvents();};
|
||||
const integRow=o=>may('integrations')?integration(o):integration({name:o.name,state:o.state,tone:o.tone,summary:o.summary});
|
||||
let mpCheck=null;
|
||||
function renderIntegrations(){
|
||||
const t=board.tiny||{};const rows=may('produce')?[folderCard()]:[];
|
||||
const t=board.tiny||{};const rows=may('print')?[folderCard()]:[];
|
||||
$('event-log').hidden=!may('integrations');
|
||||
if(!may('manage')){$('integrations').replaceChildren(...rows);return;}
|
||||
const act=(text,fn)=>button(text,fn,'btn small');
|
||||
|
||||
Reference in New Issue
Block a user