Data Sources
Connect your data warehouses
Connect your data warehouses
Fill in the details to tether your cloud warehouse.
Connect another source
Data source connected
Last sync: ${lastSyncText}
Connect another source
`; grid.appendChild(emptyCard); } async function handleFormSubmit(e) { e.preventDefault(); if (!requireAuth()) return; const name = document.getElementById('nameInput').value; if (!name.trim()) { alert('Please enter a data source name'); return; } let payload; if (currentProvider === 'redshift') { const host = document.getElementById('hostInput').value; const port = document.getElementById('portInput').value; const database = document.getElementById('databaseInput').value; const user = document.getElementById('userInput').value; const password = document.getElementById('passwordInput').value; if (!host || !port || !database || !user || !password) { alert('Please fill in all Redshift fields'); return; } payload = { type: 'redshift', name: name, config: { host, port: parseInt(port), database, user, password } }; } else { const region = document.getElementById('regionInput').value; const access_key_id = document.getElementById('accessKeyInput').value; const secret_access_key = document.getElementById('secretKeyInput').value; const s3_output_location = document.getElementById('s3LocationInput').value; const catalog_name = document.getElementById('catalogNameInput').value; if (!region || !access_key_id || !secret_access_key || !s3_output_location) { alert('Please fill in all Athena fields'); return; } payload = { type: 'athena', name: name, config: { region, access_key_id, secret_access_key, s3_output_location, catalog_name } }; } try { const res = await apiFetch('/api/connectors', { method: 'POST', body: JSON.stringify(payload) }); if (!res) return; if (res.status === 201) { closeModal(); await loadConnectors(); } else { const err = await res.json(); alert('Error: ' + (err.message || 'Failed to create connector')); } } catch (err) { console.error('Error creating connector:', err); alert('Error: ' + err.message); } } async function syncConnector(id) { if (!requireAuth()) return; try { const res = await apiFetch('/api/connectors/' + id + '/sync', { method: 'POST' }); if (!res) return; if (res.status === 200) { await loadConnectors(); } else { alert('Sync failed'); } } catch (err) { console.error('Error syncing connector:', err); alert('Error: ' + err.message); } } async function removeConnector(id) { if (!confirm('Are you sure you want to remove this connector?')) return; if (!requireAuth()) return; try { const res = await apiFetch('/api/connectors/' + id, { method: 'DELETE' }); if (!res) return; if (res.status === 204) { const card = document.getElementById('connector-' + id); if (card) card.remove(); await loadConnectors(); } else { alert('Failed to remove connector'); } } catch (err) { console.error('Error removing connector:', err); alert('Error: ' + err.message); } } function testConnection() { alert('Test connection feature coming soon'); } // Initialize on page load if (requireAuth()) { loadConnectors(); }