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';
|
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-07-01 21:34: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;
|
2023-07-08 13:07:55 +02:00
|
|
|
export let tab = 'stats';
|
2023-01-10 17:28:27 +01:00
|
|
|
|
2023-07-08 13:07:55 +02:00
|
|
|
const tabs = {
|
|
|
|
'stats': { icon: 'chart', title: 'Stats', component: Stats },
|
|
|
|
'find': { icon: 'db', title: 'Find', component: Find },
|
|
|
|
'insert': { icon: '+', title: 'Insert', component: Insert },
|
|
|
|
'update': { icon: 'edit', title: 'Update', component: Update },
|
|
|
|
'remove': { icon: 'trash', title: 'Remove', component: Remove },
|
|
|
|
'indexes': { icon: 'list', title: 'Indexes', component: Indexes },
|
|
|
|
'aggregate': { icon: 're', title: 'Aggregate', component: Aggregate },
|
|
|
|
'shell': { icon: 'shell', title: 'Shell', component: Shell },
|
|
|
|
};
|
2023-01-10 17:28:27 +01:00
|
|
|
|
2023-07-08 13:07:55 +02:00
|
|
|
for (const key of Object.keys(tabs)) {
|
|
|
|
tabs[key].key = key;
|
2023-01-10 17:28:27 +01:00
|
|
|
}
|
2023-01-13 16:56:48 +01:00
|
|
|
|
|
|
|
async function catchQuery(event) {
|
|
|
|
tab = 'find';
|
|
|
|
await tick();
|
2023-07-08 13:07:55 +02:00
|
|
|
tabs.find.instance.performQuery(event.detail);
|
2023-01-13 16:56:48 +01:00
|
|
|
}
|
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-07-08 13:07:55 +02:00
|
|
|
<TabBar tabs={Object.values(tabs)} bind:selectedKey={tab} />
|
2023-01-10 17:28:27 +01:00
|
|
|
|
2023-07-08 13:07:55 +02:00
|
|
|
{#each Object.values(tabs) as view}
|
|
|
|
<div class="container" class:hidden={tab !== view.key}>
|
|
|
|
<svelte:component
|
|
|
|
this={view.component}
|
|
|
|
visible={tab === view.key}
|
|
|
|
on:performFind={catchQuery}
|
|
|
|
{collection}
|
|
|
|
/>
|
2023-01-11 20:41:15 +01:00
|
|
|
</div>
|
2023-07-08 13:07:55 +02:00
|
|
|
{/each}
|
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
|
|
|
}
|
2023-07-08 13:07:55 +02:00
|
|
|
.container.hidden {
|
|
|
|
display: none;
|
|
|
|
}
|
2023-01-11 20:41:15 +01:00
|
|
|
.container > :global(*) {
|
|
|
|
width: 100%;
|
2023-01-10 17:28:27 +01:00
|
|
|
}
|
|
|
|
</style>
|