Finalize mail settings admin UI and Mailrise compatibility

This commit is contained in:
ske087
2025-07-26 18:50:42 +03:00
parent 2a5b5ee468
commit 377e379883
23 changed files with 629 additions and 170 deletions

View File

@@ -173,6 +173,11 @@
<i class="fas fa-chart-bar"></i> Analytics
</a>
</li>
<li class="nav-item">
<a class="nav-link {{ 'active' if request.endpoint == 'admin.mail_settings' }}" href="{{ url_for('admin.mail_settings') }}">
<i class="fas fa-envelope"></i> Mail Server Settings
</a>
</li>
</ul>
<div class="sidebar-heading">

View File

@@ -0,0 +1,66 @@
{% extends 'admin/base.html' %}
{% block admin_content %}
<h2>Mail Server Settings</h2>
<form method="post">
<div class="form-group">
<label for="enabled">Enable Email Sending</label>
<input type="checkbox" id="enabled" name="enabled" value="1" {% if settings and settings.enabled %}checked{% endif %}>
</div>
<div class="form-group">
<label for="provider">Provider</label>
<select id="provider" name="provider" class="form-control">
<option value="smtp" {% if settings and settings.provider == 'smtp' %}selected{% endif %}>SMTP</option>
<option value="mailrise" {% if settings and settings.provider == 'mailrise' %}selected{% endif %}>Mailrise</option>
</select>
</div>
<div class="form-group">
<label for="server">Server</label>
<input type="text" id="server" name="server" class="form-control" value="{{ settings.server if settings else '' }}">
</div>
<div class="form-group">
<label for="port">Port</label>
<input type="number" id="port" name="port" class="form-control" value="{{ settings.port if settings else '' }}">
</div>
<div class="form-group">
<label for="use_tls">Use TLS</label>
<input type="checkbox" id="use_tls" name="use_tls" value="1" {% if settings and settings.use_tls %}checked{% endif %}>
</div>
<div class="form-group">
<label for="username">Username</label>
<input type="text" id="username" name="username" class="form-control" value="{{ settings.username if settings else '' }}">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" class="form-control" value="{{ settings.password if settings else '' }}">
</div>
<div class="form-group">
<label for="default_sender">Default Sender</label>
<input type="text" id="default_sender" name="default_sender" class="form-control" value="{{ settings.default_sender if settings else '' }}">
</div>
<button type="submit" class="btn btn-primary">Save Settings</button>
</form>
<hr>
<h3>Sent Emails Log</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Date</th>
<th>Recipient</th>
<th>Subject</th>
<th>Status</th>
<th>Error</th>
</tr>
</thead>
<tbody>
{% for email in sent_emails %}
<tr>
<td>{{ email.sent_at.strftime('%Y-%m-%d %H:%M') }}</td>
<td>{{ email.recipient }}</td>
<td>{{ email.subject }}</td>
<td>{{ email.status }}</td>
<td>{{ email.error or '' }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@@ -17,6 +17,19 @@
<div class="row">
<!-- User Information -->
<div class="col-lg-4">
<!-- Admin: Reset Password Card -->
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-danger">Admin: Reset Password</h6>
</div>
<div class="card-body">
<form method="POST" action="{{ url_for('admin.reset_user_password', user_id=user.id) }}">
<button type="submit" class="btn btn-warning w-100" onclick="return confirm('Send password reset email to this user?')">
<i class="fas fa-envelope"></i> Send Password Reset Email
</button>
</form>
</div>
</div>
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">User Information</h6>