Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions console/atest-ui/src/views/DataManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { GetDataManagerPreference, SetDataManagerPreference } from './cache'
import { ElMessage } from 'element-plus'
import { Codemirror } from 'vue-codemirror'
import { sql, StandardSQL, MySQL, PostgreSQL, Cassandra } from "@codemirror/lang-sql"
import type { SQLConfig } from "@codemirror/lang-sql"
import HistoryInput from '../components/HistoryInput.vue'
import type { Ref } from 'vue'
import { Refresh, Document } from '@element-plus/icons-vue'
Expand Down Expand Up @@ -153,6 +154,7 @@ API.GetStores((data) => {
loadingStores.value = false
})

const showNativeSQL = ref(true)
const ormDataHandler = (data: QueryData) => {
const result = [] as any[]
const cols = new Set<string>()
Expand All @@ -168,7 +170,7 @@ const ormDataHandler = (data: QueryData) => {

columns.value = [] as string[]
data.meta.labels = data.meta.labels.filter((item) => {
if (item.key === '_native_sql') {
if (showNativeSQL.value && item.key === '_native_sql') {
sqlQuery.value = item.value
return false
}
Expand Down Expand Up @@ -210,15 +212,15 @@ const keyValueDataHandler = (data: QueryData) => {
})
})
}

const sqlConfig = ref({
dialect: StandardSQL,
defaultSchema: queryDataMeta.value.currentDatabase,
upperCaseKeywords: true,
schema: {}
})
} as SQLConfig)

const executeQuery = async () => {
showNativeSQL.value = true
if (sqlQuery.value === '') {
switch (kind.value) {
case ExtensionKind.ExtensionKindElasticsearch:
Expand Down Expand Up @@ -291,6 +293,13 @@ Magic.AdvancedKeys([{
Keys: ['Ctrl+E', 'Ctrl+Enter'],
Func: executeQuery,
Description: 'Execute query'
}, {
Keys: ['Ctrl+Shift+O'],
Func: () => {
showNativeSQL.value = false
executeWithQuery(sqlQuery.value)
},
Description: 'Execute query without showing native SQL'
}])
</script>

Expand Down
37 changes: 3 additions & 34 deletions console/atest-ui/src/views/TestCase.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, watch, reactive } from 'vue'
import { ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import { Edit, Delete, Search, CopyDocument, Help } from '@element-plus/icons-vue'
import JsonViewer from 'vue-json-viewer'
Expand All @@ -20,9 +20,7 @@ import jsonlint from 'jsonlint-mod'

import CodeMirror from 'codemirror'
import { json, jsonLanguage } from "@codemirror/lang-json"
import { LanguageSupport } from "@codemirror/language"
import { CompletionContext } from "@codemirror/autocomplete"
import type { Completion } from "@codemirror/autocomplete"
import { NewLanguageComplete } from './languageComplete'
import 'codemirror/lib/codemirror.css'
import 'codemirror/addon/merge/merge.js'
import 'codemirror/addon/merge/merge.css'
Expand All @@ -34,36 +32,7 @@ window.DIFF_DELETE = -1;
window.DIFF_INSERT = 1;
window.DIFF_EQUAL = 0;

const templateFuncs = ref([] as Completion[])
function myCompletions(context: CompletionContext) {
if (templateFuncs.value.length == 0) {
API.FunctionsQuery("", "template", (e) => {
if (e.data) {
e.data.forEach((item: any) => {
templateFuncs.value.push({
label: item.key,
type: "text",
} as Completion)
})
}
})
}

let word = context.matchBefore(/\w*/) || {
from: "",
to: ""
}
if (word.from == word.to && !context.explicit)
return null
return {
from: word.from,
options: templateFuncs.value
}
}
const jsonComplete = new LanguageSupport(jsonLanguage, jsonLanguage.data.of(
{autocomplete: myCompletions}
))

const jsonComplete = NewLanguageComplete(jsonLanguage)
const { t } = useI18n()

const props = defineProps({
Expand Down
38 changes: 38 additions & 0 deletions console/atest-ui/src/views/languageComplete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Language, LanguageSupport } from "@codemirror/language"
import { CompletionContext } from "@codemirror/autocomplete"
import type { Completion } from "@codemirror/autocomplete"
import { API } from './net'
import { ref } from 'vue'

const templateFuncs = ref([] as Completion[])
function tplFuncCompletions(context: CompletionContext) {
if (templateFuncs.value.length == 0) {
API.FunctionsQuery("", "template", (e) => {
if (e.data) {
e.data.forEach((item: any) => {
templateFuncs.value.push({
label: item.key,
type: "text",
} as Completion)
})
}
})
}

let word = context.matchBefore(/\w*/) || {

Check warning on line 22 in console/atest-ui/src/views/languageComplete.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

console/atest-ui/src/views/languageComplete.ts#L22

'word' is never reassigned. Use 'const' instead.
from: "",
to: ""
}
if (word.from == word.to && !context.explicit)
return null
return {
from: word.from,
options: templateFuncs.value
}
}

export const NewLanguageComplete = (lang: Language) => {
return new LanguageSupport(lang, lang.data.of(
{autocomplete: tplFuncCompletions}
))
}
Loading