Skip to content

Commit

Permalink
Merge pull request #894 from chat2db/refactor-workspace
Browse files Browse the repository at this point in the history
Refactor workspace
  • Loading branch information
shanhexi authored Nov 28, 2023
2 parents f1d5aeb + a440573 commit 46eee1f
Show file tree
Hide file tree
Showing 82 changed files with 1,406 additions and 1,387 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 3.0.14

`2023-11-20`

**Changelog**

- 🐞【Fixed】Team paging problem
- 🐞【Fixed】Oracle service name bug
- 🐞【Fixed】Oracle datatype error
- 🐞【Fixed】Fixed an issue where MySQL changed table structure without displaying comments.
- ⚡️【Optimize】Support database or schema
- 【Developer】Friends don't worry, the company has some things recently, and is preparing 3.1.0, be patient

## 3.0.13

`2023-11-15`
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.0.14

`2023-11-20`

**更新日志**

- 🐞【修复】团队分页问题
- 🐞【修复】Oracle服务名称错误
- 🐞【修复】Oracle数据类型错误
- 🐞【修复】修复MySQL修改表结构,不回显注释的问题。
- ⚡️【优化】支持数据库或模式
- 【开发者】友友们不要着急呀,最近公司有些事情,并且在准备3.1.0,耐心等待哦
## 3.0.13

`2023-11-15`
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ Redis and MongoDB are partially supported , Hbase、Elasticsearch、openGauss、

### CONFIGURE CUSTOM AI

