Unverified Commit e12fe5b1 authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

[Fix] fix datasource bug (#2157)

* fix datasource bug * 优化表格和分页的布局效果
parent 0959a37e
...@@ -199,6 +199,10 @@ ol { ...@@ -199,6 +199,10 @@ ol {
overflow: hidden; overflow: hidden;
} }
.ant-list .ant-list-pagination {
margin-block-start: 0; // 去除 分页组件和 上边表格的间距
}
.ant-table-wrapper { .ant-table-wrapper {
overflow-y: auto; overflow-y: auto;
overflow-x: auto; overflow-x: auto;
...@@ -329,6 +333,10 @@ ol { ...@@ -329,6 +333,10 @@ ol {
align-content: center; align-content: center;
} }
.ant-pro-checkcard-title {
overflow: unset;
}
h5 { h5 {
margin-left: 0.5rem; margin-left: 0.5rem;
margin-bottom: 0; margin-bottom: 0;
......
...@@ -147,6 +147,8 @@ export default { ...@@ -147,6 +147,8 @@ export default {
'global.table.runmode.local': 'Local', 'global.table.runmode.local': 'Local',
'global.table.runmode.remote': 'Remote', 'global.table.runmode.remote': 'Remote',
'global.search.text': 'Input Key to Search',
'global.savepoint.strategy.disabled': 'Disabled', 'global.savepoint.strategy.disabled': 'Disabled',
'global.savepoint.strategy.latest': 'Latest', 'global.savepoint.strategy.latest': 'Latest',
'global.savepoint.strategy.earliest': 'Earliest', 'global.savepoint.strategy.earliest': 'Earliest',
......
...@@ -145,6 +145,9 @@ export default { ...@@ -145,6 +145,9 @@ export default {
'global.table.runmode.local': '本地', 'global.table.runmode.local': '本地',
'global.table.runmode.remote': '远程', 'global.table.runmode.remote': '远程',
'global.search.text': '输入关键字搜索',
'global.savepoint.strategy.disabled': '禁用', 'global.savepoint.strategy.disabled': '禁用',
'global.savepoint.strategy.latest': '最近一次', 'global.savepoint.strategy.latest': '最近一次',
'global.savepoint.strategy.earliest': '最早一次', 'global.savepoint.strategy.earliest': '最早一次',
......
import {connect} from "@umijs/max"; import {connect} from "@umijs/max";
import { StateType} from "../../model"; import { StateType} from "../../model";
import {Select, Space, Spin, Tag} from "antd"; import {Spin, Tag} from "antd";
import React, {useEffect, useState} from "react"; import React, {useEffect, useState} from "react";
import { import {
DatabaseOutlined, ReloadOutlined, DatabaseOutlined, ReloadOutlined,
...@@ -12,7 +12,6 @@ import {Key, ProForm, ProFormSelect} from "@ant-design/pro-components"; ...@@ -12,7 +12,6 @@ import {Key, ProForm, ProFormSelect} from "@ant-design/pro-components";
import {TagAlignLeft} from "@/components/StyledComponents"; import {TagAlignLeft} from "@/components/StyledComponents";
import SchemaTree from "@/pages/RegCenter/DataSource/components/DataSourceDetail/SchemaTree"; import SchemaTree from "@/pages/RegCenter/DataSource/components/DataSourceDetail/SchemaTree";
import {DataSources} from "@/types/RegCenter/data"; import {DataSources} from "@/types/RegCenter/data";
import ContentScroll from "@/components/Scroll/ContentScroll";
const MetaData = (props: any) => { const MetaData = (props: any) => {
...@@ -159,7 +158,7 @@ const MetaData = (props: any) => { ...@@ -159,7 +158,7 @@ const MetaData = (props: any) => {
name={"selectDb"} name={"selectDb"}
placeholder={l('pages.metadata.selectDatabase')} placeholder={l('pages.metadata.selectDatabase')}
options={getDataBaseOptions()} options={getDataBaseOptions()}
fieldProps={{onSelect: (selectId) => handleSelectDataBaseId(selectId)}} fieldProps={{onSelect: (selectId) => handleSelectDataBaseId(selectId as number)}}
/> />
</ProForm> </ProForm>
<SchemaTree selectKeys={selectKeys} expandKeys={expandKeys} style={{height: (toolContentHeight - 64 - 20 )}} onNodeClick={handleTreeNodeClick} treeData={treeData} onExpand={handleTreeExpand}/> <SchemaTree selectKeys={selectKeys} expandKeys={expandKeys} style={{height: (toolContentHeight - 64 - 20 )}} onNodeClick={handleTreeNodeClick} treeData={treeData} onExpand={handleTreeExpand}/>
......
...@@ -16,10 +16,11 @@ ...@@ -16,10 +16,11 @@
*/ */
import {Empty, Input, Space, Tree} from 'antd'; import {Empty, Input, Tree} from 'antd';
import React, {useCallback, useState} from 'react'; import React, {useCallback, useState} from 'react';
import {buildSchemaTree} from '@/pages/RegCenter/DataSource/components/DataSourceDetail/function'; import {buildSchemaTree} from '@/pages/RegCenter/DataSource/components/DataSourceDetail/function';
import {Key} from '@ant-design/pro-components'; import {Key} from '@ant-design/pro-components';
import {l} from "@/utils/intl";
const {DirectoryTree} = Tree; const {DirectoryTree} = Tree;
/** /**
...@@ -56,7 +57,7 @@ const SchemaTree: React.FC<SchemaTreeProps> = (props) => { ...@@ -56,7 +57,7 @@ const SchemaTree: React.FC<SchemaTreeProps> = (props) => {
(treeData.length > 0) ? (treeData.length > 0) ?
<> <>
<Input <Input
placeholder="请输入关键字搜索" placeholder={l('global.search.text')}
allowClear allowClear
style={{marginBottom: 8}} style={{marginBottom: 8}}
value={searchValue} value={searchValue}
......
...@@ -25,24 +25,23 @@ import SchemaTree from '@/pages/RegCenter/DataSource/components/DataSourceDetail ...@@ -25,24 +25,23 @@ import SchemaTree from '@/pages/RegCenter/DataSource/components/DataSourceDetail
import RightTagsRouter from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter'; import RightTagsRouter from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter';
import {useNavigate} from '@umijs/max'; import {useNavigate} from '@umijs/max';
import {API_CONSTANTS, RESPONSE_CODE} from '@/services/constants'; import {API_CONSTANTS, RESPONSE_CODE} from '@/services/constants';
import {getDataByIdReturnResult, queryDataByParams} from '@/services/BusinessCrud'; import {getDataByIdReturnResult} from '@/services/BusinessCrud';
import {ProCard} from '@ant-design/pro-components'; import {Key, ProCard} from '@ant-design/pro-components';
import {QueryParams} from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/data'; import {QueryParams} from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/data';
import {connect} from "@@/exports";
import {StateType} from "@/pages/DataStudio/model";
type DataSourceDetailProps = { const DataSourceDetail = (props : any) => {
dataSource: Partial<DataSources.DataSource>;
backClick: () => void;
}
const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
const navigate = useNavigate(); const navigate = useNavigate();
const {dataSource, backClick} = props; const {dataSource, backClick , dispatch ,database: { dbData , selectDatabaseId , expandKeys, selectKeys}} = props;
const [loading, setLoading] = useState<boolean>(false); const [loading, setLoading] = useState<boolean>(false);
const [disabled, setDisabled] = useState<boolean>(true); const [disabled, setDisabled] = useState<boolean>(true);
const [treeData, setTreeData] = useState<Partial<any>[]>([]); const [treeData, setTreeData] = useState<Partial<any>[]>([]);
const [tableInfo, setTableInfo] = useState<Partial<DataSources.Table>>({}); const [tableInfo, setTableInfo] = useState<Partial<DataSources.Table>>({});
const [params, setParams] = useState<QueryParams>({id: 0, schemaName: '', tableName: ''}); const [params, setParams] = useState<QueryParams>({id: 0, schemaName: '', tableName: ''});
const selectDb = (dbData as DataSources.DataSource[]).filter(x=> x.id === selectDatabaseId)[0]
const handleBackClick = () => { const handleBackClick = () => {
// go back // go back
...@@ -81,8 +80,27 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => { ...@@ -81,8 +80,27 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
/** /**
* tree node click * tree node click
*/ */
const onSchemaTreeNodeClick = useCallback(async (info: any) => { const onSchemaTreeNodeClick = useCallback(async (keys: Key[] ,info: any) => {
const {node: {isLeaf, parentId: schemaName, name: tableName, fullInfo}} = info; const {node: {isLeaf, parentId: schemaName, name: tableName, fullInfo}} = info;
// 选中的key
dispatch({
type: "Studio/updateDatabaseSelectKey",
payload: keys
})
if (isLeaf) {
const queryParams = {id: selectDatabaseId , schemaName, tableName};
dispatch({
type: "Studio/addTab",
payload: {
icon: selectDb.type,
id: selectDatabaseId + schemaName + tableName,
breadcrumbLabel: [selectDb.type,selectDb.name].join("/"),
label: schemaName + '.' + tableName ,
params:{ queryParams: queryParams, tableInfo: fullInfo},
type: "metadata"
}
})
}
if (isLeaf) { if (isLeaf) {
setParams({ setParams({
id: dataSource.id as number, id: dataSource.id as number,
...@@ -100,6 +118,19 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => { ...@@ -100,6 +118,19 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
} }
}, []); }, []);
/**
* 树节点展开事件
* @param {Key[]} expandedKeys
*/
const handleTreeExpand = (expandedKeys: Key[]) => {
dispatch({
type: "Studio/updateDatabaseExpandKey",
payload: expandedKeys
})
}
/** /**
* render back button and refresh button * render back button and refresh button
* @return {JSX.Element} * @return {JSX.Element}
...@@ -124,7 +155,7 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => { ...@@ -124,7 +155,7 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
<ProCard loading={loading} ghost gutter={[16, 16]} split="vertical"> <ProCard loading={loading} ghost gutter={[16, 16]} split="vertical">
<ProCard hoverable bordered className={'siderTree schemaTree'} colSpan="16%"> <ProCard hoverable bordered className={'siderTree schemaTree'} colSpan="16%">
{/* tree */} {/* tree */}
<SchemaTree onNodeClick={(info: any) => onSchemaTreeNodeClick(info)} treeData={treeData}/> <SchemaTree selectKeys={selectKeys} expandKeys={expandKeys} onExpand={handleTreeExpand} onNodeClick={onSchemaTreeNodeClick} treeData={treeData}/>
</ProCard> </ProCard>
<ProCard hoverable colSpan="84%" ghost headerBordered> <ProCard hoverable colSpan="84%" ghost headerBordered>
{/* tags */} {/* tags */}
...@@ -139,4 +170,6 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => { ...@@ -139,4 +170,6 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
</>; </>;
}; };
export default DataSourceDetail; export default connect(({Studio}: { Studio: StateType }) => ({
database: Studio.database,
}))(DataSourceDetail); ;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment