2023-01-10 17:28:27 +01:00
|
|
|
<script>
|
2023-02-15 19:27:51 +01:00
|
|
|
import BlankState from '$components/blankstate.svelte';
|
|
|
|
import TabBar from '$components/tabbar.svelte';
|
|
|
|
import { EventsOn } from '$wails/runtime/runtime';
|
2023-01-13 16:56:48 +01:00
|
|
|
import { tick } from 'svelte';
|
2023-06-18 21:31:55 +02:00
|
|
|
|
2023-02-18 15:41:53 +01:00
|
|
|
import Aggregate from './aggregate.svelte';
|
2023-01-10 17:28:27 +01:00
|
|
|
import Find from './find.svelte';
|
|
|
|
import Indexes from './indexes.svelte';
|
|
|
|
import Insert from './insert.svelte';
|
|
|
|
import Remove from './remove.svelte';
|
2023-06-24 10:11:32 +02:00
|
|
|
import Shell from './shell.svelte';
|
2023-01-11 20:41:15 +01:00
|
|
|
import Stats from './stats.svelte';
|
2023-01-18 11:22:02 +01:00
|
|
|
import Update from './update.svelte';
|
2023-01-10 17:28:27 +01:00
|
|
|
|
|
|
|
export let collection;
|
|
|
|
export let hostKey;
|
|
|
|
export let dbKey;
|
2023-06-07 21:30:22 +02:00
|
|
|
export let collKey;
|
2023-01-10 17:28:27 +01:00
|
|
|
|
|
|
|
let tab = 'find';
|
2023-01-13 16:56:48 +01:00
|
|
|
let find;
|
2023-01-10 17:28:27 +01:00
|
|
|
|
|
|
|
$: if (collection) {
|
|
|
|
collection.hostKey = hostKey;
|
|
|
|
collection.dbKey = dbKey;
|
2023-06-07 21:30:22 +02:00
|
|
|
collection.key = collKey;
|
2023-01-10 17:28:27 +01:00
|
|
|
}
|
2023-01-13 16:56:48 +01:00
|
|
|
|
2023-06-07 21:30:22 +02:00
|
|
|
$: if (hostKey || dbKey || collKey) {
|
2023-02-19 17:26:32 +01:00
|
|
|
tab = 'find';
|
|
|
|
}
|
|
|
|
|
2023-01-23 14:12:14 +01:00
|
|
|
EventsOn('OpenCollectionTab', name => (tab = name || tab));
|
|
|
|
|
2023-01-13 16:56:48 +01:00
|
|
|
async function catchQuery(event) {
|
|
|
|
tab = 'find';
|
|
|
|
await tick();
|
|
|
|
find.performQuery(event.detail);
|
|
|
|
}
|
2023-01-10 17:28:27 +01:00
|
|
|
</script>
|
|
|
|
|
2023-06-07 21:30:22 +02:00
|
|
|
<div class="view" class:empty={!collection}>
|
2023-01-10 17:28:27 +01:00
|
|
|
{#if collection}
|
2023-01-11 20:41:15 +01:00
|
|
|
{#key collection}
|
|
|
|
<TabBar tabs={[
|
2023-02-18 15:41:53 +01:00
|
|
|
{ key: 'stats', icon: 'chart', title: 'Stats' },
|
|
|
|
{ key: 'find', icon: 'db', title: 'Find' },
|
|
|
|
{ key: 'insert', icon: '+', title: 'Insert' },
|
|
|
|
{ key: 'update', icon: 'edit', title: 'Update' },
|
|
|
|
{ key: 'remove', icon: 'trash', title: 'Remove' },
|
|
|
|
{ key: 'indexes', icon: 'list', title: 'Indexes' },
|
|
|
|
{ key: 'aggregate', icon: 're', title: 'Aggregate' },
|
2023-06-24 10:11:32 +02:00
|
|
|
{ key: 'shell', icon: 'shell', title: 'Shell' },
|
2023-06-11 09:34:00 +02:00
|
|
|
]}
|
|
|
|
bind:selectedKey={tab} />
|
2023-01-10 17:28:27 +01:00
|
|
|
|
2023-01-11 20:41:15 +01:00
|
|
|
<div class="container">
|
|
|
|
{#if tab === 'stats'} <Stats {collection} />
|
2023-06-18 21:31:55 +02:00
|
|
|
{:else if tab === 'find'} <Find {collection} bind:this={find} />
|
|
|
|
{:else if tab === 'insert'} <Insert {collection} on:performFind={catchQuery} />
|
2023-01-18 11:22:02 +01:00
|
|
|
{:else if tab === 'update'} <Update {collection} on:performFind={catchQuery} />
|
2023-01-11 20:41:15 +01:00
|
|
|
{:else if tab === 'remove'} <Remove {collection} />
|
|
|
|
{:else if tab === 'indexes'} <Indexes {collection} />
|
2023-02-18 15:41:53 +01:00
|
|
|
{:else if tab === 'aggregate'} <Aggregate {collection} />
|
2023-06-24 10:11:32 +02:00
|
|
|
{:else if tab === 'shell'} <Shell {collection} />
|
2023-01-11 20:41:15 +01:00
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
{/key}
|
2023-01-10 17:28:27 +01:00
|
|
|
{:else}
|
2023-01-15 17:10:30 +01:00
|
|
|
<BlankState label="Select a collection to continue" />
|
2023-01-10 17:28:27 +01:00
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
2023-06-07 21:30:22 +02:00
|
|
|
.view {
|
2023-01-10 17:28:27 +01:00
|
|
|
height: 100%;
|
2023-01-11 20:41:15 +01:00
|
|
|
display: grid;
|
|
|
|
grid-template: auto 1fr / 1fr;
|
2023-01-10 17:28:27 +01:00
|
|
|
}
|
2023-06-07 21:30:22 +02:00
|
|
|
.view.empty {
|
2023-01-15 17:10:30 +01:00
|
|
|
grid-template: 1fr / 1fr;
|
|
|
|
}
|
2023-01-10 17:28:27 +01:00
|
|
|
|
|
|
|
.container {
|
2023-01-17 16:50:58 +01:00
|
|
|
padding: 0.5rem;
|
2023-01-10 17:28:27 +01:00
|
|
|
display: flex;
|
2023-01-11 20:41:15 +01:00
|
|
|
align-items: stretch;
|
2023-01-17 16:22:49 +01:00
|
|
|
overflow: auto;
|
|
|
|
min-height: 0;
|
|
|
|
min-width: 0;
|
2023-01-11 20:41:15 +01:00
|
|
|
}
|
|
|
|
.container > :global(*) {
|
|
|
|
width: 100%;
|
2023-01-10 17:28:27 +01:00
|
|
|
}
|
|
|
|
</style>
|