Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: #874 BI report Column has no information to show. #955

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 3.1.19

`2024-1-3`

**Changelog**

- ⭐【New Features】Open table supports filtering sort
- ⚡️【Optimize】Optimize startup speed
- 🐞【Fixed】SQL error generated by modifying the table structure
- 🐞【Fixed】The problem of direct query table data error due to characters
- 🐞【Fixed】null point error


## 3.1.18

`2023-12-28`
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG_CN.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 3.1.19

`2024-1-3`

**更新日志**

- ⭐【新功能】打开表支持筛选排序
- ⚡️【优化】优化启动速度
- 🐞【修复】修改表结构生成SQL错误
- 🐞【修复】直接查询表因字符导致数据错误的问题
- 🐞【修复】null point error

## 3.1.18

`2023-12-28`
Expand Down
36 changes: 9 additions & 27 deletions chat2db-client/src/blocks/Setting/AiSetting/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { useEffect, useState } from 'react';
import configService from '@/service/config';
import { AIType } from '@/typings/ai';
import { Alert, Button, Form, Input, Radio, RadioChangeEvent, Spin } from 'antd';
import { Alert, Button, Form, Input, Radio, RadioChangeEvent } from 'antd';
import i18n from '@/i18n';
import { IAiConfig } from '@/typings/setting';
import { getUser } from '@/service/user';
import { ILoginUser, IRole } from '@/typings/user';
import { IRole } from '@/typings/user';
import { AIFormConfig, AITypeName } from './aiTypeConfig';
import styles from './index.less';
import { useUserStore } from '@/store/user'

