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';
|
2023-05-28 21:54:40 +02:00
|
|
|
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;
|
2023-05-28 21:54:40 +02:00
|
|
|
$: if (info) {
|
|
|
|
info.viewKey = viewKey;
|
|
|
|
}
|
2023-05-26 17:21:39 +02:00
|
|
|
|
|
|
|
async function performExport() {
|
|
|
|
info.view = $views[viewKey];
|
2023-05-28 21:54:40 +02:00
|
|
|
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>
|
|
|
|
|
2023-05-28 21:54:40 +02:00
|
|
|
<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-28 21:54:40 +02:00
|
|
|
|
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>
|
2023-05-28 21:54:40 +02:00
|
|
|
<option value="ndjson">Newline delimited JSON</option>
|
2023-05-26 17:21:39 +02:00
|
|
|
<option value="csv">CSV</option>
|
|
|
|
</select>
|
|
|
|
</label>
|
2023-05-28 21:54:40 +02:00
|
|
|
|
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>
|
2023-05-28 21:54:40 +02:00
|
|
|
|
|
|
|
<button class="btn" type="submit">
|
|
|
|
<Icon name="play" />
|
|
|
|
Start export
|
|
|
|
</button>
|
2023-05-26 17:21:39 +02:00
|
|
|
</form>
|
|
|
|
</Modal>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
form {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
gap: 0.5rem;
|
|
|
|
}
|
|
|
|
</style>
|