diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..2c37329 --- /dev/null +++ b/index.html @@ -0,0 +1,1403 @@ + + + +
+ + +Erro ao carregar
'; + return; + } + + container.innerHTML = ''; + if (data.length === 0) { + container.innerHTML = 'Nenhuma ocorrência pendente.
${o.descricao}
+Nenhum aviso no mural.
'; + return; + } + + data.forEach(a => { + const item = document.createElement('a'); + item.className = 'list-group-item list-group-item-action flex-column align-items-start border-start border-4 border-info shadow-sm mb-2'; + item.innerHTML = ` +${a.mensagem}
+ `; + list.appendChild(item); + }); +} + +function prepareCreateAviso() { + document.getElementById('form-aviso').reset(); +} + +async function saveAviso(e) { + e.preventDefault(); + const titulo = document.getElementById('aviso-titulo').value; + const mensagem = document.getElementById('aviso-mensagem').value; + + const { error } = await dbInsert('avisos', { titulo, mensagem }); + + if (error) showToast("Erro: " + error.message, "danger"); + else { + bootstrap.Modal.getInstance(document.getElementById('modalAviso')).hide(); + renderAvisos(); + showToast("Aviso publicado!", "info"); + } +} + + +async function deleteItem(table, id) { + if (confirm('Tem certeza que deseja excluir?')) { + const { error } = await dbDelete(table, id); + if (error) showToast("Erro ao excluir", "danger"); + else { + showToast("Item excluído.", "success"); + if (table === 'moradores') renderMoradores(); + if (table === 'financeiro') renderFinanceiro(); + } + } +} + +function exportPDF(tableId, filename) { + const { jsPDF } = window.jspdf; + const doc = new jsPDF(); + + doc.text(filename.replace('_', ' '), 14, 15); + doc.autoTable({ html: '#' + tableId, startY: 20 }); + doc.save(filename + '.pdf'); + showToast("PDF gerado com sucesso!", "success"); +} diff --git a/style.css b/style.css new file mode 100644 index 0000000..b123a03 --- /dev/null +++ b/style.css @@ -0,0 +1,81 @@ +:root { + --sidebar-width: 250px; + --primary-color: #3498db; + --secondary-color: #2c3e50; + --background-color: #f8f9fa; +} + +body { + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + background-color: var(--background-color); +} + +.sidebar { + width: var(--sidebar-width); + background-color: var(--secondary-color); + min-height: 100vh; + transition: all 0.3s; +} + +.nav-link { + color: rgba(255, 255, 255, 0.8) !important; + margin-bottom: 5px; + transition: all 0.2s; +} + +.nav-link:hover, .nav-link.active { + background-color: var(--primary-color) !important; + color: white !important; + transform: translateX(5px); +} + +.nav-link i { + width: 25px; + text-align: center; +} + +.card { + border: none; + transition: transform 0.2s ease-in-out, box-shadow 0.2s; + border-radius: 10px; +} + +.card:hover { + transform: translateY(-3px); + box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important; +} + +@media (max-width: 768px) { + .sidebar { + width: 100%; + height: auto; + min-height: 0; + position: absolute; + z-index: 1000; + transform: translateX(-100%); + } + + .sidebar.show { + transform: translateX(0); + } + + #app-layout { + flex-direction: column; + } +} + +.cursor-pointer { + cursor: pointer; +} + +.transition-width { + transition: width 0.3s ease; +} + +.ocorrencia-img { + height: 200px; + object-fit: cover; + width: 100%; + border-top-left-radius: 10px; + border-top-right-radius: 10px; +} diff --git a/sw.js b/sw.js new file mode 100644 index 0000000..e06cdd4 --- /dev/null +++ b/sw.js @@ -0,0 +1,28 @@ +const CACHE_NAME = 'condopro-v1'; +const ASSETS_TO_CACHE = [ + './', + './index.html', + './style.css', + './script.js', + 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css', + 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css', + 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js', + 'https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2', + 'https://cdn.jsdelivr.net/npm/chart.js', + 'https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js', + 'https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.23/jspdf.plugin.autotable.min.js' +]; + +self.addEventListener('install', (event) => { + event.waitUntil( + caches.open(CACHE_NAME) + .then((cache) => cache.addAll(ASSETS_TO_CACHE)) + ); +}); + +self.addEventListener('fetch', (event) => { + event.respondWith( + caches.match(event.request) + .then((response) => response || fetch(event.request)) + ); +});