Skip to content

Commit

Permalink
[Fix] fix datasource bug (DataLinkDC#2157)
Browse files Browse the repository at this point in the history
* fix datasource bug

* 优化表格和分页的布局效果
  • Loading branch information
Zzm0809 authored Jul 28, 2023
1 parent 0959a37 commit e12fe5b
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 16 deletions.
Binary file removed dinky-web/public/database/clickhouse.png
Binary file not shown.
Binary file removed dinky-web/public/database/db.jpg
Binary file not shown.
Binary file removed dinky-web/public/database/doris.jpeg
Binary file not shown.
Binary file removed dinky-web/public/database/hive.png
Binary file not shown.
Binary file removed dinky-web/public/database/mysql.jpg
Binary file not shown.
Binary file removed dinky-web/public/database/oracle.jpg
Binary file not shown.
Binary file removed dinky-web/public/database/phoenix.png
Binary file not shown.
Binary file removed dinky-web/public/database/postgresql.jpg
Binary file not shown.
Binary file removed dinky-web/public/database/presto.png
Binary file not shown.
Binary file removed dinky-web/public/database/sqlserver.jpg
Binary file not shown.
Binary file removed dinky-web/public/database/starrocks.jpg
Binary file not shown.
8 changes: 8 additions & 0 deletions dinky-web/src/global.less
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ ol {
overflow: hidden;
}

.ant-list .ant-list-pagination {
margin-block-start: 0; // 去除 分页组件和 上边表格的间距
}

.ant-table-wrapper {
overflow-y: auto;
overflow-x: auto;
Expand Down Expand Up @@ -329,6 +333,10 @@ ol {
align-content: center;
}

.ant-pro-checkcard-title {
overflow: unset;
}

h5 {
margin-left: 0.5rem;
margin-bottom: 0;
Expand Down
2 changes: 2 additions & 0 deletions dinky-web/src/locales/en-US/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ export default {
'global.table.runmode.local': 'Local',
'global.table.runmode.remote': 'Remote',

'global.search.text': 'Input Key to Search',

'global.savepoint.strategy.disabled': 'Disabled',
'global.savepoint.strategy.latest': 'Latest',
'global.savepoint.strategy.earliest': 'Earliest',
Expand Down
3 changes: 3 additions & 0 deletions dinky-web/src/locales/zh-CN/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ export default {
'global.table.runmode.local': '本地',
'global.table.runmode.remote': '远程',

'global.search.text': '输入关键字搜索',


'global.savepoint.strategy.disabled': '禁用',
'global.savepoint.strategy.latest': '最近一次',
'global.savepoint.strategy.earliest': '最早一次',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {connect} from "@umijs/max";
import { StateType} from "../../model";
import {Select, Space, Spin, Tag} from "antd";
import {Spin, Tag} from "antd";
import React, {useEffect, useState} from "react";
import {
DatabaseOutlined, ReloadOutlined,
Expand All @@ -12,7 +12,6 @@ import {Key, ProForm, ProFormSelect} from "@ant-design/pro-components";
import {TagAlignLeft} from "@/components/StyledComponents";
import SchemaTree from "@/pages/RegCenter/DataSource/components/DataSourceDetail/SchemaTree";
import {DataSources} from "@/types/RegCenter/data";
import ContentScroll from "@/components/Scroll/ContentScroll";

const MetaData = (props: any) => {

Expand Down Expand Up @@ -159,7 +158,7 @@ const MetaData = (props: any) => {
name={"selectDb"}
placeholder={l('pages.metadata.selectDatabase')}
options={getDataBaseOptions()}
fieldProps={{onSelect: (selectId) => handleSelectDataBaseId(selectId)}}
fieldProps={{onSelect: (selectId) => handleSelectDataBaseId(selectId as number)}}
/>
</ProForm>
<SchemaTree selectKeys={selectKeys} expandKeys={expandKeys} style={{height: (toolContentHeight - 64 - 20 )}} onNodeClick={handleTreeNodeClick} treeData={treeData} onExpand={handleTreeExpand}/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
*/


import {Empty, Input, Space, Tree} from 'antd';
import {Empty, Input, Tree} from 'antd';
import React, {useCallback, useState} from 'react';
import {buildSchemaTree} from '@/pages/RegCenter/DataSource/components/DataSourceDetail/function';
import {Key} from '@ant-design/pro-components';
import {l} from "@/utils/intl";

const {DirectoryTree} = Tree;
/**
Expand Down Expand Up @@ -56,7 +57,7 @@ const SchemaTree: React.FC<SchemaTreeProps> = (props) => {
(treeData.length > 0) ?
<>
<Input
placeholder="请输入关键字搜索"
placeholder={l('global.search.text')}
allowClear
style={{marginBottom: 8}}
value={searchValue}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,23 @@ import SchemaTree from '@/pages/RegCenter/DataSource/components/DataSourceDetail
import RightTagsRouter from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter';
import {useNavigate} from '@umijs/max';
import {API_CONSTANTS, RESPONSE_CODE} from '@/services/constants';
import {getDataByIdReturnResult, queryDataByParams} from '@/services/BusinessCrud';
import {ProCard} from '@ant-design/pro-components';
import {getDataByIdReturnResult} from '@/services/BusinessCrud';
import {Key, ProCard} from '@ant-design/pro-components';
import {QueryParams} from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/data';
import {connect} from "@@/exports";
import {StateType} from "@/pages/DataStudio/model";

type DataSourceDetailProps = {
dataSource: Partial<DataSources.DataSource>;
backClick: () => void;
}
const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
const DataSourceDetail = (props : any) => {
const navigate = useNavigate();


const {dataSource, backClick} = props;
const {dataSource, backClick , dispatch ,database: { dbData , selectDatabaseId , expandKeys, selectKeys}} = props;
const [loading, setLoading] = useState<boolean>(false);
const [disabled, setDisabled] = useState<boolean>(true);
const [treeData, setTreeData] = useState<Partial<any>[]>([]);
const [tableInfo, setTableInfo] = useState<Partial<DataSources.Table>>({});
const [params, setParams] = useState<QueryParams>({id: 0, schemaName: '', tableName: ''});
const selectDb = (dbData as DataSources.DataSource[]).filter(x=> x.id === selectDatabaseId)[0]

const handleBackClick = () => {
// go back
Expand Down Expand Up @@ -81,8 +80,27 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
/**
* 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;
// 选中的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) {
setParams({
id: dataSource.id as number,
Expand All @@ -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
* @return {JSX.Element}
Expand All @@ -124,7 +155,7 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
<ProCard loading={loading} ghost gutter={[16, 16]} split="vertical">
<ProCard hoverable bordered className={'siderTree schemaTree'} colSpan="16%">
{/* tree */}
<SchemaTree onNodeClick={(info: any) => onSchemaTreeNodeClick(info)} treeData={treeData}/>
<SchemaTree selectKeys={selectKeys} expandKeys={expandKeys} onExpand={handleTreeExpand} onNodeClick={onSchemaTreeNodeClick} treeData={treeData}/>
</ProCard>
<ProCard hoverable colSpan="84%" ghost headerBordered>
{/* tags */}
Expand All @@ -139,4 +170,6 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
</>;
};

export default DataSourceDetail;
export default connect(({Studio}: { Studio: StateType }) => ({
database: Studio.database,
}))(DataSourceDetail); ;

0 comments on commit e12fe5b

Please sign in to comment.