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

74 lines
1.8 KiB
Svelte
Raw Normal View History

2023-01-10 17:28:27 +01:00
<script>
2023-01-13 16:56:48 +01:00
import { tick } from 'svelte';
2023-01-10 17:28:27 +01:00
import TabBar from '../../components/tabbar.svelte';
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-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-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
async function catchQuery(event) {
tab = 'find';
await tick();
find.performQuery(event.detail);
}
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-13 16:56:48 +01:00
{:else if tab === 'find'} <Find {collection} bind:this={find} />
{:else if tab === 'insert'} <Insert {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}
No collection selected
{/if}
</div>
<style>
.collection {
height: 100%;
2023-01-11 20:41:15 +01:00
display: grid;
grid-template: auto 1fr / 1fr;
gap: 0.5rem;
2023-01-10 17:28:27 +01:00
}
.container {
2023-01-11 20:41:15 +01:00
padding: 0 0.5rem;
2023-01-10 17:28:27 +01:00
display: flex;
2023-01-11 20:41:15 +01:00
align-items: stretch;
}
.container > :global(*) {
width: 100%;
2023-01-10 17:28:27 +01:00
}
</style>