Skip to content

Commit 56211a3

Browse files
committed
fix:Dashboard
1 parent 886ec8a commit 56211a3

11 files changed

Lines changed: 137 additions & 142 deletions

File tree

chat2db-client/.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"DBAI",
3737
"dbhub",
3838
"Dmaven",
39+
"echart",
3940
"echarts",
4041
"favicons",
4142
"findstr",

chat2db-client/src/blocks/Tree/index.tsx

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,22 @@ const TreeNode = memo((props: TreeNodeIProps) => {
8585
},
8686
refresh: _props?.refresh || false,
8787
})
88-
.then((res) => {
89-
if (res.length) {
88+
.then((res: any) => {
89+
if (res.length || res.data) {
9090
setTimeout(() => {
91-
setTreeNodeData({
92-
...treeNodeData,
93-
children: res,
94-
});
91+
console.log(res);
92+
if (res.data) {
93+
setTreeNodeData({
94+
...treeNodeData,
95+
children: res.data,
96+
total: res.total,
97+
});
98+
} else {
99+
setTreeNodeData({
100+
...treeNodeData,
101+
children: res,
102+
});
103+
}
95104
setIsLoading(false);
96105
}, 200);
97106
} else {
@@ -274,11 +283,21 @@ const TreeNode = memo((props: TreeNodeIProps) => {
274283
);
275284
}, [isFocus, isLoading, rightClickMenu]);
276285

286+
const sectionHeight = useMemo(() => {
287+
console.log(treeNodeData.total);
288+
289+
if (treeNodeData.total) {
290+
return `${treeNodeData.total * 26}px`;
291+
} else {
292+
return 'auto';
293+
}
294+
}, [treeNodeData.total]);
295+
277296
return (
278-
<>
297+
<div style={{ height: sectionHeight }}>
279298
{(showTreeNode || showParentNode) && treeNodeDom}
280299
{treeNodes}
281-
</>
300+
</div>
282301
);
283302
});
284303

chat2db-client/src/blocks/Tree/treeConfig.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,12 @@ export const treeConfig: { [key in TreeNodeType]: ITreeConfigItem } = {
261261
},
262262
};
263263
});
264-
r(tableList);
265-
// {
266-
// data: tableList,
267-
// pageNo: res.pageNo,
268-
// pageSize: res.pageSize,
269-
// total: res.total,
270-
// }
264+
r({
265+
data: tableList,
266+
pageNo: res.pageNo,
267+
pageSize: res.pageSize,
268+
total: res.total,
269+
} as any);
271270
})
272271
.catch((error) => {
273272
j(error);
@@ -276,7 +275,7 @@ export const treeConfig: { [key in TreeNodeType]: ITreeConfigItem } = {
276275
},
277276
operationColumn: [
278277
OperationColumn.CreateConsole,
279-
OperationColumn.ViewAllTable,
278+
// OperationColumn.ViewAllTable,
280279
OperationColumn.CreateTable,
281280
OperationColumn.Refresh,
282281
],

chat2db-client/src/components/ConsoleEditor/components/SelectBoundInfo/index.tsx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,14 @@ const SelectBoundInfo = memo((props: IProps) => {
190190
databaseName: void 0,
191191
schemaName: void 0,
192192
});
193-
historyService.updateSavedConsole({
194-
id: boundInfo.consoleId,
195-
dataSourceId: currentData.value,
196-
dataSourceName: currentData.label,
197-
type: currentData.type,
198-
});
193+
if (boundInfo.consoleId) {
194+
historyService.updateSavedConsole({
195+
id: boundInfo.consoleId,
196+
dataSourceId: currentData.value,
197+
dataSourceName: currentData.label,
198+
type: currentData.type,
199+
});
200+
}
199201
};
200202

201203
// 选择数据库
@@ -208,10 +210,12 @@ const SelectBoundInfo = memo((props: IProps) => {
208210
schemaName: void 0,
209211
});
210212

211-
historyService.updateSavedConsole({
212-
id: boundInfo.consoleId,
213-
databaseName: _databaseName,
214-
});
213+
if (boundInfo.consoleId) {
214+
historyService.updateSavedConsole({
215+
id: boundInfo.consoleId,
216+
databaseName: _databaseName,
217+
});
218+
}
215219
};
216220

