mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 18:43:58 +00:00
execute query
This commit is contained in:
@@ -13,7 +13,14 @@
|
|||||||
|
|
||||||
const commandsValue = get(commands);
|
const commandsValue = get(commands);
|
||||||
const command: any = Object.values(commandsValue).find(
|
const command: any = Object.values(commandsValue).find(
|
||||||
(x: any) => x.enabled && x.keyText && x.keyText.toLowerCase() == keyText.toLowerCase()
|
(x: any) =>
|
||||||
|
x.enabled &&
|
||||||
|
x.keyText &&
|
||||||
|
x.keyText
|
||||||
|
.toLowerCase()
|
||||||
|
.split('|')
|
||||||
|
.map(x => x.trim())
|
||||||
|
.includes(keyText.toLowerCase())
|
||||||
);
|
);
|
||||||
|
|
||||||
if (command) {
|
if (command) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div bind:clientWidth bind:clientHeight class="ace-container">
|
<div bind:clientWidth bind:clientHeight class="ace-container">
|
||||||
<AceEditorCore {...$$props} width={clientWidth} height={clientHeight} on:input/>
|
<AceEditorCore {...$$props} width={clientWidth} height={clientHeight} on:input on:focus on:blur />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import AceEditor from './AceEditor.svelte';
|
import AceEditor from './AceEditor.svelte';
|
||||||
export let engine;
|
export let engine;
|
||||||
|
let domEditor;
|
||||||
|
|
||||||
let mode;
|
let mode;
|
||||||
|
|
||||||
@@ -16,6 +17,10 @@
|
|||||||
const match = (engine || '').match(/^([^@]*)@/);
|
const match = (engine || '').match(/^([^@]*)@/);
|
||||||
mode = engineToMode[match ? match[1] : engine] || 'sql';
|
mode = engineToMode[match ? match[1] : engine] || 'sql';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getSelectedText() {
|
||||||
|
return domEditor.getSelectedText()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<AceEditor {mode} {...$$props} on:input />
|
<AceEditor {mode} {...$$props} on:input on:focus on:blur bind:this={domEditor}/>
|
||||||
|
|||||||
@@ -1,4 +1,24 @@
|
|||||||
|
<script lang="ts" context="module">
|
||||||
|
const currentQuery = writable(null);
|
||||||
|
|
||||||
|
registerCommand({
|
||||||
|
id: 'query.execute',
|
||||||
|
category: 'Query',
|
||||||
|
name: 'Execute',
|
||||||
|
icon: 'icon run',
|
||||||
|
toolbar: true,
|
||||||
|
keyText: 'F5 | Ctrl+Enter',
|
||||||
|
enabledStore: derived(currentQuery, query => query != null),
|
||||||
|
onClick: () => get(currentQuery).execute(),
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { get_current_component } from 'svelte/internal';
|
||||||
|
|
||||||
|
import { writable, derived, get } from 'svelte/store';
|
||||||
|
import registerCommand from '../commands/registerCommand';
|
||||||
|
|
||||||
import VerticalSplitter from '../elements/VerticalSplitter.svelte';
|
import VerticalSplitter from '../elements/VerticalSplitter.svelte';
|
||||||
import SqlEditor from '../query/SqlEditor.svelte';
|
import SqlEditor from '../query/SqlEditor.svelte';
|
||||||
import useEditorData from '../query/useEditorData';
|
import useEditorData from '../query/useEditorData';
|
||||||
@@ -11,6 +31,8 @@
|
|||||||
export let database;
|
export let database;
|
||||||
export let initialArgs;
|
export let initialArgs;
|
||||||
|
|
||||||
|
const instance = get_current_component();
|
||||||
|
|
||||||
$: connection = useConnectionInfo({ conid });
|
$: connection = useConnectionInfo({ conid });
|
||||||
|
|
||||||
const { editorState, setEditorData } = useEditorData({
|
const { editorState, setEditorData } = useEditorData({
|
||||||
@@ -28,6 +50,7 @@
|
|||||||
engine={$connection && $connection.engine}
|
engine={$connection && $connection.engine}
|
||||||
value={$editorState.value || ''}
|
value={$editorState.value || ''}
|
||||||
on:input={e => setEditorData(e.detail)}
|
on:input={e => setEditorData(e.detail)}
|
||||||
|
on:focus={() => currentQuery.set(instance)}
|
||||||
/>
|
/>
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</VerticalSplitter>
|
</VerticalSplitter>
|
||||||
|
|||||||
Reference in New Issue
Block a user