diff --git a/dental-server/public/app.js b/dental-server/public/app.js index 3b3f0c6..f30dd25 100644 --- a/dental-server/public/app.js +++ b/dental-server/public/app.js @@ -105,7 +105,7 @@ let fineTuneAngle = 0; // ================================================================ const searchInput = document.getElementById('searchInput'); -const clientFilter = document.getElementById('clientFilter'); +const clientFilter = document.getElementById('clientFilter'); // Pode ser null se removido do header const toggleDisabledBtn = document.getElementById('toggleDisabledBtn'); const toggleText = document.getElementById('toggleText'); const imagesGrid = document.getElementById('imagesGrid'); @@ -170,10 +170,12 @@ function setupEventListeners() { else loadPatientImages(selectedPatient.patient_name); }, 400)); - clientFilter.addEventListener('change', e => { - selectedClient = e.target.value; - if (view === 'patients') loadPatients(); - }); + if (clientFilter) { + clientFilter.addEventListener('change', e => { + selectedClient = e.target.value; + if (view === 'patients') loadPatients(); + }); + } toggleDisabledBtn.addEventListener('click', () => { showDisabled = !showDisabled; @@ -225,26 +227,72 @@ async function loadClientsList() { } function updateClientsDropdown() { - const current = clientFilter.value; - clientFilter.innerHTML = ''; + // Se por acaso o elemento clientFilter ainda existir no DOM em alguma outra tela, atualiza ele + if (clientFilter) { + const current = clientFilter.value; + clientFilter.innerHTML = ''; + const sorted = [...clientsList].sort((a, b) => { + const o = { identified: 1, connected: 2, historic: 3 }; + return (o[a.status] || 99) - (o[b.status] || 99); + }); + sorted.forEach(c => { + const opt = document.createElement('option'); + opt.value = c.name; + let lbl = c.name; + if (c.name === 'Upload Web') { + lbl = 'Upload Web 💻 (Imagens do Painel)'; + } else { + if (c.status === 'identified') lbl += ' ✅'; + else if (c.status === 'historic') lbl += ' 📚'; + } + opt.textContent = lbl; + clientFilter.appendChild(opt); + }); + clientFilter.value = current || selectedClient; + } + + // Renderizar o submenu dinâmico na sidebar + const submenu = document.getElementById('clientsSubmenu'); + if (!submenu) return; + const sorted = [...clientsList].sort((a, b) => { const o = { identified: 1, connected: 2, historic: 3 }; return (o[a.status] || 99) - (o[b.status] || 99); }); + + submenu.innerHTML = ''; + + // Adiciona o item "Todos os Clientes" + const allItem = document.createElement('div'); + allItem.className = `submenu-item${selectedClient === '' ? ' active' : ''}`; + allItem.innerHTML = '📋 Todos os Clientes'; + allItem.onclick = () => selectClientFilter(''); + submenu.appendChild(allItem); + sorted.forEach(c => { - const opt = document.createElement('option'); - opt.value = c.name; + const item = document.createElement('div'); + item.className = `submenu-item${selectedClient === c.name ? ' active' : ''}`; let lbl = c.name; if (c.name === 'Upload Web') { - lbl = 'Upload Web 💻 (Imagens do Painel)'; + lbl = 'Upload Web 💻'; } else { if (c.status === 'identified') lbl += ' ✅'; else if (c.status === 'historic') lbl += ' 📚'; } - opt.textContent = lbl; - clientFilter.appendChild(opt); + item.textContent = lbl; + item.onclick = () => selectClientFilter(c.name); + submenu.appendChild(item); }); - clientFilter.value = current || selectedClient; +} + +function selectClientFilter(clientName) { + selectedClient = clientName; + if (view === 'patients') { + loadPatients(); + } else { + showPatientsView(); + } + updateClientsDropdown(); } // ================================================================ @@ -256,6 +304,11 @@ function showPatientsView() { selectedPatient = null; backBtn.style.display = 'none'; patientHeader.style.display = 'none'; + + // Restaurar título do header + const mainTitle = document.getElementById('mainTitle'); + if (mainTitle) mainTitle.textContent = 'Galeria de Imagens'; + loadPatients(); } @@ -425,9 +478,18 @@ function openPatient(patient) { selectedPatient = patient; view = 'patient-images'; backBtn.style.display = 'inline-flex'; - patientHeader.style.display = 'block'; + + // Ocultar o patientHeader para manter o header na mesma altura de 70px + patientHeader.style.display = 'none'; + // Mudar o título principal para o nome do paciente - dentista const fullName = patient.patient_name || 'Sem nome'; + const doctorName = patient.doctor ? ` - ${patient.doctor}` : ''; + const mainTitle = document.getElementById('mainTitle'); + if (mainTitle) { + mainTitle.textContent = `${fullName}${doctorName}`; + } + patientTitle.textContent = fullName; patientMeta.textContent = `${patient.image_count || 0} imagem(ns) · ${patient.doctor || '—'}`; diff --git a/dental-server/public/index.html b/dental-server/public/index.html index 0b79b0f..901c006 100644 --- a/dental-server/public/index.html +++ b/dental-server/public/index.html @@ -6,7 +6,7 @@ Gerenciador de Imagens Dentais - +
@@ -19,6 +19,7 @@ 🖼️ Pacientes + Novo Paciente @@ -56,9 +57,6 @@

Galeria de Imagens

- - + diff --git a/dental-server/public/style.css b/dental-server/public/style.css index ff731c5..af6f841 100644 --- a/dental-server/public/style.css +++ b/dental-server/public/style.css @@ -1456,3 +1456,38 @@ body { box-sizing: border-box !important; } } + +/* Submenu de Clientes na Sidebar */ +.sidebar-submenu { + display: flex; + flex-direction: column; + gap: 2px; + margin-bottom: 8px; +} + +.submenu-item { + display: flex; + align-items: center; + padding: 6px 15px 6px 42px; /* Alinha o texto do submenu abaixo do ícone do menu pai */ + color: var(--text-color); + text-decoration: none; + font-size: 0.82rem; + font-weight: 500; + transition: all 0.2s ease; + border-left: 3px solid transparent; + cursor: pointer; + border-radius: 4px; + margin: 0 15px; +} + +.submenu-item:hover { + background-color: rgba(102, 126, 234, 0.06); + color: var(--primary-color); +} + +.submenu-item.active { + background-color: rgba(102, 126, 234, 0.1); + color: var(--primary-color); + border-left-color: var(--primary-color); + font-weight: 600; +}