-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
653 lines (569 loc) · 27.4 KB
/
Copy pathadmin.html
File metadata and controls
653 lines (569 loc) · 27.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Painel Administrativo - SATELITE v3</title>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
:root {
--primary: #00f2fe;
--secondary: #4facfe;
--bg: #0b0e14;
--surface: #161b22;
--text: #e6edf3;
--text-dim: #8b949e;
--accent: #f1c40f;
--danger: #ff7b72;
--success: #3fb950;
--glass: rgba(22, 27, 34, 0.8);
--card-border: rgba(255, 255, 255, 0.1);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Outfit', sans-serif;
background: var(--bg);
color: var(--text);
min-height: 100vh;
padding: 40px 20px;
background-image: radial-gradient(circle at top right, rgba(0, 242, 254, 0.05), transparent 400px);
}
.container { max-width: 1200px; margin: 0 auto; }
.header-nav {
display: flex;
justify-content: flex-end;
align-items: center;
margin-bottom: 40px;
}
.nav-wrapper { position: relative; }
.nav-toggle { display: none; }
.hamburger-icon {
display: flex;
align-items: center;
justify-content: center;
width: 34px;
height: 34px;
border: 1px solid var(--card-border);
border-radius: 8px;
color: var(--text-dim);
cursor: pointer;
font-size: 1.1rem;
transition: all 0.3s;
position: relative;
z-index: 210;
}
.hamburger-icon:hover { border-color: var(--primary); color: var(--primary); }
.nav-overlay {
display: none;
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
z-index: 190;
cursor: default;
}
.nav-toggle:checked ~ .nav-overlay { display: block; }
.page-nav {
display: none;
flex-direction: column;
gap: 4px;
position: absolute;
top: 44px;
right: 0;
background: var(--surface);
border: 1px solid var(--card-border);
border-radius: 12px;
padding: 10px;
min-width: 180px;
z-index: 200;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.nav-toggle:checked ~ .page-nav { display: flex; }
.page-nav a, .page-nav .active {
padding: 8px 10px;
border-radius: 8px;
color: var(--text-dim);
text-decoration: none;
transition: background 0.2s, color 0.2s;
}
.page-nav a:hover { background: rgba(255, 255, 255, 0.05); color: var(--primary); }
.page-nav .active { color: var(--primary); font-weight: 600; }
h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 10px; }
.subtitle { color: var(--text-dim); margin-bottom: 40px; }
.admin-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
gap: 30px;
}
.card {
background: var(--surface);
border: 1px solid var(--card-border);
border-radius: 24px;
padding: 30px;
display: flex;
flex-direction: column;
gap: 20px;
}
.card h2 { font-size: 1.5rem; display: flex; align-items: center; gap: 12px; }
.card p { color: var(--text-dim); font-size: 0.9rem; line-height: 1.6; }
.import-zone {
border: 2px dashed var(--card-border);
padding: 30px;
text-align: center;
border-radius: 16px;
cursor: pointer;
transition: all 0.3s;
display: flex;
flex-direction: column;
align-items: center;
gap: 10px;
}
.import-zone:hover { border-color: var(--primary); background: rgba(0, 242, 254, 0.05); }
.import-zone i { font-size: 2rem; }
.btn {
padding: 12px 20px;
border-radius: 12px;
border: none;
font-weight: 600;
cursor: pointer;
transition: all 0.3s;
font-family: inherit;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 10px;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #000; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(0, 242, 254, 0.2); }
.btn-outline { background: transparent; border: 1px solid var(--card-border); color: var(--text); }
.btn-outline:hover { background: rgba(255, 255, 255, 0.05); }
.sync-status {
display: flex;
align-items: center;
gap: 10px;
padding: 15px;
background: rgba(0,0,0,0.2);
border-radius: 12px;
font-size: 0.85rem;
}
.sync-status-copy { display: flex; flex-direction: column; gap: 3px; }
.gas-version-status { color: var(--text-dim); font-size: 0.75rem; }
.gas-version-status.compatible { color: var(--success); }
.gas-version-status.outdated { color: var(--warning); }
.gas-version-status.error { color: var(--danger); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-online { background: var(--success); box-shadow: 0 0 10px var(--success); }
.status-offline { background: var(--danger); }
/* Modal Styles */
.modal {
display: none;
position: fixed;
top: 0; left: 0; width: 100%; height: 100%;
background: rgba(0, 0, 0, 0.9);
backdrop-filter: blur(8px);
z-index: 1000;
justify-content: center;
align-items: center;
padding: 20px;
}
.modal-content {
background: var(--surface);
padding: 40px;
border-radius: 24px;
width: 100%;
max-width: 900px;
max-height: 90vh;
overflow-y: auto;
border: 1px solid var(--card-border);
}
.point-preview-list {
margin-top: 20px;
display: flex;
flex-direction: column;
gap: 10px;
}
.point-preview-item {
display: grid;
grid-template-columns: 80px 1fr 1.5fr;
gap: 15px;
padding: 12px;
background: rgba(255,255,255,0.03);
border-radius: 8px;
align-items: center;
}
input {
background: rgba(0,0,0,0.3);
border: 1px solid var(--card-border);
color: var(--text);
padding: 8px 12px;
border-radius: 6px;
outline: none;
}
input:focus { border-color: var(--primary); }
.loader {
display: none;
position: fixed;
top: 50%; left: 50%;
transform: translate(-50%, -50%);
z-index: 2000;
text-align: center;
}
.spinner {
width: 50px; height: 50px;
border: 5px solid rgba(255,255,255,0.1);
border-top-color: var(--primary);
border-radius: 50%;
animation: spin 1s linear infinite;
margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
</style>
<link rel="stylesheet" href="theme.css">
<script src="theme.js"></script>
<script src="config.js"></script>
<script src="config.local.js"></script>
</head>
<body>
<div class="container">
<div class="header-nav">
<div class="nav-wrapper">
<input type="checkbox" id="navToggle" class="nav-toggle">
<label for="navToggle" class="hamburger-icon">☰</label>
<label for="navToggle" class="nav-overlay"></label>
<nav class="page-nav">
<a href="index.html">🏠 Início</a>
<a href="roteiros.html">📍 Roteiros</a>
<a href="coleta-checklist.html">✅ Coleta</a>
<a href="analise.html">📊 Análise</a>
<a href="agendamentos.html">📅 Agendamentos</a>
<span class="active">⚙️ Admin</span>
<a href="ajuda-integracao-access.html" target="_blank">🔄 Integração Access</a>
<a href="ajuda-coleta.html" target="_blank">❓ Ajuda</a>
</nav>
</div>
</div>
<h1>Administração do Sistema</h1>
<p class="subtitle">Gerenciamento de dados legados, integridade do banco SQLite e sincronização em nuvem.</p>
<div class="admin-grid">
<!-- MIGRACAO LEGADA -->
<div class="card">
<h2>📦 Migração de Dados Legados</h2>
<p>Absorva pontos, rotas e históricos do sistema antigo (Access/Excel) diretamente para o banco de dados local.</p>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px;">
<div class="import-zone" onclick="document.getElementById('legacyRota').click()">
<input type="file" id="legacyRota" style="display: none" accept=".xlsx">
<span>Rotas (.xlsx)</span>
</div>
<div class="import-zone" onclick="document.getElementById('legacyRoteiro').click()">
<input type="file" id="legacyRoteiro" style="display: none" accept=".xlsx">
<span>Pontos (.xlsx)</span>
</div>
</div>
<div class="import-zone" style="border-color: var(--accent);" onclick="document.getElementById('legacyColeta').click()">
<input type="file" id="legacyColeta" style="display: none" accept=".xlsx">
<span style="color: var(--accent);">Historico de Coletas (tblColeta.xlsx)</span>
</div>
<button id="btnOpenLegacyPreview" class="btn btn-primary" disabled>
Visualizar e Incorporar Dados
</button>
</div>
<!-- SINCRONIZACAO GOOGLE -->
<div class="card">
<h2>☁️ Sincronização Google</h2>
<p>Transfira os dados locais para a nuvem (Google Sheets) para que outros dispositivos na rede possam acessar os roteiros atualizados. Rotas e pontos são atualizados automaticamente a partir do arquivo na pasta do Google Drive.</p>
<div class="sync-status">
<div class="status-dot status-offline" id="syncStatusDot"></div>
<div class="sync-status-copy">
<span id="syncStatusText">Verificando...</span>
<span class="gas-version-status" id="gasVersionStatus">API GAS: verificando...</span>
</div>
</div>
<div style="display: flex; flex-direction: column; gap: 10px;">
<input type="text" id="gasUrl" placeholder="URL do Web App do Google Apps Script">
<input type="password" id="gasRouteToken" placeholder="Token para alterações de roteiros">
<span class="gas-version-status" id="routeChangesStatus">Alterações de roteiros: verificando...</span>
<a href="ajuda-integracao-access.html" target="_blank" style="color: var(--accent); font-size: 0.9rem;">
❓ Como enviar alterações de roteiros para o Access
</a>
</div>
<div style="display: flex; gap: 10px;">
<button class="btn btn-primary" style="flex: 1;" onclick="checkDriveUpdate()">Verificar agora</button>
<button class="btn btn-outline" onclick="backupSQLite()">Backup Local</button>
</div>
</div>
<!-- MANUTENÇÃO DO BANCO -->
<div class="card">
<h2>🛠️ Manutenção do Banco</h2>
<p>Gerencie o estado atual do SQLite, limpe dados temporários ou redefina o sistema.</p>
<div style="background: rgba(0,0,0,0.2); border-radius: 12px; padding: 15px;">
<div style="display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 0.9rem;">
<span>Pontos Cadastrados:</span>
<span id="statPointsCount" style="font-family: 'JetBrains Mono'; color: var(--primary);">0</span>
</div>
<div style="display: flex; justify-content: space-between; font-size: 0.9rem;">
<span>Registros de Coleta:</span>
<span id="statCollectsCount" style="font-family: 'JetBrains Mono'; color: var(--primary);">0</span>
</div>
<div style="display: flex; justify-content: space-between; font-size: 0.9rem; margin-top: 8px;">
<span>Coletas Pendentes de Sincronização:</span>
<span id="statPendingSyncCount" style="font-family: 'JetBrains Mono'; color: var(--accent);">0</span>
</div>
<div style="display: flex; justify-content: space-between; font-size: 0.9rem; margin-top: 8px;">
<span>Alterações de Roteiro Pendentes:</span>
<span id="statPendingRouteCount" style="font-family: 'JetBrains Mono'; color: var(--accent);">0</span>
</div>
</div>
<button class="btn btn-outline" style="border-color: var(--danger); color: var(--danger);" onclick="resetDatabase()">
⚠️ Resetar Banco de Dados
</button>
</div>
<!-- FERRAMENTAS -->
<div class="card">
<h2>🛠️ Ferramentas</h2>
<p>Utilitários auxiliares que não fazem parte do fluxo principal de coleta.</p>
<a href="whatsapp-sender.html" class="btn btn-outline" style="display: inline-block; text-decoration: none;">📲 Disparo WhatsApp</a>
</div>
</div>
</div>
<!-- MODAL PREVIEW LEGADO -->
<div id="legacyPreviewModal" class="modal">
<div class="modal-content">
<h2 style="margin-bottom: 10px;">Revisão de Pontos Legados</h2>
<p class="subtitle" style="font-size: 0.9rem;">Dê nomes amigáveis aos pontos antes de integrá-los ao sistema de coleta.</p>
<div class="point-preview-list" id="legacyList">
<!-- Injected via JS -->
</div>
<div style="display: flex; justify-content: flex-end; gap: 15px; margin-top: 30px;">
<button class="btn btn-outline" onclick="document.getElementById('legacyPreviewModal').style.display='none'">Cancelar</button>
<button class="btn btn-primary" onclick="confirmLegacyMigration()">Finalizar Migração</button>
</div>
</div>
</div>
<div class="loader" id="loader">
<div class="spinner"></div>
<p id="loaderText">Sincronizando...</p>
</div>
<script src="vendor/papaparse.min.js"></script>
<script src="vendor/xlsx.full.min.js"></script>
<script src="vendor/sql-wasm.js"></script>
<script type="module">
import db from './database.js';
import {
getGasUrl,
setGasUrl,
getGasStatus,
checkAndImportRoteiros,
getGasRouteToken,
setGasRouteToken,
syncPendingRoteiroChanges,
REQUIRED_GAS_API_VERSION
} from './google-sync.js';
let legacyData = { rotas: [], roteiros: [], coletas: [] };
async function init() {
await db.init();
updateStats();
document.getElementById('gasUrl').value = getGasUrl();
document.getElementById('gasUrl').onchange = (e) => {
setGasUrl(e.target.value.trim());
window.checkDriveUpdate();
};
document.getElementById('gasRouteToken').value = getGasRouteToken();
document.getElementById('gasRouteToken').onchange = (e) => {
setGasRouteToken(e.target.value.trim());
window.checkDriveUpdate();
};
// File listeners
document.getElementById('legacyRota').onchange = (e) => handleFile(e, 'rotas');
document.getElementById('legacyRoteiro').onchange = (e) => handleFile(e, 'roteiros');
document.getElementById('legacyColeta').onchange = (e) => handleFile(e, 'coletas');
document.getElementById('btnOpenLegacyPreview').onclick = () => {
renderLegacyPreview();
document.getElementById('legacyPreviewModal').style.display = 'flex';
};
checkDriveUpdate();
}
async function handleFile(e, type) {
const file = e.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = (event) => {
const data = new Uint8Array(event.target.result);
const wb = XLSX.read(data, { type: 'array' });
const ws = wb.Sheets[wb.SheetNames[0]];
legacyData[type] = XLSX.utils.sheet_to_json(ws, { defval: '' });
if (type === 'roteiros') {
document.getElementById('btnOpenLegacyPreview').disabled = false;
}
if (type === 'coletas') {
alert(`${legacyData.coletas.length} registros de histórico carregados. Estarão prontos para incorporação.`);
}
};
reader.readAsArrayBuffer(file);
}
function renderLegacyPreview() {
const list = document.getElementById('legacyList');
list.innerHTML = '';
legacyData.roteiros.forEach((p, i) => {
const id = p.ID_Rota || p.id_rota || i;
const logr = p.Logradouro || p.Rua || '';
const num = p.Numero || p.Nº || '';
const suggestedName = p.Cliente || p.Nome || `${p.Bairro || ''} - ${logr} ${num}`.trim() || `Ponto ${id}`;
const div = document.createElement('div');
div.className = 'point-preview-item';
div.innerHTML = `
<div style="font-family: 'JetBrains Mono'; font-weight: 600;">${id}</div>
<div style="color: var(--text-dim); font-size: 0.8rem;">${logr}, ${num}</div>
<input type="text" value="${suggestedName}" class="legacy-name-input" data-idx="${i}">
`;
list.appendChild(div);
});
}
window.confirmLegacyMigration = async () => {
showLoader("Incorporando ao SQLite...");
// 1. Process Roteiros (Rotas)
const routeMap = {};
legacyData.rotas.forEach(r => {
const nome = r.Nome_Rota || r.Rota || r.Descricao || `Rota ${r.ID_Rota}`;
db.addRoteiro(nome);
});
const dbRoteiros = db.getRoteiros();
dbRoteiros.forEach(r => routeMap[r.nome] = r.id);
// 2. Process Clientes (Pontos)
const inputs = document.querySelectorAll('.legacy-name-input');
legacyData.roteiros.forEach((p, i) => {
const name = inputs[i].value;
const idRota = (p.ID_Rota || p.id_rota || i).toString();
let roteiroId = null;
const rotaIdLegacy = p.ID_Rota_Ref || p.RotaID || p.id_rota;
const legacyRota = legacyData.rotas.find(r => r.ID_Rota == rotaIdLegacy);
if (legacyRota) {
const rotaNome = legacyRota.Nome_Rota || legacyRota.Rota || legacyRota.Descricao || `Rota ${legacyRota.ID_Rota}`;
roteiroId = routeMap[rotaNome];
}
db.upsertCliente({
idRota: idRota,
Cliente: name,
logradouro: p.Logradouro || p.Rua || '',
Número: p.Numero || p.Nº || '',
CEP: p.CEP || '',
roteiro_id: roteiroId || (dbRoteiros[0]?.id),
Ordem: p.Ordem || (i * 10),
ativo: true
});
});
// 3. Process History (Coletas)
legacyData.coletas.forEach(c => {
const idRota = c.ID_Rota || c.id_rota || c.ID_Ponto;
const data = c.Data_Coleta || c.Data || c.data;
const qtd = c.Quantidade || c.Qtd || c.Bombonas;
if (idRota && data) {
db.addColeta({
id_rota: idRota.toString(),
data: data,
quantidade: parseInt(qtd) || 0,
intercorrencia: c.Intercorrencia || c.Obs || ''
});
}
});
hideLoader();
alert("Migração concluída com sucesso!");
document.getElementById('legacyPreviewModal').style.display = 'none';
updateStats();
};
function updateStats() {
const pCount = db.db.exec("SELECT COUNT(*) FROM clientes")[0]?.values[0][0] || 0;
const cCount = db.db.exec("SELECT COUNT(*) FROM coletas")[0]?.values[0][0] || 0;
document.getElementById('statPointsCount').textContent = pCount;
document.getElementById('statCollectsCount').textContent = cCount;
document.getElementById('statPendingSyncCount').textContent = db.getUnsyncedColetas().length;
document.getElementById('statPendingRouteCount').textContent = db.getPendingRoteiroChangesCount();
}
window.checkDriveUpdate = async () => {
const dot = document.getElementById('syncStatusDot');
const text = document.getElementById('syncStatusText');
const versionText = document.getElementById('gasVersionStatus');
const routeChangesText = document.getElementById('routeChangesStatus');
if (!getGasUrl()) {
dot.className = 'status-dot status-offline';
text.textContent = 'URL do Google Apps Script não configurada';
versionText.className = 'gas-version-status error';
versionText.textContent = 'API GAS: não configurada';
routeChangesText.className = 'gas-version-status error';
routeChangesText.textContent = 'Alterações de roteiros: URL não configurada';
return;
}
text.textContent = 'Verificando atualização...';
versionText.className = 'gas-version-status';
versionText.textContent = 'API GAS: verificando...';
routeChangesText.className = 'gas-version-status';
routeChangesText.textContent = 'Alterações de roteiros: verificando...';
const [gasStatus, result, routeSync] = await Promise.all([
getGasStatus(),
checkAndImportRoteiros(db),
syncPendingRoteiroChanges(db)
]);
if (!gasStatus.ok) {
versionText.className = 'gas-version-status error';
versionText.textContent = `API GAS: não foi possível verificar (${gasStatus.error || 'erro desconhecido'})`;
} else if (Number(gasStatus.apiVersion) < REQUIRED_GAS_API_VERSION) {
versionText.className = 'gas-version-status outdated';
versionText.textContent = `API GAS v${gasStatus.apiVersion}: atualização v${REQUIRED_GAS_API_VERSION} necessária`;
} else {
versionText.className = 'gas-version-status compatible';
versionText.textContent = `API GAS v${gasStatus.apiVersion}: compatível`;
}
if (gasStatus.ok && !gasStatus.routeChangesConfigured) {
routeChangesText.className = 'gas-version-status error';
routeChangesText.textContent = 'Alterações de roteiros: ROUTE_CHANGES_TOKEN não configurado no GAS';
} else if (!getGasRouteToken()) {
routeChangesText.className = 'gas-version-status error';
routeChangesText.textContent = 'Alterações de roteiros: informe o token neste app';
} else if (!routeSync.ok) {
routeChangesText.className = 'gas-version-status error';
routeChangesText.textContent = `Alterações de roteiros: ${routeSync.error || 'erro desconhecido'}`;
} else {
routeChangesText.className = 'gas-version-status compatible';
routeChangesText.textContent = routeSync.count
? `${routeSync.count} alteração(ões) aplicada(s) na planilha`
: 'Alterações de roteiros: fila local sincronizada';
}
if (result.error) {
dot.className = 'status-dot status-offline';
// status responde (resposta pequena, inline) mas o import do CSV
// deu 404 mesmo após as tentativas. Isso pode ser um 404
// transitório do Google em respostas grandes OU uma implantação
// obsoleta. Mensagem sugere tentar de novo antes de suspeitar da URL.
const importe404 = gasStatus.ok && /Falha HTTP 404/.test(result.error);
text.textContent = importe404
? 'Erro: HTTP 404 no import do CSV (o status responde normalmente). Costuma ser falha temporária do Google em respostas grandes — clique em "Verificar agora" novamente. Se persistir, confirme se a URL é a da implantação atual (campo acima) ou reimplante o Code.gs na mesma implantação.'
: `Erro: ${result.error}`;
return;
}
if (result.warning) {
dot.className = 'status-dot status-offline';
text.textContent = result.warning;
return;
}
dot.className = 'status-dot status-online';
text.textContent = result.updated
? `Atualizado agora: ${result.roteiros} roteiros, ${result.clientes} pontos`
: 'Rotas e pontos já estão atualizados';
updateStats();
};
window.backupSQLite = () => db.downloadDatabase();
window.resetDatabase = () => {
if (confirm("TEM CERTEZA? Todos os dados locais serão apagados permanentemente.")) {
localStorage.removeItem('app3_db');
location.reload();
}
};
function showLoader(text) {
document.getElementById('loaderText').textContent = text;
document.getElementById('loader').style.display = 'block';
}
function hideLoader() {
document.getElementById('loader').style.display = 'none';
}
init();
</script>
<script src="nav-menu.js"></script>
</body>
</html>