Feature: Admin Outreach — E-Mail-Versand via Hetzner SMTP, Vorlagen, Log, SW by-v567
This commit is contained in:
parent
230455c250
commit
b6258db6bc
6 changed files with 261 additions and 2 deletions
|
|
@ -3,7 +3,7 @@
|
|||
Router, State-Management, Navigation, Initialisierung.
|
||||
============================================================ */
|
||||
|
||||
const APP_VER = '543'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VER = '544'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VERSION = '1.1.4'; // ← semantische Version, wird bei make release gesetzt
|
||||
const IS_STAGING = location.hostname === 'staging.banyaro.app';
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ window.Page_admin = (() => {
|
|||
{ id: 'system', label: 'System', icon: 'gear' },
|
||||
{ id: 'jobs', label: 'Jobs', icon: 'clock' },
|
||||
{ id: 'partner', label: 'Partner', icon: 'handshake' },
|
||||
{ id: 'outreach', label: 'Outreach', icon: 'envelope' },
|
||||
{ id: 'audit', label: 'Audit-Log', icon: 'clipboard-text' },
|
||||
];
|
||||
|
||||
|
|
@ -90,6 +91,7 @@ window.Page_admin = (() => {
|
|||
case 'system': await _renderSystem(el); break;
|
||||
case 'jobs': await _renderJobs(el); break;
|
||||
case 'partner': await _renderPartner(el); break;
|
||||
case 'outreach': await _renderOutreach(el); break;
|
||||
case 'audit': await _renderAudit(el); break;
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
@ -2016,6 +2018,123 @@ window.Page_admin = (() => {
|
|||
});
|
||||
}
|
||||
|
||||
async function _renderOutreach(el) {
|
||||
const [templates, log] = await Promise.all([
|
||||
API.get('/outreach/templates').catch(() => []),
|
||||
API.get('/outreach/log').catch(() => []),
|
||||
]);
|
||||
|
||||
el.innerHTML = `
|
||||
<div style="display:flex;flex-direction:column;gap:var(--space-5)">
|
||||
|
||||
<!-- Compose -->
|
||||
<div class="by-card" style="padding:var(--space-4)">
|
||||
<h3 style="margin:0 0 var(--space-1);font-size:var(--text-base)">E-Mail senden</h3>
|
||||
<p style="font-size:var(--text-xs);color:var(--c-text-muted);margin:0 0 var(--space-4)">
|
||||
Von: <strong>partner@banyaro.app</strong> via Hetzner SMTP
|
||||
</p>
|
||||
|
||||
<form id="adm-outreach-form" style="display:flex;flex-direction:column;gap:var(--space-3)">
|
||||
|
||||
<!-- Vorlage -->
|
||||
<div>
|
||||
<label class="form-label" style="font-size:var(--text-xs)">Vorlage laden</label>
|
||||
<select id="adm-outreach-tpl" class="form-control">
|
||||
<option value="">— Vorlage wählen —</option>
|
||||
${templates.map(t => `<option value="${t.id}">${_esc(t.label)}</option>`).join('')}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Empfänger -->
|
||||
<div>
|
||||
<label class="form-label" style="font-size:var(--text-xs)">
|
||||
Empfänger <span style="color:var(--c-text-muted)">(mehrere mit Komma trennen)</span>
|
||||
</label>
|
||||
<input class="form-control" id="adm-outreach-to" type="text"
|
||||
placeholder="name@example.com, andere@example.com">
|
||||
</div>
|
||||
|
||||
<!-- Betreff -->
|
||||
<div>
|
||||
<label class="form-label" style="font-size:var(--text-xs)">Betreff</label>
|
||||
<input class="form-control" id="adm-outreach-subject" type="text">
|
||||
</div>
|
||||
|
||||
<!-- Text -->
|
||||
<div>
|
||||
<label class="form-label" style="font-size:var(--text-xs)">Text</label>
|
||||
<textarea id="adm-outreach-body" class="form-control" rows="12"
|
||||
style="font-family:monospace;font-size:var(--text-sm);resize:vertical"></textarea>
|
||||
</div>
|
||||
|
||||
<div style="display:flex;gap:var(--space-3);align-items:center">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
${UI.icon('paper-plane-tilt')} Senden
|
||||
</button>
|
||||
<span style="font-size:var(--text-xs);color:var(--c-text-muted)">
|
||||
Hinweis: {name} im Text wird nicht automatisch ersetzt — bitte manuell anpassen.
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Versand-Log -->
|
||||
<div class="by-card" style="padding:var(--space-4)">
|
||||
<h3 style="margin:0 0 var(--space-3);font-size:var(--text-base)">Versand-Log</h3>
|
||||
${log.length === 0
|
||||
? `<p style="color:var(--c-text-muted);font-size:var(--text-sm)">Noch keine E-Mails gesendet.</p>`
|
||||
: `<table style="width:100%;border-collapse:collapse;font-size:var(--text-xs)">
|
||||
<thead>
|
||||
<tr style="border-bottom:1px solid var(--c-border)">
|
||||
<th style="text-align:left;padding:var(--space-2);color:var(--c-text-muted)">Empfänger</th>
|
||||
<th style="text-align:left;padding:var(--space-2);color:var(--c-text-muted)">Betreff</th>
|
||||
<th style="text-align:left;padding:var(--space-2);color:var(--c-text-muted)">Gesendet</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${log.map(l => `
|
||||
<tr style="border-bottom:1px solid var(--c-border)">
|
||||
<td style="padding:var(--space-2)">${_esc(l.recipient)}</td>
|
||||
<td style="padding:var(--space-2);color:var(--c-text-secondary)">${_esc(l.subject)}</td>
|
||||
<td style="padding:var(--space-2);color:var(--c-text-muted)">${l.sent_at?.slice(0,16).replace('T',' ')}</td>
|
||||
</tr>`).join('')}
|
||||
</tbody>
|
||||
</table>`}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Vorlage laden
|
||||
el.querySelector('#adm-outreach-tpl')?.addEventListener('change', e => {
|
||||
const tpl = templates.find(t => t.id === e.target.value);
|
||||
if (!tpl) return;
|
||||
el.querySelector('#adm-outreach-subject').value = tpl.subject;
|
||||
el.querySelector('#adm-outreach-body').value = tpl.body;
|
||||
});
|
||||
|
||||
// Senden
|
||||
el.querySelector('#adm-outreach-form')?.addEventListener('submit', async e => {
|
||||
e.preventDefault();
|
||||
const btn = e.target.querySelector('[type="submit"]');
|
||||
const to = (el.querySelector('#adm-outreach-to').value || '')
|
||||
.split(',').map(s => s.trim()).filter(Boolean);
|
||||
const subject = el.querySelector('#adm-outreach-subject').value.trim();
|
||||
const body = el.querySelector('#adm-outreach-body').value.trim();
|
||||
|
||||
if (!to.length) { UI.toast.warning('Bitte mindestens einen Empfänger eingeben.'); return; }
|
||||
if (!subject) { UI.toast.warning('Betreff fehlt.'); return; }
|
||||
if (!body) { UI.toast.warning('Text fehlt.'); return; }
|
||||
|
||||
await UI.asyncButton(btn, async () => {
|
||||
const res = await API.post('/outreach/send', { to, subject, body });
|
||||
if (res.sent?.length) UI.toast.success(`${res.sent.length} E-Mail(s) gesendet.`);
|
||||
if (res.failed?.length) UI.toast.error(`${res.failed.length} Fehler: ${res.failed.map(f=>f.error).join(', ')}`);
|
||||
await _renderOutreach(el);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function _renderAudit(el) {
|
||||
el.innerHTML = `
|
||||
<div style="display:flex;justify-content:flex-end;margin-bottom:var(--space-3)">
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Offline-Cache + Push Notifications + Tile-Cache
|
||||
============================================================ */
|
||||
|
||||
const CACHE_VERSION = 'by-v566';
|
||||
const CACHE_VERSION = 'by-v567';
|
||||
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
||||
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
||||
const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue