From 2fa49a83a5f869f4be6f344d0e112e9e85f1ebf8 Mon Sep 17 00:00:00 2001 From: Oliver Roick Date: Fri, 7 Mar 2025 08:18:15 +1100 Subject: [PATCH 1/4] Update items page to match collections page - Add new pagination layout - Add empty state when collection has no items - Remove jQuery dependency - Extend from base.html --- runtimes/eoapi/stac/eoapi/stac/client.py | 5 + .../stac/eoapi/stac/templates/items.html | 204 +++++++++--------- 2 files changed, 109 insertions(+), 100 deletions(-) diff --git a/runtimes/eoapi/stac/eoapi/stac/client.py b/runtimes/eoapi/stac/eoapi/stac/client.py index e492a1b..10e70c0 100644 --- a/runtimes/eoapi/stac/eoapi/stac/client.py +++ b/runtimes/eoapi/stac/eoapi/stac/client.py @@ -512,12 +512,17 @@ async def item_collection( ) if output_type == MimeTypes.html: + offset = int(request.query_params.get("offset") or 0) + limit = int(request.query_params.get("limit") or 10) + item_collection["id"] = collection_id return create_html_response( request, item_collection, template_name="items", title=f"{collection_id} items", + limit=limit, + offset=offset, ) elif output_type == MimeTypes.csv: diff --git a/runtimes/eoapi/stac/eoapi/stac/templates/items.html b/runtimes/eoapi/stac/eoapi/stac/templates/items.html index c21a404..af612b8 100644 --- a/runtimes/eoapi/stac/eoapi/stac/templates/items.html +++ b/runtimes/eoapi/stac/eoapi/stac/templates/items.html @@ -1,4 +1,4 @@ -{% include "header.html" %} +{% extends "base.html" %} {% set show_prev_link = false %} {% set show_next_link = false %} @@ -8,13 +8,14 @@ {% set urlq = url + '?' %} {% endif %} - +{% block content %} -

Collection Items: {{ response.title or response.id }}

- -
Loading...
- -

- Number of matching items: {{ response.numberMatched }}
- Number of returned items: {{ response.numberReturned }}
-

- -
- {% for link in response.links %} - {% if link.rel == 'previous' %} - +

+ Collection Items: + {{ response.title or response.id }} +

+{% if response.features|length > 0 %} +
+
+
+ + +
+ {% if response.links|length > 0 %} +
+ {% for link in response.links %} + {% if link.rel == 'prev' or link.rel == 'previous' %} + « prev + {% endif %} + {% endfor %} + {% for link in response.links %} + {% if link.rel == 'next' %} + next » + {% endif %} + {% endfor %} {% endif %} - {% endfor %} -
- +
- {% for link in response.links %} - {% if link.rel == 'next' %} - - {% endif %} - {% endfor %}
+ +
Loading...
+
-{% if response.features is defined and response.features|length > 0 %} - - - -{% for key, value in response.features.0.properties.items() %} - -{% endfor %} - - -{% for feature in response.features %} - - - {% for key, value in feature.properties.items() %} - - {% endfor %} - -{% endfor %} - -
ID{{ key }}
{{ feature.id }}{{ value }}
-{% endif %} + {% if response.features and response.features|length > 0 %} + + + + {% for key, value in response.features.0.properties.items() %} + + {% endfor %} + + + {% for feature in response.features %} + + + {% for key, value in feature.properties.items() %} + + {% endfor %} + + {% endfor %} + +
ID{{ key }}
{{ feature.id }}{{ value }}
+ {% endif %} +
+{% else %} +
+

No items found

+

You need to add STAC Collections and Items; for example by following the MAXAR open data demo or other demos.

+{% endif %} - -{% include "footer.html" %} +{% endblock %} From c948aad400da60410ee65c6cb6f6b30c1fbcd86b Mon Sep 17 00:00:00 2001 From: Oliver Roick Date: Sat, 8 Mar 2025 18:16:20 +1100 Subject: [PATCH 2/4] Remove offset, use limit function argument --- runtimes/eoapi/stac/eoapi/stac/client.py | 6 +----- runtimes/eoapi/stac/eoapi/stac/templates/items.html | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/runtimes/eoapi/stac/eoapi/stac/client.py b/runtimes/eoapi/stac/eoapi/stac/client.py index 10e70c0..a6f8495 100644 --- a/runtimes/eoapi/stac/eoapi/stac/client.py +++ b/runtimes/eoapi/stac/eoapi/stac/client.py @@ -512,17 +512,13 @@ async def item_collection( ) if output_type == MimeTypes.html: - offset = int(request.query_params.get("offset") or 0) - limit = int(request.query_params.get("limit") or 10) - item_collection["id"] = collection_id return create_html_response( request, item_collection, template_name="items", title=f"{collection_id} items", - limit=limit, - offset=offset, + limit=limit ) elif output_type == MimeTypes.csv: diff --git a/runtimes/eoapi/stac/eoapi/stac/templates/items.html b/runtimes/eoapi/stac/eoapi/stac/templates/items.html index af612b8..1b56b99 100644 --- a/runtimes/eoapi/stac/eoapi/stac/templates/items.html +++ b/runtimes/eoapi/stac/eoapi/stac/templates/items.html @@ -96,7 +96,6 @@

let url = "{{ template.api_root }}/collections/{{ response.id }}/items?"; const searchParams = new URLSearchParams(window.location.search); searchParams.set('limit', limit); - searchParams.set('offset', 0); url += searchParams.toString(); window.location.href = url; }); From 3274bc429044877374c6b751929f3d8297201184 Mon Sep 17 00:00:00 2001 From: Oliver Roick Date: Tue, 11 Mar 2025 11:31:44 +1100 Subject: [PATCH 3/4] Add trailing comma --- runtimes/eoapi/stac/eoapi/stac/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtimes/eoapi/stac/eoapi/stac/client.py b/runtimes/eoapi/stac/eoapi/stac/client.py index a6f8495..6f43213 100644 --- a/runtimes/eoapi/stac/eoapi/stac/client.py +++ b/runtimes/eoapi/stac/eoapi/stac/client.py @@ -518,7 +518,7 @@ async def item_collection( item_collection, template_name="items", title=f"{collection_id} items", - limit=limit + limit=limit, ) elif output_type == MimeTypes.csv: From 74b4a8ced17c2db449ebd84852ff51c8742f1289 Mon Sep 17 00:00:00 2001 From: Oliver Roick Date: Fri, 21 Mar 2025 10:21:59 +1100 Subject: [PATCH 4/4] Add num returned and num matched indicator --- runtimes/eoapi/stac/eoapi/stac/templates/items.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtimes/eoapi/stac/eoapi/stac/templates/items.html b/runtimes/eoapi/stac/eoapi/stac/templates/items.html index 1b56b99..d2f4470 100644 --- a/runtimes/eoapi/stac/eoapi/stac/templates/items.html +++ b/runtimes/eoapi/stac/eoapi/stac/templates/items.html @@ -29,6 +29,9 @@

{% if response.features|length > 0 %}
+
+ Showing {{ response.numberReturned }} of {{ response.numberMatched }} items +