From 0a6cc8912c6a40ec81644c365dfe105771047864 Mon Sep 17 00:00:00 2001 From: Mike Cantelon Date: Wed, 27 Sep 2023 00:54:41 -0700 Subject: [PATCH] Use server-side paging in aips page. (#209) To avoid slow page responses when there are a large amount of AIPs use server-side paging to limit the number of AIP HTML sent to the browser. --- AIPscan/Reporter/helpers.py | 10 +++++++++ AIPscan/Reporter/templates/aips.html | 31 ++++++++++++++++++++++++---- AIPscan/Reporter/views.py | 19 +++++++++++++---- 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/AIPscan/Reporter/helpers.py b/AIPscan/Reporter/helpers.py index 17c38048..4fa1bb36 100644 --- a/AIPscan/Reporter/helpers.py +++ b/AIPscan/Reporter/helpers.py @@ -145,3 +145,13 @@ def get_premis_xml_lines(file_object): premis_xml_lines = file_object.premis_object.split("\n") return premis_xml_lines + + +def calculate_paging_window(page, pagination): + first_item = ((page - 1) * pagination.per_page) + 1 + last_item = page * pagination.per_page + + if last_item > pagination.total: + last_item = pagination.total + + return first_item, last_item diff --git a/AIPscan/Reporter/templates/aips.html b/AIPscan/Reporter/templates/aips.html index c456f527..45f05689 100644 --- a/AIPscan/Reporter/templates/aips.html +++ b/AIPscan/Reporter/templates/aips.html @@ -2,7 +2,7 @@ {% block content %} -
AIPs ({{ aips|length }})
+
AIPs ({{ pagination.items|length }})
{% if storage_services %} @@ -42,9 +42,9 @@ - {% if aips %} + {% if pagination.items %} - +
@@ -56,7 +56,7 @@ {% if aips %} - {% for aip in aips %} + {% for aip in pagination.items %} @@ -85,6 +85,29 @@ {% endif %} +{% if pagination.total %} + +
+
+
+
Showing {{ first_item }} to {{ last_item }} of {{ pagination.total }} entries
+
+ +
+
+ +{% endif %} +
Transfer name
{{ aip.transfer_name }} {{ aip.uuid }}