Yhdistä IMAP/SMTP-asetukset vierekkäin + "Käytä samoja tunnuksia"
Mailbox-lomake näyttää nyt Saapuva (IMAP) ja Lähtevä (SMTP) vierekkäin. SMTP-puolella on "Käytä samoja tunnuksia kuin saapuvassa" -checkbox (oletuksena päällä), joka piilottaa SMTP-kentät ja kopioi IMAP-asetukset tallennettaessa. Lähettäjän sähköposti ja nimi omana osionaan alhaalla. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
41
script.js
41
script.js
@@ -2532,9 +2532,24 @@ function showMailboxForm(mb = null) {
|
||||
document.getElementById('mailbox-form-smtp-user').value = mb ? (mb.smtp_user || '') : '';
|
||||
document.getElementById('mailbox-form-smtp-pass').value = mb ? (mb.smtp_password || '') : '';
|
||||
document.getElementById('mailbox-form-smtp-encryption').value = mb ? (mb.smtp_encryption || 'tls') : 'tls';
|
||||
// "Käytä samoja tunnuksia" — oletuksena päällä uudelle, olemassa olevalle tarkistetaan
|
||||
const sameCheck = document.getElementById('mailbox-form-smtp-same');
|
||||
if (mb) {
|
||||
// Jos SMTP-host on tyhjä tai sama kuin IMAP -> samoja tunnuksia
|
||||
const smtpIsSame = !mb.smtp_host || mb.smtp_host === mb.imap_host;
|
||||
sameCheck.checked = smtpIsSame;
|
||||
} else {
|
||||
sameCheck.checked = true;
|
||||
}
|
||||
toggleSmtpFields();
|
||||
document.getElementById('mailbox-form-container').style.display = '';
|
||||
}
|
||||
|
||||
function toggleSmtpFields() {
|
||||
const same = document.getElementById('mailbox-form-smtp-same').checked;
|
||||
document.getElementById('smtp-custom-fields').style.display = same ? 'none' : '';
|
||||
}
|
||||
|
||||
function editMailbox(id) {
|
||||
const mb = mailboxesData.find(m => m.id === id);
|
||||
if (mb) showMailboxForm(mb);
|
||||
@@ -2548,22 +2563,30 @@ async function deleteMailbox(id, nimi) {
|
||||
} catch (e) { alert(e.message); }
|
||||
}
|
||||
|
||||
// SMTP "Käytä samoja tunnuksia" -checkbox toggle
|
||||
document.getElementById('mailbox-form-smtp-same').addEventListener('change', toggleSmtpFields);
|
||||
|
||||
document.getElementById('btn-save-mailbox').addEventListener('click', async () => {
|
||||
const useSame = document.getElementById('mailbox-form-smtp-same').checked;
|
||||
const imapHost = document.getElementById('mailbox-form-host').value;
|
||||
const imapUser = document.getElementById('mailbox-form-user').value;
|
||||
const imapPass = document.getElementById('mailbox-form-password').value;
|
||||
const imapEnc = document.getElementById('mailbox-form-encryption').value;
|
||||
const data = {
|
||||
id: document.getElementById('mailbox-form-id').value || undefined,
|
||||
nimi: document.getElementById('mailbox-form-nimi').value,
|
||||
imap_host: document.getElementById('mailbox-form-host').value,
|
||||
imap_host: imapHost,
|
||||
imap_port: parseInt(document.getElementById('mailbox-form-port').value) || 993,
|
||||
imap_user: document.getElementById('mailbox-form-user').value,
|
||||
imap_password: document.getElementById('mailbox-form-password').value,
|
||||
imap_encryption: document.getElementById('mailbox-form-encryption').value,
|
||||
imap_user: imapUser,
|
||||
imap_password: imapPass,
|
||||
imap_encryption: imapEnc,
|
||||
smtp_from_email: document.getElementById('mailbox-form-smtp-email').value,
|
||||
smtp_from_name: document.getElementById('mailbox-form-smtp-name').value,
|
||||
smtp_host: document.getElementById('mailbox-form-smtp-host').value,
|
||||
smtp_port: parseInt(document.getElementById('mailbox-form-smtp-port').value) || 587,
|
||||
smtp_user: document.getElementById('mailbox-form-smtp-user').value,
|
||||
smtp_password: document.getElementById('mailbox-form-smtp-pass').value,
|
||||
smtp_encryption: document.getElementById('mailbox-form-smtp-encryption').value,
|
||||
smtp_host: useSame ? imapHost : document.getElementById('mailbox-form-smtp-host').value,
|
||||
smtp_port: useSame ? 587 : (parseInt(document.getElementById('mailbox-form-smtp-port').value) || 587),
|
||||
smtp_user: useSame ? imapUser : document.getElementById('mailbox-form-smtp-user').value,
|
||||
smtp_password: useSame ? imapPass : document.getElementById('mailbox-form-smtp-pass').value,
|
||||
smtp_encryption: useSame ? 'tls' : document.getElementById('mailbox-form-smtp-encryption').value,
|
||||
aktiivinen: true,
|
||||
};
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user