1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-04-19 08:51:03 +00:00

75 lines
2.2 KiB
Svelte
Raw Normal View History

2023-05-26 17:21:39 +02:00
<script>
import Icon from '$components/icon.svelte';
import Modal from '$components/modal.svelte';
import views from '$lib/stores/views';
import { PerformFindExport } from '$wails/go/app/App';
2023-05-26 17:21:39 +02:00
import { createEventDispatcher } from 'svelte';
export let info;
export let collection;
const dispatch = createEventDispatcher();
let viewKey = collection.viewKey;
$: viewKey = collection.viewKey;
$: if (info) {
info.viewKey = viewKey;
}
2023-05-26 17:21:39 +02:00
async function performExport() {
info.view = $views[viewKey];
const success = await PerformFindExport(collection.hostKey, collection.dbKey, collection.key, JSON.stringify(info));
if (success) {
info = undefined;
}
2023-05-26 17:21:39 +02:00
}
</script>
<Modal bind:show={info} title="Export results" width="450px">
2023-05-26 17:21:39 +02:00
<form on:submit|preventDefault={performExport}>
<label class="field">
<span class="label">Export</span>
<select bind:value={info.contents}>
<option value="all">all records</option>
<option value="query">all records matching query</option>
<option value="querylimitskip">all records matching query, considering limit and skip</option>
</select>
</label>
2023-05-26 17:21:39 +02:00
<label class="field">
<span class="label">Format</span>
<select bind:value={info.format}>
<option value="jsonarray">JSON array</option>
<option value="ndjson">Newline delimited JSON</option>
2023-05-26 17:21:39 +02:00
<option value="csv">CSV</option>
</select>
</label>
2023-05-26 17:21:39 +02:00
<label class="field">
<span class="label">View to use</span>
<select bind:value={viewKey}>
{#each Object.entries(views.forCollection(collection.hostKey, collection.dbKey, collection.key)) as [key, { name }]}
<option value={key}>{name}</option>
{/each}
</select>
<button class="btn" type="button" on:click={() => dispatch('openViewConfig')} title="Edit view">
<Icon name="cog" />
</button>
</label>
</form>
<svelte:fragment slot="footer">
<button class="btn" on:click={performExport}>
<Icon name="play" /> Start export
</button>
</svelte:fragment>
2023-05-26 17:21:39 +02:00
</Modal>
<style>
form {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
</style>