fix: Integrações is a tidy list, with the long text under "Detalhes"
All checks were successful
Build and deploy / Validate source (push) Successful in 8s
Build and deploy / Integration suite on a real stack (push) Successful in 2m43s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Successful in 1m2s

The page was a grid of cards stuffed with paragraphs (Tiny's dates, the
freight's box and cubage, the Firefox how-to), so the cards had uneven
heights and left gaps. Each integration is now one row: name, state, one
line of summary and its main button. Everything else (dates, numbers,
how-tos, secondary buttons like Reconectar or Trocar pasta) opens under
"Detalhes", below its own row, without moving the others around; what is
open stays open through the automatic refresh. Mercado Pago's "Verificar
conta" now shows its result there instead of a 60-second message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-09 11:44:52 -03:00
parent 58ce0a4166
commit 86507ed7b5
3 changed files with 150 additions and 89 deletions

View File

@@ -249,21 +249,40 @@ main{padding:0 24px 24px}
.charttable summary{cursor:pointer}
.charttable table{margin-top:8px}
#stats-stages .swatch{display:inline-block;width:10px;height:10px;border-radius:3px;background:var(--c);margin-right:8px}
.grid4{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:12px}
.integration{display:flex;flex-direction:column;gap:10px;padding:16px;border-radius:12px;border:1px solid var(--line2);background:var(--card)}
.integration .head{display:flex;align-items:center;gap:8px}
.integration .head b{font-size:15px}
.integration .head .dot{width:9px;height:9px;border-radius:999px;background:var(--dot,#5B6168)}
.integration .head em{margin-left:auto;font-style:normal;font-size:13.5px;font-weight:700;color:var(--dotx,var(--muted))}
.integration p{margin:0;font-size:14px;color:var(--muted)}
.integration .buttons{margin-top:auto}
.integration code.flag{font-size:13px;padding:6px 8px;border-radius:8px;background:var(--card2);color:var(--tx2);user-select:all;overflow-wrap:anywhere}
/* Integrações: one row per service; long text opens under "Detalhes". */
.integ-list{border:1px solid var(--line2);border-radius:12px;background:var(--card);overflow:hidden}
.integ+.integ{border-top:1px solid var(--line)}
.integ-main{display:grid;grid-template-columns:minmax(170px,230px) 150px minmax(0,1fr) auto 104px;align-items:center;gap:16px;padding:12px 16px 12px 18px;min-height:58px}
.integ-name{display:flex;align-items:center;gap:10px;min-width:0}
.integ-name b{font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.integ-name .dot{width:8px;height:8px;border-radius:999px;background:var(--c);flex-shrink:0}
.integ-state{justify-self:start;font-size:12.5px;font-weight:700;padding:3px 10px;border-radius:999px;color:var(--c);background:color-mix(in srgb,var(--c) 13%,transparent);white-space:nowrap}
.integ-summary{color:var(--muted);font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
.integ-actions{display:flex;gap:8px;justify-content:flex-end;align-items:center}
.integ-toggle{display:flex;justify-content:flex-end}
.integ-more{display:inline-flex;align-items:center;gap:6px}
.integ-more svg{transition:transform .15s}
.integ-more[aria-expanded=true]{color:var(--tx)}
.integ-more[aria-expanded=true] svg{transform:rotate(180deg)}
.integ-details{margin:0 16px 14px 36px;padding:14px 16px;border-radius:10px;background:var(--panel);border:1px solid var(--line);display:flex;flex-direction:column;gap:10px;font-size:14px;color:var(--tx2)}
.integ-details p{margin:0;color:var(--muted)}
.integ-details dl{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 24px;margin:0}
.integ-details dt{color:var(--faint)}
.integ-details dd{margin:0;overflow-wrap:anywhere}
.integ-steps{margin:0;padding-left:20px;display:flex;flex-direction:column;gap:6px}
.integ-details code.flag{font-size:13px;padding:2px 6px;border-radius:6px;background:var(--card2);color:var(--tx);user-select:all;overflow-wrap:anywhere}
table.log{width:100%;border-collapse:collapse;font-size:14px}
table.log th{text-align:left;color:var(--faint);font-weight:600;padding:8px 12px;border-bottom:1px solid var(--line)}
table.log td{padding:10px 12px;border-bottom:1px solid #1E2226;vertical-align:top}
.good{color:var(--ok);font-weight:600}.retry{color:var(--warn);font-weight:600}
@media (max-width:900px){
.integ-main{grid-template-columns:minmax(0,1fr) auto;gap:8px 12px}
.integ-name b{white-space:normal}
.integ-summary{grid-column:1/-1;white-space:normal}
.integ-actions{justify-content:flex-start;flex-wrap:wrap}
.integ-toggle:empty{display:none}
.integ-details{margin-left:16px}
.top{flex-wrap:wrap;height:auto;padding:10px 16px;gap:10px}
.searchbox{order:5;width:100%;flex-basis:100%;margin-left:0}
.search{width:100%}

View File

@@ -97,7 +97,7 @@
</section>
<section id="tab-integrations" class="page" hidden>
<h1>Integrações</h1>
<section><div class="grid4" id="integrations"></div></section>
<section><div class="integ-list" id="integrations"></div></section>
<section id="event-log"><h2>Registro de envios</h2>
<div class="filters" id="event-filters"></div>
<table class="log"><thead><tr><th scope="col">Quando</th><th scope="col">Pedido</th><th scope="col">Destino</th><th scope="col">Evento</th><th scope="col">Resultado</th></tr></thead><tbody id="events"></tbody></table>

View File

@@ -224,49 +224,57 @@ async function restoreFolder(){
if(!FOLDER.granted)setTimeout(()=>say('Para voltar a salvar os arquivos da fila na pasta, abra Integrações e clique em “Liberar pasta”.',false,10000),2500);}}
catch{FOLDER.handle=null;}
}
// The card in Integrações, redrawn whenever the folder's state changes.
// The folder's row in Integrações, redrawn whenever its state changes. The
// row says what is happening; the how-to and the secondary buttons are under
// "Detalhes".
function folderCard(){
const name='Pasta da Fila de impressão', h=FOLDER.handle;
const primary=(text,fn)=>button(text,fn,'btn');
const ghost=(text,fn)=>button(text,fn,'btn ghost');
let card;
const act=(text,fn)=>button(text,fn,'btn small');
const ghost=(text,fn)=>button(text,fn,'btn ghost small');
const steps=(...lines)=>{const ol=node('ol',undefined,'integ-steps');for(const l of lines)ol.append(l instanceof Node?l:node('li',l));return ol;};
let row;
if(FOLDER.mode==='none'){
card=FOLDER.brave
? integration(name,'Desligada no Brave','warn','O Brave vem com o acesso a pastas desligado. Copie o endereço abaixo, cole na barra do Brave, '+
'mude “File System Access API” para “Enabled” e reinicie o Brave. Ou abra o Kanban no Chrome ou no Edge.',
[ghost('Copiar endereço',async()=>{await navigator.clipboard.writeText(BRAVE_FLAG);say('Endereço copiado: cole na barra do Brave.');})])
: integration(name,'Não funciona aqui','off','Este navegador não salva arquivos numa pasta. Abra o Kanban no Chrome ou no Edge. '+
'Aqui, use “Baixar” na Fila de impressão.');
if(FOLDER.brave)card.querySelector('p').after(node('code',BRAVE_FLAG,'flag'));
if(FOLDER.brave){
const first=node('li','Copie este endereço: ');first.append(node('code',BRAVE_FLAG,'flag'));
row=integration({name,state:'Desligada no Brave',tone:'warn',summary:'O Brave bloqueia o acesso a pastas. Dá para liberar em 1 minuto.',
actions:[act('Copiar endereço',async()=>{await navigator.clipboard.writeText(BRAVE_FLAG);say('Endereço copiado: cole na barra do Brave.');})],
details:[steps(first,'Cole na barra do Brave e mude “File System Access API” para “Enabled”.','Reinicie o Brave e volte aqui.'),
node('p','Ou abra o Kanban no Chrome ou no Edge, que já vêm com isso ligado.')]});
}else row=integration({name,state:'Não funciona aqui',tone:'off',summary:'Abra o Kanban no Chrome ou no Edge para salvar numa pasta.'});
}else if(FOLDER.mode==='downloads'){
card=FOLDER.downloads
? integration(name,FOLDER.error?'Verificar':'Ligada',FOLDER.error?'warn':'ok',FOLDER.error||FOLDER.status||
'Os arquivos que entram na Fila de impressão são baixados sozinhos na pasta de downloads do Firefox. '+folderCount(),
[ghost('Desligar',()=>setDownloads(false))])
: integration(name,'Desligada','off','No Firefox, os arquivos vão para a pasta de downloads. Em Configurações → Geral → Arquivos e aplicativos, '+
'escolha em “Salvar arquivos em” a pasta do FlexiPRINT e desmarque “Sempre perguntar onde salvar arquivos”. '+
'Use um perfil do Firefox só para o Kanban: os outros downloads também vão para lá.',
[primary('Ligar download automático',()=>setDownloads(true))]);
const how=[steps('No Firefox, abra Configurações → Geral → Arquivos e aplicativos.',
'Em “Salvar arquivos em”, escolha a pasta que o FlexiPRINT lê.','Desmarque “Sempre perguntar onde salvar arquivos”.'),
node('p','Use um perfil do Firefox só para o Kanban: os outros downloads também vão para essa pasta.')];
row=FOLDER.downloads
? integration({name,state:FOLDER.error?'Verificar':'Ligada',tone:FOLDER.error?'warn':'ok',
summary:FOLDER.error||FOLDER.status||'Baixando na pasta de downloads do Firefox · '+folderCount(),
details:how,extra:[ghost('Desligar',()=>setDownloads(false))]})
: integration({name,state:'Desligada',tone:'off',summary:'Baixa sozinho, no Firefox, os arquivos que entram na fila.',
actions:[act('Ligar',()=>setDownloads(true))],details:how});
}else if(!h){
card=integration(name,'Desligada','off','Escolha a pasta que o FlexiPRINT lê, ou a pasta da rede do servidor. Cada pedido que entra na '+
'Fila de impressão tem os arquivos finais salvos lá sozinhos, com o número do pedido no nome. Vale para este computador, com o Kanban aberto.',
[primary('Escolher pasta',chooseFolder)]);
row=integration({name,state:'Desligada',tone:'off',summary:'Salva sozinho, numa pasta, os arquivos que entram na fila.',
actions:[act('Escolher pasta',chooseFolder)],
details:[node('p','Escolha a pasta que o FlexiPRINT lê, ou a pasta da rede do servidor. Os arquivos levam o número do pedido no nome. '+
'Funciona neste computador, com o Kanban aberto.')]});
}else if(!FOLDER.granted){
card=integration(name,'Liberar','warn','O navegador foi reaberto e pede um clique para voltar a salvar em “'+h.name+'”.',
[primary('Liberar pasta',releaseFolder),ghost('Trocar pasta',chooseFolder),ghost('Desligar',forgetFolder)]);
row=integration({name,state:'Liberar',tone:'warn',summary:'O navegador pede um clique para voltar a salvar em “'+h.name+'”.',
actions:[act('Liberar pasta',releaseFolder)],extra:[ghost('Trocar pasta',chooseFolder),ghost('Desligar',forgetFolder)]});
}else{
card=integration(name,FOLDER.error?'Verificar':'Ligada',FOLDER.error?'warn':'ok',FOLDER.error||FOLDER.status||
'Os arquivos que entram na Fila de impressão são salvos em “'+h.name+'”. '+folderCount()+' Deixe o Kanban aberto neste computador.',
[ghost('Trocar pasta',chooseFolder),ghost('Desligar',forgetFolder)]);
row=integration({name,state:FOLDER.error?'Verificar':'Ligada',tone:FOLDER.error?'warn':'ok',
summary:FOLDER.error||FOLDER.status||'Salvando em “'+h.name+'” · '+folderCount(),
details:[['Pasta','“'+h.name+'”'],['Arquivos salvos',String(FOLDER.saved.size)],
['Último',FOLDER.last?FOLDER.last.toLocaleTimeString('pt-BR',{hour:'2-digit',minute:'2-digit'}):'—'],
node('p','Deixe o Kanban aberto neste computador. Um arquivo que o FlexiPRINT tirar da pasta não é baixado de novo.')],
extra:[ghost('Trocar pasta',chooseFolder),ghost('Desligar',forgetFolder)]});
}
card.id='folder-card';return card;
row.id='folder-card';return row;
}
function folderCount(){
const n=FOLDER.saved.size;
return (n?n+(n>1?' arquivos salvos':' arquivo salvo')+' neste computador':'Nenhum arquivo salvo ainda')+
(FOLDER.last?', o último às '+FOLDER.last.toLocaleTimeString('pt-BR',{hour:'2-digit',minute:'2-digit'}):'')+'.';
return (n?n+(n>1?' arquivos salvos':' arquivo salvo'):'nenhum arquivo salvo ainda')+
(FOLDER.last?', o último às '+FOLDER.last.toLocaleTimeString('pt-BR',{hour:'2-digit',minute:'2-digit'}):'');
}
// The card and the tab's warning sign, which shows the folder needs a click.
// 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);
@@ -1346,14 +1354,37 @@ function tinyDetail(t){
const problem=TINY_PROBLEMS[t.problem];
return (problem?problem+(t.failed_at&&t.problem!=='expired'?' (falha em '+when(t.failed_at)+')':'')+' · ':'')+parts.join(' · ');
}
function integration(name,state,tone,text,actions=[]){
const box=node('div',undefined,'integration');
const head=node('div',undefined,'head');const dot=node('span',undefined,'dot');
const colors={ok:['var(--fin)','var(--ok)'],warn:['var(--warn)','var(--warn)'],off:['#5B6168','var(--muted)']}[tone];
dot.style.setProperty('--dot',colors[0]);const em=node('em',state);em.style.setProperty('--dotx',colors[1]);
head.append(dot,node('b',name),em);box.append(head,node('p',text));
if(actions.length){const b=node('div',undefined,'buttons');b.append(...actions);box.append(b);}
return box;
// One row of Integrações: name, state, one line of summary and the main
// button. Anything longer (how-tos, dates, numbers, secondary buttons) opens
// under "Detalhes", so every row keeps the same height. Which rows are open
// survives the page's automatic refresh.
const OPEN_INTEG=new Set();
const TONES={ok:'var(--ok)',warn:'var(--warn)',off:'var(--faint)'};
function integration({name,state,tone,summary,actions=[],details=[],extra=[]}){
const row=node('div',undefined,'integ');row.dataset.integ=name;
const main=node('div',undefined,'integ-main');main.style.setProperty('--c',TONES[tone]);
const title=node('div',undefined,'integ-name');title.append(node('span',undefined,'dot'),node('b',name));
const text=node('span',summary,'integ-summary');text.title=summary;
const buttons=node('div',undefined,'integ-actions');buttons.append(...actions);
// "Detalhes" has a column of its own, so the main buttons line up.
const more=node('div',undefined,'integ-toggle');
main.append(title,node('span',state,'integ-state'),text,buttons,more);row.append(main);
if(!details.length&&!extra.length)return row;
const panel=node('div',undefined,'integ-details');panel.id='integ-'+name.replace(/\W+/g,'-').toLowerCase();
const list=node('dl');
for(const part of details){
if(Array.isArray(part)){list.append(node('dt',part[0]),node('dd',part[1]));continue;}
if(list.children.length){panel.append(list.cloneNode(true));list.replaceChildren();}
panel.append(part);
}
if(list.children.length)panel.append(list);
if(extra.length){const b=node('div',undefined,'buttons');b.append(...extra);panel.append(b);}
const open=OPEN_INTEG.has(name);panel.hidden=!open;
const toggle=node('button','Detalhes','btn ghost small integ-more');toggle.type='button';
toggle.append(icon(['M6 9l6 6 6-6']));toggle.setAttribute('aria-expanded',String(open));toggle.setAttribute('aria-controls',panel.id);
toggle.onclick=()=>{const now=panel.hidden;panel.hidden=!now;toggle.setAttribute('aria-expanded',String(now));
if(now)OPEN_INTEG.add(name);else OPEN_INTEG.delete(name);};
more.append(toggle);row.append(panel);return row;
}
// The page bar under every list: page size, range, first/previous/page/next/last.
const PAGE_SIZES=[10,20,50,100];
@@ -1489,56 +1520,67 @@ function renderEvents(){
// An operator opens Integrações only for the print room's folder.
const eventsIfAllowed=async()=>{if(may('manage'))await loadEvents();};
let mpCheck=null;
function renderIntegrations(){
const t=board.tiny||{};const cards=may('produce')?[folderCard()]:[];
const t=board.tiny||{};const rows=may('produce')?[folderCard()]:[];
$('event-log').hidden=!may('manage');
if(!may('manage')){$('integrations').replaceChildren(...cards);return;}
if(!t.configured)cards.push(integration('Tiny','Não configurado','off','Credenciais ausentes no servidor.'));
if(!may('manage')){$('integrations').replaceChildren(...rows);return;}
const act=(text,fn)=>button(text,fn,'btn small');
const ghost=(text,fn)=>button(text,fn,'btn ghost small');
if(!t.configured)rows.push(integration({name:'Tiny',state:'Não configurado',tone:'off',summary:'Credenciais ausentes no servidor.'}));
else{
const connect=button(t.connected?'Reconectar':'Conectar Tiny',async()=>{const r=await api('/tiny/connect',{});location.href=r.url;},t.connected?'btn ghost':'btn');
const actions=[connect];
if(t.connected){
actions.unshift(button('Testar conexão',async()=>{const r=await api('/tiny/test',{});
say(r.ok?'Conexão com o Tiny ok: pedidos, contatos, os 4 produtos e a retirada conferidos.':'Tiny: '+Object.entries(r.results).filter(([,v])=>v!=='ok').map(([k,v])=>k+': '+v).join(' · '),!r.ok);}));}
cards.push(integration('Tiny',!t.connected?'Não conectado':t.problem?'Verificar':'Conectado',
t.connected&&!t.problem?'ok':'warn',tinyDetail(t),actions));
const connect=(text,cls)=>button(text,async()=>{const r=await api('/tiny/connect',{});location.href=r.url;},cls);
const test=act('Testar conexão',async()=>{const r=await api('/tiny/test',{});
say(r.ok?'Conexão com o Tiny ok: pedidos, contatos, os 4 produtos e a retirada conferidos.':'Tiny: '+Object.entries(r.results).filter(([,v])=>v!=='ok').map(([k,v])=>k+': '+v).join(' · '),!r.ok);});
const problem=TINY_PROBLEMS[t.problem];
rows.push(integration({name:'Tiny',state:!t.connected?'Não conectado':t.problem?'Verificar':'Conectado',tone:t.connected&&!t.problem?'ok':'warn',
summary:problem||(t.connected_by?t.connected_by+' · envio de pedidos '+(t.orders_enabled?'ativo':'desativado'):'Conecte com uma conta do Tiny.'),
actions:t.connected?[test]:[connect('Conectar Tiny','btn small')],
details:t.connected_by?[['Conta',t.connected_by],['Conectado em',when(t.connected_at)],['Renovado em',when(t.renewed_at)],
['Validade',t.offline?'Sem expiração diária':t.expires_at?'Até '+when(t.expires_at):'—'],
['Envio de pedidos',t.orders_enabled?'Ativo':'Desativado'],
...(t.failed_at&&t.problem!=='expired'?[['Última falha',when(t.failed_at)]]:[])]:[],
extra:t.connected?[connect('Reconectar','btn ghost small')]:[]}));
}
const mp=board.providers?.payment;
const mpActions=mp==='mercadopago'?[button('Verificar conta',async()=>{
const r=await api('/mercadopago/check',{});
const conta=r.account.error?'conta: '+r.account.error:'conta '+r.account.nickname+' ('+r.account.id+') · '+
(r.account.test_user?'usuário de teste':'não é usuário de teste');
const bin=Array.isArray(r.bin)?(r.bin.length?r.bin.map(o=>o.method+' '+o.type+' · '+o.issuer+' · até '+Math.max(...o.installments)+'x').join('; '):'cartão de teste não reconhecido'):'cartão: '+r.bin.error;
const w=r.webhooks||{};
const avisos='avisos nas últimas 24 h: '+w.accepted_24h+' aceitos, '+w.refused_24h+' recusados pela assinatura'+
(w.last?' · último em '+new Date(w.last.received_at).toLocaleString('pt-BR')+' ('+w.last.status+')':' · nenhum recebido ainda');
say('Mercado Pago: credencial '+(r.token==='test'?'de teste':'de produção')+' · '+conta+' · '+bin+' · '+avisos,false,60000);
},'btn ghost')]:[];
cards.push(integration('Mercado Pago',mp==='mercadopago'?'Ativo':'Não configurado',mp==='mercadopago'?'ok':'off',
mp==='mercadopago'?'PIX e cartão ativos.':'Aguardando credenciais.',mpActions));
const mp=board.providers?.payment==='mercadopago';
rows.push(integration({name:'Mercado Pago',state:mp?'Ativo':'Não configurado',tone:mp?'ok':'off',
summary:mp?'PIX e cartão ativos.':'Aguardando credenciais.',
actions:mp?[ghost('Verificar conta',async()=>{mpCheck=await api('/mercadopago/check',{});OPEN_INTEG.add('Mercado Pago');renderIntegrations();})]:[],
details:mp&&mpCheck?mercadoPagoCheck(mpCheck):[]}));
const fr=board.providers?.freight||{};
const kg=v=>String(v).replace('.',',')+' kg';
// Jadlog charges the larger of the real and the cubed weight: without the
// box and the contract's factor, a light big box is quoted below its price.
const caixa=fr.box_cm?' Caixa '+fr.box_cm.map(n=>String(n).replace('.',',')).join(' × ')+' cm a '+
String(fr.cubage_kg_m3).replace('.',',')+' kg/m³ = '+kg(fr.cubed_kg)+' cubados'+
(fr.metres_per_box?', até '+String(fr.metres_per_box).replace('.',',')+' m por caixa':'')+'; vale o maior dos dois pesos.'
:' Cubagem não configurada: a cotação usa só o peso real, e a Jadlog pode cobrar pelo tamanho da caixa.';
cards.push(fr.provider==='jadlog'
? integration('Frete',fr.box_cm?'Ativo':'Verificar',fr.box_cm?'ok':'warn','Entrega pela Jadlog e retirada em Franca. Pacote: '+kg(fr.base_kg)+
' + '+kg(fr.per_metre_kg)+' por metro.'+caixa+' Prazo da Jadlog + '+fr.production_days+' dia(s) de produção.')
: integration('Frete','Não configurado','off','Somente retirada.'));
cards.push(integration('WhatsApp','Não configurado','off','Mensagens registradas, sem envio.'));
rows.push(fr.provider==='jadlog'
? integration({name:'Frete',state:fr.box_cm?'Ativo':'Verificar',tone:fr.box_cm?'ok':'warn',
summary:fr.box_cm?'Jadlog e retirada em Franca · prazo da Jadlog + '+fr.production_days+' dia(s) de produção.'
:'Cubagem não configurada: a Jadlog pode cobrar mais que a cotação.',
details:[['Pacote',kg(fr.base_kg)+' + '+kg(fr.per_metre_kg)+' por metro'],
...(fr.box_cm?[['Caixa',fr.box_cm.map(n=>String(n).replace('.',',')).join(' × ')+' cm'],
['Cubagem',String(fr.cubage_kg_m3).replace('.',',')+' kg/m³ = '+kg(fr.cubed_kg)+' cubados'],
...(fr.metres_per_box?[['Por caixa','Até '+String(fr.metres_per_box).replace('.',',')+' m']]:[])]:[]),
// Jadlog charges the larger of the real and the cubed weight.
node('p',fr.box_cm?'A Jadlog cobra o maior entre o peso real e o cubado.':'Sem a caixa, a cotação usa só o peso real.')]})
: integration({name:'Frete',state:'Não configurado',tone:'off',summary:'Somente retirada.'}));
rows.push(integration({name:'WhatsApp',state:'Não configurado',tone:'off',summary:'Mensagens registradas, sem envio.'}));
const bk=board.providers?.backup||{};
const ontem=bk.last_ok&&Date.now()-new Date(bk.last_ok)<26*3600e3;
const tam=bk.bytes?' · '+(bk.bytes<1048576?Math.max(1,Math.round(bk.bytes/1024))+' KB':(bk.bytes/1048576).toFixed(1).replace('.',',')+' MB'):'';
cards.push(integration('Backup do banco',!bk.last_ok&&!bk.failed?'Não configurado':ontem&&!bk.failed?'Em dia':'Verificar',
!bk.last_ok&&!bk.failed?'off':ontem&&!bk.failed?'ok':'warn',
(bk.last_ok?'Último backup em '+when(bk.last_ok)+tam+'.':'Nenhum backup feito ainda.')+
(bk.failed?' A última tentativa falhou ('+when(bk.failed_at)+'): '+bk.failed:'')+' Cópia diária, criptografada, fora do servidor.'));
$('integrations').replaceChildren(...cards);
const tam=bk.bytes?(bk.bytes<1048576?Math.max(1,Math.round(bk.bytes/1024))+' KB':(bk.bytes/1048576).toFixed(1).replace('.',',')+' MB'):'';
const never=!bk.last_ok&&!bk.failed;
rows.push(integration({name:'Backup do banco',state:never?'Não configurado':ontem&&!bk.failed?'Em dia':'Verificar',
tone:never?'off':ontem&&!bk.failed?'ok':'warn',
summary:bk.failed?'A última tentativa falhou ('+when(bk.failed_at)+').':bk.last_ok?'Último em '+when(bk.last_ok)+(tam?' · '+tam:''):'Nenhum backup feito ainda.',
details:[...(bk.last_ok?[['Último backup',when(bk.last_ok)+(tam?' · '+tam:'')]]:[]),...(bk.failed?[['Erro',bk.failed]]:[]),
node('p','Cópia diária, criptografada, fora do servidor.')]}));
$('integrations').replaceChildren(...rows);
eventFilters();
}
function mercadoPagoCheck(r){
const w=r.webhooks||{};
return [['Credencial',r.token==='test'?'De teste':'De produção'],
['Conta',r.account.error||r.account.nickname+' ('+r.account.id+')'+(r.account.test_user?' · usuário de teste':'')],
['Cartão de teste',Array.isArray(r.bin)?(r.bin.length?r.bin.map(o=>o.method+' '+o.type+' · '+o.issuer+' · até '+Math.max(...o.installments)+'x').join('; '):'Não reconhecido'):r.bin.error],
['Avisos em 24 h',w.accepted_24h+' aceitos, '+w.refused_24h+' recusados pela assinatura'],
['Último aviso',w.last?when(w.last.received_at)+' ('+w.last.status+')':'Nenhum recebido ainda']];
}
// ---- Wiring --------------------------------------------------------------