This commit is contained in:
@@ -339,6 +339,24 @@ $('aiProviderForm').addEventListener('submit',saveAiProviderSettings);$('aiProvi
|
||||
if (badge) badge.textContent = 'Public and operator-controlled sources';
|
||||
if (copy) copy.textContent = 'Register bounded public sources or operator-controlled imports. New sources start disabled and must be tested before use.';
|
||||
}
|
||||
async function configureSourceFromUi(source, button) {
|
||||
const type = sourceType(source);
|
||||
const label = type === 'public_website' ? 'Enter a public website URL' : type === 'dns' ? 'Enter a domain for DNS lookup' : type === 'rdap' ? 'Enter a domain for RDAP lookup' : type === 'ct_logs' ? 'Enter a domain for certificate-transparency lookup' : 'Enter source configuration';
|
||||
const value = window.prompt(label + ':');
|
||||
if (!value || !value.trim()) return;
|
||||
const text = value.trim();
|
||||
const config = type === 'public_website' ? {urls:[text]} : type === 'dns' ? {domains:[text]} : {domain:text};
|
||||
button.disabled = true;
|
||||
try { await jsonRequest(`/api/v1/sources/${encodeURIComponent(source.id)}`, {method:'PATCH', headers:{'Content-Type':'application/json'}, body:JSON.stringify({config})}); sourceMessage('Source configuration saved. Test it before enabling.'); await loadSources(); }
|
||||
catch (error) { if (error.message !== 'unauthorized') sourceMessage(error.message || 'Unable to configure source.', true); }
|
||||
finally { button.disabled = false; }
|
||||
}
|
||||
$('sourcesList')?.addEventListener('click', event => {
|
||||
const actionButton = event.target.closest?.('[data-source-action="toggle"]');
|
||||
if (!actionButton) return;
|
||||
const source = sources.find(item => String(item.id) === String(actionButton.dataset.sourceId));
|
||||
if (source && !source.configured && source.available) { event.preventDefault(); event.stopImmediatePropagation(); configureSourceFromUi(source, actionButton); }
|
||||
}, true);
|
||||
document.querySelectorAll('.sidebar nav a, [data-scroll]').forEach(link => link.addEventListener('click', event => { const target = (link.getAttribute('href') || link.dataset.scroll || '').replace(/^#/, ''); const view = viewMap[target]; if (view) { event.preventDefault(); activateView(view); document.querySelector('.sidebar')?.classList.remove('open'); } }));
|
||||
bootstrap();
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user