217221
// 选择schema
@@ -222,10 +226,12 @@ const SelectBoundInfo = memo((props: IProps) => {
222226
schemaName: _schemaName,
223227
});
224228

225-
historyService.updateSavedConsole({
226-
id: boundInfo.consoleId,
227-
schemaName: _schemaName,
228-
});
229+
if (boundInfo.consoleId) {
230+
historyService.updateSavedConsole({
231+
id: boundInfo.consoleId,
232+
schemaName: _schemaName,
233+
});
234+
}
229235
};
230236

231237
const getAllTableNameList = (dataSourceId, databaseName, schemaName?) => {

chat2db-client/src/components/ConsoleEditor/hooks/useSaveEditorData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getCookie } from '@/utils';
99

1010
interface IProps {
1111
isActive?: boolean;
12-
source: string;
12+
source?: string;
1313
editorRef: any;
1414
boundInfo: any;
1515
defaultValue?: string;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export type IAppendValue = {
4848
};
4949

5050
export interface IBoundInfo {
51-
consoleId: number;
51+
consoleId?: number;
5252
dataSourceId: number;
5353
dataSourceName: string;
5454
databaseType: DatabaseTypeCode;
@@ -59,7 +59,7 @@ export interface IBoundInfo {
5959

6060
interface IProps {
6161
/** 调用来源 */
62-
source: 'workspace';
62+
source?: 'workspace';
6363
isActive: boolean;
6464
/** 添加或修改的内容 */
6565
appendValue?: IAppendValue;

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.container {
22
flex: 1;
33
position: relative;
4-
// border: 1px solid var(--color-gray-300);
54
border: 1px solid var(--color-border);
65
border-radius: var(--border-radius-l-g);
76
padding: 16px;
@@ -16,9 +15,6 @@
1615
font-size: 14px;
1716
}
1817

19-
.title {
20-
}
21-
2218
.edit {
2319
cursor: pointer;
2420
}
@@ -117,24 +113,26 @@
117113
}
118114

119115
.editBlock {
120-
border-radius: var(--border-radius-l-g);
121-
background-color: var(--color-bg-subtle);
122-
max-height: 600px;
116+
border-radius: 4px;
117+
// background-color: var(--color-bg-subtle);
118+
max-height: 1000px;
123119
}
124120

125121
.editorBlock {
126122
display: flex;
127-
border-bottom: 1px solid var(--color-border-secondary);
123+
// flex-direction: column;
128124
flex-wrap: wrap;
129125
}
130126

131127
.editor {
132128
flex: 2;
133129
min-width: 320px;
134-
max-height: 320px;
130+
min-height: 320px;
135131
display: flex;
136132
flex-direction: column;
137133
position: relative;
134+
border: 1px solid var(--color-border-secondary);
135+
overflow: hidden;
138136
}
139137

140138
.dataSourceSelect {
@@ -144,10 +142,11 @@
144142
}
145143

146144
.chartParamsForm {
145+
border: 1px solid var(--color-border);
146+
border-left: 1px solid var(--color-border);
147147
color: var(--color-text);
148148
flex: 1;
149149
min-width: 120px;
150-
border-left: 1px solid var(--color-border-secondary);
151150
display: flex;
152151
flex-direction: column;
153152
justify-content: start;
@@ -163,5 +162,7 @@
163162
}
164163

165164
.editorOptionBlock {
166-
padding: 12px;
165+
display: flex;
166+
justify-content: flex-end;
167+
padding: 20px 0px 0px 0px;
167168
}

0 commit comments

Comments
 (0)