bak
This commit is contained in:
1 parent
5aa3abc860
commit
5f9db690a4
24 files changed
+1447
-597
No files matched your search
@@ -32,7 +32,8 @@ overlay?.querySelectorAll('.settings-tab').forEach(tab => {
|
||||
const panel = tab.dataset.tab;
|
||||
overlay.querySelectorAll('[id^="settings-panel-"]').forEach(p => p.classList.add('hidden'));
|
||||
$(`settings-panel-${panel}`)?.classList.remove('hidden');
|
||||
if (panel === 'sync') window._loadCaldavSettings?.();
|
||||
if (panel === 'caldav') { window._loadCaldavSettings?.(); }
|
||||
if (panel === 'relay') { window._loadRelaySettings?.(); }
|
||||
if (panel === 'notifications') renderNotifSettings();
|
||||
if (panel === 'behavior') initBehaviorSettings();
|
||||
});
|
||||
@@ -46,9 +47,37 @@ function updateStats() {
|
||||
const st = $('stats-tags'); if (st) st.textContent = tags.size;
|
||||
}
|
||||
|
||||
// Vault key
|
||||
$('settings-vault-save')?.addEventListener('click', async () => {
|
||||
const key = $('settings-vault-key')?.value;
|
||||
const status = $('settings-vault-status');
|
||||
if (!key || key.length < 8) { if (status) { status.textContent = 'min 8 characters'; status.style.color = 'var(--t-danger)'; } return; }
|
||||
const res = await fetch('api/auth/vault-key', {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': getCsrf() },
|
||||
body: JSON.stringify({ key }),
|
||||
}).then(r => r.json()).catch(() => ({ error: 'failed' }));
|
||||
if (res.ok) {
|
||||
if (status) { status.textContent = res.rekey ? 'saved — notes will re-encrypt on next sync' : 'saved'; status.style.color = 'var(--t-accent)'; }
|
||||
$('settings-vault-key').value = '';
|
||||
if (res.rekey) window._triggerSync?.();
|
||||
} else {
|
||||
if (status) { status.textContent = res.error || 'failed'; status.style.color = 'var(--t-danger)'; }
|
||||
}
|
||||
});
|
||||
|
||||
async function loadVaultStatus() {
|
||||
const res = await api('api/auth/vault-key');
|
||||
if (!res) return;
|
||||
const status = $('settings-vault-status');
|
||||
const input = $('settings-vault-key');
|
||||
if (input) input.placeholder = res.has_key ? '(set — enter new to change)' : 'enter vault key';
|
||||
if (status && res.has_key) { status.textContent = 'vault key is set'; status.style.color = 'var(--t-dim)'; }
|
||||
}
|
||||
|
||||
$('settings-btn')?.addEventListener('click', () => {
|
||||
renderThemes();
|
||||
updateStats();
|
||||
loadVaultStatus();
|
||||
overlay?.classList.add('open');
|
||||
});
|
||||
$('settings-close')?.addEventListener('click', () => overlay?.classList.remove('open'));
|
||||
|
||||
Reference in new issue
Block a user