1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-19 05:27:57 +00:00
rolens/frontend/src/organisms/connection/index.svelte

60 lines
1.4 KiB
Svelte
Raw Normal View History

2023-01-16 19:03:56 +00:00
<script>
import Icon from '$components/icon.svelte';
import hostTree from '$lib/stores/hosttree';
import sharedState from '$lib/stores/sharedstate';
import CollectionView from './collection/index.svelte';
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
let path = [];
2023-01-16 19:03:56 +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">
<div class="tree-buttons">
<button class="button-small" on:click={hostTree.newHost}>
<Icon name="+" /> New host
</button>
</div>
<HostTree bind:path />
2023-01-23 12:17:07 +00:00
</div>
2023-01-16 19:03:56 +00:00
{#if activeCollKey}
<CollectionView
collection={$hostTree[activeHostKey]?.databases[activeDbKey]?.collections?.[activeCollKey]}
hostKey={activeHostKey}
dbKey={activeDbKey}
collKey={activeCollKey}
/>
{:else if activeDbKey}
<DatabaseView
database={$hostTree[activeHostKey]?.databases[activeDbKey]}
hostKey={activeHostKey}
dbKey={activeDbKey}
/>
2023-06-07 19:52:43 +00:00
{:else if activeHostKey}
<HostView
host={$hostTree[activeHostKey]}
2023-06-07 19:52:43 +00:00
hostKey={activeHostKey}
/>
{/if}
2023-01-16 19:03:56 +00:00
<style>
2023-01-23 12:17:07 +00:00
.tree {
padding: 0.5rem;
background-color: #fff;
}
.tree-buttons {
margin-bottom: 1rem;
}
</style>