feat: machines share the work by metres open, with an optional limit, their load on show and operators set from the machine
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 3m31s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Successful in 59s
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 3m31s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Successful in 59s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -466,6 +466,31 @@ a.zap{display:inline-flex;align-items:center;gap:4px;vertical-align:bottom}
|
||||
.danger-text{color:var(--bad)}
|
||||
.machine-select{height:36px;padding:0 10px;border-radius:8px;border:1px solid var(--line3);background:var(--bg);color:var(--tx);font:inherit;font-size:14px}
|
||||
.card .machine{color:var(--accent-tx)}
|
||||
.chip.over{border-color:var(--bad-line);color:var(--bad)}
|
||||
/* Chips that are checkboxes: products, machines, operators. */
|
||||
.pills{display:flex;flex-wrap:wrap;gap:8px}
|
||||
.pill{position:relative;display:inline-flex;align-items:center;height:34px;padding:0 12px;border-radius:8px;border:1px solid var(--line2);color:var(--muted);font-size:14px;font-weight:600;cursor:pointer;user-select:none}
|
||||
.pill input{position:absolute;opacity:0;width:1px;height:1px;margin:0}
|
||||
.pill:has(input:checked){border-color:var(--accent);background:rgba(255,139,43,.12);color:var(--accent-tx)}
|
||||
.pill:has(input:focus-visible){outline:2px solid var(--accent);outline-offset:2px}
|
||||
.unit{display:flex;align-items:center;gap:10px}
|
||||
.unit input{flex:1;min-width:0}
|
||||
.unit span{font-weight:500}
|
||||
/* Machines: one card each, with the metres open against its limit. */
|
||||
.mtiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(280px,100%),1fr));gap:12px}
|
||||
.mtile{display:flex;flex-direction:column;gap:8px;padding:16px 18px;border:1px solid var(--line2);border-radius:12px;background:var(--card)}
|
||||
.mtile.off{opacity:.6}
|
||||
.mtile-head{display:flex;align-items:center;gap:10px}
|
||||
.mtile-head b{font-size:15.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.mtile-head .integ-state{margin-left:auto}
|
||||
.mtile .meta{font-size:13.5px;color:var(--muted)}
|
||||
.mbar{height:8px;border-radius:999px;background:var(--line2);overflow:hidden;margin-top:4px}
|
||||
.mbar span{display:block;height:100%;border-radius:inherit;background:var(--ok)}
|
||||
.mbar.full span{background:var(--warn)}
|
||||
.mbar.over span{background:var(--bad)}
|
||||
.mload{display:flex;justify-content:space-between;gap:8px;font-size:13.5px;color:var(--tx2)}
|
||||
.mload.over{color:var(--bad);font-weight:600}
|
||||
.mtile-actions{display:flex;justify-content:flex-end;gap:6px;margin-top:4px}
|
||||
/* Fila de impressão's tools: Baixar. */
|
||||
.coltools{display:flex;gap:6px;flex-shrink:0}
|
||||
|
||||
|
||||
@@ -91,9 +91,8 @@
|
||||
Gestão: tudo, menos usuários. Operador: move pedidos e aprova arquivos. Vendedor: só consulta.</p>
|
||||
<section class="statbox"><table class="log"><thead><tr><th scope="col">Nome</th><th scope="col">Perfil</th><th scope="col">Máquinas</th><th scope="col">Último acesso</th><th scope="col"></th></tr></thead><tbody id="users-list"></tbody></table></section>
|
||||
<div class="pagehead"><h2>Máquinas</h2><button class="btn" id="new-machine" type="button">Nova máquina</button></div>
|
||||
<p class="faint stats-note">Cada pedido vai para a primeira máquina ativa que imprime o produto dele; no pedido dá para escolher outra.
|
||||
Um operador ligado a máquinas vê só os pedidos delas.</p>
|
||||
<section class="statbox"><table class="log"><thead><tr><th scope="col">Máquina</th><th scope="col">Produtos</th><th scope="col">Situação</th><th scope="col"></th></tr></thead><tbody id="machines-list"></tbody></table></section>
|
||||
<p class="faint stats-note">Cada pedido vai para a máquina do produto com menos metros em aberto, dentro do limite. No pedido dá para trocar.</p>
|
||||
<div class="mtiles" id="machines-list"></div>
|
||||
</section>
|
||||
<section id="tab-integrations" class="page" hidden>
|
||||
<h1>Integrações</h1>
|
||||
|
||||
@@ -557,6 +557,7 @@ function matchesFilter(order,key){
|
||||
if(key==='cancelados')return !!order.cancelled_at;
|
||||
if(order.cancelled_at)return false;
|
||||
const modes=order.snapshot.items.map(i=>i.mode);
|
||||
if(key.startsWith('m:'))return order.machine?.id===key.slice(2);
|
||||
if(key==='textil')return modes.some(m=>m==='file'||m==='avulsa');
|
||||
if(key==='uv')return modes.some(m=>m==='uvfile'||m==='uv');
|
||||
if(key==='entrega')return !!order.snapshot.destination;
|
||||
@@ -573,10 +574,16 @@ function renderBoard(){
|
||||
['parados','Parados'],['contato','Aguardando contato'],['manual','Preparar à mão'],['cancelados','Cancelados']];
|
||||
// Each chip says how many orders in progress it would show.
|
||||
const inProgress=board.orders.filter(o=>o.state!=='fin'&&!o.cancelled_at);
|
||||
// One chip per machine, when there is more than one to tell apart.
|
||||
const machineChips=(board.machines||[]).filter(m=>m.active||m.open_orders);
|
||||
if(machineChips.length>1)filters.splice(3,0,...machineChips.map(m=>['m:'+m.id,m.name]));
|
||||
if(!filters.some(([key])=>key===filter))filter='all';
|
||||
$('filters').replaceChildren(...filters.map(([key,label])=>{
|
||||
const b=node('button',label,'chip');b.type='button';b.setAttribute('aria-pressed',String(filter===key));
|
||||
b.append(node('span',String((key==='cancelados'?board.orders:inProgress).filter(o=>matchesFilter(o,key)).length),'chip-n'));
|
||||
if(key==='parados')b.title='Sem mudar de etapa há mais de '+LATE_HOURS+' h';
|
||||
if(key.startsWith('m:')){const m=board.machines.find(x=>'m:'+x.id===key);b.title=machineLoad(m);
|
||||
if(m.limit_metres&&m.open_metres>m.limit_metres)b.classList.add('over');}
|
||||
b.onclick=()=>{filter=key;renderBoard();};return b;}));
|
||||
const active=board.orders.filter(o=>['rec','tra','fil','imp'].includes(o.state));
|
||||
const queued=active.reduce((s,o)=>s+o.snapshot.items.reduce((t,i)=>t+Number(i.billed_metres),0),0);
|
||||
@@ -1076,16 +1083,31 @@ function machineCard(order){
|
||||
}
|
||||
const select=node('select',undefined,'machine-select');select.setAttribute('aria-label','Máquina do pedido');
|
||||
const auto=node('option','Automática'+(current&&!current.chosen?' ('+current.name+')':''));auto.value='';select.append(auto);
|
||||
for(const m of board.machines.filter(m=>m.active||m.id===current?.id)){
|
||||
const o=node('option',m.name);o.value=m.id;select.append(o);
|
||||
const family=order.snapshot.items.some(i=>i.mode==='uvfile'||i.mode==='uv')?'uv':'textil';
|
||||
for(const m of board.machines.filter(m=>m.active&&m.products.includes(family)||m.id===current?.id)){
|
||||
const o=node('option',m.name+' · '+machineLoad(m));o.value=m.id;select.append(o);
|
||||
}
|
||||
select.value=current?.chosen?current.id:'';
|
||||
select.onchange=async()=>{try{await api('/orders/'+order.id+'/machine',{machine_id:select.value||null});
|
||||
say(select.value?'Pedido enviado para '+select.selectedOptions[0].textContent+'.':'Máquina automática pelo produto.');await load();}
|
||||
catch(e){say(e.message,true);}};
|
||||
box.append(select,node('span',current?.chosen?'Escolhida para este pedido.':'Pelo produto do pedido.','faint'));
|
||||
box.append(select,node('span',current?.chosen?'Escolhida para este pedido.':current?'Escolhida automaticamente quando o pedido chegou.':'Nenhuma máquina imprime este produto.','faint'));
|
||||
return box;
|
||||
}
|
||||
// "120,00 m de 300,00 m" or "120,00 m em aberto".
|
||||
function machineLoad(m){
|
||||
return m.limit_metres?metres(m.open_metres)+' de '+metres(m.limit_metres):metres(m.open_metres)+' em aberto';
|
||||
}
|
||||
// Checkboxes drawn as chips; .values() is what is ticked.
|
||||
function pills(options,selected){
|
||||
const box=node('div',undefined,'pills');
|
||||
const inputs=options.map(([value,label])=>{const c=node('input');c.type='checkbox';c.value=value;c.checked=selected.includes(value);
|
||||
const pill=node('label',undefined,'pill');pill.append(c,node('span',label));box.append(pill);return c;});
|
||||
box.values=()=>inputs.filter(c=>c.checked).map(c=>c.value);
|
||||
return box;
|
||||
}
|
||||
// A dialog field that is a group (chips, a list) rather than one input.
|
||||
function group(label,...content){const g=node('div',undefined,'mfield');g.append(node('span',label),...content);return g;}
|
||||
const PRODUCT_LABEL={textil:'Têxtil',uv:'UV'};
|
||||
let usersData=null;
|
||||
async function loadUsers(){
|
||||
@@ -1109,15 +1131,31 @@ function renderUsers(){
|
||||
tr.append(who,node('td',ROLE_NAMES[u.role]+(u.active?'':' · desativado')),machinesTd,seen,actions);return tr;
|
||||
});
|
||||
$('users-list').replaceChildren(...rows);
|
||||
$('machines-list').replaceChildren(...(machines.length?machines.map(m=>{
|
||||
const tr=node('tr');if(!m.active)tr.classList.add('off');
|
||||
const actions=node('td',undefined,'actions');
|
||||
actions.append(button('Editar',()=>machineForm(m),'btn ghost small'),button('Excluir',async()=>{
|
||||
if(!window.confirm('Excluir a máquina '+m.name+'? Os pedidos dela voltam para a escolha automática.'))return;
|
||||
await api('/machines/'+m.id+'/delete',{});say('Máquina excluída.');await loadUsers();await load();},'btn ghost small danger-text'));
|
||||
tr.append(node('td',m.name),node('td',m.products.map(p=>PRODUCT_LABEL[p]).join(' e ')||'Nenhum produto'),
|
||||
node('td',m.active?'Ativa':'Desativada'),actions);return tr;
|
||||
}):[(()=>{const tr=node('tr');const td=node('td','Nenhuma máquina cadastrada. Sem máquinas, todos os pedidos aparecem para todos.','faint');td.colSpan=4;tr.append(td);return tr;})()]));
|
||||
$('machines-list').replaceChildren(...(machines.length?machines.map(machineTile)
|
||||
:[node('p','Nenhuma máquina cadastrada.','faint')]));
|
||||
}
|
||||
const OPEN_STAGES=['rec','tra','fil','imp','cor'];
|
||||
function machineTile(m){
|
||||
const tile=node('article',undefined,'mtile'+(m.active?'':' off'));
|
||||
const head=node('div',undefined,'mtile-head');
|
||||
const state=node('span',m.active?'Ativa':'Desativada','integ-state');state.style.setProperty('--c',m.active?'var(--ok)':'var(--faint)');
|
||||
head.append(node('b',m.name),state);
|
||||
const over=!!m.limit_metres&&m.open_metres>m.limit_metres;
|
||||
const full=!over&&!!m.limit_metres&&m.open_metres>=m.limit_metres;
|
||||
const bar=node('div',undefined,'mbar'+(over?' over':full?' full':''));const fill=node('span');
|
||||
fill.style.width=(m.limit_metres?Math.min(100,m.open_metres/m.limit_metres*100):0)+'%';bar.append(fill);
|
||||
const used=node('div',undefined,'mload'+(over?' over':''));
|
||||
used.append(node('span',machineLoad(m)),node('span',over?'acima do limite':full?'no limite':m.limit_metres?'':'sem limite'));
|
||||
const stages=OPEN_STAGES.filter(s=>m.states[s]).map(s=>(board?.states?.[s]||s)+' '+m.states[s]).join(' · ');
|
||||
const actions=node('div',undefined,'mtile-actions');
|
||||
actions.append(button('Editar',()=>machineForm(m),'btn ghost small'),button('Excluir',async()=>{
|
||||
if(!window.confirm('Excluir a máquina '+m.name+'? Os pedidos dela vão para outra máquina do produto.'))return;
|
||||
await api('/machines/'+m.id+'/delete',{});say('Máquina excluída.');await loadUsers();await load();},'btn ghost small danger-text'));
|
||||
tile.append(head,node('span',m.products.map(p=>PRODUCT_LABEL[p]).join(' e ')||'Nenhum produto','meta'),
|
||||
...(m.active||m.open_orders?[bar,used]:[]),
|
||||
node('span',stages||'Nenhum pedido em aberto','meta'),
|
||||
node('span',m.operators.length?'Operadores: '+m.operators.map(o=>o.name).join(', '):'Nenhum operador ligado','meta'),actions);
|
||||
return tile;
|
||||
}
|
||||
// One dialog for creating and editing, for users and machines alike.
|
||||
function dialog(title,fields,onsave){
|
||||
@@ -1143,15 +1181,13 @@ function userForm(u){
|
||||
pass.required=!editing;pass.placeholder=editing?'Deixe em branco para manter':'8 caracteres ou mais';
|
||||
const active=node('input');active.type='checkbox';active.checked=u?u.active:true;active.disabled=u?.email===ME.email;
|
||||
const activeLabel=node('label',undefined,'check');activeLabel.append(active,'Ativo (pode entrar no Kanban)');
|
||||
const boxes=usersData.machines.map(m=>{const c=node('input');c.type='checkbox';c.value=m.id;c.checked=!!u?.machines.includes(m.id);
|
||||
const l=node('label',undefined,'check');l.append(c,m.name);return l;});
|
||||
const machinesField=node('div',undefined,'mfield');
|
||||
machinesField.append('Máquinas (só para operadores; nenhuma = todas)',...(boxes.length?boxes:[node('span','Nenhuma máquina cadastrada.','faint')]));
|
||||
const syncMachines=()=>{machinesField.hidden=role.value!=='operador';};role.onchange=syncMachines;syncMachines();
|
||||
const picks=pills(usersData.machines.map(m=>[m.id,m.name]),u?.machines||[]);
|
||||
const machinesField=group('Máquinas',picks);
|
||||
const syncMachines=()=>{machinesField.hidden=role.value!=='operador'||!usersData.machines.length;};role.onchange=syncMachines;syncMachines();
|
||||
dialog(editing?'Editar usuário':'Novo usuário',[field('Nome',name),field('E-mail',email),field('Perfil',role),
|
||||
field(editing?'Nova senha':'Senha inicial',pass),machinesField,activeLabel],async()=>{
|
||||
const body={name:name.value,email:email.value,role:role.value==='superadmin'?'admin':role.value,active:active.checked,
|
||||
machines:role.value==='operador'?boxes.map(l=>l.querySelector('input')).filter(c=>c.checked).map(c=>c.value):[],
|
||||
machines:role.value==='operador'?picks.values():[],
|
||||
password:pass.value||null};
|
||||
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();
|
||||
@@ -1159,14 +1195,19 @@ function userForm(u){
|
||||
}
|
||||
function machineForm(m){
|
||||
const name=node('input');name.required=true;name.maxLength=60;name.value=m?.name||'';
|
||||
const prods=['textil','uv'].map(p=>{const c=node('input');c.type='checkbox';c.value=p;c.checked=!!m?.products.includes(p);
|
||||
const l=node('label',undefined,'check');l.append(c,'Imprime '+PRODUCT_LABEL[p]);return l;});
|
||||
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 unit=node('div',undefined,'unit');unit.append(limit,node('span','metros em aberto','faint'));
|
||||
const operators=usersData.users.filter(u=>u.role==='operador');
|
||||
const crew=pills(operators.map(u=>[u.id,u.name||u.email]),(m?.operators||[]).map(o=>o.id));
|
||||
const active=node('input');active.type='checkbox';active.checked=m?m.active:true;
|
||||
const activeLabel=node('label',undefined,'check');activeLabel.append(active,'Ativa (recebe pedidos)');
|
||||
const prodField=node('div',undefined,'mfield');prodField.append('Produtos',...prods);
|
||||
dialog(m?'Editar máquina':'Nova máquina',[field('Nome',name),prodField,activeLabel],async()=>{
|
||||
await api(m?'/machines/'+m.id:'/machines',{name:name.value,active:active.checked,
|
||||
products:prods.map(l=>l.querySelector('input')).filter(c=>c.checked).map(c=>c.value)});
|
||||
dialog(m?'Editar máquina':'Nova máquina',[field('Nome',name),group('Imprime',products),field('Limite',unit),
|
||||
group('Operadores',operators.length?crew:node('span','Nenhum operador cadastrado.','faint')),activeLabel],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,operators:crew.values()});
|
||||
say(m?'Máquina salva.':'Máquina criada.');await loadUsers();await load();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user