Sent emails log: add read (eye) and delete buttons matching files page style
This commit is contained in:
parent
d31af062ed
commit
7a9a69c86d
2 changed files with 40 additions and 13 deletions
8
app.py
8
app.py
|
|
@ -3574,12 +3574,18 @@ def delete_journal_entry(message_id):
|
|||
@login_required
|
||||
def delete_sent_email(sent_id):
|
||||
"""Löscht einen einzelnen Outbox-Eintrag."""
|
||||
try:
|
||||
con = sqlite3.connect(EMAIL_JOURNAL_DB)
|
||||
con.execute("DELETE FROM sent_emails WHERE id = ?", (sent_id,))
|
||||
con.commit()
|
||||
con.close()
|
||||
# JSON für fetch()-Aufrufe, Redirect-Fallback für direkte Formular-Posts
|
||||
if 'application/json' in request.headers.get('Accept', ''):
|
||||
return jsonify({'success': True})
|
||||
flash('Gesendete Email aus Log gelöscht.', 'success')
|
||||
return redirect(url_for('email_log_view'))
|
||||
return redirect(url_for('emails'))
|
||||
except Exception as e:
|
||||
return jsonify({'success': False, 'message': str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/email-log')
|
||||
|
|
|
|||
|
|
@ -131,12 +131,12 @@
|
|||
<th style="width:160px;">Von Agent</th>
|
||||
<th style="width:70px;">Task</th>
|
||||
<th style="width:60px;">Status</th>
|
||||
<th style="width:50px;"></th>
|
||||
<th style="width:80px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for mail in sent_emails %}
|
||||
<tr>
|
||||
<tr id="sent-row-{{ mail.id }}">
|
||||
<td style="color:var(--text-muted);">{{ mail.id }}</td>
|
||||
<td style="color:var(--text-muted);white-space:nowrap;">{{ mail.sent_at[:16].replace('T',' ') }}</td>
|
||||
<td style="font-weight:500;">{{ mail.to_address }}</td>
|
||||
|
|
@ -153,11 +153,14 @@
|
|||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-outline-secondary"
|
||||
<div class="d-flex gap-1">
|
||||
<button class="btn btn-sm btn-secondary"
|
||||
onclick="showSentEmail({{ mail.id }}, {{ mail.to_address|tojson }}, {{ mail.subject|tojson }}, {{ mail.sent_at|tojson }}, {{ mail.triggered_by|tojson }}, {{ (mail.body or '')|tojson }})"
|
||||
title="Inhalt anzeigen">
|
||||
🔍
|
||||
</button>
|
||||
title="Lesen">👁</button>
|
||||
<button class="btn btn-sm btn-danger"
|
||||
onclick="deleteSentEmail({{ mail.id }})"
|
||||
title="Löschen">✕</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
@ -219,5 +222,23 @@ function showSentEmail(id, to, subject, date, agent, body) {
|
|||
document.getElementById('sentEmailBody').textContent = body || '(kein Inhalt gespeichert)';
|
||||
new bootstrap.Modal(document.getElementById('sentEmailModal')).show();
|
||||
}
|
||||
|
||||
function deleteSentEmail(id) {
|
||||
if (!confirm('Eintrag #' + id + ' aus dem Log löschen?')) return;
|
||||
fetch('/emails/sent/' + id + '/delete', {
|
||||
method: 'POST',
|
||||
headers: {'Accept': 'application/json'}
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(d => {
|
||||
if (d.success) {
|
||||
const row = document.getElementById('sent-row-' + id);
|
||||
if (row) row.remove();
|
||||
} else {
|
||||
alert('Fehler: ' + d.message);
|
||||
}
|
||||
})
|
||||
.catch(() => alert('Netzwerkfehler.'));
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue