@@ -22,20 +22,34 @@ <h1>Collections</h1>
22
22
< p > You need to add STAC Collections and Items; for example by following the < a href ="https://github.com/vincentsarago/MAXAR_opendata_to_pgstac "> MAXAR open data demo</ a > or < a href ="https://github.com/developmentseed/eoAPI/tree/main/demo "> other demos.</ a > </ p >
23
23
</ div >
24
24
{% else %}
25
- < div class ="d-flex flex-row align-items-center mb-4 ">
26
- < div class ="flex-grow-1 ">
25
+ < div class ="d-flex flex-row align-items-center mb-4 flex-wrap ">
26
+ < div class ="mr-3 ">
27
27
Showing {{ offset + 1 }} - {{ offset + response.numberReturned }} of {{ response.numberMatched }} collections
28
28
</ div >
29
+
30
+ < form id ="search-form " class ="d-flex flex-wrap flex-grow-1 " style ="gap: 8px ">
31
+ < div class ="input-group input-group-sm " style ="max-width: 180px ">
32
+ < input type ="text " class ="form-control " id ="q " placeholder ="Text search "
33
+ value ="{{ request.query_params.get('q', '') }} " title ="Text search ">
34
+ </ div >
35
+
36
+ < div class ="btn-group btn-group-sm ">
37
+ < button type ="submit " class ="btn btn-primary "> Search</ button >
38
+ < button type ="button " id ="clear-search " class ="btn btn-secondary "> Clear</ button >
39
+ </ div >
40
+ </ form >
41
+
29
42
< div class ="form-inline " style ="gap: 10px ">
30
43
< div class ="d-flex ">
31
- < label for ="limit "> Page size: </ label >
32
- < 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 -- >
44
+ < label for ="limit " class =" mr-1 small " > Page size:</ label >
45
+ < select class ="form-control form-control-sm " id ="limit " aria-label ="Select page size " style =" width: 70px " >
33
46
< option value ="10 " {% if limit == 10 %}selected{% endif %} > 10</ option >
34
47
< option value ="25 " {% if limit == 25 %}selected{% endif %} > 25</ option >
35
48
< option value ="50 " {% if limit == 50 %}selected{% endif %} > 50</ option >
36
49
< option value ="100 " {% if limit == 100 %}selected{% endif %} > 100</ option >
37
50
</ select >
38
51
</ div >
52
+
39
53
{% if response.links|length > 0 %}
40
54
< div class ="btn-group btn-group-sm " role ="group " aria-label ="Paginate ">
41
55
{% for link in response.links %}
@@ -48,8 +62,8 @@ <h1>Collections</h1>
48
62
< a class ="btn btn-secondary " title ="next page " href ="{{ link.href }} "> next »</ a >
49
63
{% endif %}
50
64
{% endfor %}
51
- {% endif %}
52
65
</ div >
66
+ {% endif %}
53
67
</ div >
54
68
</ div >
55
69
@@ -74,14 +88,31 @@ <h1>Collections</h1>
74
88
75
89
< script >
76
90
document . getElementById ( "limit" ) . addEventListener ( "change" , ( event ) => {
77
- // Set new page size
78
91
const limit = event . target . value ;
79
- var url = "{{ template.api_root }}/collections?" ;
80
92
const searchParams = new URLSearchParams ( window . location . search ) ;
81
93
searchParams . set ( 'limit' , limit ) ;
82
94
searchParams . set ( 'offset' , 0 ) ;
83
- url += searchParams . toString ( ) ;
84
- window . location . href = url ;
95
+ window . location . href = "{{ template.api_root }}/collections?" + searchParams . toString ( ) ;
96
+ } ) ;
97
+
98
+ document . getElementById ( "search-form" ) . addEventListener ( "submit" , ( event ) => {
99
+ event . preventDefault ( ) ;
100
+ const searchParams = new URLSearchParams ( ) ;
101
+
102
+ const q = document . getElementById ( 'q' ) . value . trim ( ) ;
103
+ const limit = document . getElementById ( 'limit' ) . value ;
104
+
105
+ if ( q ) searchParams . set ( 'q' , q ) ;
106
+ searchParams . set ( 'limit' , limit ) ;
107
+
108
+ window . location . href = "{{ template.api_root }}/collections?" + searchParams . toString ( ) ;
109
+ return false ;
110
+ } ) ;
111
+
112
+ document . getElementById ( "clear-search" ) . addEventListener ( "click" , ( ) => {
113
+ const searchParams = new URLSearchParams ( ) ;
114
+ searchParams . set ( 'limit' , document . getElementById ( 'limit' ) . value ) ;
115
+ window . location . href = "{{ template.api_root }}/collections?" + searchParams . toString ( ) ;
85
116
} ) ;
86
117
</ script >
87
118
{% endif %}
0 commit comments