Skip to content

Commit 533eb0a

Browse files
authored
Small HTML improvements (#2368)
* Small improvements to EDR HTML * Conditionally create Data/Record collection sections
1 parent 76528fc commit 533eb0a

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

pygeoapi/templates/collections/collection.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h1>{{ data['title'] }}</h1>
2828
</div>
2929
</div>
3030
<div class="row">
31-
<div class="col-sm-12">
31+
<div class="col-sm-12 mb-2">
3232
<div id="collection-map"></div>
3333
</div>
3434
</div>
@@ -88,6 +88,23 @@ <h3>{% trans %}Tiles{% endtrans %}</h3>
8888
{% endfor %}
8989
{% endif %}
9090

91+
{%- if data['data_queries'] -%}
92+
<h3>Data Queries</h3>
93+
<table class="table table-striped table-bordered">
94+
<tr>
95+
<th>Query Name</th>
96+
<th>Query Location</th>
97+
</tr>
98+
{% for query_name, query in data['data_queries'].items() %}
99+
<tr>
100+
<td>{{ query_name }}</td>
101+
<td><a title="{{ query_name }}" href="{{ query['link']['href'] }}">{{ query['link']['href'] }}</a></td>
102+
</tr>
103+
{% endfor %}
104+
<caption><em>Note: EDR Queries may require query parameters not provided in the Query Location.</em></caption>
105+
</table>
106+
{%- endif -%}
107+
91108
{% if 'parameter_names' in data %}
92109
<h3>Parameters</h3>
93110
<table class="table table-striped table-bordered">

pygeoapi/templates/collections/edr/query.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@
270270

271271
var items = new L.GeoJSON(geojson_data, {
272272
onEachFeature: function (feature, layer) {
273-
var html = '<span>' + {% if data['title_field'] %} feature['properties']['{{ data['title_field'] }}'] {% else %} feature.id {% endif %} + '</span>';
273+
var url = '{{ data['query_path'] }}/' + feature.id + '?f=html';
274+
var html = '<span><a href="' + url + '">' + {% if data['title_field'] %} feature['properties']['{{ data['title_field'] }}'] {% else %} feature.id {% endif %} + '</a></span>';
274275
layer.bindPopup(html);
275276
}
276277
});

pygeoapi/templates/collections/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
/ <a href="{{ data['collections_path'] }}">{% trans %}Collections{% endtrans %}</a>
55
{% endblock %}
66
{% block body %}
7+
{% set collections = namespace(data=false, records=false) %}
8+
{% for col in data['collections'] %}
9+
{% if col.get('itemType') == 'record' %}
10+
{% set collections.records = true %}
11+
{% else %}
12+
{% set collections.data = true %}
13+
{% endif %}
14+
{% endfor %}
15+
{% if collections.data %}
716
<section id="data-collections">
817
<h1>{% trans %}Data collections in this service{% endtrans %}</h1>
918
<table class="table table-striped table-bordered">
@@ -31,6 +40,8 @@ <h1>{% trans %}Data collections in this service{% endtrans %}</h1>
3140
</tbody>
3241
</table>
3342
</section>
43+
{% endif %}
44+
{% if collections.records %}
3445
<section id="record-collections">
3546
<h1>{% trans %}Record collections in this service{% endtrans %}</h1>
3647
<table class="table table-striped table-bordered">
@@ -58,4 +69,5 @@ <h1>{% trans %}Record collections in this service{% endtrans %}</h1>
5869
</tbody>
5970
</table>
6071
</section>
72+
{% endif %}
6173
{% endblock %}

0 commit comments

Comments
 (0)