Skip to content

Commit 52f609f

Browse files
committed
fix: some bug fixed
1 parent 61ea669 commit 52f609f

11 files changed

Lines changed: 78 additions & 55 deletions

File tree

chat2db-client/.umirc.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ export default defineConfig({
4444
},
4545
},
4646
headScripts: ['if (window.myAPI) { window.myAPI.startServerForSpawn() }'],
47+
favicons: ['logo.ico'],
4748
});

chat2db-client/public/logo.ico

9.59 KB
Binary file not shown.

chat2db-client/src/components/CreateConnection/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ export default function CreateConnection(props: IProps) {
147147
? i18n('common.message.modifySuccessfully')
148148
: i18n('common.message.addedSuccessfully'),
149149
);
150+
151+
if (type === submitType.SAVE) {
152+
setBackfillData({
153+
...backfillData,
154+
id: res,
155+
});
156+
}
150157
}
151158
})
152159
.finally(() => {

chat2db-client/src/i18n/en-us/connection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ export default {
1717
'connection.message.testSshConnection': 'Test the ssh connection',
1818
'connection.tableHeader.name': 'Name',
1919
'connection.tableHeader.value': 'Value',
20+
'connection.menu.enterToWorkSpace': 'Go to DataSource',
2021
};

chat2db-client/src/i18n/zh-cn/connection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ export default {
1717
'connection.message.testSshConnection': '测试ssh连接',
1818
'connection.tableHeader.name': '名称',
1919
'connection.tableHeader.value': '值',
20+
'connection.menu.enterToWorkSpace': '前往数据源',
2021
}

chat2db-client/src/pages/main/connections/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ export default memo<IProps>(function Connections(props) {
8181
<Dropdown
8282
menu={{
8383
items: [
84+
{
85+
key: 'EnterWorkSpace',
86+
label: i18n('connection.menu.enterToWorkSpace'),
87+
onClick: () => {
88+
window.location.replace('/workspace');
89+
},
90+
},
8491
{
8592
key: 'Delete',
8693
label: i18n('common.button.delete'),

chat2db-client/src/pages/main/dashboard/index.less

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
@import '../../../styles/var.less';
2+
13
.box {
24
display: flex;
35
background-color: var(--color-bg);
46
height: 100%;
57
width: 100%;
6-
font-family: Helvetica;
78
}
89

910
.boxLeft {
@@ -23,14 +24,22 @@
2324

2425
.boxLeftTitle {
2526
font-size: 20px;
26-
// color: rgba(0, 0, 0);
2727
line-height: 24px;
2828
font-weight: 500;
2929
margin-bottom: 40px;
30-
padding-left: 24px;
30+
padding-left: 20px;
3131
padding-right: 8px;
3232
display: flex;
3333
justify-content: space-between;
34+
align-items: center;
35+
}
36+
.plusIcon {
37+
font-size: 18px;
38+
padding: 2px;
39+
cursor: pointer;
40+
&:hover {
41+
background-color: var(--color-hover-bg);
42+
}
3443
}
3544

3645
.boxLeftItem {
@@ -56,12 +65,10 @@
5665
}
5766
}
5867

59-
6068
.activeItem {
6169
background-color: var(--color-bg-elevated);
6270
}
6371

64-
6572
.boxRight {
6673
flex: 1;
6774
padding: 24px 40px;
@@ -78,10 +85,10 @@
7885
margin-bottom: 24px;
7986
}
8087

81-
.boxRightContent {}
88+
.boxRightContent {
89+
}
8290

8391
.boxRightContentRow {
84-
8592
display: flex;
8693
}
8794

@@ -92,4 +99,4 @@
9299
&:last-child {
93100
margin-right: 0px;
94101
}
95-
}
102+
}

chat2db-client/src/pages/main/dashboard/index.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
updateChart,
1818
updateDashboard,
1919
} from '@/service/dashboard';
20-
import { MoreOutlined, PlusOutlined } from '@ant-design/icons';
20+
import { MoreOutlined } from '@ant-design/icons';
2121
import styles from './index.less';
2222
import i18n from '@/i18n';
2323

@@ -234,7 +234,7 @@ function Chart(props: IProps) {
234234
<div className={styles.boxLeft}>
235235
<div className={styles.boxLeftTitle}>
236236
<div>{i18n('dashboard.title')}</div>
237-
<PlusOutlined onClick={() => setOpenAddDashboard(true)} />
237+
<Iconfont code="&#xe631;" className={styles.plusIcon} onClick={() => setOpenAddDashboard(true)} />
238238
</div>
239239
{renderLeft()}
240240
</div>
@@ -270,18 +270,13 @@ function Chart(props: IProps) {
270270
okText="Confirm"
271271
cancelText="Cancel"
272272
>
273-
<Form form={form} autoComplete={'off'}>
273+
<Form labelCol={{ span: 4 }} wrapperCol={{ span: 20 }} form={form} autoComplete={'off'}>
274274
<Form.Item label={'name'} name={'name'} rules={[{ required: true, message: 'Please input your name' }]}>
275275
<Input />
276276
</Form.Item>
277277
<Form.Item label={'description'} name={'description'}>
278278
<Input.TextArea />
279279
</Form.Item>
280-
{/* <Form.Item>
281-
<Button type="primary" onClick={onCheck}>
282-
Check
283-
</Button>
284-
</Form.Item> */}
285280
</Form>
286281
</Modal>
287282
</>

chat2db-client/src/pages/main/workspace/components/WorkspaceLeft/index.tsx

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { treeConfig } from '../Tree/treeConfig';
77
import Tree from '../Tree';
88
import Iconfont from '@/components/Iconfont';
99
import { TreeNodeType } from '@/constants/tree';
10-
import { ITreeNode } from '@/typings/tree'
10+
import { ITreeNode } from '@/typings/tree';
1111
import { useReducerContext } from '../../index';
1212
import { workspaceActionType } from '../../context';
1313
interface IProps {
@@ -17,15 +17,17 @@ interface IProps {
1717
export default memo<IProps>(function WorkspaceLeft(props) {
1818
const { className } = props;
1919

20-
return <div className={classnames(styles.box, className)}>
21-
<div className={styles.header}>
22-
<RenderSelectDatabase></RenderSelectDatabase>
20+
return (
21+
<div className={classnames(styles.box, className)}>
22+
<div className={styles.header}>
23+
<RenderSelectDatabase></RenderSelectDatabase>
24+
</div>
25+
<div className={styles.save_box}>Save</div>
26+
<Divider />
27+
<RenderTableBox></RenderTableBox>
2328
</div>
24-
<div className={styles.save_box}>Save</div>
25-
<Divider />
26-
<RenderTableBox></RenderTableBox>
27-
</div>
28-
})
29+
);
30+
});
2931

3032
interface Option {
3133
value: number;
@@ -47,18 +49,18 @@ function RenderSelectDatabase() {
4749
pageNo: 1,
4850
pageSize: 999,
4951
};
50-
treeConfig[TreeNodeType.DATA_SOURCES].getChildren!(p).then(res => {
52+
treeConfig[TreeNodeType.DATA_SOURCES].getChildren!(p).then((res) => {
5153
let newOptions: any = res.map((t) => {
5254
return {
5355
label: t.name,
5456
value: t.key,
5557
type: TreeNodeType.DATA_SOURCE,
5658
isLeaf: false,
57-
databaseType: t.extraParams?.databaseType
59+
databaseType: t.extraParams?.databaseType,
5860
};
5961
});
6062
setOptions(newOptions);
61-
})
63+
});
6264
}
6365

6466
const onChange: any = (valueArr: any, selectedOptions: any) => {
@@ -72,36 +74,36 @@ function RenderSelectDatabase() {
7274
databaseSourceName: labelArr[0],
7375
databaseName: labelArr[1],
7476
schemaName: labelArr[2],
75-
databaseType: selectedOptions[0].databaseType
76-
}
77+
databaseType: selectedOptions[0].databaseType,
78+
};
7779

7880
dispatch({
7981
type: workspaceActionType.CURRENT_WORKSPACE_DATA,
80-
payload: currentWorkspaceData
82+
payload: currentWorkspaceData,
8183
});
8284
};
8385

8486
// 及联loadData
8587
const loadData = (selectedOptions: any) => {
8688
if (selectedOptions.length > 1) {
87-
return
89+
return;
8890
}
8991

9092
const targetOption = selectedOptions[0];
9193
treeConfig[TreeNodeType.DATA_SOURCE].getChildren!({
92-
id: targetOption.value
93-
}).then(res => {
94+
id: targetOption.value,
95+
}).then((res) => {
9496
let newOptions = res.map((t) => {
9597
return {
9698
label: t.name,
9799
value: t.key,
98100
type: TreeNodeType.DATABASE,
99-
databaseType: t.extraParams?.databaseType
101+
databaseType: t.extraParams?.databaseType,
100102
};
101103
});
102104
targetOption.children = newOptions;
103105
setOptions([...(options || [])]);
104-
})
106+
});
105107

106108
// TODO:根据后端字段 如果有SCHEMAS再去查询SCHEMAS
107109
// if (targetOption.type === TreeNodeType.SCHEMAS) {
@@ -120,7 +122,6 @@ function RenderSelectDatabase() {
120122
// })
121123
// } else {
122124
// }
123-
124125
};
125126

126127
const dropdownRender = (menus: React.ReactNode) => (
@@ -132,7 +133,7 @@ function RenderSelectDatabase() {
132133

133134
function renderCurrentSelected() {
134135
const { databaseName, schemaName, databaseSourceName } = currentWorkspaceData;
135-
const currentSelectedArr = [databaseSourceName, databaseName, schemaName].filter(t => t);
136+
const currentSelectedArr = [databaseSourceName, databaseName, schemaName].filter((t) => t);
136137
return currentSelectedArr.join('/');
137138
}
138139

@@ -145,16 +146,17 @@ function RenderSelectDatabase() {
145146
loadData={loadData}
146147
bordered={false}
147148
dropdownRender={dropdownRender}
149+
placeholder={'xxxxxxx'}
148150
>
149151
<div className={styles.current_database}>
150-
<div className={styles.name}>
151-
{renderCurrentSelected()}
152-
</div>
152+
<div className={styles.name}>{renderCurrentSelected()}</div>
153153
<Iconfont code="&#xe608;" />
154154
</div>
155155
</Cascader>
156156
<div className={styles.other_operations}>
157-
<div className={styles.icon_box}><Iconfont code='&#xec08;' /></div>
157+
<div className={styles.icon_box}>
158+
<Iconfont code="&#xec08;" />
159+
</div>
158160
</div>
159161
</div>
160162
);
@@ -167,21 +169,22 @@ function RenderTableBox() {
167169

168170
useEffect(() => {
169171
getInitialData();
170-
}, [currentWorkspaceData])
172+
}, [currentWorkspaceData]);
171173

172174
function getInitialData() {
173175
treeConfig[TreeNodeType.TABLES].getChildren!({
174176
pageNo: 1,
175177
pageSize: 999,
176178
...currentWorkspaceData,
177-
extraParams: currentWorkspaceData
178-
}).then(res => {
179+
extraParams: currentWorkspaceData,
180+
}).then((res) => {
179181
setInitialData(res);
180-
})
182+
});
181183
}
182184

183-
184-
return <div className={styles.table_box}>
185-
<Tree className={styles.tree} initialData={initialData}></Tree>
186-
</div>
185+
return (
186+
<div className={styles.table_box}>
187+
<Tree className={styles.tree} initialData={initialData}></Tree>
188+
</div>
189+
);
187190
}

chat2db-client/src/theme/common.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const commonToken = {
2-
"wireframe": true,
3-
"borderRadius": '4px',
4-
"borderRadiusLG": '8px',
5-
}
2+
fontSize1: 14,
3+
wireframe: true,
4+
borderRadius: 4,
5+
borderRadiusLG: 12,
6+
};

0 commit comments

Comments
 (0)