diff --git a/frontend/src/lib/strings.js b/frontend/src/lib/strings.js
index 1d05eab..cc06f29 100644
--- a/frontend/src/lib/strings.js
+++ b/frontend/src/lib/strings.js
@@ -24,8 +24,5 @@ export function looseJsonIsValid(json) {
}
export function stringCouldBeID(string) {
- if (looseJsonIsValid(string)) {
- return false;
- }
return /^[a-zA-Z0-9_-]{1,}$/.test(string);
}
diff --git a/frontend/src/organisms/connection/collection/index.svelte b/frontend/src/organisms/connection/collection/index.svelte
index e0018ec..696f8b9 100644
--- a/frontend/src/organisms/connection/collection/index.svelte
+++ b/frontend/src/organisms/connection/collection/index.svelte
@@ -12,6 +12,8 @@
import Stats from './stats.svelte';
import Update from './update.svelte';
+ export let host;
+ export let database;
export let collection;
export let tab = 'stats';
@@ -47,6 +49,8 @@
this={view.component}
visible={tab === view.key}
on:performFind={catchQuery}
+ {host}
+ {database}
{collection}
/>
diff --git a/frontend/src/organisms/connection/database/index.svelte b/frontend/src/organisms/connection/database/index.svelte
index 2ee1327..9de360f 100644
--- a/frontend/src/organisms/connection/database/index.svelte
+++ b/frontend/src/organisms/connection/database/index.svelte
@@ -6,6 +6,7 @@
import Shell from '../shell.svelte';
import Stats from './stats.svelte';
+ export let host;
export let database;
export let tab = 'stats';
@@ -28,7 +29,7 @@
{#each Object.values(tabs) as view}
-
+
{/each}
{/key}
diff --git a/frontend/src/organisms/connection/index.svelte b/frontend/src/organisms/connection/index.svelte
index 277d5cd..370bfb4 100644
--- a/frontend/src/organisms/connection/index.svelte
+++ b/frontend/src/organisms/connection/index.svelte
@@ -64,11 +64,20 @@
{#if activeCollKey}
{#key activeCollKey}
-
+
{/key}
{:else if activeDbKey}
{#key activeDbKey}
-
+
{/key}
{:else if activeHostKey}
{#key activeHostKey}
diff --git a/frontend/src/organisms/connection/shell.svelte b/frontend/src/organisms/connection/shell.svelte
index 5ebf6ea..aeb2e2b 100644
--- a/frontend/src/organisms/connection/shell.svelte
+++ b/frontend/src/organisms/connection/shell.svelte
@@ -2,6 +2,7 @@
import BlankState from '$components/blankstate.svelte';
import CodeEditor from '$components/codeeditor.svelte';
import Icon from '$components/icon.svelte';
+ import { OpenShellScript, SaveShellScript } from '$wails/go/app/App';
import { javascript } from '@codemirror/lang-javascript';
import { onDestroy, onMount } from 'svelte';
@@ -19,7 +20,7 @@
let busy = false;
let editor;
- async function run() {
+ async function runScript() {
busy = true;
if (collection) {
@@ -35,6 +36,36 @@
busy = false;
}
+ async function loadScript() {
+ const _script = await OpenShellScript();
+ if (_script) {
+ script = _script;
+ editor.dispatch({
+ changes: {
+ from: 0,
+ to: editor.state.doc.length,
+ insert: script,
+ },
+ selection: {
+ from: 0,
+ anchor: 0,
+ to: 0,
+ head: 0,
+ },
+ });
+ }
+ }
+
+ async function saveScript() {
+ await SaveShellScript(
+ host?.key || '',
+ database?.key || '',
+ collection?.key || '',
+ script,
+ false // not temporary
+ );
+ }
+
async function copyErrorDescription() {
await navigator.clipboard.writeText(result.errorDescription);
copySucceeded = true;
@@ -86,10 +117,19 @@
-