mail setup
This commit is contained in:
@@ -24,9 +24,11 @@ export function initEditor() {
|
||||
const sendSubject = document.getElementById('send_subject');
|
||||
const sendInfo = document.getElementById('send_template_info');
|
||||
const btnCancelSend= document.getElementById('btn-cancel-send');
|
||||
const btnSendNow = document.getElementById('btn-send-now');
|
||||
const btnSendNow = document.getElementById('btn-send-now');
|
||||
const sendSender = document.getElementById('send_sender');
|
||||
const sendSenderHint = document.getElementById('send_sender_hint');
|
||||
const sendSmtpProfile = document.getElementById('send_smtp_profile');
|
||||
const sendSmtpProfileHint = document.getElementById('send_smtp_profile_hint');
|
||||
const prevFrame = document.getElementById('previewFrame');
|
||||
const btnPrevClose = document.getElementById('btn-close-preview');
|
||||
const unsavedDialog = document.getElementById('unsavedDialog');
|
||||
@@ -46,6 +48,8 @@ export function initEditor() {
|
||||
let reqToken = 0; // steigender Token pro Öffnen -> ignoriert verspätete Events
|
||||
let senderOptions = [];
|
||||
let senderLoadPromise = null;
|
||||
let smtpProfileOptions = [];
|
||||
let smtpProfileLoadPromise = null;
|
||||
let currentEditorType = 'grapesjs';
|
||||
let versionItems = [];
|
||||
let savedSnapshot = '';
|
||||
@@ -902,6 +906,24 @@ export function initEditor() {
|
||||
return senderLoadPromise;
|
||||
}
|
||||
|
||||
async function loadSmtpProfileOptions(force = false) {
|
||||
if (!sendSmtpProfile) return;
|
||||
if (smtpProfileLoadPromise && !force) return smtpProfileLoadPromise;
|
||||
smtpProfileLoadPromise = apiAction('account.smtp_profiles.list', { method: 'GET' })
|
||||
.then(res => {
|
||||
smtpProfileOptions = res?.items || [];
|
||||
renderSmtpProfileOptions();
|
||||
})
|
||||
.catch(() => {
|
||||
smtpProfileOptions = [];
|
||||
renderSmtpProfileOptions();
|
||||
})
|
||||
.finally(() => {
|
||||
smtpProfileLoadPromise = null;
|
||||
});
|
||||
return smtpProfileLoadPromise;
|
||||
}
|
||||
|
||||
function renderSenderOptions() {
|
||||
if (!sendSender) return;
|
||||
const previous = sendSender.value;
|
||||
@@ -921,6 +943,25 @@ export function initEditor() {
|
||||
}
|
||||
}
|
||||
|
||||
function renderSmtpProfileOptions() {
|
||||
if (!sendSmtpProfile) return;
|
||||
const previous = sendSmtpProfile.value;
|
||||
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>`;
|
||||
});
|
||||
sendSmtpProfile.innerHTML = html;
|
||||
if (previous && smtpProfileOptions.some(opt => String(opt.id) === previous)) {
|
||||
sendSmtpProfile.value = previous;
|
||||
} else {
|
||||
sendSmtpProfile.value = '';
|
||||
}
|
||||
if (sendSmtpProfileHint) {
|
||||
sendSmtpProfileHint.classList.toggle('hidden', smtpProfileOptions.length > 0);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Initialen HTML-Inhalt in Editor pushen (mit Token/Race-Schutz) ----------
|
||||
async function pushInitialHtmlToEditor({ mode, html, snippets, ref, token, hasJson, json }) {
|
||||
if (token !== reqToken) return; // veraltete Anfrage ignorieren
|
||||
@@ -1266,11 +1307,13 @@ export function initEditor() {
|
||||
if (sendSubject) sendSubject.value = ctx?.subject || 'Testversand';
|
||||
if (sendTo) sendTo.value = ctx?.to || '';
|
||||
await loadSenderOptions(true);
|
||||
await loadSmtpProfileOptions(true);
|
||||
sendDlg?.showModal?.();
|
||||
}
|
||||
function closeSend(){
|
||||
sendDlg?.close?.();
|
||||
if (sendSender) sendSender.value = '';
|
||||
if (sendSmtpProfile) sendSmtpProfile.value = '';
|
||||
}
|
||||
|
||||
async function doSend(ev){
|
||||
@@ -1291,6 +1334,9 @@ export function initEditor() {
|
||||
if (sendSender && sendSender.value) {
|
||||
payload.sender_id = Number(sendSender.value);
|
||||
}
|
||||
if (sendSmtpProfile && sendSmtpProfile.value) {
|
||||
payload.smtp_profile_id = Number(sendSmtpProfile.value);
|
||||
}
|
||||
const r = await apiAction('templates.test_send', { method:'POST', data: payload });
|
||||
if(r?.ok){ toast("Testversand ausgelöst"); closeSend(); } else { toast("Senden fehlgeschlagen", false); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user