2023-01-10 17:28:27 +01:00
|
|
|
<script>
|
2023-01-16 20:03:56 +01:00
|
|
|
import BlankState from '../../../components/blankstate.svelte';
|
2023-01-13 16:56:48 +01:00
|
|
|
import { tick } from 'svelte';
|
2023-01-16 20:03:56 +01:00
|
|
|
import TabBar from '../../../components/tabbar.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-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-23 14:12:14 +01:00
|
|
|
import { EventsOn } from '../../../../wailsjs/runtime/runtime';
|
2023-01-29 20:00:15 +01:00
|
|
|
import ViewConfig from './components/viewconfig.svelte';
|
2023-01-10 17:28:27 +01:00
|
|
|
|
|
|
|
export let collection;
|
|
|
|
export let hostKey;
|
|
|
|
export let dbKey;
|
|
|
|
export let collectionKey;
|
|
|
|
|
|
|
|
let tab = 'find';
|
2023-01-13 16:56:48 +01:00
|
|
|
let find;
|
2023-01-29 20:00:15 +01:00
|
|
|
let viewConfigModalOpen = false;
|
|
|
|
let firstItem;
|
2023-01-10 17:28:27 +01:00
|
|
|
|
|
|
|
$: if (collection) {
|
|
|
|
collection.hostKey = hostKey;
|
|
|
|
collection.dbKey = dbKey;
|
|
|
|
collection.key = collectionKey;
|
|
|
|
}
|
2023-01-13 16:56:48 +01:00
|
|
|
|
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-29 20:00:15 +01:00
|
|
|
|
|
|
|
function openViewConfig(event) {
|
|
|
|
firstItem = event.detail?.firstItem;
|
|
|
|
viewConfigModalOpen = true;
|
|
|
|
}
|
2023-01-10 17:28:27 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="collection" class:empty={!collection}>
|
|
|
|
{#if collection}
|
2023-01-11 20:41:15 +01:00
|
|
|
{#key collection}
|
|
|
|
<TabBar tabs={[
|
|
|
|
{ key: 'stats', title: 'Stats' },
|
|
|
|
{ key: 'find', title: 'Find' },
|
|
|
|
{ key: 'insert', title: 'Insert' },
|
|
|
|
{ key: 'update', title: 'Update' },
|
|
|
|
{ key: 'remove', title: 'Remove' },
|
|
|
|
{ key: 'indexes', title: 'Indexes' },
|
|
|
|
]} 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-01-29 20:00:15 +01:00
|
|
|
{:else if tab === 'find'} <Find {collection} bind:this={find} on:openViewConfig={openViewConfig} />
|
|
|
|
{:else if tab === 'insert'} <Insert {collection} on:performFind={catchQuery} on:openViewConfig={openViewConfig} />
|
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} />
|
|
|
|
{/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>
|
|
|
|
|
2023-01-29 20:00:15 +01:00
|
|
|
{#if collection}
|
|
|
|
<ViewConfig
|
|
|
|
bind:show={viewConfigModalOpen}
|
|
|
|
bind:activeViewKey={collection.viewKey}
|
|
|
|
{firstItem}
|
|
|
|
{collection}
|
|
|
|
/>
|
|
|
|
{/if}
|
|
|
|
|
2023-01-10 17:28:27 +01:00
|
|
|
<style>
|
|
|
|
.collection {
|
|
|
|
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-01-15 17:10:30 +01:00
|
|
|
.collection.empty {
|
|
|
|
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>
|