Pagination in the admin

This commit is contained in:
Thomas Sileo 2022-06-28 20:10:25 +02:00
parent 489ed6cbe0
commit d4c80dedeb
8 changed files with 112 additions and 29 deletions

View file

@ -2,6 +2,8 @@
{% extends "layout.html" %}
{% block content %}
{{ utils.display_box_filters("admin_inbox") }}
{% for inbox_object in inbox %}
{% if inbox_object.ap_type == "Announce" %}
{{ utils.display_object(inbox_object.relates_to_anybox_object) }}
@ -14,4 +16,8 @@
{% endif %}
{% endfor %}
{% if next_cursor %}
<p><a href="{{ url_for("admin_inbox") }}?cursor={{ next_cursor }}{% if request.query_params.filter_by %}&filter_by={{ request.query_params.filter_by }}{% endif %}">See more</a></p>
{% endif %}
{% endblock %}

View file

@ -2,17 +2,7 @@
{% extends "layout.html" %}
{% block content %}
<p>Filter by
{% for ap_type in ["Note", "Like", "Announce", "Follow"] %}
<a style="margin-right:12px;" href="{{ url_for("admin_outbox") }}?filter_by={{ ap_type }}">
{% if request.query_params.filter_by == ap_type %}
<strong>{{ ap_type }}</strong>
{% else %}
{{ ap_type }}
{% endif %}</a>
{% endfor %}.
{% if request.query_params.filter_by %}<a href="{{ url_for("admin_outbox") }}">Reset filter</a>{% endif %}</p>
</p>
{{ utils.display_box_filters("admin_outbox") }}
{% for outbox_object in outbox %}
@ -33,4 +23,8 @@
{% endfor %}
{% if next_cursor %}
<p><a href="{{ url_for("admin_outbox") }}?cursor={{ next_cursor }}{% if request.query_params.filter_by %}&filter_by={{ request.query_params.filter_by }}{% endif %}">See more</a></p>
{% endif %}
{% endblock %}

View file

@ -8,5 +8,15 @@
<li>{{ utils.display_actor(follower.actor, actors_metadata) }}</li>
{% endfor %}
</ul>
{% set x_more = followers_count - followers | length %}
{% if x_more > 0 %}
<p>And {{ x_more }} more.</p>
{% endif %}
{% if is_admin %}
<p><a href="{{ url_for("admin_inbox") }}?filter_by=Follow">Manage followers</a></p>
{% endif %}
</div>
{% endblock %}

View file

@ -8,5 +8,15 @@
<li>{{ utils.display_actor(follow.actor, actors_metadata) }}</li>
{% endfor %}
</ul>
{% set x_more = following_count - following | length %}
{% if x_more > 0 %}
<p>And {{ x_more }} more.</p>
{% endif %}
{% if is_admin %}
<p><a href="{{ url_for("admin_outbox") }}?filter_by=Follow">Manage follows</a></p>
{% endif %}
</div>
{% endblock %}

View file

@ -109,6 +109,20 @@
</form>
{% endmacro %}
{% macro display_box_filters(route) %}
<p>Filter by
{% for ap_type in ["Note", "Like", "Announce", "Follow"] %}
<a style="margin-right:12px;" href="{{ url_for(route) }}?filter_by={{ ap_type }}">
{% if request.query_params.filter_by == ap_type %}
<strong>{{ ap_type }}</strong>
{% else %}
{{ ap_type }}
{% endif %}</a>
{% endfor %}.
{% if request.query_params.filter_by %}<a href="{{ url_for(route) }}">Reset filter</a>{% endif %}</p>
</p>
{% endmacro %}
{% macro display_actor(actor, actors_metadata) %}
{% set metadata = actors_metadata.get(actor.ap_id) %}
<div style="display: flex;column-gap: 20px;margin:20px 0 10px 0;" class="actor-box h-card p-author">