Unverified Commit e740150e authored by 高岩's avatar 高岩 Committed by GitHub

DataStudio metadata add refesh button (#1253)

Co-authored-by: steve <woai1998>
parent df106ae6
...@@ -18,12 +18,19 @@ ...@@ -18,12 +18,19 @@
*/ */
import {Button, Empty, Modal, Select, Tabs, Tag, Tree} from "antd"; import {Button, Col, Empty, Modal, Row, Select, Spin, Tabs, Tag, Tree} from "antd";
import {StateType} from "@/pages/DataStudio/model"; import {StateType} from "@/pages/DataStudio/model";
import {connect} from "umi"; import {connect} from "umi";
import React, {useState} from "react"; import React, {useState} from "react";
import {CodepenOutlined, DatabaseOutlined, DownOutlined, OrderedListOutlined, TableOutlined} from '@ant-design/icons'; import {
import {showMetaDataTable} from "@/components/Studio/StudioEvent/DDL"; CodepenOutlined,
DatabaseOutlined,
DownOutlined,
OrderedListOutlined,
PoweroffOutlined,
TableOutlined
} from '@ant-design/icons';
import {clearMetaDataTable, showMetaDataTable} from "@/components/Studio/StudioEvent/DDL";
import {Scrollbars} from 'react-custom-scrollbars'; import {Scrollbars} from 'react-custom-scrollbars';
import Columns from "@/pages/DataBase/Columns"; import Columns from "@/pages/DataBase/Columns";
import Tables from "@/pages/DataBase/Tables"; import Tables from "@/pages/DataBase/Tables";
...@@ -42,12 +49,19 @@ const StudioMetaData = (props: any) => { ...@@ -42,12 +49,19 @@ const StudioMetaData = (props: any) => {
const [treeData, setTreeData] = useState<[]>([]); const [treeData, setTreeData] = useState<[]>([]);
const [modalVisit, setModalVisit] = useState(false); const [modalVisit, setModalVisit] = useState(false);
const [row, setRow] = useState<TreeDataNode>(); const [row, setRow] = useState<TreeDataNode>();
const [loadingDatabase, setloadingDatabase] = useState(false);
const onRefreshTreeData = (databaseId: number) => { const onRefreshTreeData = (databaseId: number) => {
if (!databaseId) return; if (!databaseId) {
setloadingDatabase(false);
return;
}
setloadingDatabase(true);
setDatabaseId(databaseId); setDatabaseId(databaseId);
const res = showMetaDataTable(databaseId); const res = showMetaDataTable(databaseId);
res.then((result) => { res.then((result) => {
setloadingDatabase(false);
let tables = result.datas; let tables = result.datas;
if (tables) { if (tables) {
for (let i = 0; i < tables.length; i++) { for (let i = 0; i < tables.length; i++) {
...@@ -95,17 +109,34 @@ const StudioMetaData = (props: any) => { ...@@ -95,17 +109,34 @@ const StudioMetaData = (props: any) => {
setRow(undefined); setRow(undefined);
setModalVisit(false); setModalVisit(false);
} }
const refeshDataBase = (value:number) => {
if (!databaseId) return;
setloadingDatabase(true);
clearMetaDataTable(databaseId).then(result => {
onChangeDataBase(databaseId);
})
};
return ( return (
<> <Spin spinning={loadingDatabase} delay={500}>
<Select <Row>
style={{width: '90%'}} <Col span={18}>
placeholder="选择数据源" <Select
optionLabelProp="label" style={{width: '90%'}}
onChange={onChangeDataBase} placeholder="选择数据源"
> optionLabelProp="label"
{getDataBaseOptions()} onChange={onChangeDataBase}
</Select> >
{getDataBaseOptions()}
</Select>
</Col>
<Col span={1}>
<Button type="link"
onClick={() => {refeshDataBase(databaseId)}}
>{l('button.refresh')}</Button>
</Col>
</Row>
<Scrollbars style={{height: (toolHeight - 32)}}> <Scrollbars style={{height: (toolHeight - 32)}}>
{treeData.length > 0 ? ( {treeData.length > 0 ? (
<DirectoryTree <DirectoryTree
...@@ -170,7 +201,7 @@ const StudioMetaData = (props: any) => { ...@@ -170,7 +201,7 @@ const StudioMetaData = (props: any) => {
</TabPane> </TabPane>
</Tabs> </Tabs>
</Modal> </Modal>
</> </Spin>
); );
}; };
......
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