mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-07-19 14:14:05 +00:00
Export/dump... wip
This commit is contained in:
@ -1,12 +1,30 @@
|
||||
<script>
|
||||
import { busy, connections } from '../../../stores';
|
||||
import { applicationSettings, busy, connections } from '../../../stores';
|
||||
import Grid from '../../../components/grid.svelte';
|
||||
import Modal from '../../../components/modal.svelte';
|
||||
import { OpenConnection, OpenDatabase } from '../../../../wailsjs/go/app/App';
|
||||
import { OpenConnection, OpenDatabase, PerformExport } from '../../../../wailsjs/go/app/App';
|
||||
import DirectoryChooser from '../../../components/directorychooser.svelte';
|
||||
|
||||
export let info;
|
||||
export let hosts = {};
|
||||
|
||||
const actionLabel = {
|
||||
export: 'Perform export',
|
||||
dump: 'Perform dump',
|
||||
};
|
||||
|
||||
$: if (info) {
|
||||
info.outdir = info.outdir || $applicationSettings.defaultExportDirectory;
|
||||
info.filename = info.filename || `Export ${new Date().getTime()}`;
|
||||
|
||||
if (info.filetype === 'bson') {
|
||||
info.type = 'dump';
|
||||
}
|
||||
else {
|
||||
info.type = 'export';
|
||||
}
|
||||
}
|
||||
|
||||
async function selectHost(hostKey) {
|
||||
info.hostKey = hostKey;
|
||||
info.dbKey = undefined;
|
||||
@ -43,17 +61,35 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function performExport() {
|
||||
await PerformExport(JSON.stringify(info));
|
||||
}
|
||||
|
||||
function selectCollection(collKey) {
|
||||
info.collKeys = [ collKey ];
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show={info} title="Dump database data">
|
||||
<div class="info">
|
||||
<Modal bind:show={info} title={actionLabel[info?.type]}>
|
||||
<form on:submit|preventDefault={performExport}>
|
||||
<div class="meta">
|
||||
<!-- svelte-ignore a11y-label-has-associated-control - input is in DirectoryChooser -->
|
||||
<label class="field">
|
||||
<span class="label">Output filename</span>
|
||||
<input type="text">
|
||||
<span class="label">Output directory</span>
|
||||
<DirectoryChooser bind:value={info.outdir} />
|
||||
</label>
|
||||
<label class="field">
|
||||
<span class="label">Filename</span>
|
||||
<input type="text" bind:value={info.filename} />
|
||||
<select bind:value={info.filetype} class="filetype">
|
||||
<optgroup label="Dump (mongodump)">
|
||||
<option value="bson">.bson</option>
|
||||
</optgroup>
|
||||
<optgroup label="Export (mongoexport)">
|
||||
<option value="csv">.csv</option>
|
||||
<option value="json">.json</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div class="location">
|
||||
@ -106,11 +142,15 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button type="submit" class="btn">{actionLabel[info.type]}</button>
|
||||
</div>
|
||||
</form>
|
||||
</Modal>
|
||||
|
||||
<style>
|
||||
.info {
|
||||
form {
|
||||
display: grid;
|
||||
grid-template: auto / 1fr;
|
||||
}
|
||||
@ -124,4 +164,15 @@
|
||||
padding: 0.3rem;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.meta {
|
||||
display: grid;
|
||||
grid-template: 1fr / 1fr 1fr;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
select.filetype {
|
||||
flex: 0 1;
|
||||
}
|
||||
</style>
|
@ -1,3 +0,0 @@
|
||||
<script>
|
||||
export let info;
|
||||
</script>
|
@ -9,8 +9,7 @@
|
||||
import HostDetail from './hostdetail.svelte';
|
||||
import Icon from '../../components/icon.svelte';
|
||||
import { EventsOn } from '../../../wailsjs/runtime/runtime';
|
||||
import ExportInfo from './export/exportinfo.svelte';
|
||||
import DumpInfo from './export/dumpinfo.svelte';
|
||||
import Export from './export/export.svelte';
|
||||
import Hint from '../../components/hint.svelte';
|
||||
|
||||
export let hosts = {};
|
||||
@ -29,7 +28,6 @@
|
||||
let newCollKey = '';
|
||||
|
||||
let exportInfo;
|
||||
let dumpInfo;
|
||||
|
||||
async function getHosts() {
|
||||
hosts = await Hosts();
|
||||
@ -74,6 +72,8 @@
|
||||
|
||||
function exportCollection(collKey) {
|
||||
exportInfo = {
|
||||
type: 'export',
|
||||
filetype: 'json',
|
||||
hostKey: activeHostKey,
|
||||
dbKey: activeDbKey,
|
||||
collKeys: [ collKey ],
|
||||
@ -81,7 +81,9 @@
|
||||
}
|
||||
|
||||
function dumpCollection(collKey) {
|
||||
dumpInfo = {
|
||||
exportInfo = {
|
||||
type: 'dump',
|
||||
filetype: 'bson',
|
||||
hostKey: activeHostKey,
|
||||
dbKey: activeDbKey,
|
||||
collKeys: [ collKey ],
|
||||
@ -125,8 +127,7 @@
|
||||
{hosts}
|
||||
/>
|
||||
|
||||
<ExportInfo bind:info={exportInfo} {hosts} />
|
||||
<DumpInfo bind:info={dumpInfo} {hosts} />
|
||||
<Export bind:info={exportInfo} {hosts} />
|
||||
|
||||
{#if newDb}
|
||||
<Modal bind:show={newDb}>
|
||||
|
Reference in New Issue
Block a user