feat: Add email settings management and templates functionality
- Implemented email settings configuration in the admin panel, allowing for SMTP settings and notification preferences. - Created a new template for email settings with fields for SMTP host, port, username, password, sender address, and recipients. - Added JavaScript functionality to handle loading, saving, and validating email settings. - Introduced email templates management, enabling the listing, editing, and saving of email templates. - Updated navigation to include links to email settings and templates. - Added tests for email settings and templates to ensure proper functionality and validation.
This commit is contained in:
@@ -1,53 +1,43 @@
|
||||
<nav class="nav">
|
||||
<!--
|
||||
admin_dashboard.html
|
||||
admin_newsletter.html
|
||||
admin_newsletter_create.html
|
||||
admin_settings.html
|
||||
admin_submissions.html
|
||||
admin_embeds.html
|
||||
|
||||
newsletter_manage.html
|
||||
unsubscribe_confirmation.html
|
||||
-->
|
||||
<a
|
||||
href="/admin/"
|
||||
style="color: #007bff; text-decoration: none; margin-right: 20px"
|
||||
href="{{ url_for('admin.dashboard') }}"
|
||||
class="nav-link{% if request.path in ['/admin', '/admin/'] %} active{% endif %}"
|
||||
>Dashboard</a
|
||||
>
|
||||
<a
|
||||
href="/admin/submissions"
|
||||
style="color: #007bff; text-decoration: none; margin-right: 20px"
|
||||
href="{{ url_for('admin.submissions') }}"
|
||||
class="nav-link{% if request.path.startswith('/admin/submissions') %} active{% endif %}"
|
||||
>Contact Submissions</a
|
||||
>
|
||||
<a
|
||||
href="/admin/newsletter"
|
||||
style="color: #007bff; text-decoration: none; margin-right: 20px"
|
||||
href="{{ url_for('admin.newsletter_subscribers') }}"
|
||||
class="nav-link{% if request.path == '/admin/newsletter' %} active{% endif %}"
|
||||
>Subscribers</a
|
||||
>
|
||||
<a
|
||||
href="/admin/newsletter/create"
|
||||
style="color: #007bff; text-decoration: none; margin-right: 20px"
|
||||
href="{{ url_for('admin.newsletter_create') }}"
|
||||
class="nav-link{% if request.path.startswith('/admin/newsletter/create') %} active{% endif %}"
|
||||
>Create Newsletter</a
|
||||
>
|
||||
<a
|
||||
href="/admin/embeds"
|
||||
style="color: #007bff; text-decoration: none; margin-right: 20px"
|
||||
href="{{ url_for('admin.embeds') }}"
|
||||
class="nav-link{% if request.path.startswith('/admin/embeds') %} active{% endif %}"
|
||||
>Embeds</a
|
||||
>
|
||||
<a
|
||||
href="/admin/email-templates"
|
||||
style="color: #007bff; text-decoration: none; margin-right: 20px"
|
||||
href="{{ url_for('admin.email_settings_page') }}"
|
||||
class="nav-link{% if request.path.startswith('/admin/email-settings') %} active{% endif %}"
|
||||
>Email Settings</a
|
||||
>
|
||||
<a
|
||||
href="{{ url_for('admin.email_templates') }}"
|
||||
class="nav-link{% if request.path.startswith('/admin/email-templates') %} active{% endif %}"
|
||||
>Email Templates</a
|
||||
>
|
||||
<a
|
||||
href="/admin/settings"
|
||||
style="color: #007bff; text-decoration: none; margin-right: 20px"
|
||||
href="{{ url_for('admin.settings_page') }}"
|
||||
class="nav-link{% if request.path.startswith('/admin/settings') and not request.path.startswith('/admin/email-settings') %} active{% endif %}"
|
||||
>Settings</a
|
||||
>
|
||||
<a
|
||||
href="{{ url_for('auth.logout') }}"
|
||||
style="color: #007bff; text-decoration: none"
|
||||
>Logout</a
|
||||
>
|
||||
<a href="{{ url_for('auth.logout') }}" class="nav-link">Logout</a>
|
||||
</nav>
|
||||
|
||||
81
templates/admin/admin_email_settings.html
Normal file
81
templates/admin/admin_email_settings.html
Normal file
@@ -0,0 +1,81 @@
|
||||
{% extends "_base.html" %}
|
||||
{% block title %}Email Settings{% endblock %}
|
||||
{% block heading %}Email Notification Settings{% endblock %}
|
||||
{% block extra_styles %}
|
||||
<link rel="stylesheet" href="/static/css/admin.css" />
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="form-section">
|
||||
<h2>SMTP Configuration</h2>
|
||||
<p>
|
||||
Adjust the SMTP server configuration and notification preferences used for
|
||||
contact form alerts and newsletter messaging. Values saved here override the
|
||||
environment defaults documented in <code>.env</code>.
|
||||
</p>
|
||||
|
||||
<div id="message"></div>
|
||||
|
||||
<form id="emailSettingsForm" class="email-settings-form">
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="smtpHost">SMTP Host</label>
|
||||
<input type="text" id="smtpHost" name="smtp_host" autocomplete="off" required />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="smtpPort">SMTP Port</label>
|
||||
<input type="number" id="smtpPort" name="smtp_port" min="1" max="65535" required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="smtpUsername">SMTP Username</label>
|
||||
<input type="text" id="smtpUsername" name="smtp_username" autocomplete="username" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="smtpPassword">SMTP Password</label>
|
||||
<input type="password" id="smtpPassword" name="smtp_password" autocomplete="current-password" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="smtpSender">Sender Address</label>
|
||||
<input type="email" id="smtpSender" name="smtp_sender" autocomplete="email" required />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="smtpRecipients">Notification Recipients</label>
|
||||
<textarea id="smtpRecipients" name="smtp_recipients" rows="3" placeholder="comma-separated emails"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label class="checkbox-inline">
|
||||
<input type="checkbox" id="smtpUseTls" name="smtp_use_tls" />
|
||||
Use TLS when sending mail
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="checkbox-inline">
|
||||
<input type="checkbox" id="notifyContactForm" name="notify_contact_form" />
|
||||
Email notifications for new contact submissions
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="checkbox-inline">
|
||||
<input type="checkbox" id="notifyNewsletter" name="notify_newsletter_signups" />
|
||||
Confirmation emails for newsletter signups
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="margin-top: 20px;">
|
||||
<button type="submit" class="btn btn-primary">Save Email Settings</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block extra_scripts %}
|
||||
<script src="/static/js/admin.js"></script>
|
||||
{% endblock %}
|
||||
@@ -1,20 +1,41 @@
|
||||
{% extends "_base.html" %} {% block title %}Email Templates{% endblock %} {%
|
||||
block heading %}Email Templates{% endblock %} {% block extra_styles %}
|
||||
<link rel="stylesheet" href="/static/css/admin.css" /> {% endblock %} {% block
|
||||
content %}
|
||||
<div class="settings-management">
|
||||
<h2>Newsletter Confirmation Template</h2>
|
||||
<p>Edit the HTML template used for the newsletter confirmation email.</p>
|
||||
<div id="message"></div>
|
||||
<form id="templateForm">
|
||||
<div class="form-group">
|
||||
<label for="newsletterTemplate">Template HTML</label>
|
||||
<textarea id="newsletterTemplate" rows="15" cols="80"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button class="btn btn-primary" type="submit">Save Template</button>
|
||||
</div>
|
||||
</form>
|
||||
<link rel="stylesheet" href="/static/css/admin.css" />
|
||||
{% endblock %} {% block content %}
|
||||
<div class="email-templates-container" id="emailTemplatesPage">
|
||||
<aside
|
||||
class="email-templates-list"
|
||||
id="emailTemplatesList"
|
||||
aria-label="Available email templates"
|
||||
></aside>
|
||||
|
||||
<section class="email-template-editor">
|
||||
<div id="templateMessage" class="message" style="display: none"></div>
|
||||
<h2 id="templateTitle">Select a template to start editing</h2>
|
||||
<p id="templateDescription" class="template-description"></p>
|
||||
|
||||
<form id="emailTemplateForm">
|
||||
<div class="form-group">
|
||||
<label for="templateContent">Template HTML</label>
|
||||
<textarea
|
||||
id="templateContent"
|
||||
rows="20"
|
||||
class="template-content"
|
||||
disabled
|
||||
></textarea>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
type="submit"
|
||||
id="saveTemplateButton"
|
||||
disabled
|
||||
>
|
||||
Save Template
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
{% endblock %} {% block extra_scripts %}
|
||||
<script src="/static/js/admin.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user