Skip to content

Commit 37ae152

Browse files
committed
add data query ui page
1 parent 9f88604 commit 37ae152

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

console/atest-ui/src/App.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
Share,
88
ArrowDown,
99
Guide,
10+
DataAnalysis
1011
} from '@element-plus/icons-vue'
1112
import { ref, watch } from 'vue'
1213
import { API } from './views/net'
@@ -17,6 +18,7 @@ import MockManager from './views/MockManager.vue'
1718
import StoreManager from './views/StoreManager.vue'
1819
import SecretManager from './views/SecretManager.vue'
1920
import WelcomePage from './views/WelcomePage.vue'
21+
import DataManager from './views/DataManager.vue'
2022
import { useI18n } from 'vue-i18n'
2123
2224
const { t, locale: i18nLocale } = useI18n()
@@ -114,6 +116,10 @@ const toHistoryPanel = ({ ID: selectID, panelName: historyPanelName }) => {
114116
<el-icon><Guide /></el-icon>
115117
<template #title>{{ t('title.mock' )}}</template>
116118
</el-menu-item>
119+
<el-menu-item index="data" test-id="data-menu">
120+
<el-icon><DataAnalysis /></el-icon>
121+
<template #title>{{ t('title.data' )}}</template>
122+
</el-menu-item>
117123
<el-menu-item index="secret">
118124
<el-icon><document /></el-icon>
119125
<template #title>{{ t('title.secrets') }}</template>
@@ -142,6 +148,7 @@ const toHistoryPanel = ({ ID: selectID, panelName: historyPanelName }) => {
142148
</div>
143149
<TestingPanel v-if="panelName === 'testing'" @toHistoryPanel="toHistoryPanel"/>
144150
<TestingHistoryPanel v-else-if="panelName === 'history'" :ID="ID"/>
151+
<DataManager v-else-if="panelName === 'data'" />
145152
<MockManager v-else-if="panelName === 'mock'" />
146153
<StoreManager v-else-if="panelName === 'store'" />
147154
<SecretManager v-else-if="panelName === 'secret'" />
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<script setup lang="ts">
2+
import { ref } from 'vue'
3+
import { API } from './net'
4+
5+
const sqlQuery = ref('')
6+
const queryResult = ref([])
7+
8+
const executeQuery = async () => {
9+
API.DataQuery(sqlQuery.value, (data) => {
10+
queryResult.value = data
11+
})
12+
}
13+
</script>
14+
15+
<template>
16+
<div>
17+
<el-form @submit.prevent="executeQuery">
18+
<el-form-item>
19+
<el-input v-model="sqlQuery" placeholder="Enter SQL query"></el-input>
20+
</el-form-item>
21+
<el-form-item>
22+
<el-button type="primary" @click="executeQuery">Execute</el-button>
23+
</el-form-item>
24+
</el-form>
25+
<el-table :data="queryResult">
26+
<el-table-column v-for="(value, key) in queryResult[0]" :key="key" :prop="key" :label="key"></el-table-column>
27+
</el-table>
28+
</div>
29+
</template>

console/atest-ui/src/views/net.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,21 @@ var SBOM = (callback: (d: any) => void) => {
773773
.then(callback)
774774
}
775775

776+
var DataQuery = (query: string, callback: (d: any) => void) => {
777+
const requestOptions = {
778+
method: 'POST',
779+
headers: {
780+
'X-Store-Name': Cache.GetCurrentStore().name
781+
},
782+
body: JSON.stringify({
783+
sql: query
784+
})
785+
}
786+
fetch(`/api/v1/data/query`, requestOptions)
787+
.then(DefaultResponseProcess)
788+
.then(callback)
789+
}
790+
776791
export const API = {
777792
DefaultResponseProcess,
778793
GetVersion,
@@ -785,6 +800,6 @@ export const API = {
785800
FunctionsQuery,
786801
GetSecrets, DeleteSecret, CreateOrUpdateSecret,
787802
GetSuggestedAPIs,
788-
ReloadMockServer, GetMockConfig, SBOM,
803+
ReloadMockServer, GetMockConfig, SBOM, DataQuery,
789804
getToken
790805
}

0 commit comments

Comments
 (0)