Skip to content

Commit f71337c

Browse files
committed
feat: improve the ui for the larget content view on data mgr
1 parent 403545f commit f71337c

File tree

2 files changed

+40
-8
lines changed

2 files changed

+40
-8
lines changed

console/atest-ui/src/views/DataManager.vue

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ const queryResultAsJSON = ref('')
2424
const columns = ref([] as string[])
2525
const queryTip = ref('')
2626
const loadingStores = ref(true)
27+
const showOverflowTooltip = ref(true)
2728
const dataFormat = ref('table')
2829
const dataFormatOptions = ['table', 'json']
2930
const queryDataMeta = ref({} as QueryDataMeta)
31+
const largeContent = ref('')
32+
const largeContentDialogVisible = ref(false)
3033
3134
interface TreeItem {
3235
label: string
@@ -140,22 +143,28 @@ const ormDataHandler = (data: QueryData) => {
140143
result.push(obj)
141144
})
142145
146+
columns.value = [] as string[]
143147
data.meta.labels = data.meta.labels.filter((item) => {
144148
if (item.key === '_native_sql') {
145149
sqlQuery.value = item.value
146150
return false
147151
}
152+
if (item.key === '_columns') {
153+
columns.value = JSON.parse(item.value)
154+
}
148155
return !item.key.startsWith('_')
149156
})
150157
151158
queryDataMeta.value = data.meta
152159
queryResult.value = result
153160
queryResultAsJSON.value = JSON.stringify(result, null, 2)
154-
columns.value = Array.from(cols).sort((a, b) => {
155-
if (a === 'id') return -1;
156-
if (b === 'id') return 1;
157-
return a.localeCompare(b);
158-
})
161+
if (columns.value.length == 0) {
162+
columns.value = Array.from(cols).sort((a, b) => {
163+
if (a === 'id') return -1;
164+
if (b === 'id') return 1;
165+
return a.localeCompare(b);
166+
})
167+
}
159168
160169
tablesTree.value = []
161170
queryDataMeta.value.tables.forEach((i) => {
@@ -231,6 +240,19 @@ const nextPage = () => {
231240
query.value.offset += query.value.limit
232241
executeQuery()
233242
}
243+
const overflowChange = () => {
244+
showOverflowTooltip.value = !showOverflowTooltip.value
245+
}
246+
const tryShowPrettyJSON = (row: any, column: any, cell: HTMLTableCellElement, event: Event) => {
247+
const cellValue = row[column.rawColumnKey]
248+
const obj = JSON.parse(cellValue)
249+
if (obj) {
250+
largeContent.value = JSON.stringify(obj, null, 2)
251+
}
252+
}
253+
watch(largeContent, (e) => {
254+
largeContentDialogVisible.value = e !== ''
255+
})
234256
</script>
235257

236258
<template>
@@ -312,15 +334,25 @@ const nextPage = () => {
312334
<el-tag type="primary" v-if="queryResult.length > 0">{{ queryResult.length }} rows</el-tag>
313335
<el-tag type="primary" v-if="queryDataMeta.duration">{{ queryDataMeta.duration }}</el-tag>
314336
<el-tag type="primary" v-for="label in queryDataMeta.labels">{{ label.value }}</el-tag>
337+
<el-check-tag type="primary" :checked="showOverflowTooltip" @change="overflowChange" v-if="queryResult.length > 0">overflow</el-check-tag>
315338
</div>
316-
<el-table :data="queryResult" stripe v-if="dataFormat === 'table'" height="calc(100vh - 200px)">
317-
<el-table-column v-for="col in columns" :key="col" :prop="col" :label="col" sortable />
339+
<el-table :data="queryResult" stripe v-if="dataFormat === 'table'" height="calc(100vh - 200px)" @cell-dblclick="tryShowPrettyJSON">
340+
<el-table-column v-for="col in columns" :key="col" :prop="col" :label="col" sortable :show-overflow-tooltip="showOverflowTooltip" />
318341
</el-table>
319342
<Codemirror v-else-if="dataFormat === 'json'" v-model="queryResultAsJSON" />
320343
</el-main>
321344
</el-container>
322345
</el-container>
323346
</div>
347+
348+
<el-dialog
349+
v-model="largeContentDialogVisible"
350+
destroy-on-close
351+
@closed="largeContent=''"
352+
center
353+
>
354+
<Codemirror v-model="largeContent" />
355+
</el-dialog>
324356
</template>
325357

326358
<style>

docs/site/content/zh/latest/tasks/grpc-manual.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,4 @@ expect:
117117

118118
请注意,对于服务端流和双向流模式,服务器发送多条消息的情况下,此处的`data`字段内的填写的目标数组,需同时满足与待验证数组长度相,两个数组同一下标的内容完全相同。
119119

120-
`gRPC API`的`verify`功能与`HTTP API`保持一致,此处不再赘述。
120+
`gRPC API`的`verify`功能与`HTTP API`保持一致,此处不再赘述。

0 commit comments

Comments
 (0)