diff --git a/frontend/src/organisms/connection/collection/insert.svelte b/frontend/src/organisms/connection/collection/insert.svelte
index 669c044..d32b0c8 100644
--- a/frontend/src/organisms/connection/collection/insert.svelte
+++ b/frontend/src/organisms/connection/collection/insert.svelte
@@ -14,6 +14,7 @@
import Form from './components/form.svelte';
export let collection;
+ export let visible = false;
const dispatch = createEventDispatcher();
const formValidity = {};
@@ -98,6 +99,8 @@
views.openConfig(collection);
}
+ $: visible && editor.focus();
+
onMount(() => {
if (collection.viewKey === 'list') {
editor.dispatch({
@@ -110,7 +113,6 @@
anchor: 3,
},
});
- editor.focus();
}
});
diff --git a/frontend/src/organisms/connection/collection/remove.svelte b/frontend/src/organisms/connection/collection/remove.svelte
index d7bb300..06703d5 100644
--- a/frontend/src/organisms/connection/collection/remove.svelte
+++ b/frontend/src/organisms/connection/collection/remove.svelte
@@ -6,6 +6,7 @@
import { onMount } from 'svelte';
export let collection;
+ export let visible = false;
let json = '';
let many = true;
@@ -23,6 +24,8 @@
);
}
+ $: visible && editor.focus();
+
onMount(() => {
editor.dispatch({
changes: {
@@ -34,7 +37,6 @@
anchor: 3,
},
});
- editor.focus();
});
diff --git a/frontend/src/organisms/connection/database/index.svelte b/frontend/src/organisms/connection/database/index.svelte
index b3d37eb..2ee1327 100644
--- a/frontend/src/organisms/connection/database/index.svelte
+++ b/frontend/src/organisms/connection/database/index.svelte
@@ -7,17 +7,15 @@
import Stats from './stats.svelte';
export let database;
- export let hostKey;
- export let dbKey;
export let tab = 'stats';
- $: if (database) {
- database.hostKey = hostKey;
- database.dbKey = dbKey;
- }
+ const tabs = {
+ 'stats': { icon: 'chart', title: 'Database stats', component: Stats },
+ 'shell': { icon: 'shell', title: 'Shell', component: Shell },
+ };
- $: if (hostKey || dbKey) {
- tab = 'stats';
+ for (const key of Object.keys(tabs)) {
+ tabs[key].key = key;
}
EventsOn('OpenStatsTab', name => (tab = name || tab));
@@ -26,17 +24,13 @@
{#if database}
{#key database}
-
-
- {#if tab === 'stats'}
- {:else if tab === 'shell'}
- {/if}
-
+
+
+ {#each Object.values(tabs) as view}
+
+
+
+ {/each}
{/key}
{:else}
@@ -61,6 +55,9 @@
min-height: 0;
min-width: 0;
}
+ .container.hidden {
+ display: none;
+ }
.container > :global(*) {
width: 100%;
}
diff --git a/frontend/src/organisms/connection/host/index.svelte b/frontend/src/organisms/connection/host/index.svelte
index 3da1b4a..cdb57e5 100644
--- a/frontend/src/organisms/connection/host/index.svelte
+++ b/frontend/src/organisms/connection/host/index.svelte
@@ -9,15 +9,17 @@
import SystemInfo from './systeminfo.svelte';
export let host;
- export let hostKey;
export let tab = 'status';
- $: if (host) {
- host.hostKey = hostKey;
- }
+ const tabs = {
+ 'status': { icon: 'chart', title: 'Host status', component: Status },
+ 'shell': { icon: 'shell', title: 'Shell', component: Shell },
+ 'logs': { icon: 'doc', title: 'Logs', component: Logs },
+ 'systemInfo': { icon: 'server', title: 'System info', component: SystemInfo },
+ };
- $: if (hostKey) {
- tab = 'status';
+ for (const key of Object.keys(tabs)) {
+ tabs[key].key = key;
}
EventsOn('OpenStatusTab', name => (tab = name || tab));
@@ -26,23 +28,13 @@
{#if host}
{#key host}
-
+
-
- {#if tab === 'status'}
- {:else if tab === 'logs'}
- {:else if tab === 'systemInfo'}
- {:else if tab === 'shell'}
- {/if}
-
+ {#each Object.values(tabs) as view}
+
+
+
+ {/each}
{/key}
{:else}
@@ -67,6 +59,9 @@
min-height: 0;
min-width: 0;
}
+ .container.hidden {
+ display: none;
+ }
.container > :global(*) {
width: 100%;
}
diff --git a/frontend/src/organisms/connection/host/logs.svelte b/frontend/src/organisms/connection/host/logs.svelte
index 6b105e1..ea61acf 100644
--- a/frontend/src/organisms/connection/host/logs.svelte
+++ b/frontend/src/organisms/connection/host/logs.svelte
@@ -8,6 +8,7 @@
import { onDestroy } from 'svelte';
export let host;
+ export let visible = false;
const autoReloadIntervals = [ 1, 2, 5, 10, 30, 60 ];
let filter = 'global';
@@ -31,6 +32,10 @@
}
async function refresh() {
+ if (!visible) {
+ return;
+ }
+
let _logs = [];
({ logs: _logs, total, error } = await host.getLogs(filter));
logs = [];
@@ -64,6 +69,8 @@
setTimeout(() => copySucceeded = false, 1500);
}
+ $: visible && !logs && refresh();
+
onDestroy(() => {
if (interval) {
clearInterval(interval);
diff --git a/frontend/src/organisms/connection/index.svelte b/frontend/src/organisms/connection/index.svelte
index a730686..277d5cd 100644
--- a/frontend/src/organisms/connection/index.svelte
+++ b/frontend/src/organisms/connection/index.svelte
@@ -9,10 +9,18 @@
import HostTree from './hosttree.svelte';
let path = [];
+ let prevPath = '';
let hostTab = '';
let dbTab = '';
let collTab = '';
+ $: if (path.join('.') !== prevPath) {
+ hostTab = 'status';
+ dbTab = 'stats';
+ collTab = 'stats';
+ prevPath = path.join('.');
+ }
+
$: activeHostKey = path[0];
$: activeDbKey = path[1];
$: activeCollKey = path[2];
@@ -55,26 +63,17 @@
{#if activeCollKey}
-
+ {#key activeCollKey}
+
+ {/key}
{:else if activeDbKey}
-
+ {#key activeDbKey}
+
+ {/key}
{:else if activeHostKey}
-
+ {#key activeHostKey}
+
+ {/key}
{/if}