Better fill codes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{% macro mails_tab(mails, csrf_token, users, total_pages, current_page) %}
|
||||
{% macro mails_tab(mails, csrf_token, users, total_pages, current_page, email_templates, status='', date_range='7d', user_id='', template_id='') %}
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
@@ -6,20 +6,26 @@
|
||||
<div class="d-flex gap-2">
|
||||
<select class="form-select form-select-sm" id="statusFilter" onchange="updateFilters()">
|
||||
<option value="">All Statuses</option>
|
||||
<option value="pending">Pending</option>
|
||||
<option value="sent">Sent</option>
|
||||
<option value="failed">Failed</option>
|
||||
<option value="pending" {% if status == 'pending' %}selected{% endif %}>Pending</option>
|
||||
<option value="sent" {% if status == 'sent' %}selected{% endif %}>Sent</option>
|
||||
<option value="failed" {% if status == 'failed' %}selected{% endif %}>Failed</option>
|
||||
</select>
|
||||
<select class="form-select form-select-sm" id="dateRangeFilter" onchange="updateFilters()">
|
||||
<option value="24h">Last 24 Hours</option>
|
||||
<option value="7d" selected>Last 7 Days</option>
|
||||
<option value="30d">Last 30 Days</option>
|
||||
<option value="all">All Time</option>
|
||||
<option value="24h" {% if date_range == '24h' %}selected{% endif %}>Last 24 Hours</option>
|
||||
<option value="7d" {% if date_range == '7d' %}selected{% endif %}>Last 7 Days</option>
|
||||
<option value="30d" {% if date_range == '30d' %}selected{% endif %}>Last 30 Days</option>
|
||||
<option value="all" {% if date_range == 'all' %}selected{% endif %}>All Time</option>
|
||||
</select>
|
||||
<select class="form-select form-select-sm" id="userFilter" onchange="updateFilters()">
|
||||
<option value="">All Recipients</option>
|
||||
{% for user in users %}
|
||||
<option value="{{ user.id }}">{{ user.username }} {{ user.last_name }}</option>
|
||||
<option value="{{ user.id }}" {% if user_id|int == user.id %}selected{% endif %}>{{ user.username }} {{ user.last_name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<select class="form-select form-select-sm" id="templateFilter" onchange="updateFilters()">
|
||||
<option value="">All Templates</option>
|
||||
{% for template in email_templates %}
|
||||
<option value="{{ template.id }}" {% if template_id|int == template.id %}selected{% endif %}>{{ template.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button class="btn btn-secondary btn-sm" onclick="clearFilters()">
|
||||
@@ -190,16 +196,18 @@ function downloadMailLog() {
|
||||
const status = document.getElementById('statusFilter').value;
|
||||
const dateRange = document.getElementById('dateRangeFilter').value;
|
||||
const userId = document.getElementById('userFilter').value;
|
||||
const templateId = document.getElementById('templateFilter').value;
|
||||
|
||||
window.location.href = `/settings/mails/download?status=${status}&date_range=${dateRange}&user_id=${userId}`;
|
||||
window.location.href = `/settings/mails/download?status=${status}&date_range=${dateRange}&user_id=${userId}&template_id=${templateId}`;
|
||||
}
|
||||
|
||||
function updateFilters() {
|
||||
const status = document.getElementById('statusFilter').value;
|
||||
const dateRange = document.getElementById('dateRangeFilter').value;
|
||||
const userId = document.getElementById('userFilter').value;
|
||||
const templateId = document.getElementById('templateFilter').value;
|
||||
|
||||
window.location.href = `/settings/mails?status=${status}&date_range=${dateRange}&user_id=${userId}`;
|
||||
window.location.href = `/settings/mails?status=${status}&date_range=${dateRange}&user_id=${userId}&template_id=${templateId}`;
|
||||
}
|
||||
|
||||
function clearFilters() {
|
||||
@@ -210,8 +218,9 @@ function changePage(page) {
|
||||
const status = document.getElementById('statusFilter').value;
|
||||
const dateRange = document.getElementById('dateRangeFilter').value;
|
||||
const userId = document.getElementById('userFilter').value;
|
||||
const templateId = document.getElementById('templateFilter').value;
|
||||
|
||||
window.location.href = `/settings/mails?page=${page}&status=${status}&date_range=${dateRange}&user_id=${userId}`;
|
||||
window.location.href = `/settings/mails?page=${page}&status=${status}&date_range=${dateRange}&user_id=${userId}&template_id=${templateId}`;
|
||||
}
|
||||
</script>
|
||||
{% endmacro %}
|
||||
Reference in New Issue
Block a user