Skip to content

Commit

Permalink
Finished task "Web SQL Editor supports run SQL snippets #6248"
Browse files Browse the repository at this point in the history
  • Loading branch information
dupen01 committed Apr 7, 2024
1 parent 4fcc5c7 commit e0767bb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 14 additions & 0 deletions kyuubi-server/web-ui/src/components/monaco-editor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@
})
emit('editorMounted', editor)
}
const getSelectValue = () => {
const selection: any = editor.getSelection()
const range: any = {
startLineNumber: selection.selectionStartLineNumber,
startColumn: selection.selectionStartColumn,
endLineNumber: selection.positionLineNumber,
endColumn: selection.positionColumn
}
const model: any = editor.getModel()
return model.getValueInRange(range)
}
watch(
() => props.modelValue,
(newValue) => {
Expand Down Expand Up @@ -146,4 +157,7 @@
onMounted(() => {
init()
})
defineExpose({
getSelectValue
})
</script>
6 changes: 4 additions & 2 deletions kyuubi-server/web-ui/src/views/editor/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
</el-space>
<section>
<MonacoEditor
ref="monacoEditor"
v-model="editorVariables.content"
:language="editorVariables.language"
:theme="theme"
Expand Down Expand Up @@ -113,6 +114,7 @@
})
const limit = ref(10)
const sqlResult: Ref<any[] | null> = ref(null)
const monacoEditor = ref()
const sqlLog = ref('')
const activeTab = ref('result')
const resultLoading = ref(false)
Expand Down Expand Up @@ -156,10 +158,10 @@
if (!openSessionResponse) return
sessionIdentifier.value = openSessionResponse.identifier
}

const selectValue = monacoEditor.value.getSelectValue()
const runSqlResponse: IResponse = await runSql(
{
statement: editorVariables.content,
statement: selectValue || editorVariables.content,
runAsync: false
},
sessionIdentifier.value
Expand Down

0 comments on commit e0767bb

Please sign in to comment.