* [Refer here to deploy your ChatGLM-6B model](https://github.com/chat2db/chat2db-chatglm-6b-deploy)
* [Refer here to deploy your sqlcoder model](https://github.com/chat2db/chat2db-sqlcoder-deploy)
* The rest api format for Custom AI is same as ChatGPT.

## 📦 Docker installation

Expand Down Expand Up @@ -179,12 +178,18 @@ $ npm run build:web:prod / cp -r dist ../chat2db-server/chat2db-server-start/src

## ☎️ Contact Us

Please star and fork on GitHub before joining the group.
Follow our WeChat public account.
### WeChat

<a><img src="https://github.com/chat2db/Chat2DB/assets/22975773/e4239d29-1426-4361-bf57-f1b0b67d1281" width="40%"/></a>

Click and join <a href="https://discord.gg/dqae8nsC">discord server</a>
### Discord
<!-- [![Discord](https://img.shields.io/badge/-Discord-%237289DA.svg?style=flat&logo=Discord&logoColor=white)](您的Discord邀请链接) -->
[![Discord](https://img.shields.io/badge/-Join%20us%20on%20Discord-%237289DA.svg?style=flat&logo=discord&logoColor=white)](https://discord.gg/N6JscF7q)

## LICENSE

The primary license used by this software is the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0), supplemented by the [Chat2DB License](./Chat2DB_LICENSE).


## ❤️ Acknowledgements

Expand Down
3 changes: 1 addition & 2 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ Redis和MongoDB得到部分支持,Hbase、Elasticsearch、openGauss、TiDB、I
### 使用Chat2DB AI 上手即用

### 使用自定义大模型
- [参考这里部署本地ChatGLM-6B模型](https://github.com/chat2db/chat2db-chatglm-6b-deploy/blob/main/README_CN.md)
- [参考这里部署本地sqlcoder模型](https://github.com/chat2db/chat2db-sqlcoder-deploy/blob/main/README_CN.md)
- 使用自定义大模型,接口格式需要和open ai的接口格式保持一致

## 📦 Docker 部署

Expand Down
24 changes: 24 additions & 0 deletions chat2db-client/.umirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,30 @@ export default defineConfig({
path: '/',
component: '@/layouts/GlobalLayout',
routes: [
{
path: '/login',
component: '@/pages/login',
},
{
path: '/demo',
component: '@/pages/demo',
},
{
path: '/connections',
component: 'main',
},
{
path: '/dashboard',
component: 'main',
},
{
path: '/team',
component: 'main',
},
{
path: '/workspace',
component: 'main',
},
{
path: '/',
component: 'main',
Expand Down
18 changes: 10 additions & 8 deletions chat2db-client/src/blocks/CreateConnection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ type IEditConnectionDetail = IConnectionDetails | null | Pick<IConnectionDetails

interface IProps {
className?: string;
onSubmit?: (data: IConnectionDetails) => void; // 点击保存或修改的回调,我会把数据给你
connectionDetail: IEditConnectionDetail;
onSubmit?: (data: IConnectionDetails) => Promise<any>; // 点击保存或修改的回调,我会把数据给你
connectionDetail: IEditConnectionDetail | null | undefined;
noPermission?: boolean;
}

export default memo<IProps>((props) => {
const { className, onSubmit, connectionDetail: externalConnectionDetail } = props;
const [connectionDetail, setConnectionDetail] = useState<IEditConnectionDetail>(externalConnectionDetail);
const [connectionDetail, setConnectionDetail] = useState<IEditConnectionDetail | null | undefined>(
externalConnectionDetail,
);

useEffect(() => {
setConnectionDetail(externalConnectionDetail);
Expand All @@ -32,9 +34,9 @@ export default memo<IProps>((props) => {
});
}

function handleSubmit(data: IConnectionDetails) {
onSubmit?.(data);
}
// function handleSubmit(data: IConnectionDetails) {
// return onSubmit?.(data);
// }

return (
<div className={classnames(styles.box, className)}>
Expand All @@ -49,11 +51,11 @@ export default memo<IProps>((props) => {
setConnectionDetail(null);
}}
connectionData={connectionDetail as any}
submit={handleSubmit}
submit={onSubmit}
/>
</div>
)}
{!connectionDetail && (
{connectionDetail === null && (
<div className={styles.dataBaseListBox}>
<div className={styles.dataBaseList}>
{databaseTypeList.map((t) => {
Expand Down
27 changes: 5 additions & 22 deletions chat2db-client/src/blocks/SQLExecute/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,19 @@ import { DatabaseTypeCode, ConsoleStatus } from '@/constants';

interface IProps {
boundInfo: {
databaseName: string;
dataSourceId: number;
type: DatabaseTypeCode;
dataSourceName: string;
databaseType: DatabaseTypeCode;
databaseName?: string;
schemaName?: string;
consoleId: number;
status: ConsoleStatus;
consoleId: number;
};
initDDL: string;
// 异步加载sql
loadSQL: () => Promise<string>;
}

interface IContext {
boundInfoContext: {
databaseName: string;
dataSourceId: number;
type: DatabaseTypeCode;
schemaName?: string;
consoleId: number;
status: ConsoleStatus;
};
setBoundInfoContext: (boundInfo: IContext['boundInfoContext']) => void;
}

const SQLExecute = memo<IProps>((props) => {
const { boundInfo: _boundInfo, initDDL, loadSQL } = props;
const draggableRef = useRef<any>();
Expand All @@ -48,10 +37,6 @@ const SQLExecute = memo<IProps>((props) => {
}
}, []);

// useUpdateEffect(() => {
// consoleRef.current?.editorRef?.setValue(initDDL, 'cover');
// }, [initDDL]);

return (
<div className={classnames(styles.sqlExecute)}>
<DraggableContainer layout="column" className={styles.boxRightCenter}>
Expand All @@ -64,12 +49,10 @@ const SQLExecute = memo<IProps>((props) => {
setBoundInfo={setBoundInfo}
hasAiChat={true}
hasAi2Lang={true}
isActive={true}
onExecuteSQL={(sql) => {
searchResultRef.current?.handleExecuteSQL(sql);
}}
// isActive={isActive}
// tables={curTableList || []}
// remainingUse={aiModel.remainingUse}
/>
</div>
<div className={styles.boxRightResult}>
Expand Down
33 changes: 12 additions & 21 deletions chat2db-client/src/blocks/Setting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import BaseSetting from './BaseSetting';
import AISetting from './AiSetting';
import ProxySetting from './ProxySetting';
import About from './About';
import { connect } from 'umi';
import { IAIState } from '@/models/ai';
import { IAiConfig } from '@/typings';
import styles from './index.less';
import { ILatestVersion } from '@/service/config';
import UpdateDetection, { IUpdateDetectionRef, UpdatedStatusEnum } from '@/blocks/Setting/UpdateDetection';

// ---- store -----
import { useSettingStore, getAiSystemConfig, setAiSystemConfig } from '@/store/setting'

interface IProps {
aiConfig: IAiConfig;
className?: string;
Expand All @@ -29,11 +30,12 @@ export interface IUpdateDetectionData extends ILatestVersion {
}

function Setting(props: IProps) {
const { className, dispatch, noLogin = false, defaultArouse, defaultMenu = 0 } = props;
const { className, noLogin = false, defaultArouse, defaultMenu = 0 } = props;
const [isModalVisible, setIsModalVisible] = useState(false);
const [currentMenu, setCurrentMenu] = useState<number>(defaultMenu);
const [updateDetectionData, setUpdateDetectionData] = useState<IUpdateDetectionData | null>(null);
const updateDetectionRef = React.useRef<IUpdateDetectionRef>(null);
const aiConfig = useSettingStore(state => state.aiConfig);

useEffect(() => {
if (defaultArouse) {
Expand All @@ -53,13 +55,6 @@ function Setting(props: IProps) {
}
}, []);

const getAiSystemConfig = () => {
/** 获取ai相关配置 */
dispatch({
type: 'ai/getAiSystemConfig',
});
};

const showModal = (_currentMenu: number = 0) => {
setCurrentMenu(_currentMenu);
setIsModalVisible(true);
Expand All @@ -77,13 +72,6 @@ function Setting(props: IProps) {
setCurrentMenu(t);
}

const handleApplyAiConfig = (aiConfig: IAiConfig) => {
dispatch({
type: 'ai/setAiSystemConfig',
payload: aiConfig,
});
};

const menusList = [
{
label: i18n('setting.nav.basic'),
Expand All @@ -94,7 +82,7 @@ function Setting(props: IProps) {
{
label: i18n('setting.nav.customAi'),
icon: '\ue646',
body: <AISetting aiConfig={props.aiConfig} handleApplyAiConfig={handleApplyAiConfig} />,
body: <AISetting aiConfig={aiConfig} handleApplyAiConfig={setAiSystemConfig} />,
code: 'ai',
},
{
Expand Down Expand Up @@ -178,6 +166,9 @@ function Setting(props: IProps) {
);
}

export default connect(({ ai }: { ai: IAIState }) => ({
aiConfig: ai.aiConfig,
}))(Setting);
// export default connect(({ ai }: { ai: IAIState }) => ({
// aiConfig: ai.aiConfig,
// }))();

export default Setting;

9 changes: 5 additions & 4 deletions chat2db-client/src/blocks/Tree/hooks/useGetRightClickMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { ITreeConfigItem, treeConfig } from '../treeConfig';
import { useMemo } from 'react';

// ----- store -----
import { createConsole, addWorkspaceTab } from '@/store/console';
import { useWorkspaceStore } from '@/store/workspace';
import { createConsole, addWorkspaceTab } from '@/pages/main/workspace/store/console';
import { useWorkspaceStore } from '@/pages/main/workspace/store';

// ---- functions -----
import { openView, openFunction, openProcedure, openTrigger } from '../functions/openAsyncSql';
Expand Down Expand Up @@ -122,9 +122,10 @@ export const useGetRightClickMenu = (props: IProps) => {
icon: '\ue619',
handle: () => {
createConsole({
name: 'create console',
name: 'new console',
dataSourceId: treeNodeData.extraParams!.dataSourceId!,
type: treeNodeData.extraParams!.databaseType!,
dataSourceName: treeNodeData.extraParams!.dataSourceName!,
databaseType: treeNodeData.extraParams!.databaseType!,
databaseName: treeNodeData.extraParams?.databaseName,
schemaName: treeNodeData.extraParams?.schemaName,
});
Expand Down
8 changes: 4 additions & 4 deletions chat2db-client/src/blocks/Tree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import LoadingContent from '@/components/Loading/LoadingContent';

interface IProps {
className?: string;
initialData: ITreeNode[] | null;
treeData: ITreeNode[] | null;
searchValue: string;
}
interface TreeNodeIProps {
Expand All @@ -31,12 +31,12 @@ interface IContext {
export const Context = createContext<IContext>({} as any);

const Tree = (props: IProps) => {
const { className, initialData, searchValue } = props;
const { className, treeData: outerTreeData, searchValue } = props;
const [treeData, setTreeData] = useState<ITreeNode[] | null>(null);

useEffect(() => {
setTreeData(initialData);
}, [initialData]);
setTreeData(outerTreeData);
}, [outerTreeData]);

const treeNodes = useMemo(() => {
return treeData?.map((item, index) => {
Expand Down
2 changes: 1 addition & 1 deletion chat2db-client/src/blocks/Tree/treeConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const treeConfig: { [key in TreeNodeType]: ITreeConfigItem } = {
const _extraParams = params.extraParams;
delete params.extraParams;
connectionService
.getDBList(params)
.getDatabaseList(params)
.then((res) => {
const data: ITreeNode[] = res.map((t: any) => {
return {
Expand Down
2 changes: 1 addition & 1 deletion chat2db-client/src/components/CascaderDB/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function CascaderDB(props: IProps) {
if (curDataSourceId === undefined) {
return;
}
const databaseList = await connection.getDBList({
const databaseList = await connection.getDatabaseList({
dataSourceId: curDataSourceId,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
}
.downloadTextError{
color: var(--color-error-text);
cursor: pointer;
}
.downloadTextLoading{
display: flex;
Expand Down
Loading

0 comments on commit 46eee1f

Please sign in to comment.