Skip to content

Commit 692d46a

Browse files
committed
handle limit-offset in templates
1 parent dfb8713 commit 692d46a

File tree

3 files changed

+9
-21
lines changed

3 files changed

+9
-21
lines changed

runtimes/eoapi/stac/eoapi/stac/client.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""eoapi-devseed: Custom pgstac client."""
22

33
import csv
4-
import math
54
import re
65
from typing import (
76
Any,
@@ -363,21 +362,11 @@ async def all_collections(
363362
)
364363

365364
if output_type == MimeTypes.html:
366-
offset = int(request.query_params.get("offset") or 0)
367-
limit = int(request.query_params.get("limit") or 10)
368-
369-
current_page = 1
370-
if limit > 0:
371-
current_page = math.ceil((offset + limit) / limit)
372-
373365
return create_html_response(
374366
request,
375367
collections,
376368
template_name="collections",
377369
title="Collections list",
378-
current_page=current_page,
379-
limit=limit,
380-
offset=offset,
381370
)
382371

383372
return collections
@@ -529,7 +518,6 @@ async def item_collection(
529518
item_collection,
530519
template_name="items",
531520
title=f"{collection_id} items",
532-
limit=limit,
533521
)
534522

535523
elif output_type == MimeTypes.csv:

runtimes/eoapi/stac/eoapi/stac/templates/collections.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h1>Collections</h1>
2424
{% else %}
2525
<div class="d-flex flex-row align-items-center mb-4 flex-wrap">
2626
<div class="mr-3">
27-
Showing {{ offset + 1 }} - {{ offset + response.numberReturned }} of {{ response.numberMatched }} collections
27+
Showing {{ template.params.get("offset", 0)|int + 1 }} - {{ template.params.get("offset", 0)|int + response.numberReturned }} of {{ response.numberMatched }} collections
2828
</div>
2929

3030
<form id="search-form" class="d-flex flex-wrap flex-grow-1" style="gap: 8px">
@@ -43,10 +43,10 @@ <h1>Collections</h1>
4343
<div class="d-flex">
4444
<label for="limit" class="mr-1 small">Page size:</label>
4545
<select class="form-control form-control-sm" id="limit" aria-label="Select page size" style="width: 70px">
46-
<option value="10" {% if limit == 10 %}selected{% endif %}>10</option>
47-
<option value="25" {% if limit == 25 %}selected{% endif %}>25</option>
48-
<option value="50" {% if limit == 50 %}selected{% endif %}>50</option>
49-
<option value="100" {% if limit == 100 %}selected{% endif %}>100</option>
46+
<option value="10" {% if template.params.get("limit", 10)|int == 10 %}selected{% endif %}>10</option>
47+
<option value="25" {% if template.params.get("limit", 10)|int == 25 %}selected{% endif %}>25</option>
48+
<option value="50" {% if template.params.get("limit", 10)|int == 50 %}selected{% endif %}>50</option>
49+
<option value="100" {% if template.params.get("limit", 10)|int == 100 %}selected{% endif %}>100</option>
5050
</select>
5151
</div>
5252

runtimes/eoapi/stac/eoapi/stac/templates/items.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ <h1 class="my-4">
3636
<div class="d-flex">
3737
<label for="limit">Page size: </label>
3838
<select class="form-control form-control-sm ml-1" id="limit" aria-label="Select page size"> <!-- TODO: dynamically populate the values based on oga_max_limit -->
39-
<option value="10" {% if limit == 10 %}selected{% endif %}>10</option>
40-
<option value="25" {% if limit == 25 %}selected{% endif %}>25</option>
41-
<option value="50" {% if limit == 50 %}selected{% endif %}>50</option>
42-
<option value="100" {% if limit == 100 %}selected{% endif %}>100</option>
39+
<option value="10" {% if template.params.get("limit", 10)|int == 10 %}selected{% endif %}>10</option>
40+
<option value="25" {% if template.params.get("limit", 10)|int == 25 %}selected{% endif %}>25</option>
41+
<option value="50" {% if template.params.get("limit", 10)|int == 50 %}selected{% endif %}>50</option>
42+
<option value="100" {% if template.params.get("limit", 10)|int == 100 %}selected{% endif %}>100</option>
4343
</select>
4444
</div>
4545
{% if response.links|length > 0 %}

0 commit comments

Comments
 (0)