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

[Refactor][web] optimize datasource's detail layout (#1995)

* optimize datasource's detail layout * added i18n
parent 6c516cb5
...@@ -71,7 +71,7 @@ export default [ ...@@ -71,7 +71,7 @@ export default [
path: '/devops/joblist', path: '/devops/joblist',
name: 'job', name: 'job',
hideInMenu: true, hideInMenu: true,
component: './DevOps/JobList', component: './DevOps',
}, },
], ],
}, },
......
...@@ -29,3 +29,16 @@ export const DataSourceDetailBackButton = styled.div` ...@@ -29,3 +29,16 @@ export const DataSourceDetailBackButton = styled.div`
display: flex !important; display: flex !important;
justify-content: flex-end; justify-content: flex-end;
`; `;
export const Height80VHDiv = styled.div`
height: 80vh;
overflow: auto;
`;
export const StartButton = styled.div`
position: absolute;
color: #1890ff;
font-size: large;
z-index: 2;
top: 50%;
`;
...@@ -232,8 +232,8 @@ ol { ...@@ -232,8 +232,8 @@ ol {
} }
.schemaTree{ .schemaTree{
max-height: 78vh; max-height: 90vh;
min-height: 78vh; min-height: 90vh;
} }
.code-content-empty { .code-content-empty {
......
...@@ -132,6 +132,7 @@ export default { ...@@ -132,6 +132,7 @@ export default {
'global.table.jobname': 'Job Name', 'global.table.jobname': 'Job Name',
'global.table.jobid': 'Job Id', 'global.table.jobid': 'Job Id',
'global.table.taskid': 'Task Id',
'global.table.lifecycle': 'Life Cycle', 'global.table.lifecycle': 'Life Cycle',
'global.table.lifecycle.all': 'All', 'global.table.lifecycle.all': 'All',
'global.table.lifecycle.dev': 'Develop', 'global.table.lifecycle.dev': 'Develop',
......
...@@ -2,14 +2,14 @@ import type {ActionType, ProColumns} from '@ant-design/pro-components'; ...@@ -2,14 +2,14 @@ import type {ActionType, ProColumns} from '@ant-design/pro-components';
import {ProTable} from '@ant-design/pro-components'; import {ProTable} from '@ant-design/pro-components';
import {Button, Table} from 'antd'; import {Button, Table} from 'antd';
import React, {useEffect, useRef} from 'react'; import React, {useEffect, useRef} from 'react';
import {Jobs} from "@/types/DevOps/data"; import {Jobs} from '@/types/DevOps/data';
import JobHistoryList from "@/pages/DevOps/JobList/compents/JobHistoryList"; import JobHistoryList from '@/pages/DevOps/JobList/compents/JobHistoryList';
import {l} from "@/utils/intl"; import {l} from '@/utils/intl';
import {parseSecondStr} from "@/utils/function"; import {parseSecondStr} from '@/utils/function';
import {API_CONSTANTS} from "@/services/constants"; import {API_CONSTANTS} from '@/services/constants';
import {queryList} from "@/services/api"; import {queryList} from '@/services/api';
import {ClockCircleTwoTone, EyeTwoTone} from "@ant-design/icons"; import {ClockCircleTwoTone, EyeTwoTone} from '@ant-design/icons';
import {JOB_STATUS_FILTER, LIFECYCLE_FILTER, TagJobLifeCycle, TagJobStatus} from "@/pages/DevOps/JobList/function"; import {JOB_STATUS_FILTER, LIFECYCLE_FILTER, TagJobLifeCycle, TagJobStatus} from '@/pages/DevOps/JobList/function';
const JobList = () => { const JobList = () => {
const tableRef = useRef<ActionType>(); const tableRef = useRef<ActionType>();
...@@ -17,32 +17,33 @@ const JobList = () => { ...@@ -17,32 +17,33 @@ const JobList = () => {
const jobListColums: ProColumns<Jobs.JobInstance>[] = [ const jobListColums: ProColumns<Jobs.JobInstance>[] = [
{ {
title: l('global.table.taskid'), title: l('global.table.taskid'),
dataIndex: "taskId", dataIndex: 'taskId',
}, },
{ {
title: l('global.table.jobname'), title: l('global.table.jobname'),
dataIndex: "name", dataIndex: 'name',
}, },
{ {
title: l('global.table.lifecycle'), title: l('global.table.lifecycle'),
filters: LIFECYCLE_FILTER(), filters: LIFECYCLE_FILTER(),
hideInSearch:true, hideInSearch: true,
dataIndex: "step", filterMultiple: false,
dataIndex: 'step',
render: (_, row) => TagJobLifeCycle(row.step) render: (_, row) => TagJobLifeCycle(row.step)
}, },
{ {
title: l('global.table.runmode'), title: l('global.table.runmode'),
dataIndex: "type", dataIndex: 'type',
hideInSearch: true hideInSearch: true
}, },
{ {
title: l('global.table.jobid'), title: l('global.table.jobid'),
dataIndex: "jid", dataIndex: 'jid',
}, },
{ {
title: l('global.table.createTime'), title: l('global.table.createTime'),
hideInSearch: true, hideInSearch: true,
dataIndex: "createTime", dataIndex: 'createTime',
}, },
{ {
title: l('global.table.useTime'), title: l('global.table.useTime'),
...@@ -52,8 +53,9 @@ const JobList = () => { ...@@ -52,8 +53,9 @@ const JobList = () => {
{ {
title: l('global.table.status'), title: l('global.table.status'),
filters: JOB_STATUS_FILTER(), filters: JOB_STATUS_FILTER(),
hideInSearch:true, filterMultiple: false,
dataIndex: "status", hideInSearch: true,
dataIndex: 'status',
render: (_, row) => TagJobStatus(row.status) render: (_, row) => TagJobStatus(row.status)
}, },
Table.EXPAND_COLUMN, Table.EXPAND_COLUMN,
...@@ -72,7 +74,7 @@ const JobList = () => { ...@@ -72,7 +74,7 @@ const JobList = () => {
]; ];
useEffect(() => { useEffect(() => {
setInterval(()=>tableRef.current?.reload(false), 5*1000); setInterval(() => tableRef.current?.reload(false), 5 * 1000);
}, []); }, []);
return ( return (
...@@ -82,13 +84,11 @@ const JobList = () => { ...@@ -82,13 +84,11 @@ const JobList = () => {
params={{isHistory: false}} params={{isHistory: false}}
actionRef={tableRef} actionRef={tableRef}
headerTitle={l('devops.joblist.joblist')} headerTitle={l('devops.joblist.joblist')}
request={async (params, sorter, filter: any) => { request={async (params, sorter, filter: any) => queryList(API_CONSTANTS.GET_JOB_LIST, {
return queryList(API_CONSTANTS.GET_JOB_LIST, { ...params,
...params, sorter,
sorter, filter
filter })}
})
}}
expandable={{ expandable={{
expandedRowRender: (record) => <JobHistoryList taskId={record.taskId} key={record.jid}/>, expandedRowRender: (record) => <JobHistoryList taskId={record.taskId} key={record.jid}/>,
expandIcon: ({expanded, onExpand, record}) => { expandIcon: ({expanded, onExpand, record}) => {
...@@ -100,10 +100,10 @@ const JobList = () => { ...@@ -100,10 +100,10 @@ const JobList = () => {
title={l('devops.joblist.history')} title={l('devops.joblist.history')}
icon={<ClockCircleTwoTone twoToneColor={expanded ? '#52c41a' : '#4096ff'}/>} icon={<ClockCircleTwoTone twoToneColor={expanded ? '#52c41a' : '#4096ff'}/>}
/> />
) );
} }
}} }}
/> />
); );
} };
export default JobList; export default JobList;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {PageContainer} from '@ant-design/pro-layout';
import JobList from '@/pages/DevOps/JobList';
export default () => {
/**
* breadcrumb={{style:{display:'none'}}} is used to hide the breadcrumb || 隐藏右上角的路由导航面包屑
*/
return <>
<PageContainer title={false} breadcrumb={{style:{display:'none'}}}>
<JobList/>
</PageContainer>
</>;
}
...@@ -19,12 +19,14 @@ import {DataSources} from '@/types/RegCenter/data'; ...@@ -19,12 +19,14 @@ import {DataSources} from '@/types/RegCenter/data';
import React, {useCallback, useEffect, useState} from 'react'; import React, {useCallback, useEffect, useState} from 'react';
import CodeShow from '@/components/CustomEditor/CodeShow'; import CodeShow from '@/components/CustomEditor/CodeShow';
import {ProCard} from '@ant-design/pro-components'; import {ProCard} from '@ant-design/pro-components';
import {Empty} from 'antd'; import {Empty, Typography} from 'antd';
import {l} from '@/utils/intl'; import {l} from '@/utils/intl';
import {queryDataByParams} from '@/services/BusinessCrud'; import {queryDataByParams} from '@/services/BusinessCrud';
import {API_CONSTANTS} from '@/services/constants'; import {API_CONSTANTS} from '@/services/constants';
import {QueryParams} from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/data'; import {QueryParams} from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/data';
const {Paragraph} = Typography;
type GenSQLProps = { type GenSQLProps = {
queryParams: Partial<QueryParams>, queryParams: Partial<QueryParams>,
tagDisabled: boolean tagDisabled: boolean
...@@ -34,7 +36,7 @@ type GenSQLProps = { ...@@ -34,7 +36,7 @@ type GenSQLProps = {
* props for CodeShow * props for CodeShow
*/ */
const CodeShowProps = { const CodeShowProps = {
height: '60vh', height: '68vh',
width: '100%', width: '100%',
lineNumbers: 'on', lineNumbers: 'on',
language: 'sql', language: 'sql',
...@@ -70,6 +72,16 @@ const GenSQL: React.FC<GenSQLProps> = (props) => { ...@@ -70,6 +72,16 @@ const GenSQL: React.FC<GenSQLProps> = (props) => {
return <CodeShow {...CodeShowProps} code={tagDisabled ? '' : code}/>; return <CodeShow {...CodeShowProps} code={tagDisabled ? '' : code}/>;
}; };
/**
* render label
* @param {string} content
* @param {string} title
* @returns {JSX.Element}
*/
const renderLabel = (content: string, title: string) => {
return <Paragraph copyable={{text: content}}>{title}</Paragraph>;
};
/** /**
* tab list * tab list
...@@ -77,19 +89,19 @@ const GenSQL: React.FC<GenSQLProps> = (props) => { ...@@ -77,19 +89,19 @@ const GenSQL: React.FC<GenSQLProps> = (props) => {
const tabList = [ const tabList = [
{ {
key: 'flinkddl', key: 'flinkddl',
label: 'Flink DDL', label: renderLabel(genSQL.flinkSqlCreate || '', 'Flink DDL'),
disabled: tagDisabled, disabled: tagDisabled,
children: renderContent(genSQL.sqlCreate) children: renderContent(genSQL.flinkSqlCreate)
}, },
{ {
key: 'select', key: 'select',
label: 'Select', label: renderLabel(genSQL.sqlSelect || '', 'Select'),
disabled: tagDisabled, disabled: tagDisabled,
children:renderContent(genSQL.sqlSelect) children: renderContent(genSQL.sqlSelect)
}, },
{ {
key: 'sqlddl', key: 'sqlddl',
label: 'SQL DDL', label: renderLabel(genSQL.sqlCreate || '', 'SQL DDL'),
disabled: tagDisabled, disabled: tagDisabled,
children: renderContent(genSQL.sqlCreate) children: renderContent(genSQL.sqlCreate)
} }
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {PROTABLE_OPTIONS_PUBLIC} from '@/services/constants';
import {ProTable} from '@ant-design/pro-components';
import React from 'react';
import {ProColumns} from '@ant-design/pro-table';
type DataListProps = {
columns: ProColumns[];
data: any[];
}
const DataList: React.FC<DataListProps> = (props) => {
const {columns, data} = props;
return <>
<ProTable
{...PROTABLE_OPTIONS_PUBLIC}
pagination={{
position: ['bottomCenter'],
pageSize: 9,
showQuickJumper: true,
hideOnSinglePage: true,
}}
columns={columns}
dataSource={data}
search={false}
options={false}
scroll={{x: 'max-content'}}
/>
</>;
};
export default DataList;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {l} from '@/utils/intl';
import {PlayCircleOutlined} from '@ant-design/icons';
import {Col, Row} from 'antd';
import React, {memo} from 'react';
import {StartButton} from '@/components/StyledComponents';
import CodeEdit from '@/components/CustomEditor/CodeEdit';
const CodeEditProps = {
height: '26vh',
lineNumbers: 'on',
language: 'sql',
// autoRange: true, // todo: 使用此配置项,后续可以自动识别光标位置,根据;分割,得到 sql 片段区间, 在左侧自动添加 执行按钮 和 区间选中效果, 规划内,暂未实现
};
type EditorProps = {
loading: boolean;
execCallback: () => void;
handleInputChange: (value: string) => void;
inputValue: string;
}
// todo: 代码编辑器, 代码片段执行, 代码片段选中, 代码片段执行按钮, 代码片段执行结果, 代码片段执行结果展示
const Editor: React.FC<EditorProps> = (props) => {
const {loading, execCallback, handleInputChange, inputValue} = props;
return <>
<Row>
<Col flex="auto">
<StartButton>
<PlayCircleOutlined
title={l('rc.ds.console.exec')}
spin={loading}
onClick={execCallback}
disabled={loading}
/>
</StartButton>
<CodeEdit {...CodeEditProps} onChange={handleInputChange} code={inputValue}/>
</Col>
</Row>
</>;
};
export default memo(Editor);
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// todo: mock data for test
export const tempColumns = [
{
title: 'col1',
dataIndex: 'col1',
},
{
title: 'col2',
dataIndex: 'col2',
},
{
title: 'col3',
dataIndex: 'col3',
},
{
title: 'col4',
dataIndex: 'col4',
},
{
title: 'col5',
dataIndex: 'col5',
},
{
title: 'col6',
dataIndex: 'col6',
},
{
title: 'col7',
dataIndex: 'col7',
},
{
title: 'col8',
dataIndex: 'col8',
},
{
title: 'col9',
dataIndex: 'col9',
},
{
title: 'col10',
dataIndex: 'col10',
},
{
title: 'col11',
dataIndex: 'col11',
},
{
title: 'col12',
dataIndex: 'col12',
},
{
title: 'col13',
dataIndex: 'col13',
},
{
title: 'col14',
dataIndex: 'col14',
},
{
title: 'col15',
dataIndex: 'col15',
},
{
title: 'col16',
dataIndex: 'col16',
}
];
export const tempData = [
{
col1: 'col1',
col2: 'col2',
},
{
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
},
{
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
}, {
col1: 'col1',
col2: 'col2',
},
];
...@@ -15,40 +15,51 @@ ...@@ -15,40 +15,51 @@
* limitations under the License. * limitations under the License.
*/ */
import CodeEdit from '@/components/CustomEditor/CodeEdit';
import React, {useState} from 'react'; import React, {useState} from 'react';
import {Height80VHDiv} from '@/components/StyledComponents';
import {Alert, Result} from 'antd';
import {PageLoading} from '@ant-design/pro-components';
import DataList from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SQLConsole/DataList';
import Editor from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SQLConsole/Editor';
import {l} from '@/utils/intl';
import {
tempColumns,
tempData
} from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SQLConsole/data';
const CodeEditProps = {
height: '35vh',
width: '100%',
lineNumbers: 'on',
language: 'sql',
// autoRange: true, // todo: 使用此配置项,后续可以自动识别光标位置,根据;分割,得到 sql 片段区间, 在左侧自动添加 执行按钮 和 区间选中效果, 规划内,暂未实现
};
type SQLConsoleProps = {
querySQL: string,
}
const SQLConsole:React.FC<SQLConsoleProps> = (props) => { const SQLConsole: React.FC = () => {
const {querySQL} = props;
const [inputValue, setInputValue] = useState(''); const [inputValue, setInputValue] = useState('');
const [loading, setLoading] = useState<boolean>(false); const [loading, setLoading] = useState<boolean>(false);
const handleInputChange = (value: string) => { const handleInputChange = (value: string) => {
setInputValue(value); setInputValue(value);
} };
const execSql = async () => { const execSql = async () => {
setLoading(true); setLoading(true);
// todo: exec sql callback // todo: exec sql callback
setLoading(false); setTimeout(() => {
} setLoading(false);
}, 3000);
};
return <> const renderAlertMsg = (flag: boolean, msg: string) => {
<CodeEdit {...CodeEditProps} onChange={handleInputChange} code={inputValue}/> if (!flag) {
</> return <Alert style={{margin: 0, height: '2vw', alignItems: 'center'}} message={msg} type="error" showIcon/>;
} } else {
return <Alert style={{margin: 0, height: '2vw', alignItems: 'center'}} message={msg} type="success" showIcon/>;
}
};
return <Height80VHDiv>
<Editor inputValue={inputValue} loading={loading} execCallback={execSql} handleInputChange={handleInputChange}/>
{/*{renderAlertMsg(false, '执行成功')}*/}
{loading ? <Result icon={<PageLoading spin={loading}/>} title={l('rc.ds.console.running')}/> :
<DataList columns={tempColumns} data={tempData}/>}
</Height80VHDiv>;
};
export default SQLConsole; export default SQLConsole;
...@@ -59,7 +59,6 @@ const QueryForm: React.FC<QueryFormProps> = (props) => { ...@@ -59,7 +59,6 @@ const QueryForm: React.FC<QueryFormProps> = (props) => {
}; };
const renderForm = () => { const renderForm = () => {
return <> return <>
<AutoComplete <AutoComplete
......
...@@ -25,6 +25,7 @@ import {l} from '@/utils/intl'; ...@@ -25,6 +25,7 @@ import {l} from '@/utils/intl';
import {DefaultOptionType} from 'rc-select/lib/Select'; import {DefaultOptionType} from 'rc-select/lib/Select';
import QueryForm from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SQLQuery/QueryForm'; import QueryForm from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SQLQuery/QueryForm';
import {buildColumnsQueryKeyWord} from '@/pages/RegCenter/DataSource/components/function'; import {buildColumnsQueryKeyWord} from '@/pages/RegCenter/DataSource/components/function';
import {Height80VHDiv} from '@/components/StyledComponents';
// props // props
type SQLQueryProps = { type SQLQueryProps = {
queryParams: QueryParams queryParams: QueryParams
...@@ -66,7 +67,7 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => { ...@@ -66,7 +67,7 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => {
tooltip: item, tooltip: item,
width: '8%', width: '8%',
})); }));
setAutoCompleteColumns( buildColumnsQueryKeyWord(columns)); setAutoCompleteColumns(buildColumnsQueryKeyWord(columns));
setTableData({columns: tableColumns, rowData: rowData}); setTableData({columns: tableColumns, rowData: rowData});
setLoading(false); setLoading(false);
}; };
...@@ -123,7 +124,7 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => { ...@@ -123,7 +124,7 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => {
/** /**
* render * render
*/ */
return <> return <Height80VHDiv>
{ {
(dbId && tableName && schemaName) ? ( (dbId && tableName && schemaName) ? (
<ProTable <ProTable
...@@ -133,7 +134,8 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => { ...@@ -133,7 +134,8 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => {
size={'small'} size={'small'}
search={false} search={false}
pagination={{ pagination={{
defaultPageSize: 12, defaultPageSize: 15,
hideOnSinglePage: true,
}} }}
dateFormatter="string" dateFormatter="string"
columns={tableData.columns} columns={tableData.columns}
...@@ -148,7 +150,7 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => { ...@@ -148,7 +150,7 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => {
/> />
) : <Empty className={'code-content-empty'} description={l('rc.ds.detail.tips')}/> ) : <Empty className={'code-content-empty'} description={l('rc.ds.detail.tips')}/>
} }
</>; </Height80VHDiv>;
}; };
export default SQLQuery; export default SQLQuery;
...@@ -115,7 +115,7 @@ const ColumnInfo: React.FC<ColumnInfoProps> = (props) => { ...@@ -115,7 +115,7 @@ const ColumnInfo: React.FC<ColumnInfoProps> = (props) => {
<ProTable<DataSources.Column> <ProTable<DataSources.Column>
toolBarRender={false} toolBarRender={false}
pagination={{ pagination={{
defaultPageSize: 10, defaultPageSize: 14,
hideOnSinglePage: true, hideOnSinglePage: true,
}} }}
search={false} search={false}
......
...@@ -28,7 +28,7 @@ const TableInfo: React.FC<TableInfoProps> = (props) => { ...@@ -28,7 +28,7 @@ const TableInfo: React.FC<TableInfoProps> = (props) => {
const {tableInfo} = props; const {tableInfo} = props;
return <> return <>
<Descriptions size={'small'} bordered column={4}> <Descriptions size={'small'} bordered column={4}>
<Descriptions.Item label="Name">{tableInfo.name}</Descriptions.Item> <Descriptions.Item label="Name">{tableInfo.name}</Descriptions.Item>
<Descriptions.Item label="Schema">{tableInfo.schema}</Descriptions.Item> <Descriptions.Item label="Schema">{tableInfo.schema}</Descriptions.Item>
<Descriptions.Item label="Catalog">{tableInfo.catalog}</Descriptions.Item> <Descriptions.Item label="Catalog">{tableInfo.catalog}</Descriptions.Item>
......
...@@ -21,6 +21,7 @@ import React from 'react'; ...@@ -21,6 +21,7 @@ import React from 'react';
import TableInfo from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SchemaDesc/TableInfo'; import TableInfo from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SchemaDesc/TableInfo';
import ColumnInfo from './ColumnInfo/Index'; import ColumnInfo from './ColumnInfo/Index';
import {l} from '@/utils/intl'; import {l} from '@/utils/intl';
import {Height80VHDiv} from '@/components/StyledComponents';
type SchemaDescProps = { type SchemaDescProps = {
tableInfo: Partial<DataSources.Table>; tableInfo: Partial<DataSources.Table>;
...@@ -30,7 +31,7 @@ type SchemaDescProps = { ...@@ -30,7 +31,7 @@ type SchemaDescProps = {
const SchemaDesc: React.FC<SchemaDescProps> = (props) => { const SchemaDesc: React.FC<SchemaDescProps> = (props) => {
const {tableInfo, tableColumns} = props; const {tableInfo, tableColumns} = props;
return <> return <Height80VHDiv>
{!(Object.keys(tableInfo).length === 0 && tableColumns.length === 0) ? {!(Object.keys(tableInfo).length === 0 && tableColumns.length === 0) ?
<> <>
<TableInfo tableInfo={tableInfo}/> <TableInfo tableInfo={tableInfo}/>
...@@ -38,7 +39,7 @@ const SchemaDesc: React.FC<SchemaDescProps> = (props) => { ...@@ -38,7 +39,7 @@ const SchemaDesc: React.FC<SchemaDescProps> = (props) => {
</> </>
: <Empty className={'code-content-empty'} description={l('rc.ds.detail.tips')}/> : <Empty className={'code-content-empty'} description={l('rc.ds.detail.tips')}/>
} }
</>; </Height80VHDiv>;
}; };
export default SchemaDesc; export default SchemaDesc;
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
import {Space} from 'antd'; import {Space} from 'antd';
import {l} from '@/utils/intl'; import {l} from '@/utils/intl';
import { import {
BookOutlined, BookOutlined, ConsoleSqlOutlined, HighlightOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import React, {useState} from 'react'; import React, {useState} from 'react';
import {DataSources} from '@/types/RegCenter/data'; import {DataSources} from '@/types/RegCenter/data';
...@@ -27,6 +27,8 @@ import GenSQL from '@/pages/RegCenter/DataSource/components/DataSourceDetail/Rig ...@@ -27,6 +27,8 @@ import GenSQL from '@/pages/RegCenter/DataSource/components/DataSourceDetail/Rig
import {ProCard} from '@ant-design/pro-components'; import {ProCard} from '@ant-design/pro-components';
import SQLQuery from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SQLQuery'; import SQLQuery from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SQLQuery';
import {QueryParams} from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/data'; import {QueryParams} from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/data';
import SQLConsole from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SQLConsole';
import {SearchOutline} from 'antd-mobile-icons';
/** /**
...@@ -43,7 +45,7 @@ type RightTagsRouterProps = { ...@@ -43,7 +45,7 @@ type RightTagsRouterProps = {
const RightTagsRouter: React.FC<RightTagsRouterProps> = (props) => { const RightTagsRouter: React.FC<RightTagsRouterProps> = (props) => {
const {tableColumns, tableInfo,queryParams, tagDisabled, rightButtons} = props; const {tableColumns, tableInfo, queryParams, tagDisabled, rightButtons} = props;
// state // state
const [activeKey, setActiveKey] = useState('desc'); const [activeKey, setActiveKey] = useState('desc');
...@@ -57,21 +59,20 @@ const RightTagsRouter: React.FC<RightTagsRouterProps> = (props) => { ...@@ -57,21 +59,20 @@ const RightTagsRouter: React.FC<RightTagsRouterProps> = (props) => {
}, },
{ {
key: 'query', key: 'query',
label: <Space><BookOutlined/>{l('rc.ds.detail.tag.query')}</Space>, label: <Space><SearchOutline/>{l('rc.ds.detail.tag.query')}</Space>,
children: <SQLQuery queryParams={queryParams}/>, children: <SQLQuery queryParams={queryParams}/>,
disabled: tagDisabled disabled: tagDisabled
}, },
{ {
key: 'gensql', key: 'gensql',
label: <Space><BookOutlined/>{l('rc.ds.detail.tag.gensql')}</Space>, label: <Space><HighlightOutlined/>{l('rc.ds.detail.tag.gensql')}</Space>,
children: <GenSQL tagDisabled={tagDisabled} queryParams={queryParams}/>, children: <GenSQL tagDisabled={tagDisabled} queryParams={queryParams}/>,
disabled: tagDisabled disabled: tagDisabled
}, },
{ {
key: 'console', key: 'console',
label: <Space><BookOutlined/>{l('rc.ds.detail.tag.console')}</Space>, label: <Space><ConsoleSqlOutlined/>{l('rc.ds.detail.tag.console')}</Space>,
disabled: tagDisabled, children: <SQLConsole/>
// children: <SQLConsole dbId={dataSourceInfo.id} schema={tableInfo.schema} table={tableInfo.name} />
}, },
]; ];
...@@ -89,7 +90,7 @@ const RightTagsRouter: React.FC<RightTagsRouterProps> = (props) => { ...@@ -89,7 +90,7 @@ const RightTagsRouter: React.FC<RightTagsRouterProps> = (props) => {
* render * render
*/ */
return <> return <>
<ProCard size="small" bordered tabs={{...restTabProps}}/> <ProCard className={'schemaTree'} size="small" bordered tabs={{...restTabProps}}/>
</>; </>;
}; };
......
...@@ -73,7 +73,7 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => { ...@@ -73,7 +73,7 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
} }
}); });
setLoading(false); setLoading(false);
}, []); }, [dataSource.id]);
useEffect(() => { useEffect(() => {
...@@ -128,12 +128,12 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => { ...@@ -128,12 +128,12 @@ const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
* render * render
*/ */
return <> return <>
<ProCard loading={loading} ghost split="vertical"> <ProCard loading={loading} ghost gutter={[16, 16]} split="vertical">
<ProCard bordered className={'siderTree schemaTree'} colSpan="20%"> <ProCard hoverable bordered className={'siderTree schemaTree'} colSpan="16%">
{/* tree */} {/* tree */}
<SchemaTree onNodeClick={(info: any) => onSchemaTreeNodeClick(info)} treeData={treeData}/> <SchemaTree onNodeClick={(info: any) => onSchemaTreeNodeClick(info)} treeData={treeData}/>
</ProCard> </ProCard>
<ProCard colSpan="80%" loading={loading} ghost headerBordered> <ProCard hoverable colSpan="84%" ghost headerBordered>
{/* tags */} {/* tags */}
<RightTagsRouter <RightTagsRouter
tableInfo={tableInfo} tableInfo={tableInfo}
......
...@@ -15,16 +15,16 @@ ...@@ -15,16 +15,16 @@
* limitations under the License. * limitations under the License.
*/ */
import React from "react"; import React from 'react';
import {FormInstance} from "antd/es/form/hooks/useForm"; import {FormInstance} from 'antd/es/form/hooks/useForm';
import {Values} from "async-validator"; import {Values} from 'async-validator';
import {ProForm, ProFormGroup, ProFormSelect, ProFormText} from "@ant-design/pro-components"; import {ProForm, ProFormGroup, ProFormSelect, ProFormText} from '@ant-design/pro-components';
import {l} from "@/utils/intl"; import {l} from '@/utils/intl';
import {DataSources} from "@/types/RegCenter/data.d"; import {DataSources} from '@/types/RegCenter/data.d';
import {AUTO_COMPLETE_TYPE, GROUP_TYPE} from "@/pages/RegCenter/DataSource/components/constants"; import {AUTO_COMPLETE_TYPE, GROUP_TYPE} from '@/pages/RegCenter/DataSource/components/constants';
import {AutoComplete, Input} from "antd"; import {AutoComplete, Input} from 'antd';
import CodeEdit from "@/components/CustomEditor/CodeEdit"; import CodeEdit from '@/components/CustomEditor/CodeEdit';
import {renderDataSourceType} from "@/pages/RegCenter/DataSource/components/function"; import {renderDataSourceType} from '@/pages/RegCenter/DataSource/components/function';
type DataSourceProFormProps = { type DataSourceProFormProps = {
values: Partial<DataSources.DataSource>, values: Partial<DataSources.DataSource>,
...@@ -35,10 +35,10 @@ type DataSourceProFormProps = { ...@@ -35,10 +35,10 @@ type DataSourceProFormProps = {
const CodeEditProps = { const CodeEditProps = {
height: "30vh", height: '30vh',
width: "22vw", width: '22vw',
lineNumbers: "off", lineNumbers: 'off',
language: "sql", language: 'sql',
}; };
const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => { const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => {
...@@ -48,7 +48,7 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => { ...@@ -48,7 +48,7 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => {
const handleTypeChange = (type: string) => { const handleTypeChange = (type: string) => {
if (type === "Hive" || type === "Presto") { if (type === 'Hive' || type === 'Presto') {
setExcludeFormItem(true); setExcludeFormItem(true);
} else { } else {
setExcludeFormItem(false); setExcludeFormItem(false);
...@@ -60,48 +60,48 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => { ...@@ -60,48 +60,48 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => {
<ProForm.Group> <ProForm.Group>
<ProFormText <ProFormText
name="name" name="name"
width={"md"} width={'md'}
label={l("rc.ds.name")} label={l('rc.ds.name')}
rules={[{required: true, message: l("rc.ds.namePlaceholder")}]} rules={[{required: true, message: l('rc.ds.namePlaceholder')}]}
placeholder={l("rc.ds.namePlaceholder")} placeholder={l('rc.ds.namePlaceholder')}
/> />
<ProFormSelect <ProFormSelect
name="groupName" name="groupName"
width={"sm"} width={'sm'}
label={l("rc.ds.groupName")} label={l('rc.ds.groupName')}
options={GROUP_TYPE} options={GROUP_TYPE}
placeholder={l("rc.ds.groupNamePlaceholder")} placeholder={l('rc.ds.groupNamePlaceholder')}
/> />
<ProFormSelect <ProFormSelect
name="type" name="type"
width={"sm"} width={'sm'}
label={l("rc.ds.type")} label={l('rc.ds.type')}
showSearch showSearch
options={renderDataSourceType()} options={renderDataSourceType()}
rules={[{required: true, message: l("rc.ds.typePlaceholder")}]} rules={[{required: true, message: l('rc.ds.typePlaceholder')}]}
placeholder={l("rc.ds.typePlaceholder")} placeholder={l('rc.ds.typePlaceholder')}
/> />
<ProFormText <ProFormText
name="username" name="username"
width={"sm"} width={'sm'}
label={l("rc.ds.username")} label={l('rc.ds.username')}
rules={[{required: true, message: l("rc.ds.usernamePlaceholder")}]} rules={[{required: true, message: l('rc.ds.usernamePlaceholder')}]}
placeholder={l("rc.ds.usernamePlaceholder")} placeholder={l('rc.ds.usernamePlaceholder')}
/> />
<ProFormText.Password <ProFormText.Password
name="password" name="password"
width={"sm"} width={'sm'}
label={l("rc.ds.password")} label={l('rc.ds.password')}
rules={[{required: true, message: l("rc.ds.passwordPlaceholder")}]} rules={[{required: true, message: l('rc.ds.passwordPlaceholder')}]}
placeholder={l("rc.ds.passwordPlaceholder")} placeholder={l('rc.ds.passwordPlaceholder')}
/> />
<ProFormText <ProFormText
name="note" name="note"
width={"md"} width={'md'}
label={l("global.table.note")} label={l('global.table.note')}
placeholder={l("global.table.notePlaceholder")} placeholder={l('global.table.notePlaceholder')}
/> />
</ProForm.Group> </ProForm.Group>
...@@ -112,10 +112,10 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => { ...@@ -112,10 +112,10 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => {
> >
<ProForm.Item <ProForm.Item
name="url" name="url"
label={l("rc.ds.url")} label={l('rc.ds.url')}
rules={[{required: true, message: l("rc.ds.urlPlaceholder")}]} rules={[{required: true, message: l('rc.ds.urlPlaceholder')}]}
> >
<Input.TextArea rows={3} cols={130} placeholder={l("rc.ds.urlPlaceholder")}/> <Input.TextArea rows={3} cols={130} placeholder={l('rc.ds.urlPlaceholder')}/>
</ProForm.Item> </ProForm.Item>
</AutoComplete> </AutoComplete>
...@@ -125,18 +125,18 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => { ...@@ -125,18 +125,18 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => {
<ProFormGroup> <ProFormGroup>
<ProForm.Item <ProForm.Item
name="flinkConfig" name="flinkConfig"
label={l("rc.ds.flinkConfig")} label={l('rc.ds.flinkConfig')}
tooltip={l("rc.ds.flinkConfigTooltip")} tooltip={l('rc.ds.flinkConfigTooltip')}
> >
<CodeEdit {...CodeEditProps} onChange={flinkConfigChange} code={values.flinkConfig || ""}/> <CodeEdit {...CodeEditProps} onChange={flinkConfigChange} code={values.flinkConfig || ''}/>
</ProForm.Item> </ProForm.Item>
<ProForm.Item <ProForm.Item
name="flinkTemplate" name="flinkTemplate"
label={l("rc.ds.flinkTemplate")} label={l('rc.ds.flinkTemplate')}
tooltip={l("rc.ds.flinkTemplateTooltip")} tooltip={l('rc.ds.flinkTemplateTooltip')}
> >
<CodeEdit {...CodeEditProps} onChange={flinkTemplateChange} code={values.flinkTemplate || ""}/> <CodeEdit {...CodeEditProps} onChange={flinkTemplateChange} code={values.flinkTemplate || ''}/>
</ProForm.Item> </ProForm.Item>
</ProFormGroup> </ProFormGroup>
} }
......
...@@ -15,14 +15,14 @@ ...@@ -15,14 +15,14 @@
* limitations under the License. * limitations under the License.
*/ */
import {Button, Form} from "antd"; import {Button, Form} from 'antd';
import {l} from "@/utils/intl"; import {l} from '@/utils/intl';
import React, {useEffect} from "react"; import React, {useEffect} from 'react';
import {MODAL_FORM_OPTIONS} from "@/services/constants"; import {MODAL_FORM_OPTIONS} from '@/services/constants';
import {DataSources} from "@/types/RegCenter/data"; import {DataSources} from '@/types/RegCenter/data';
import DataSourceProForm from "@/pages/RegCenter/DataSource/components/DataSourceModal/DataSourceProForm"; import DataSourceProForm from '@/pages/RegCenter/DataSource/components/DataSourceModal/DataSourceProForm';
import {FormContextValue} from "@/components/Context/FormContext"; import {FormContextValue} from '@/components/Context/FormContext';
import {ModalForm} from "@ant-design/pro-components"; import {ModalForm} from '@ant-design/pro-components';
type DataSourceModalProps = { type DataSourceModalProps = {
visible: boolean; visible: boolean;
...@@ -36,8 +36,8 @@ const DataSourceModal: React.FC<DataSourceModalProps> = (props) => { ...@@ -36,8 +36,8 @@ const DataSourceModal: React.FC<DataSourceModalProps> = (props) => {
const {visible, values, onCancel, onSubmit, onTest} = props; const {visible, values, onCancel, onSubmit, onTest} = props;
const [submitting, setSubmitting] = React.useState<boolean>(false); const [submitting, setSubmitting] = React.useState<boolean>(false);
const [flinkConfigValue, setFlinkConfigValue] = React.useState<string>(values.flinkConfig || ""); const [flinkConfigValue, setFlinkConfigValue] = React.useState<string>(values.flinkConfig || '');
const [flinkTemplateValue, setFlinkTemplateValue] = React.useState<string>(values.flinkTemplate || ""); const [flinkTemplateValue, setFlinkTemplateValue] = React.useState<string>(values.flinkTemplate || '');
/** /**
* init form * init form
...@@ -110,11 +110,11 @@ const DataSourceModal: React.FC<DataSourceModalProps> = (props) => { ...@@ -110,11 +110,11 @@ const DataSourceModal: React.FC<DataSourceModalProps> = (props) => {
*/ */
const renderFooter = () => { const renderFooter = () => {
return [ return [
<Button key={"cancel"} onClick={() => handleCancel()}>{l("button.cancel")}</Button>, <Button key={'cancel'} onClick={() => handleCancel()}>{l('button.cancel')}</Button>,
<Button key={"test"} loading={submitting} type="primary" <Button key={'test'} loading={submitting} type="primary"
onClick={handleTestConnect}>{l("button.test")}</Button>, onClick={handleTestConnect}>{l('button.test')}</Button>,
<Button key={"finish"} loading={submitting} type="primary" <Button key={'finish'} loading={submitting} type="primary"
onClick={() => submitForm()}>{l("button.finish")}</Button>, onClick={() => submitForm()}>{l('button.finish')}</Button>,
]; ];
}; };
...@@ -126,7 +126,7 @@ const DataSourceModal: React.FC<DataSourceModalProps> = (props) => { ...@@ -126,7 +126,7 @@ const DataSourceModal: React.FC<DataSourceModalProps> = (props) => {
{...MODAL_FORM_OPTIONS} {...MODAL_FORM_OPTIONS}
open={visible} open={visible}
modalProps={{onCancel: handleCancel}} modalProps={{onCancel: handleCancel}}
title={values.id ? l("rc.ds.modify") : l("rc.ds.create")} title={values.id ? l('rc.ds.modify') : l('rc.ds.create')}
form={form} form={form}
submitter={{render: () => [...renderFooter()]}} submitter={{render: () => [...renderFooter()]}}
initialValues={{...values, flinkConfig: flinkConfigValue, flinkTemplate: flinkTemplateValue}} initialValues={{...values, flinkConfig: flinkConfigValue, flinkTemplate: flinkTemplateValue}}
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
import {DATA_SOURCE_TYPE, QUERY_KEYWORD} from '@/pages/RegCenter/DataSource/components/constants'; import {DATA_SOURCE_TYPE, QUERY_KEYWORD} from '@/pages/RegCenter/DataSource/components/constants';
import {DefaultOptionType} from "antd/es/select"; import {DefaultOptionType} from 'antd/es/select';
import { import {
ClickHouseIcons, DefaultDBIcons, ClickHouseIcons, DefaultDBIcons,
DorisIcons, HiveIcons, DorisIcons, HiveIcons,
...@@ -25,7 +25,7 @@ import { ...@@ -25,7 +25,7 @@ import {
OracleIcons, PhoenixIcons, OracleIcons, PhoenixIcons,
PostgresqlIcons, PrestoIcons, PostgresqlIcons, PrestoIcons,
SqlServerIcons, StarRocksIcons SqlServerIcons, StarRocksIcons
} from "@/components/Icons/DBIcons"; } from '@/components/Icons/DBIcons';
/** /**
...@@ -35,25 +35,25 @@ import { ...@@ -35,25 +35,25 @@ import {
*/ */
export const renderDBIcon = (type: string, size?: number) => { export const renderDBIcon = (type: string, size?: number) => {
switch (type.toLowerCase()) { switch (type.toLowerCase()) {
case "mysql": case 'mysql':
return <MysqlIcons size={size}/>; return <MysqlIcons size={size}/>;
case "oracle": case 'oracle':
return <OracleIcons size={size}/>; return <OracleIcons size={size}/>;
case "postgresql": case 'postgresql':
return <PostgresqlIcons size={size}/>; return <PostgresqlIcons size={size}/>;
case "clickhouse": case 'clickhouse':
return <ClickHouseIcons size={size}/>; return <ClickHouseIcons size={size}/>;
case "sqlserver": case 'sqlserver':
return <SqlServerIcons size={size}/>; return <SqlServerIcons size={size}/>;
case "doris": case 'doris':
return <DorisIcons size={size}/>; return <DorisIcons size={size}/>;
case "phoenix": case 'phoenix':
return <PhoenixIcons size={size}/>; return <PhoenixIcons size={size}/>;
case "hive": case 'hive':
return <HiveIcons size={size}/>; return <HiveIcons size={size}/>;
case "starrocks": case 'starrocks':
return <StarRocksIcons size={size}/>; return <StarRocksIcons size={size}/>;
case "presto": case 'presto':
return <PrestoIcons size={size}/>; return <PrestoIcons size={size}/>;
default: default:
return <DefaultDBIcons size={size}/>; return <DefaultDBIcons size={size}/>;
...@@ -75,10 +75,10 @@ export const renderDataSourceType = () => { ...@@ -75,10 +75,10 @@ export const renderDataSourceType = () => {
return dataSourceType; return dataSourceType;
}; };
export const buildColumnsQueryKeyWord = (data : string[]) => { export const buildColumnsQueryKeyWord = (data: string[]) => {
const result = data.concat(QUERY_KEYWORD).map((item: string | number) => ({ const result = data.concat(QUERY_KEYWORD).map((item: string | number) => ({
value: item, value: item,
label: item, label: item,
})) }));
return result return result;
} };
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