@@ -24,9 +24,12 @@ const queryResultAsJSON = ref('')
2424const columns = ref ([] as string [])
2525const queryTip = ref (' ' )
2626const loadingStores = ref (true )
27+ const showOverflowTooltip = ref (true )
2728const dataFormat = ref (' table' )
2829const dataFormatOptions = [' table' , ' json' ]
2930const queryDataMeta = ref ({} as QueryDataMeta )
31+ const largeContent = ref (' ' )
32+ const largeContentDialogVisible = ref (false )
3033
3134interface 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 >
0 commit comments