download templates
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
import { pipe } from 'fp-ts/lib/function';
|
import { pipe } from 'fp-ts/lib/function';
|
||||||
import { onDestroy } from 'svelte';
|
import { onDestroy } from 'svelte';
|
||||||
import DownloadCard from './lib/DownloadCard.svelte';
|
import DownloadCard from './lib/DownloadCard.svelte';
|
||||||
import FloatingAction from './lib/FloatingAction.svelte';
|
|
||||||
import Footer from './lib/Footer.svelte';
|
import Footer from './lib/Footer.svelte';
|
||||||
import Navbar from './lib/Navbar.svelte';
|
import Navbar from './lib/Navbar.svelte';
|
||||||
import Spinner from './lib/Spinner.svelte';
|
import Spinner from './lib/Spinner.svelte';
|
||||||
@@ -58,7 +57,7 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<FloatingAction />
|
<!-- <FloatingAction /> -->
|
||||||
<Footer />
|
<Footer />
|
||||||
<SvelteToast />
|
<SvelteToast />
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
const minHeight = 52;
|
const minHeight = 52;
|
||||||
const maxHeight = 600;
|
const maxHeight = window.innerHeight - 60;
|
||||||
|
|
||||||
let open = false;
|
let open = false;
|
||||||
$: open = $height > minHeight;
|
$: open = $height > minHeight;
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
import { get } from 'svelte/store';
|
import { get } from 'svelte/store';
|
||||||
import Button from './Button.svelte';
|
import Button from './Button.svelte';
|
||||||
import TextField from './TextField.svelte';
|
import TextField from './TextField.svelte';
|
||||||
import { rpcClient } from './store';
|
import { downloadTemplates, rpcClient } from './store';
|
||||||
|
|
||||||
let url: string = '';
|
let url: string = '';
|
||||||
let args: string = '';
|
let args: string = '';
|
||||||
|
|
||||||
|
$: console.log(args);
|
||||||
|
|
||||||
const download = () =>
|
const download = () =>
|
||||||
get(rpcClient).download({
|
get(rpcClient).download({
|
||||||
url,
|
url,
|
||||||
@@ -14,8 +16,15 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>
|
<div class="w-full">
|
||||||
<TextField label="url" bind:value={url} />
|
<div class="flex gap-2 w-full mb-2">
|
||||||
<TextField label="args" bind:value={args} />
|
<TextField label="url" class="w-96" bind:value={url} />
|
||||||
|
<TextField label="args" class="w-96" bind:value={args} />
|
||||||
|
</div>
|
||||||
<Button on:click={download}>Download</Button>
|
<Button on:click={download}>Download</Button>
|
||||||
|
<select bind:value={args}>
|
||||||
|
{#each $downloadTemplates as template}
|
||||||
|
<option id={template.id} value={template.content}>{template.name}</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
let clazz: string = '';
|
||||||
export let label: string;
|
export let label: string;
|
||||||
export let value: any;
|
export let value: any;
|
||||||
|
|
||||||
|
export let disabled: boolean = false;
|
||||||
|
export { clazz as class };
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col gap-0.5 text-sm">
|
<div class="flex flex-col gap-0.5 text-sm">
|
||||||
<label for=""> {label} </label>
|
<label for=""> {label} </label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
class="p-2 bg-neutral-50 border rounded-lg"
|
class={`p-2 bg-neutral-50 border rounded-lg ${clazz}`}
|
||||||
on:keyup
|
on:keyup
|
||||||
bind:value
|
bind:value
|
||||||
|
{disabled}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as O from 'fp-ts/lib/Option'
|
import * as O from 'fp-ts/lib/Option'
|
||||||
import { derived, writable } from 'svelte/store'
|
import { derived, readable, writable } from 'svelte/store'
|
||||||
import { RPCClient } from './RPCClient'
|
import { RPCClient } from './RPCClient'
|
||||||
import type { RPCResult } from './types'
|
import { type CustomTemplate, type RPCResult } from './types'
|
||||||
|
|
||||||
export const rpcHost = writable<string>(localStorage.getItem('rpcHost') ?? 'localhost')
|
export const rpcHost = writable<string>(localStorage.getItem('rpcHost') ?? 'localhost')
|
||||||
export const rpcPort = writable<number>(Number(localStorage.getItem('rpcPort')) || 3033)
|
export const rpcPort = writable<number>(Number(localStorage.getItem('rpcPort')) || 3033)
|
||||||
@@ -45,3 +45,13 @@ export const rpcClient = derived(
|
|||||||
export const downloads = writable<O.Option<RPCResult[]>>(O.none)
|
export const downloads = writable<O.Option<RPCResult[]>>(O.none)
|
||||||
|
|
||||||
export const cookiesTemplate = writable<string>('')
|
export const cookiesTemplate = writable<string>('')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fetches download templates, needs manual update
|
||||||
|
*/
|
||||||
|
export const downloadTemplates = readable<CustomTemplate[]>([], (set) => {
|
||||||
|
serverApiEndpoint
|
||||||
|
.subscribe(ep => fetch(`${ep}/api/v1/template/all`)
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => set(data)))
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user