diff --git a/app.py b/app.py index b9e41d8..0ffbba1 100644 --- a/app.py +++ b/app.py @@ -3509,11 +3509,21 @@ def emails(): email_config_valid = bool(EMAIL_CONFIG['email_address'] and EMAIL_CONFIG['email_password']) emails_list = get_emails() if email_config_valid else [] - - return render_template('emails.html', + + # Gesendete Emails aus DB laden + con = sqlite3.connect(EMAIL_JOURNAL_DB) + con.row_factory = sqlite3.Row + sent_emails_list = con.execute( + "SELECT * FROM sent_emails ORDER BY sent_at DESC LIMIT 200" + ).fetchall() + sent_emails_list = [dict(r) for r in sent_emails_list] + con.close() + + return render_template('emails.html', emails=emails_list, email_config_valid=email_config_valid, - current_email=EMAIL_CONFIG['email_address']) + current_email=EMAIL_CONFIG['email_address'], + sent_emails=sent_emails_list) @app.route('/emails/') diff --git a/templates/emails.html b/templates/emails.html index 08030ef..5277253 100644 --- a/templates/emails.html +++ b/templates/emails.html @@ -110,17 +110,87 @@ -
+ +
-
-
📋 Email Journal / Log
- Vollständiges Log +
+
Gesendete Emails
+ {{ sent_emails|length }} Einträge
-
-

- Das vollständige Email-Journal zeigt alle verarbeiteten Emails mit Details zu Status, Agent-Zuweisungen und Zeitstempeln. -

+
+ {% if sent_emails %} +
+ + + + + + + + + + + + + + + {% for mail in sent_emails %} + + + + + + + + + + + {% endfor %} + +
#ZeitpunktAnBetreffVon AgentTaskStatus
{{ mail.id }}{{ mail.sent_at[:16].replace('T',' ') }}{{ mail.to_address }}{{ mail.subject }}{{ mail.triggered_by }}{% if mail.task_id %}#{{ mail.task_id }}{% endif %} + {% if mail.status == 'sent' %} + gesendet + {% elif mail.status == 'error' %} + Fehler + {% else %} + {{ mail.status }} + {% endif %} + + +
+
+ {% else %} +
Noch keine Emails gesendet.
+ {% endif %} +
+
+
+
+ + +