feat(ble): botão Copiar log + Limpar + painel sempre aberto v1.10.6
Some checks are pending
Build Android (APK + AAB) / build-android (push) Waiting to run

Karlão mandou log antigo achando que era novo (não dava pra distinguir
log v1.10.4 de v1.10.5 sem ler timestamps). Adicionado botão 📋 Copiar
log que copia texto puro pro clipboard com header 'Shivao vX.Y.Z · log
diagnóstico' — fica óbvio qual versão está rodando.

Mudanças:
- <details> agora abre por padrão (open attribute)
- Botão 📋 Copiar log (navigator.clipboard + fallback textarea)
- Botão 🗑 Limpar pra zerar histórico antes de novo teste
- Painel max-height 200→300px + font-family mono
- Toast confirma cópia OK

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
PontualTech / Karlão 2026-04-29 07:30:56 -03:00
parent 2fca191676
commit cd4aa9c753
5 changed files with 58 additions and 10 deletions

View file

@ -1977,9 +1977,13 @@ Marque zonas de proibição (alarme alto) ou atenção (aviso suave). Detecção
<div id="bt-support" style="font-family:var(--f-mono);font-size:10.5px;letter-spacing:.04em;margin-bottom:10px">Verificando suporte...</div>
<button class="btn btn-block btn-primary" onclick="pairBluetoothDevice()">+ Parear novo dispositivo Bluetooth</button>
<div id="bt-list" style="margin-top:14px"></div>
<details style="margin-top:10px">
<details style="margin-top:10px" open>
<summary style="cursor:pointer;font-family:var(--f-mono);font-size:11px;color:var(--m-text-soft,#7d97ad);letter-spacing:.06em">📋 Diagnóstico (logs do pareamento)</summary>
<div id="bt-diag" style="background:var(--m-bg-2,#0f2a40);border:1px solid var(--m-border,rgba(255,255,255,.08));border-radius:6px;padding:10px;margin-top:6px;max-height:200px;overflow-y:auto"></div>
<div style="display:flex;gap:6px;margin-top:8px">
<button class="btn btn-sm" onclick="copyDiagLog()" style="flex:1">📋 Copiar log</button>
<button class="btn btn-sm" onclick="document.getElementById('bt-diag').innerHTML='';setBleDiag('Log limpo','info')" style="flex:1">🗑 Limpar</button>
</div>
<div id="bt-diag" style="background:var(--m-bg-2,#0f2a40);border:1px solid var(--m-border,rgba(255,255,255,.08));border-radius:6px;padding:10px;margin-top:6px;max-height:300px;overflow-y:auto;font-family:var(--f-mono);font-size:11px"></div>
</details>
<div class="field-hint" style="margin-top:8px">Limitações: <strong>iOS Safari não suporta Web Bluetooth</strong>. APK Android usa plugin nativo. BMS proprietários (Victron, JBD) podem aparecer mas não expor Battery Service padrão.</div>
</div>
@ -5790,6 +5794,26 @@ async function ensureBleNativeReady(){
_bleNativeInitialized=true;
}
// Copia log diagnóstico pro clipboard
async function copyDiagLog(){
const el=document.getElementById('bt-diag');
if(!el){toast('Log vazio');return}
// Extrai texto puro (innerText preserva quebras de linha)
const txt=`Shivao v${APP_VERSION} · log diagnóstico\n\n`+(el.innerText||el.textContent||'').trim();
try{
if(navigator.clipboard?.writeText){
await navigator.clipboard.writeText(txt);
toast('✓ Log copiado · cole no chat');
}else{
// Fallback: textarea hack
const ta=document.createElement('textarea');
ta.value=txt;document.body.appendChild(ta);ta.select();
document.execCommand('copy');ta.remove();
toast('✓ Log copiado');
}
}catch(e){toast('Erro ao copiar: '+e.message)}
}
// Diagnóstico visível: mostra cada passo no card BLE
function setBleDiag(msg,type){
const el=document.getElementById('bt-diag');
@ -6265,7 +6289,7 @@ async function removeBluetoothDevice(id){
renderBluetoothCard();
}
const APP_VERSION='1.10.5';
const APP_VERSION='1.10.6';
function renderBluetoothCard(){
const el=document.getElementById('bt-list');
const supportEl=document.getElementById('bt-support');

View file

@ -7,8 +7,8 @@ android {
applicationId "br.com.pontualtech.shivao"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 21
versionName "1.10.5"
versionCode 22
versionName "1.10.6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.

View file

@ -1,6 +1,6 @@
{
"name": "shivao-mobile",
"version": "1.10.5",
"version": "1.10.6",
"description": "Shivao app nativo (Capacitor wrapper Android/iOS)",
"main": "index.js",
"type": "module",

View file

@ -1977,9 +1977,13 @@ Marque zonas de proibição (alarme alto) ou atenção (aviso suave). Detecção
<div id="bt-support" style="font-family:var(--f-mono);font-size:10.5px;letter-spacing:.04em;margin-bottom:10px">Verificando suporte...</div>
<button class="btn btn-block btn-primary" onclick="pairBluetoothDevice()">+ Parear novo dispositivo Bluetooth</button>
<div id="bt-list" style="margin-top:14px"></div>
<details style="margin-top:10px">
<details style="margin-top:10px" open>
<summary style="cursor:pointer;font-family:var(--f-mono);font-size:11px;color:var(--m-text-soft,#7d97ad);letter-spacing:.06em">📋 Diagnóstico (logs do pareamento)</summary>
<div id="bt-diag" style="background:var(--m-bg-2,#0f2a40);border:1px solid var(--m-border,rgba(255,255,255,.08));border-radius:6px;padding:10px;margin-top:6px;max-height:200px;overflow-y:auto"></div>
<div style="display:flex;gap:6px;margin-top:8px">
<button class="btn btn-sm" onclick="copyDiagLog()" style="flex:1">📋 Copiar log</button>
<button class="btn btn-sm" onclick="document.getElementById('bt-diag').innerHTML='';setBleDiag('Log limpo','info')" style="flex:1">🗑 Limpar</button>
</div>
<div id="bt-diag" style="background:var(--m-bg-2,#0f2a40);border:1px solid var(--m-border,rgba(255,255,255,.08));border-radius:6px;padding:10px;margin-top:6px;max-height:300px;overflow-y:auto;font-family:var(--f-mono);font-size:11px"></div>
</details>
<div class="field-hint" style="margin-top:8px">Limitações: <strong>iOS Safari não suporta Web Bluetooth</strong>. APK Android usa plugin nativo. BMS proprietários (Victron, JBD) podem aparecer mas não expor Battery Service padrão.</div>
</div>
@ -5790,6 +5794,26 @@ async function ensureBleNativeReady(){
_bleNativeInitialized=true;
}
// Copia log diagnóstico pro clipboard
async function copyDiagLog(){
const el=document.getElementById('bt-diag');
if(!el){toast('Log vazio');return}
// Extrai texto puro (innerText preserva quebras de linha)
const txt=`Shivao v${APP_VERSION} · log diagnóstico\n\n`+(el.innerText||el.textContent||'').trim();
try{
if(navigator.clipboard?.writeText){
await navigator.clipboard.writeText(txt);
toast('✓ Log copiado · cole no chat');
}else{
// Fallback: textarea hack
const ta=document.createElement('textarea');
ta.value=txt;document.body.appendChild(ta);ta.select();
document.execCommand('copy');ta.remove();
toast('✓ Log copiado');
}
}catch(e){toast('Erro ao copiar: '+e.message)}
}
// Diagnóstico visível: mostra cada passo no card BLE
function setBleDiag(msg,type){
const el=document.getElementById('bt-diag');
@ -6265,7 +6289,7 @@ async function removeBluetoothDevice(id){
renderBluetoothCard();
}
const APP_VERSION='1.10.5';
const APP_VERSION='1.10.6';
function renderBluetoothCard(){
const el=document.getElementById('bt-list');
const supportEl=document.getElementById('bt-support');

View file

@ -347,7 +347,7 @@ app.get('/.well-known/assetlinks.json', (req, res) => {
});
// Atalho: /apk redireciona pra última APK release no Forgejo
const LATEST_APK_URL = 'https://git.pontualtech.work/karlao/shivao-projeto/releases/download/v1.10.5/Shivao-v1.10.5.apk';
const LATEST_APK_URL = 'https://git.pontualtech.work/karlao/shivao-projeto/releases/download/v1.10.6/Shivao-v1.10.6.apk';
app.get('/apk', (req, res) => res.redirect(302, LATEST_APK_URL));
// Página A4 imprimível com QR Code + instruções (cola no barco/marina)