s7monk commented on code in PR #315:
URL: https://github.com/apache/paimon-webui/pull/315#discussion_r1630539611


##########
paimon-web-ui/src/views/playground/components/query/components/console/components/table/index.tsx:
##########
@@ -22,18 +22,27 @@ import { useJobStore } from '@/store/job'
 
 export default defineComponent({
   name: 'TableResult',
-  setup() {
+  props: {
+    maxHeight: {
+      type: Number,

Review Comment:
   done.



##########
paimon-web-ui/src/views/playground/components/query/components/console/components/table/index.tsx:
##########
@@ -83,26 +99,76 @@ export default defineComponent({
       }
     })
 
+    const updateTableWidth = () => {
+      if (tableContainer.value) {
+        const totalColumnWidth = columns.value.reduce((acc, col) => acc + 
(col.originalWidth || 100), 0)
+        if (totalColumnWidth > tableContainer.value.clientWidth) {
+          scrollX.value = `${totalColumnWidth}px`
+          columns.value.forEach((col) => {
+            if (col.originalWidth !== undefined)
+              col.width = col.originalWidth
+          })
+        }
+        else {
+          scrollX.value = ''
+          columns.value.forEach((col) => {
+            col.width = undefined
+          })
+        }
+      }
+    }
+
+    watchEffect(updateTableWidth)
+
+    watch(data, async (newData) => {
+      if (newData && newData.length > 0) {
+        await nextTick()
+        if (tableContainer.value) {
+          const headerElement = 
tableContainer.value.querySelector('.n-data-table-base-table-header')
+          if (headerElement) {
+            const headerHeight = headerElement.clientHeight
+            maxTableHeight.value = Math.max(0, props.maxHeight - headerHeight)
+          }
+        }
+      }
+    }, { immediate: true })
+
+    onMounted(() => {
+      nextTick(() => {
+        updateTableWidth()
+        window.addEventListener('resize', updateTableWidth)
+      })
+    })
+
     onUnmounted(() => {
       mittBus.off('triggerDownloadCsv')
       mittBus.off('triggerCopyData')
+      window.removeEventListener('resize', updateTableWidth)
     })
 
     return {
       columns,
       data,
       tableRef,
+      tableContainer,
+      scrollX,
+      maxHeight: props.maxHeight,
+      maxTableHeight,
     }
   },
   render() {
     return (
-      <div>
+      <div
+        ref={(el: any) => { this.tableContainer = el }}

Review Comment:
   done.



##########
paimon-web-ui/src/views/playground/components/query/components/console/index.tsx:
##########
@@ -38,16 +41,38 @@ export default defineComponent({
       emit('ConsoleClose', 'close')
     }
 
+    const handleResize = throttle((entries) => {
+      for (const entry of entries) {
+        const { height } = entry.contentRect
+        adjustedHeight.value = height - 106
+      }
+    }, 100)
+
+    let resizeObserver: ResizeObserver
+    onMounted(() => {
+      if (editorConsoleRef.value) {
+        resizeObserver = new ResizeObserver(handleResize)
+        resizeObserver.observe(editorConsoleRef.value)
+      }
+    })
+
+    onUnmounted(() => {
+      if (editorConsoleRef.value)
+        resizeObserver.unobserve(editorConsoleRef.value)
+    })
+
     return {
       t,
       handleUp,
       handleDown,
       handleClose,
+      editorConsoleRef,
+      adjustedHeight,
     }
   },
   render() {
     return (
-      <div class={styles['editor-console']}>
+      <div class={styles['editor-console']} ref={(el: any) => { 
this.editorConsoleRef = el }}>

Review Comment:
   done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to