Skip to content

Commit

Permalink
Merge pull request #7 from TIPPECC/48-show-filesize-and-date
Browse files Browse the repository at this point in the history
48 show filesize and date
  • Loading branch information
geofranzi authored Apr 15, 2024
2 parents d2f5559 + a8e1b14 commit 78dcb35
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 34 deletions.
4 changes: 1 addition & 3 deletions src/routes/team/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { API_URL } from '../../app.config';
export async function load() {
try {
// const req = await fetch(API_URL + '/layers/get_contacts_website');
const req = await fetch(
API_URL + '/layers/get_contacts_website'
);
const req = await fetch(API_URL + '/layers/get_contacts_website');

const result: Record<string, any>[] = await req.json();
console.log({ result });
Expand Down
83 changes: 52 additions & 31 deletions src/routes/water_budget/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import { onMount } from "svelte";
import { onMount } from 'svelte';
/**
* @type {any}
Expand All @@ -13,7 +13,7 @@
*/
let folder_checkbox_bools = [];
$: wget_request_string = "";
$: wget_request_string = '';
/**
* @type {any[]}
Expand All @@ -32,16 +32,16 @@
let url = '';
// PLACEHOLDER showcase for wget display styling
let wget_cmd = "wget --input-file 'http://127.0.0.1:8000/climate/get_climate_txt?hash=21cd9c90faad4dc19b73c8c0ae75d51a'";
let wget_add_args = "-r -H -N --cut-dirs=2"
let wget_cmd =
"wget --input-file 'http://127.0.0.1:8000/climate/get_climate_txt?hash=21cd9c90faad4dc19b73c8c0ae75d51a'";
let wget_add_args = '-r -H -N --cut-dirs=2';
// set default search type
// select_search_type('collection');
// initial query
// send_query();
onMount(() => {
fetch_foldercontent();
});
Expand All @@ -65,7 +65,6 @@
}
}
async function send_query() {
query = '';
for (let i = 0; i < query_parameter.length; i++) {
Expand Down Expand Up @@ -107,8 +106,7 @@
const custom_url = "https://leutra.geogr.uni-jena.de/backend_geoportal/climate/get_content"
try {
const res = await fetch(custom_url,
{
const res = await fetch(custom_url, {
method: 'GET'
});
Expand All @@ -127,7 +125,6 @@
// sort array
folder_data['content'].sort();
console.log('folder_data', folder_data);
} catch (error) {
console.log(error);
Expand All @@ -151,22 +148,20 @@
// the response of this request is a string containing a wget request with the
// mentioned hash, that should download all selected files from our server
async function handle_checkbox_submit() {
const custom_url = "https://leutra.geogr.uni-jena.de/backend_geoportal/climate/select_for_wget"
let checked_boxes = []
const custom_url = 'https://leutra.geogr.uni-jena.de/backend_geoportal/climate/select_for_wget';
let checked_boxes = [];
for (let i = 0; i < folder_checkbox_bools.length; i++) {
if (folder_checkbox_bools[i]) {
checked_boxes.push(folder_data['content'][i]);
checked_boxes.push(folder_data['content'][i][0]);
}
}
console.log("CHECKED: ", checked_boxes);
console.log('CHECKED: ', checked_boxes);
// SEND REQUEST
try {
const res = await fetch(custom_url,
{
const res = await fetch(custom_url, {
method: 'POST',
body: JSON.stringify(checked_boxes)
});
Expand All @@ -178,38 +173,66 @@
result = await res.json();
console.log("RESULT: ", result);
wget_request_string = result['wget-command']
console.log('RESULT: ', result);
wget_request_string = result['wget-command'];
} catch (error) {
console.log(error);
}
}
// array with current geo_data['facets']['file_id']
</script>

<!-- Backend Folder Content as checkboxes -->
{#if folder_data != null}
<div>
<div class="grid grid-cols-9">
<div class="col-span-6">
Filename
</div>
<div>
Filesize
</div>
<div>
Last modified
</div>
<div>
Download Link
</div>
{#each Object.values(folder_data['content']) as datapoint, i}
<div class="pl-4">
<!-- Checkbox and filename -->
<div class="col-span-6">
<input
type="checkbox"
value={i}
id={"checkbox_" + i}
on:change={on_folder_checkbox_change}/>
&nbsp;{datapoint}&nbsp;<a href="https://leutra.geogr.uni-jena.de/backend_geoportal//climate/get_file?name={datapoint}" class="underline">download</a>
<br>
id={'checkbox_' + i}
on:change={on_folder_checkbox_change}
/>
&nbsp;{datapoint[0]}
</div>
<!-- filesize -->
<div>
{datapoint[1]}
</div>
<!-- creation date -->
<div>
{datapoint[2]}
</div>
<!-- download link -->
<div>
&nbsp;<a
href="https://leutra.geogr.uni-jena.de/backend_geoportal/climate/get_file?name={datapoint[0]}"
class="underline">download</a
>
</div>
{/each}
<button class="btn variant-ghost-primary m-4" on:click|preventDefault={handle_checkbox_submit}>Submit</button>
<button class="btn variant-ghost-primary m-4" on:click|preventDefault={handle_checkbox_submit}
>Submit</button
>
</div>

{:else}
<div>
<p>Loading...</p>
</div>


{/if}
{#if wget_request_string.length > 0}
<div style="display:flex">
Expand All @@ -223,9 +246,7 @@
{wget_request_string}
</span>
<div class="mb-1 mt-2 text-sm">
<span>
Additional arguments:
</span>
<span> Additional arguments: </span>
</div>
<span class="bg-[#f9f2f4] p-[3px] rounded-sm text-red-500 text-sm [word-spacing:4px]">
{wget_add_args}
Expand Down

0 comments on commit 78dcb35

Please sign in to comment.