testversand

This commit is contained in:
2026-02-24 01:33:52 +01:00
parent 6a8d5720c5
commit 6f7ac43a0b
5 changed files with 102 additions and 4 deletions

View File

@@ -949,13 +949,15 @@ export function initEditor() {
    let html = '<option value="">Standard (System)</option>';
    smtpProfileOptions.forEach(opt => {
      const label = opt.label || opt.smtp_host || 'Profil';
      html += `<option value="${opt.id}">${escapeHtml(label)}</option>`;
      const suffix = opt.is_default ? ' (Standard)' : '';
      html += `<option value="${opt.id}">${escapeHtml(label + suffix)}</option>`;
    });
    sendSmtpProfile.innerHTML = html;
    if (previous && smtpProfileOptions.some(opt => String(opt.id) === previous)) {
      sendSmtpProfile.value = previous;
    } else {
      sendSmtpProfile.value = '';
      const def = smtpProfileOptions.find(opt => opt.is_default);
      sendSmtpProfile.value = def ? String(def.id) : '';
    }
    if (sendSmtpProfileHint) {
      sendSmtpProfileHint.classList.toggle('hidden', smtpProfileOptions.length > 0);

View File

@@ -921,7 +921,7 @@ function renderSmtpProfileList() {
const sender = profile.from_email || '—';
return `
<tr>
<td>${escapeHtml(label)}</td>
<td>${escapeHtml(label)}${profile.is_default ? ' <span class="text-xs text-slate-500">(Standard)</span>' : ''}</td>
<td>${escapeHtml(host)}</td>
<td>${escapeHtml(user)}</td>
<td>${escapeHtml(sender)}</td>
@@ -930,6 +930,7 @@ function renderSmtpProfileList() {
<button class="btn" data-smtp-action="edit" data-smtp-id="${profile.id}">Bearbeiten</button>
<button class="btn" data-smtp-action="copy" data-smtp-id="${profile.id}">Kopieren</button>
<button class="btn btn-danger" data-smtp-action="delete" data-smtp-id="${profile.id}">Löschen</button>
${profile.is_default ? '' : `<button class="btn" data-smtp-action="set-default" data-smtp-id="${profile.id}">Standard</button>`}
</td>
</tr>`;
}).join('');
@@ -946,6 +947,8 @@ function handleSmtpProfileTableClick(ev) {
openSmtpProfileForm(profile);
} else if (action === 'test') {
runSmtpProfileTest(profile.id);
} else if (action === 'set-default') {
setDefaultSmtpProfile(profile.id);
} else if (action === 'copy') {
if (confirm(`Versandprofil "${profile.label || profile.smtp_host}" kopieren?`)) {
copySmtpProfile(id);
@@ -971,6 +974,7 @@ function openSmtpProfileForm(profile = null) {
smtpProfileForm.from_email.value = profile?.from_email || '';
smtpProfileForm.from_name.value = profile?.from_name || '';
smtpProfileForm.reply_to.value = profile?.reply_to || '';
smtpProfileForm.is_default.checked = !!profile?.is_default;
if (smtpProfileForm.smtp_pass_clear) smtpProfileForm.smtp_pass_clear.checked = false;
}
@@ -996,6 +1000,7 @@ async function submitSmtpProfileForm(ev) {
from_name: smtpProfileForm.from_name.value.trim(),
reply_to: smtpProfileForm.reply_to.value.trim(),
smtp_pass_clear: smtpProfileForm.smtp_pass_clear?.checked ? 1 : 0,
is_default: smtpProfileForm.is_default?.checked ? 1 : 0,
};
if (!payload.smtp_host) {
toast('Bitte einen SMTP-Server angeben', false);
@@ -1046,6 +1051,17 @@ async function runSmtpProfileTest(profileId) {
}
}
async function setDefaultSmtpProfile(profileId) {
try {
const res = await apiAction('account.smtp_profiles.save', { method: 'POST', data: { profile_id: profileId, is_default: 1 } });
if (!res?.ok) throw new Error(res?.error || 'Standard konnte nicht gesetzt werden');
await loadSmtpProfiles();
toast('Standard-Testprofil gesetzt', true);
} catch (err) {
toast(err.message || 'Standard konnte nicht gesetzt werden', false);
}
}
function escapeHtml(str) {
return String(str || '')
.replace(/&/g, '&amp;')