2023-01-16 19:03:56 +00:00
|
|
|
<script>
|
2023-06-18 19:31:55 +00:00
|
|
|
import Icon from '$components/icon.svelte';
|
|
|
|
import hostTree from '$lib/stores/hosttree';
|
|
|
|
import sharedState from '$lib/stores/sharedstate';
|
2023-06-07 19:30:22 +00:00
|
|
|
import CollectionView from './collection/index.svelte';
|
2023-06-18 19:31:55 +00:00
|
|
|
import DatabaseView from './database/index.svelte';
|
|
|
|
import HostView from './host/index.svelte';
|
2023-02-15 18:27:51 +00:00
|
|
|
import HostTree from './hosttree.svelte';
|
2023-01-16 19:03:56 +00:00
|
|
|
|
2023-06-18 19:31:55 +00:00
|
|
|
let path = [];
|
2023-01-16 19:03:56 +00:00
|
|
|
|
2023-06-18 19:31:55 +00:00
|
|
|
$: activeHostKey = path[0];
|
|
|
|
$: activeDbKey = path[1];
|
|
|
|
$: activeCollKey = path[2];
|
2023-01-28 12:25:14 +00:00
|
|
|
|
2023-05-27 19:18:47 +00:00
|
|
|
$: sharedState.currentHost.set(activeHostKey);
|
|
|
|
$: sharedState.currentDb.set(activeDbKey);
|
|
|
|
$: sharedState.currentColl.set(activeCollKey);
|
2023-01-16 19:03:56 +00:00
|
|
|
</script>
|
|
|
|
|
2023-01-23 12:17:07 +00:00
|
|
|
<div class="tree">
|
2023-05-31 18:20:39 +00:00
|
|
|
<div class="tree-buttons">
|
2023-06-18 19:31:55 +00:00
|
|
|
<button class="button-small" on:click={hostTree.newHost}>
|
2023-05-31 18:20:39 +00:00
|
|
|
<Icon name="+" /> New host
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
2023-06-18 19:31:55 +00:00
|
|
|
<HostTree bind:path />
|
2023-01-23 12:17:07 +00:00
|
|
|
</div>
|
2023-01-16 19:03:56 +00:00
|
|
|
|
2023-06-07 19:30:22 +00:00
|
|
|
{#if activeCollKey}
|
|
|
|
<CollectionView
|
2023-06-18 19:31:55 +00:00
|
|
|
collection={$hostTree[activeHostKey]?.databases[activeDbKey]?.collections?.[activeCollKey]}
|
2023-06-07 19:30:22 +00:00
|
|
|
hostKey={activeHostKey}
|
|
|
|
dbKey={activeDbKey}
|
|
|
|
collKey={activeCollKey}
|
|
|
|
/>
|
|
|
|
{:else if activeDbKey}
|
|
|
|
<DatabaseView
|
2023-06-18 19:31:55 +00:00
|
|
|
database={$hostTree[activeHostKey]?.databases[activeDbKey]}
|
2023-06-07 19:30:22 +00:00
|
|
|
hostKey={activeHostKey}
|
|
|
|
dbKey={activeDbKey}
|
|
|
|
/>
|
2023-06-07 19:52:43 +00:00
|
|
|
{:else if activeHostKey}
|
|
|
|
<HostView
|
2023-06-18 19:31:55 +00:00
|
|
|
host={$hostTree[activeHostKey]}
|
2023-06-07 19:52:43 +00:00
|
|
|
hostKey={activeHostKey}
|
|
|
|
/>
|
2023-06-07 19:30:22 +00:00
|
|
|
{/if}
|
2023-01-16 19:03:56 +00:00
|
|
|
|
2023-01-18 13:05:45 +00:00
|
|
|
<style>
|
2023-01-23 12:17:07 +00:00
|
|
|
.tree {
|
|
|
|
padding: 0.5rem;
|
|
|
|
background-color: #fff;
|
|
|
|
}
|
2023-05-31 18:20:39 +00:00
|
|
|
.tree-buttons {
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
}
|
2023-01-18 13:05:45 +00:00
|
|
|
</style>
|