diff --git a/web/components/chat/db-editor.tsx b/web/components/chat/db-editor.tsx index 14d8c1cff..650682cc7 100644 --- a/web/components/chat/db-editor.tsx +++ b/web/components/chat/db-editor.tsx @@ -1,8 +1,6 @@ import React from 'react'; import { useRequest } from 'ahooks'; -import { Select, Option, Table, Box, Typography, Tooltip } from '@mui/joy'; -import { Button } from 'antd'; -import AutoAwesomeMotionIcon from '@mui/icons-material/AutoAwesomeMotion'; +import { Button, Select, Table, Tooltip } from 'antd'; import { Input, Tree, Empty, Tabs } from 'antd'; import type { DataNode } from 'antd/es/tree'; import MonacoEditor from './monaco-editor'; @@ -11,6 +9,8 @@ import { useSearchParams } from 'next/navigation'; import { OnChange } from '@monaco-editor/react'; import Header from './header'; import Chart from '../chart'; +import { CaretRightOutlined, SaveFilled } from '@ant-design/icons'; +import { ColumnType } from 'antd/es/table'; const { Search } = Input; @@ -46,7 +46,8 @@ interface ITableTreeItem { function DbEditorContent({ editorValue, chartData, tableData, handleChange }: IProps) { const chartWrapper = React.useMemo(() => { - if (!chartData) return
; + if (!chartData) return null; + return (
@@ -55,40 +56,29 @@ function DbEditorContent({ editorValue, chartData, tableData, handleChange }: IP }, [chartData]); return ( - <> -
-
- -
- {chartWrapper} +
+
+
-
+
{tableData?.values?.length > 0 ? ( - - - - {tableData?.columns?.map((column: any, i: number) => ( - - ))} - - - - {tableData?.values?.map((value: any, i: number) => ( - - {Object.keys(value)?.map((v) => ( - - ))} - - ))} - -
{column}
{value[v]}
+ >((item) => ({ + key: item, + dataIndex: item, + label: item, + }))} + dataSource={tableData?.values} + /> ) : (
)} + {chartWrapper} - + ); } @@ -291,22 +281,14 @@ function DbEditor() { {beforeStr} {searchValue} {afterStr} - {item?.type && ( - - {`[${item?.type}]`} - - )} + {item?.type &&
{`[${item?.type}]`}
} ) : ( {strTitle} - {item?.type && ( - - {`[${item?.type}]`} - - )} + {item?.type &&
{`[${item?.type}]`}
}
); @@ -420,14 +402,45 @@ function DbEditor() {
-
-
+
+
+ { - setCurrentRound(newValue); - }} - > - {rounds?.data?.map((item: RoundProps) => ( - - ))} - - -
- - {treeData && treeData.length > 0 && ( - { - setExpandedKeys(newExpandedKeys); - setAutoExpandParent(false); - }} - expandedKeys={expandedKeys} - autoExpandParent={autoExpandParent} - treeData={treeData} - fieldNames={{ - title: 'showTitle', - }} - /> - )} -
-
{Array.isArray(editorValue) ? ( - <> - .ant-tabs-nav .ant-tabs-tab, & .ant-tabs-card.ant-tabs-top >div>.ant-tabs-nav .ant-tabs-tab': { - borderRadius: '0', - }, +
+ { + setCurrentTabIndex(activeKey); + setNewEditorValue(editorValue?.[Number(activeKey)]); }} - > - { - setCurrentTabIndex(activeKey); - setNewEditorValue(editorValue?.[Number(activeKey)]); - }} - items={editorValue?.map((item, i) => ({ - key: i + '', - label: item?.title, - children: ( -
- { - const { sql, thoughts } = resolveSqlAndThoughts(value); - setNewEditorValue((old) => { - return Object.assign({}, old, { - sql, - thoughts, - }); + items={editorValue?.map((item, i) => ({ + key: i + '', + label: item?.title, + children: ( +
+ { + const { sql, thoughts } = resolveSqlAndThoughts(value); + setNewEditorValue((old) => { + return Object.assign({}, old, { + sql, + thoughts, }); - }} - tableData={tableData} - chartData={chartData} - /> -
- ), - }))} - /> - - + }); + }} + tableData={tableData} + chartData={chartData} + /> +
+ ), + }))} + /> +
) : ( { if (language !== 'mysql') { return value; @@ -32,11 +35,8 @@ export default function MonacoEditor({ className, value, language = 'mysql', onC value={editorValue} language={language} onChange={onChange} - theme="vs-dark" + theme={mode === 'dark' ? 'vs-dark' : 'light'} options={{ - minimap: { - enabled: false, - }, wordWrap: 'on', }} />