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-26 19:05:05 +00:00
|
|
|
import { EventsOn } from '$wails/runtime/runtime';
|
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-07-08 11:07:55 +00:00
|
|
|
let prevPath = '';
|
2023-06-26 19:05:05 +00:00
|
|
|
let hostTab = '';
|
|
|
|
let dbTab = '';
|
|
|
|
let collTab = '';
|
2023-01-16 19:03:56 +00:00
|
|
|
|
2023-07-08 11:07:55 +00:00
|
|
|
$: if (path.join('.') !== prevPath) {
|
|
|
|
hostTab = 'status';
|
|
|
|
dbTab = 'stats';
|
|
|
|
collTab = 'stats';
|
|
|
|
prevPath = path.join('.');
|
|
|
|
}
|
|
|
|
|
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-06-26 19:05:05 +00:00
|
|
|
|
|
|
|
EventsOn('ui.host.new', () => hostTree.newHost());
|
|
|
|
EventsOn('ui.host.edit', () => $hostTree[activeHostKey]?.edit());
|
|
|
|
EventsOn('ui.host.remove', () => $hostTree[activeHostKey]?.remove());
|
|
|
|
EventsOn('ui.host.tab', tab => {
|
|
|
|
path = path.slice(0, 1);
|
|
|
|
hostTab = tab;
|
|
|
|
});
|
|
|
|
|
|
|
|
EventsOn('ui.db.new', () => $hostTree[activeHostKey]?.newDatabase());
|
|
|
|
EventsOn('ui.db.dump', () => $hostTree[activeHostKey]?.databases[activeDbKey]?.dump());
|
|
|
|
EventsOn('ui.db.drop', () => $hostTree[activeHostKey]?.databases[activeDbKey]?.drop());
|
|
|
|
EventsOn('ui.db.tab', tab => {
|
|
|
|
path = path.slice(0, 2);
|
|
|
|
dbTab = tab;
|
|
|
|
});
|
|
|
|
|
|
|
|
EventsOn('ui.coll.new', () => $hostTree[activeHostKey]?.databases[activeDbKey]?.newCollection());
|
2023-06-29 07:50:18 +00:00
|
|
|
EventsOn('ui.coll.export', () => $hostTree[activeHostKey]?.databases[activeDbKey]?.collections[activeCollKey]?.export());
|
2023-06-26 19:05:05 +00:00
|
|
|
EventsOn('ui.coll.truncate', () => $hostTree[activeHostKey]?.databases[activeDbKey]?.collections[activeCollKey]?.truncate());
|
|
|
|
EventsOn('ui.coll.drop', () => $hostTree[activeHostKey]?.databases[activeDbKey]?.collections[activeCollKey]?.drop());
|
|
|
|
EventsOn('ui.coll.tab', tab => collTab = tab);
|
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}
|
2023-07-08 11:07:55 +00:00
|
|
|
{#key activeCollKey}
|
2023-07-19 18:01:15 +00:00
|
|
|
<CollectionView
|
|
|
|
host={$hostTree[activeHostKey]}
|
|
|
|
database={$hostTree[activeHostKey]?.databases[activeDbKey]}
|
|
|
|
collection={$hostTree[activeHostKey]?.databases[activeDbKey]?.collections?.[activeCollKey]}
|
|
|
|
bind:tab={collTab}
|
|
|
|
/>
|
2023-07-08 11:07:55 +00:00
|
|
|
{/key}
|
2023-06-07 19:30:22 +00:00
|
|
|
{:else if activeDbKey}
|
2023-07-08 11:07:55 +00:00
|
|
|
{#key activeDbKey}
|
2023-07-19 18:01:15 +00:00
|
|
|
<DatabaseView
|
|
|
|
host={$hostTree[activeHostKey]}
|
|
|
|
database={$hostTree[activeHostKey]?.databases[activeDbKey]}
|
|
|
|
bind:tab={dbTab}
|
|
|
|
/>
|
2023-07-08 11:07:55 +00:00
|
|
|
{/key}
|
2023-06-07 19:52:43 +00:00
|
|
|
{:else if activeHostKey}
|
2023-07-08 11:07:55 +00:00
|
|
|
{#key activeHostKey}
|
|
|
|
<HostView host={$hostTree[activeHostKey]} bind:tab={hostTab} />
|
|
|
|
{/key}
|
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>
|