Skip to content

Commit 4a28944

Browse files
Merge pull request #48 from developmentseed/patch/remove-custom-html-params
handle limit-offset in templates
2 parents dfb8713 + 17d88c4 commit 4a28944

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-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: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{% extends "base.html" %}
22

3+
{% if params %}
4+
{% set urlq = url + '?' + params + '&' %}
5+
{% else %}
6+
{% set urlq = url + '?' %}
7+
{% endif %}
8+
39
{% block content %}
410
<nav aria-label="breadcrumb">
511
<ol class="breadcrumb bg-light">
@@ -24,7 +30,7 @@ <h1>Collections</h1>
2430
{% else %}
2531
<div class="d-flex flex-row align-items-center mb-4 flex-wrap">
2632
<div class="mr-3">
27-
Showing {{ offset + 1 }} - {{ offset + response.numberReturned }} of {{ response.numberMatched }} collections
33+
Showing {{ template.params.get("offset", 0)|int + 1 }} - {{ template.params.get("offset", 0)|int + response.numberReturned }} of {{ response.numberMatched }} collections
2834
</div>
2935

3036
<form id="search-form" class="d-flex flex-wrap flex-grow-1" style="gap: 8px">
@@ -43,10 +49,10 @@ <h1>Collections</h1>
4349
<div class="d-flex">
4450
<label for="limit" class="mr-1 small">Page size:</label>
4551
<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>
52+
<option value="10" {% if template.params.get("limit", 10)|int == 10 %}selected{% endif %}>10</option>
53+
<option value="25" {% if template.params.get("limit", 10)|int == 25 %}selected{% endif %}>25</option>
54+
<option value="50" {% if template.params.get("limit", 10)|int == 50 %}selected{% endif %}>50</option>
55+
<option value="100" {% if template.params.get("limit", 10)|int == 100 %}selected{% endif %}>100</option>
5056
</select>
5157
</div>
5258

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)