interface IProps {
handleApplyAiConfig: (aiConfig: IAiConfig) => void;
Expand All @@ -21,34 +21,16 @@ function capitalizeFirstLetter(string) {
// openAI 的设置项
export default function SettingAI(props: IProps) {
const [aiConfig, setAiConfig] = useState<IAiConfig>();
const [userInfo, setUserInfo] = useState<ILoginUser>();
const [loading, setLoading] = useState(false);

const queryUserInfo = async () => {
setLoading(true);
try {
const res = await getUser();
// 向cookie中写入当前用户id
const date = new Date('2030-12-30 12:30:00').toUTCString();
document.cookie = `CHAT2DB.USER_ID=${res?.id};Expires=${date}`;
setUserInfo(res);
} finally {
setLoading(false);
const { userInfo } = useUserStore(state => {
return {
userInfo: state.curUser
}
};

useEffect(() => {
queryUserInfo();
}, []);
})

useEffect(() => {
setAiConfig(props.aiConfig);
}, [props.aiConfig]);

if (loading) {
return <Spin spinning={loading} />;
}

if (!aiConfig) {
return <Alert description={i18n('setting.ai.tips')} type="warning" showIcon />;
}
Expand Down Expand Up @@ -84,7 +66,7 @@ export default function SettingAI(props: IProps) {
};

return (
<Spin spinning={loading}>
<>
<div className={styles.aiSqlSource}>
<div className={styles.aiSqlSourceTitle}>{i18n('setting.title.aiSource')}:</div>
<Radio.Group onChange={handleAiTypeChange} value={aiConfig?.aiSqlSource}>
Expand Down Expand Up @@ -128,6 +110,6 @@ export default function SettingAI(props: IProps) {
</div>

{/* {aiConfig?.aiSqlSource === AIType.CHAT2DBAI && !aiConfig.apiKey && <Popularize source="setting" />} */}
</Spin>
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import {
registerIntelliSenseKeyword,
registerIntelliSenseTable,
registerIntelliSenseDatabase,
resetSenseKeyword,
resetSenseTable,
resetSenseDatabase,
resetSenseField,
} from '@/utils/IntelliSense';

interface IProps {
Expand Down Expand Up @@ -42,6 +46,15 @@ const SelectBoundInfo = memo((props: IProps) => {
const [schemaList, setSchemaList] = useState<IOption<string>[]>([emptyOption]);
const [allTableList, setAllTableList] = useState<any>([]);

useEffect(() => {
if(!isActive){
resetSenseKeyword();
resetSenseTable();
resetSenseDatabase();
resetSenseField();
}
}, [isActive]);

const dataSourceList = useMemo(() => {
return (
connectionList?.map((item) => ({
Expand All @@ -55,16 +68,19 @@ const SelectBoundInfo = memo((props: IProps) => {

const supportDatabase = useMemo(() => {
return connectionList?.find((item) => item.id === boundInfo.dataSourceId)?.supportDatabase;
}, [boundInfo.dataSourceId,connectionList]);
}, [boundInfo.dataSourceId, connectionList]);

const supportSchema = useMemo(() => {
return connectionList?.find((item) => item.id === boundInfo.dataSourceId)?.supportSchema;
}, [boundInfo.dataSourceId,connectionList]);
}, [boundInfo.dataSourceId, connectionList]);

// 编辑器绑定的数据库类型变化时,重新注册智能提示
useEffect(() => {
if(!isActive){
return
}
registerIntelliSenseKeyword(boundInfo.databaseType);
}, [boundInfo.dataSourceId]);
}, [boundInfo.dataSourceId, isActive]);

// 当数据源变化时,重新获取数据库列表
useEffect(() => {
Expand Down
6 changes: 3 additions & 3 deletions chat2db-client/src/components/Iconfont/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ if (__ENV__ === 'local') {
/* 在线链接服务仅供平台体验和调试使用,平台不承诺服务的稳定性,企业客户需下载字体包自行发布使用并做好备份。 */
@font-face {
font-family: 'iconfont'; /* Project id 3633546 */
src: url('//at.alicdn.com/t/c/font_3633546_oqofqe5r679.woff2?t=1703676557975') format('woff2'),
url('//at.alicdn.com/t/c/font_3633546_oqofqe5r679.woff?t=1703676557975') format('woff'),
url('//at.alicdn.com/t/c/font_3633546_oqofqe5r679.ttf?t=1703676557975') format('truetype');
src: url('//at.alicdn.com/t/c/font_3633546_yr9ay65j0fs.woff2?t=1703837870848') format('woff2'),
url('//at.alicdn.com/t/c/font_3633546_yr9ay65j0fs.woff?t=1703837870848') format('woff'),
url('//at.alicdn.com/t/c/font_3633546_yr9ay65j0fs.ttf?t=1703837870848') format('truetype');
}
`;
const style = document.createElement('style');
Expand Down
30 changes: 25 additions & 5 deletions chat2db-client/src/components/MonacoEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ interface IProps {
defaultValue?: string;
appendValue?: IAppendValue;
didMount?: (editor: IEditorIns) => any;
shortcutKey?: (editor, monaco) => void;
isActive?: boolean;
shortcutKey?: (editor, monaco, isActive: boolean) => void;
focusChange?: (isActive: boolean) => void;
}

export interface IExportRefFunction {
Expand All @@ -51,14 +51,14 @@ function MonacoEditor(props: IProps, ref: ForwardedRef<IExportRefFunction>) {
language = 'sql',
didMount,
options,
isActive,
defaultValue,
appendValue,
shortcutKey,
} = props;
const editorRef = useRef<IEditorIns>();
const quickInputCommand = useRef<any>();
const [appTheme] = useTheme();
const [isActive, setIsActive] = React.useState(false);

// init
useEffect(() => {
Expand Down Expand Up @@ -108,12 +108,32 @@ function MonacoEditor(props: IProps, ref: ForwardedRef<IExportRefFunction>) {
};
}, []);

// 如果编辑器聚焦,就设置为true
useEffect(() => {
if (editorRef.current && isActive) {
const focus = () => {
setIsActive(true);
props.focusChange && props.focusChange(true);
};
const blur = () => {
setIsActive(false);
props.focusChange && props.focusChange(false);
};
editorRef.current?.onDidFocusEditorText(focus);
editorRef.current?.onDidBlurEditorText(blur);
// 移除监听
// return () => {
// editorRef.current?.removeEventListener('focus', focus);
// editorRef.current?.removeEventListener('blur', blur);
// };
}, []);


useEffect(() => {
if (editorRef.current) {
// eg:
// editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.KeyL, () => {
// });
shortcutKey?.(editorRef.current, monaco);
shortcutKey?.(editorRef.current, monaco, isActive);
}
}, [editorRef.current, isActive]);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.screeningResult{
display: flex;
align-items: center;
height: 18px;
padding: 4px 0px;
border-bottom: 1px solid var(--color-border);
.whereBox,.orderByBox{
width: 50%;
display: flex;
align-items: center;
height: 100%;
margin: 0px 4px;
.titleBox{
display: flex;
align-items: center;
margin-right: 10px;
width: fit-content;
flex-shrink: 0;
}
.titleIcon{
margin-right: 4px;
}
.title{
color: var(--color-text-secondary);
flex-shrink: 0;
font-weight: 500;
}
.activeTitle{
color: var(--color-primary-text);
}
.monacoEditor{
flex: 1;
height: 100%;
width: 0px;
}
}
:global {
.decorationsOverviewRuler{
display: none !important;
}
}
}