diff --git a/frontend/src/components/objecteditor.svelte b/frontend/src/components/objecteditor.svelte
index 54eaec2..36644cf 100644
--- a/frontend/src/components/objecteditor.svelte
+++ b/frontend/src/components/objecteditor.svelte
@@ -5,9 +5,13 @@
import { EditorState } from '@codemirror/state';
import { EditorView, keymap } from '@codemirror/view';
import { basicSetup } from 'codemirror';
- import { onMount } from 'svelte';
+ import { createEventDispatcher, onMount } from 'svelte';
export let text = '';
+ export let editor = undefined;
+
+ const dispatch = createEventDispatcher();
+ let editorParent;
const editorState = EditorState.create({
doc: '',
@@ -17,17 +21,14 @@
javascript(),
EditorState.tabSize.of(4),
EditorView.updateListener.of(e => {
- // if (!e.docChanged) {
- // return;
- // }
+ if (!e.docChanged) {
+ return;
+ }
text = e.state.doc.toString();
}),
],
});
- let editorParent;
- let editor;
-
onMount(() => {
editor = new EditorView({
parent: editorParent,
@@ -37,10 +38,12 @@
editor.dispatch({
changes: {
from: 0,
- to: editorState.doc.length,
+ to: editor.state.doc.length,
insert: text,
},
});
+
+ dispatch('inited', { editor });
});
@@ -49,9 +52,11 @@
diff --git a/frontend/src/organisms/connection/collection/aggregate.svelte b/frontend/src/organisms/connection/collection/aggregate.svelte
index cee90b4..fe3e3fe 100644
--- a/frontend/src/organisms/connection/collection/aggregate.svelte
+++ b/frontend/src/organisms/connection/collection/aggregate.svelte
@@ -3,7 +3,7 @@
import Icon from '$components/icon.svelte';
import Modal from '$components/modal.svelte';
import MongoCollation from '$components/mongo-collation.svelte';
- import input from '$lib/actions/input';
+ import ObjectEditor from '$components/objecteditor.svelte';
import { aggregationStageDocumentationURL, aggregationStages } from '$lib/mongo';
import { jsonLooseParse, looseJsonIsValid } from '$lib/strings';
import { Aggregate } from '$wails/go/app/App';
@@ -32,7 +32,13 @@
async function run() {
const pipeline = stages.map(stage => ({ [stage.type]: jsonLooseParse(stage.data) }));
- await Aggregate(collection.hostKey, collection.dbKey, collection.key, JSON.stringify(pipeline), JSON.stringify(options));
+ await Aggregate(
+ collection.hostKey,
+ collection.dbKey,
+ collection.key,
+ JSON.stringify(pipeline),
+ JSON.stringify(options)
+ );
}
onMount(() => {
@@ -57,8 +63,22 @@