message pagination
This commit is contained in:
@@ -235,6 +235,6 @@ async def message_list_page(
|
|||||||
"page": page,
|
"page": page,
|
||||||
"per_page": per_page,
|
"per_page": per_page,
|
||||||
"total_pages": total_pages,
|
"total_pages": total_pages,
|
||||||
"current_user": current_user,
|
"current_user": current_user.username,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -1,6 +1,12 @@
|
|||||||
<h1>Messages</h1>
|
{% extends "base.html" %}
|
||||||
|
|
||||||
<div class="mb-4 d-flex justify-content-between align-items-start flex-wrap gap-3">
|
{% block title %}Messages{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="container mt-4">
|
||||||
|
<h1>Messages</h1>
|
||||||
|
|
||||||
|
<div class="mb-4 d-flex justify-content-between align-items-start flex-wrap gap-3">
|
||||||
<div>
|
<div>
|
||||||
<!-- Type tabs -->
|
<!-- Type tabs -->
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
@@ -21,7 +27,7 @@
|
|||||||
|
|
||||||
<div class="d-flex gap-2">
|
<div class="d-flex gap-2">
|
||||||
<!-- Search form -->
|
<!-- Search form -->
|
||||||
<form method="get" class="d-flex">
|
<form method="get" class="d-flex align-items-center">
|
||||||
<input type="hidden" name="type" value="{{ current_type }}">
|
<input type="hidden" name="type" value="{{ current_type }}">
|
||||||
<input type="text" name="search" class="form-control me-2" placeholder="Search messages..." value="{{ current_search or '' }}">
|
<input type="text" name="search" class="form-control me-2" placeholder="Search messages..." value="{{ current_search or '' }}">
|
||||||
<button type="submit" class="btn btn-outline-primary">Search</button>
|
<button type="submit" class="btn btn-outline-primary">Search</button>
|
||||||
@@ -35,39 +41,47 @@
|
|||||||
Compose New Message
|
Compose New Message
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if total > 0 %}
|
{% if total > 0 %}
|
||||||
<p class="text-muted mb-3">
|
<p class="text-muted mb-3">
|
||||||
Showing {{ ((page-1)*per_page) + 1 }}–{{ page*per_page if page*per_page < total else total }} of {{ total }} messages
|
Showing {{ ((page-1)*per_page) + 1 }}–{{ page*per_page if page*per_page < total else total }} of {{ total }} messages
|
||||||
</p>
|
</p>
|
||||||
{% else %}
|
{% endif %}
|
||||||
<p class="text-muted mb-3">No messages</p>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if messages %}
|
{% if messages %}
|
||||||
<ul class="message-list">
|
<ul class="list-group message-list">
|
||||||
{% for msg in messages %}
|
{% for msg in messages %}
|
||||||
<li>
|
<li class="list-group-item">
|
||||||
<strong><a href="/dashboard/message/{{ msg.id }}">{{ msg.text[:60] }}{% if msg.text|length > 60 %}...{% endif %}</a></strong>
|
<strong>
|
||||||
{% if msg.has_attachments %}<span class="text-info">(Attachments)</span>{% endif %}
|
<a href="/dashboard/message/{{ msg.id }}">
|
||||||
{% if not msg.retrieved %}<span class="text-warning">(Unread)</span>{% endif %}
|
{{ msg.text[:80] }}{% if msg.text|length > 80 %}...{% endif %}
|
||||||
<span class="meta">
|
</a>
|
||||||
From: {{ msg.from }} | To: {{ msg.to | join(', ') }} | {{ msg.sent_at[:10] }} {{ msg.sent_at[11:19] }}
|
</strong>
|
||||||
</span>
|
{% if msg.has_attachments %}<span class="badge bg-info ms-2">Attachments</span>{% endif %}
|
||||||
<div class="preview">{{ msg.text[:200] }}{% if msg.text|length > 200 %}...{% endif %}</div>
|
{% if not msg.retrieved %}<span class="badge bg-warning ms-2">Unread</span>{% endif %}
|
||||||
|
<div class="text-muted small mt-1">
|
||||||
|
From: {{ msg.from }} | To: {{ msg.to | join(', ') }} | {{ msg.sent_at[:10] }} {{ msg.sent_at[11:16] }}
|
||||||
|
</div>
|
||||||
|
<div class="text-secondary small mt-2">
|
||||||
|
{{ msg.text[:200] }}{% if msg.text|length > 200 %}...{% endif %}
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info mt-4">
|
||||||
{% if current_search %}No messages found matching "{{ current_search }}".{% else %}No messages yet.{% endif %}
|
{% if current_search %}
|
||||||
</div>
|
No messages found matching "{{ current_search }}".
|
||||||
{% endif %}
|
{% else %}
|
||||||
|
No messages yet.
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<!-- Pagination (only if >1 page) -->
|
<!-- Pagination -->
|
||||||
{% if total_pages > 1 %}
|
{% if total_pages > 1 %}
|
||||||
<nav aria-label="Messages pagination" class="mt-4">
|
<nav aria-label="Messages pagination" class="mt-5">
|
||||||
<ul class="pagination justify-content-center">
|
<ul class="pagination justify-content-center">
|
||||||
<li class="page-item {% if page == 1 %}disabled{% endif %}">
|
<li class="page-item {% if page == 1 %}disabled{% endif %}">
|
||||||
<a class="page-link" href="?page={{ page - 1 }}&type={{ current_type }}{% if current_search %}&search={{ current_search }}{% endif %}">Previous</a>
|
<a class="page-link" href="?page={{ page - 1 }}&type={{ current_type }}{% if current_search %}&search={{ current_search }}{% endif %}">Previous</a>
|
||||||
@@ -83,7 +97,11 @@
|
|||||||
<a class="page-link" href="?page={{ page + 1 }}&type={{ current_type }}{% if current_search %}&search={{ current_search }}{% endif %}">Next</a>
|
<a class="page-link" href="?page={{ page + 1 }}&type={{ current_type }}{% if current_search %}&search={{ current_search }}{% endif %}">Next</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<p><a href="/dashboard">← Back to Dashboard</a></p>
|
<div class="mt-4">
|
||||||
|
<a href="/dashboard" class="btn btn-outline-secondary">← Back to Dashboard</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user