diff --git a/static/js/settings.js b/static/js/settings.js index 2922f7b..a43c9ec 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -2937,7 +2937,8 @@ async function initIntegrations() { const INTG_TYPES = { api: { label: 'API', icon: '' }, caldav: { label: 'CalDAV', icon: '' }, - carddav: { label: 'Contacts', icon: '' }, + contacts: { label: 'Contacts', icon: '' }, + carddav: { label: 'CardDAV', icon: '' }, email: { label: 'Email', icon: '' }, mcp: { label: 'MCP', icon: '' }, vault: { label: 'Vault', icon: '' }, @@ -2978,14 +2979,24 @@ async function initUnifiedIntegrations() { if (calRes.url) { items.push({ type: 'caldav', id: '__caldav__', name: 'Calendar (CalDAV)', detail: calRes.url, enabled: true, data: calRes }); } - // Contacts / CardDAV + // Contacts import first, then the optional CardDAV sync account. const contactCount = Number(contactsRes.count || (contactsRes.contacts || []).length || 0); - if (cardRes.url || contactCount > 0) { + if (contactCount > 0) { + items.push({ + type: 'contacts', + id: '__contacts__', + name: 'Contacts Import', + detail: `${contactCount} contact${contactCount === 1 ? '' : 's'}`, + enabled: true, + data: contactsRes, + }); + } + if (cardRes.url) { items.push({ type: 'carddav', id: '__carddav__', - name: 'Contacts', - detail: cardRes.url || `${contactCount} contact${contactCount === 1 ? '' : 's'}`, + name: 'Contacts (CardDAV)', + detail: cardRes.url, enabled: true, data: cardRes, }); @@ -3065,9 +3076,11 @@ async function initUnifiedIntegrations() { try { if (type === 'api') await fetch(`/api/auth/integrations/${id}`, { method: 'DELETE', credentials: 'same-origin' }); else if (type === 'caldav') await fetch('/api/calendar/config', { method: 'POST', credentials: 'same-origin', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ url: '', username: '', password: '' }) }); + else if (type === 'contacts') { + await fetch('/api/contacts/clear', { method: 'DELETE', credentials: 'same-origin' }); + } else if (type === 'carddav') { await fetch('/api/contacts/config', { method: 'PUT', credentials: 'same-origin', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ carddav_url: '', carddav_username: '', carddav_password: '' }) }); - await fetch('/api/contacts/clear', { method: 'DELETE', credentials: 'same-origin' }); } else if (type === 'email') await fetch(`/api/email/accounts/${id}`, { method: 'DELETE', credentials: 'same-origin' }); else if (type === 'mcp') await fetch(`/api/mcp/servers/${id}`, { method: 'DELETE', credentials: 'same-origin' }); @@ -3084,7 +3097,7 @@ async function initUnifiedIntegrations() { formEl.style.display = ''; if (type === 'api') showApiForm(editId); else if (type === 'caldav') showCalDavForm(); - else if (type === 'carddav') showCardDavForm(); + else if (type === 'contacts' || type === 'carddav') showCardDavForm(); else if (type === 'email') showEmailForm(editId); else if (type === 'mcp') showMcpForm(editId); else if (type === 'vault') showVaultForm(); @@ -3296,7 +3309,7 @@ async function initUnifiedIntegrations() {