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
77 changes: 71 additions & 6 deletions console/atest-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions console/atest-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"test": "vitest"
},
"dependencies": {
"@codemirror/lang-json": "^6.0.2",
"@codemirror/lang-sql": "github:codemirror/lang-sql",
"@vueuse/core": "^10.11.0",
"codemirror": "^5.65.17",
"diff-match-patch": "^1.0.5",
Expand Down
8 changes: 8 additions & 0 deletions console/atest-ui/src/assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@

--page-title-right-padding: 10px;
--page-title-bottom-padding: 5px;

--sql-editor-height: 180px;

Check notice on line 46 in console/atest-ui/src/assets/base.css

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

console/atest-ui/src/assets/base.css#L46

Unexpected empty line before custom property (custom-property-empty-line-before)
--payload-editor-height: 180px;
}

*,
Expand Down Expand Up @@ -99,3 +102,8 @@
height: 32px;
padding-bottom: var(--page-title-bottom-padding, 0px);
}

.block-align-right {
display: flex;
justify-content: flex-end;
}
1 change: 0 additions & 1 deletion console/atest-ui/src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#app {
margin: 0 auto;
{{/* padding-top: 40px; */}}
height: 100vh;
font-weight: normal;
}
Expand Down
1 change: 1 addition & 0 deletions console/atest-ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"send": "Send",
"copy": "Copy",
"ok": "OK",
"next-page": "Next",
"reload": "Reload",
"insertSample": "Insert Sample",
"toolbox": "Tool Box",
Expand Down
1 change: 1 addition & 0 deletions console/atest-ui/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"send": "发送",
"copy": "拷贝",
"ok": "确定",
"next-page": "下一页",
"reload": "重新加载",
"insertSample": "插入样例",
"toolbox": "工具箱",
Expand Down
21 changes: 18 additions & 3 deletions console/atest-ui/src/views/DataManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { Pair } from './types'
import { GetDataManagerPreference, SetDataManagerPreference } from './cache'
import { ElMessage } from 'element-plus'
import { Codemirror } from 'vue-codemirror'
import { sql, StandardSQL } 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 @@ -176,7 +177,9 @@ const ormDataHandler = (data: QueryData) => {
}

tablesTree.value = []
sqlConfig.value.schema = {}
queryDataMeta.value.tables.forEach((i) => {
sqlConfig.value.schema[i] = []
tablesTree.value.push({
label: i,
})
Expand All @@ -194,6 +197,13 @@ const keyValueDataHandler = (data: QueryData) => {
})
}

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

const executeQuery = async () => {
if (sqlQuery.value === '') {
switch (kind.value) {
Expand Down Expand Up @@ -264,7 +274,7 @@ watch(largeContent, (e) => {
})

Magic.AdvancedKeys([{
Keys: ['Ctrl+E'],
Keys: ['Ctrl+E', 'Ctrl+Enter'],
Func: executeQuery,
Description: 'Execute query'
}])
Expand Down Expand Up @@ -342,11 +352,16 @@ Magic.AdvancedKeys([{
</el-input>
</el-col>
<el-col :span="2">
<el-button type="primary" @click="nextPage">Next</el-button>
<el-button type="primary" @click="nextPage">{{ t("button.next-page") }}</el-button>
</el-col>
</el-row>
</el-form>
<Codemirror v-model="sqlQuery" v-if="complexEditor" style="height: 180px"/>
<Codemirror
v-model="sqlQuery"
v-if="complexEditor"
style="height: var(--sql-editor-height);"
:extensions="[sql(sqlConfig)]"
/>
</el-header>
<el-main>
<div style="display: flex; gap: 8px;">
Expand Down
36 changes: 36 additions & 0 deletions console/atest-ui/src/views/TestCase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import { Codemirror } from 'vue-codemirror'
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 'codemirror/lib/codemirror.css'
import 'codemirror/addon/merge/merge.js'
import 'codemirror/addon/merge/merge.css'
Expand All @@ -30,6 +34,36 @@ 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 { t } = useI18n()

const props = defineProps({
Expand Down Expand Up @@ -1141,6 +1175,8 @@ Magic.AdvancedKeys([{
<Codemirror v-if="bodyType === 3 || bodyType === 5 || bodyType === 6"
@blur="jsonFormat(-1)"
v-model="testCaseWithSuite.data.request.body"
style="height: var(--payload-editor-height);"
:extensions="[json(), jsonComplete]"
:disabled="isHistoryTestCase"/>
<el-table :data="testCaseWithSuite.data.request.form" style="width: 100%" v-if="bodyType === 4">
<el-table-column label="Key" width="180">
Expand Down
Loading