pagination
This commit is contained in:
74
templates/_pagination.html
Normal file
74
templates/_pagination.html
Normal file
@@ -0,0 +1,74 @@
|
||||
<div class="flex justify-between items-center mt-4 px-2">
|
||||
<div class="text-sm text-gray-700">
|
||||
Showing {{ ((current_page - 1) * per_page) + 1 }} to
|
||||
{% if current_page * per_page < total_projects %}
|
||||
{{ current_page * per_page }}
|
||||
{% else %}
|
||||
{{ total_projects }}
|
||||
{% endif %}
|
||||
of {{ total_projects }} projects
|
||||
</div>
|
||||
|
||||
<div class="flex space-x-2">
|
||||
<!-- Previous Button -->
|
||||
{% if current_page > 1 %}
|
||||
<a href="{{ url_for('dashboard', page=current_page - 1) }}"
|
||||
class="px-3 py-1 text-sm bg-gray-100 text-gray-700 rounded hover:bg-gray-200 transition-colors">
|
||||
Previous
|
||||
</a>
|
||||
{% else %}
|
||||
<span class="px-3 py-1 text-sm text-gray-400 bg-gray-50 rounded cursor-not-allowed">
|
||||
Previous
|
||||
</span>
|
||||
{% endif %}
|
||||
|
||||
<!-- Page Numbers -->
|
||||
{% set start_page = [1, current_page - 2]|max %}
|
||||
{% set end_page = [total_pages, current_page + 2]|min %}
|
||||
|
||||
{% if start_page > 1 %}
|
||||
<a href="{{ url_for('dashboard', page=1) }}"
|
||||
class="px-3 py-1 text-sm bg-gray-100 text-gray-700 rounded hover:bg-gray-200 transition-colors">
|
||||
1
|
||||
</a>
|
||||
{% if start_page > 2 %}
|
||||
<span class="px-3 py-1 text-sm text-gray-400">...</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% for page_num in range(start_page, end_page + 1) %}
|
||||
{% if page_num == current_page %}
|
||||
<span class="px-3 py-1 text-sm bg-blue-600 text-white rounded">
|
||||
{{ page_num }}
|
||||
</span>
|
||||
{% else %}
|
||||
<a href="{{ url_for('dashboard', page=page_num) }}"
|
||||
class="px-3 py-1 text-sm bg-gray-100 text-gray-700 rounded hover:bg-gray-200 transition-colors">
|
||||
{{ page_num }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if end_page < total_pages %}
|
||||
{% if end_page < total_pages - 1 %}
|
||||
<span class="px-3 py-1 text-sm text-gray-400">...</span>
|
||||
{% endif %}
|
||||
<a href="{{ url_for('dashboard', page=total_pages) }}"
|
||||
class="px-3 py-1 text-sm bg-gray-100 text-gray-700 rounded hover:bg-gray-200 transition-colors">
|
||||
{{ total_pages }}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<!-- Next Button -->
|
||||
{% if current_page < total_pages %}
|
||||
<a href="{{ url_for('dashboard', page=current_page + 1) }}"
|
||||
class="px-3 py-1 text-sm bg-gray-100 text-gray-700 rounded hover:bg-gray-200 transition-colors">
|
||||
Next
|
||||
</a>
|
||||
{% else %}
|
||||
<span class="px-3 py-1 text-sm text-gray-400 bg-gray-50 rounded cursor-not-allowed">
|
||||
Next
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -300,6 +300,10 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
{% include '_pagination.html' %}
|
||||
|
||||
<script>
|
||||
function columnConfig() {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user