|
36 | 36 | "wget --input-file 'http://127.0.0.1:8000/climate/get_climate_txt?hash=21cd9c90faad4dc19b73c8c0ae75d51a'";
|
37 | 37 | let wget_add_args = '-r -H -N --cut-dirs=2';
|
38 | 38 |
|
| 39 | + let type = 'water_budget'; |
| 40 | +
|
39 | 41 | // set default search type
|
40 | 42 | // select_search_type('collection');
|
41 | 43 |
|
|
103 | 105 | }
|
104 | 106 |
|
105 | 107 | async function fetch_foldercontent() {
|
106 |
| - const custom_url = "https://leutra.geogr.uni-jena.de/backend_geoportal/climate/get_content" |
| 108 | + const custom_url = |
| 109 | + 'https://leutra.geogr.uni-jena.de/backend_geoportal/climate/get_content?type=' + type; |
107 | 110 |
|
108 | 111 | try {
|
109 | 112 | const res = await fetch(custom_url, {
|
|
130 | 133 | console.log(error);
|
131 | 134 | }
|
132 | 135 | }
|
| 136 | + let search_term = ''; |
| 137 | + function filter_folder_data() { |
| 138 | + //folder_data.filter(( /** @type {(string | string[])[]} */ data) => data[0].includes(search_term)); |
| 139 | + const folder_data_new = Object.values(folder_data).filter((item) => |
| 140 | + item[0].includes(search_term) |
| 141 | + ); |
| 142 | + folder_data = folder_data_new; |
| 143 | + } |
133 | 144 |
|
134 | 145 | /**
|
135 | 146 | * @param {{ srcElement: { value: string; checked: any; }; }} e
|
|
148 | 159 | // the response of this request is a string containing a wget request with the
|
149 | 160 | // mentioned hash, that should download all selected files from our server
|
150 | 161 | async function handle_checkbox_submit() {
|
151 |
| - const custom_url = 'https://leutra.geogr.uni-jena.de/backend_geoportal/climate/select_for_wget'; |
| 162 | + const custom_url = |
| 163 | + 'https://leutra.geogr.uni-jena.de/backend_geoportal/climate/select_for_wget?type=' + type; |
152 | 164 | let checked_boxes = [];
|
153 | 165 |
|
154 | 166 | for (let i = 0; i < folder_checkbox_bools.length; i++) {
|
|
180 | 192 | }
|
181 | 193 | }
|
182 | 194 |
|
| 195 | + /** |
| 196 | + * @param {string} new_type |
| 197 | + */ |
| 198 | + function set_type(new_type) { |
| 199 | + if (new_type == 'water_budget') { |
| 200 | + font_bold_ind = ''; |
| 201 | + font_bold_col = 'font-bold'; |
| 202 | + type = new_type; |
| 203 | + } else if (new_type == 'water_budget_bias') { |
| 204 | + font_bold_col = ''; |
| 205 | + font_bold_ind = 'font-bold'; |
| 206 | + type = new_type; |
| 207 | + } |
| 208 | + fetch_foldercontent(); |
| 209 | + } |
| 210 | +
|
183 | 211 | // array with current geo_data['facets']['file_id']
|
184 | 212 | </script>
|
185 | 213 |
|
186 | 214 | <!-- Backend Folder Content as checkboxes -->
|
| 215 | +<div class="btn-group variant-ghost-primary [&>*+*]:border-red-500 h-6"> |
| 216 | + <button |
| 217 | + type="button" |
| 218 | + class="btn variant-filled-tertiary {font_bold_col}" |
| 219 | + on:click={() => set_type('water_budget')}>Water Budget</button |
| 220 | + > |
| 221 | + <button |
| 222 | + type="button" |
| 223 | + class="btn variant-filled-tertiary {font_bold_ind}" |
| 224 | + on:click={() => set_type('water_budget_bias')}>Water Budget bias adjusted</button |
| 225 | + > |
| 226 | +</div> |
| 227 | +<div> |
| 228 | + <input |
| 229 | + class="input w-full mt-4" |
| 230 | + type="text" |
| 231 | + placeholder="Filter filenames..." |
| 232 | + bind:value={search_term} |
| 233 | + /> |
| 234 | +</div> |
| 235 | + |
187 | 236 | {#if folder_data != null}
|
188 | 237 | <div class="grid grid-cols-9">
|
189 |
| - <div class="col-span-6"> |
190 |
| - Filename |
191 |
| - </div> |
192 |
| - <div> |
193 |
| - Filesize |
194 |
| - </div> |
195 |
| - <div> |
196 |
| - Last modified |
197 |
| - </div> |
198 |
| - <div> |
199 |
| - Download Link |
200 |
| - </div> |
| 238 | + <div class="col-span-6">Filename</div> |
| 239 | + <div>Filesize</div> |
| 240 | + <div>Last modified</div> |
| 241 | + <div>Download Link</div> |
201 | 242 | {#each Object.values(folder_data['content']) as datapoint, i}
|
202 |
| - <!-- Checkbox and filename --> |
203 |
| - <div class="col-span-6"> |
204 |
| - <input |
205 |
| - type="checkbox" |
206 |
| - value={i} |
207 |
| - id={'checkbox_' + i} |
208 |
| - on:change={on_folder_checkbox_change} |
209 |
| - /> |
210 |
| - {datapoint[0]} |
211 |
| - </div> |
212 |
| - <!-- filesize --> |
213 |
| - <div> |
214 |
| - {datapoint[1]} |
215 |
| - </div> |
216 |
| - <!-- creation date --> |
217 |
| - <div> |
218 |
| - {datapoint[2]} |
219 |
| - </div> |
220 |
| - <!-- download link --> |
221 |
| - <div> |
222 |
| - <a |
223 |
| - href="https://leutra.geogr.uni-jena.de/backend_geoportal/climate/get_file?name={datapoint[0]}" |
224 |
| - class="underline">download</a |
225 |
| - > |
226 |
| - </div> |
| 243 | + {#if datapoint[0].toLowerCase().includes(search_term.toLowerCase())} |
| 244 | + <!-- Checkbox and filename --> |
| 245 | + <div class="col-span-6"> |
| 246 | + <input |
| 247 | + type="checkbox" |
| 248 | + value={i} |
| 249 | + id={'checkbox_' + i} |
| 250 | + on:change={on_folder_checkbox_change} |
| 251 | + /> |
| 252 | + {datapoint[0]} |
| 253 | + </div> |
| 254 | + <!-- filesize --> |
| 255 | + <div> |
| 256 | + {datapoint[1]} |
| 257 | + </div> |
| 258 | + <!-- creation date --> |
| 259 | + <div> |
| 260 | + {datapoint[2]} |
| 261 | + </div> |
| 262 | + <!-- download link --> |
| 263 | + <div> |
| 264 | + <a |
| 265 | + href="https://leutra.geogr.uni-jena.de/backend_geoportal/climate/get_file?name={datapoint[0]}&type={type}" |
| 266 | + class="underline">download</a |
| 267 | + > |
| 268 | + </div> |
| 269 | + {/if} |
227 | 270 | {/each}
|
228 | 271 | <button class="btn variant-ghost-primary m-4" on:click|preventDefault={handle_checkbox_submit}
|
229 |
| - >Submit</button |
| 272 | + >Generate wget link</button |
230 | 273 | >
|
231 | 274 | </div>
|
232 | 275 | {:else}
|
|
0 commit comments