Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
3eafe155
Unverified
Commit
3eafe155
authored
Aug 19, 2023
by
Licho
Committed by
GitHub
Aug 19, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: metadate get error (#2246)
Signed-off-by:
Licho
<
lecho.sun@gmail.com
>
parent
5fbaeab2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
34 deletions
+33
-34
index.tsx
...web/src/pages/DataStudio/LeftContainer/MetaData/index.tsx
+23
-29
service.tsx
...b/src/pages/DataStudio/LeftContainer/MetaData/service.tsx
+10
-5
No files found.
dinky-web/src/pages/DataStudio/LeftContainer/MetaData/index.tsx
View file @
3eafe155
import
{
TagAlignLeft
}
from
'@/components/StyledComponents'
;
import
{
TagAlignLeft
}
from
'@/components/StyledComponents'
;
import
{
BtnRoute
}
from
'@/pages/DataStudio/route'
;
import
{
BtnRoute
}
from
'@/pages/DataStudio/route'
;
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
{
l
}
from
'@/utils/intl'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
DatabaseOutlined
,
TableOutlined
}
from
'@ant-design/icons'
;
import
{
DatabaseOutlined
,
TableOutlined
}
from
'@ant-design/icons'
;
import
{
Key
,
ProForm
,
ProFormSelect
}
from
'@ant-design/pro-components'
;
import
{
Key
,
ProForm
,
ProFormSelect
}
from
'@ant-design/pro-components'
;
import
{
connect
}
from
'@umijs/max'
;
import
{
connect
}
from
'@umijs/max'
;
import
{
Spin
,
Tag
}
from
'antd'
;
import
{
Spin
,
Tag
}
from
'antd'
;
import
{
useEffect
,
useState
}
from
'react'
;
import
{
useEffect
,
useState
}
from
'react'
;
import
{
StateType
,
STUDIO_MODEL
}
from
'../../model'
;
import
{
StateType
,
STUDIO_MODEL
}
from
'../../model'
;
import
{
clearMetaDataTable
,
showMetaDataTable
}
from
'./service'
;
import
{
clearMetaDataTable
,
showMetaDataTable
}
from
'./service'
;
const
MetaData
=
(
props
:
any
)
=>
{
const
MetaData
=
(
props
:
any
)
=>
{
const
{
const
{
...
@@ -32,12 +32,11 @@ const MetaData = (props: any) => {
...
@@ -32,12 +32,11 @@ const MetaData = (props: any) => {
setIsLoadingDatabase
(
false
);
setIsLoadingDatabase
(
false
);
return
;
return
;
}
}
setIsLoadingDatabase
(
true
);
await
showMetaDataTable
(
databaseId
).
then
((
res
)
=>
{
setIsLoadingDatabase
(
true
);
const
tables
=
await
showMetaDataTable
(
databaseId
)
??
[]
setIsLoadingDatabase
(
false
);
setIsLoadingDatabase
(
false
);
const
{
datas
:
tables
}
=
res
;
if
(
!
tables
)
return
;
for
(
let
table
of
tables
)
{
for
(
let
table
of
tables
)
{
table
.
title
=
table
.
name
;
table
.
title
=
table
.
name
;
table
.
key
=
table
.
name
;
table
.
key
=
table
.
name
;
...
@@ -52,8 +51,7 @@ const MetaData = (props: any) => {
...
@@ -52,8 +51,7 @@ const MetaData = (props: any) => {
child
.
table
=
child
.
name
;
child
.
table
=
child
.
name
;
}
}
}
}
setTreeData
(
tables
??
[]);
setTreeData
(
tables
);
});
};
};
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -70,10 +68,7 @@ const MetaData = (props: any) => {
...
@@ -70,10 +68,7 @@ const MetaData = (props: any) => {
onRefreshTreeData
(
value
);
onRefreshTreeData
(
value
);
};
};
/**
BtnRoute
[
'menu.datastudio.metadata'
][
0
].
onClick
=
()
=>
{
* 刷新数据库列表
*/
const
refreshDataBase
=
()
=>
{
if
(
!
selectDatabaseId
)
return
;
if
(
!
selectDatabaseId
)
return
;
setIsLoadingDatabase
(
true
);
setIsLoadingDatabase
(
true
);
clearMetaDataTable
(
selectDatabaseId
).
then
(()
=>
{
clearMetaDataTable
(
selectDatabaseId
).
then
(()
=>
{
...
@@ -81,11 +76,8 @@ const MetaData = (props: any) => {
...
@@ -81,11 +76,8 @@ const MetaData = (props: any) => {
});
});
};
};
BtnRoute
[
'menu.datastudio.metadata'
][
0
].
onClick
=
refreshDataBase
;
/**
/**
* 构建数据库列表 下拉框
* 构建数据库列表 下拉框
* @returns {{label: JSX.Element, value: number, key: number}[]}
*/
*/
const
getDataBaseOptions
=
()
=>
{
const
getDataBaseOptions
=
()
=>
{
return
dbData
.
map
(
return
dbData
.
map
(
...
@@ -109,7 +101,6 @@ const MetaData = (props: any) => {
...
@@ -109,7 +101,6 @@ const MetaData = (props: any) => {
* 树节点点击事件 添加tab页 并传递参数
* 树节点点击事件 添加tab页 并传递参数
* @param keys
* @param keys
* @param info
* @param info
* @returns {Promise<void>}
*/
*/
const
handleTreeNodeClick
=
async
(
keys
:
Key
[],
info
:
any
)
=>
{
const
handleTreeNodeClick
=
async
(
keys
:
Key
[],
info
:
any
)
=>
{
// 选中的key
// 选中的key
...
@@ -121,8 +112,12 @@ const MetaData = (props: any) => {
...
@@ -121,8 +112,12 @@ const MetaData = (props: any) => {
const
{
const
{
node
:
{
isLeaf
,
parentId
:
schemaName
,
name
:
tableName
,
fullInfo
},
node
:
{
isLeaf
,
parentId
:
schemaName
,
name
:
tableName
,
fullInfo
},
}
=
info
;
}
=
info
;
if
(
isLeaf
)
{
const
queryParams
=
{
id
:
selectDatabaseId
,
schemaName
,
tableName
};
if
(
!
isLeaf
)
{
return
;
}
const
queryParams
=
{
id
:
selectDatabaseId
,
schemaName
,
tableName
};
dispatch
({
dispatch
({
type
:
STUDIO_MODEL
.
addTab
,
type
:
STUDIO_MODEL
.
addTab
,
payload
:
{
payload
:
{
...
@@ -130,11 +125,10 @@ const MetaData = (props: any) => {
...
@@ -130,11 +125,10 @@ const MetaData = (props: any) => {
id
:
selectDatabaseId
+
schemaName
+
tableName
,
id
:
selectDatabaseId
+
schemaName
+
tableName
,
breadcrumbLabel
:
[
selectDb
.
type
,
selectDb
.
name
].
join
(
'/'
),
breadcrumbLabel
:
[
selectDb
.
type
,
selectDb
.
name
].
join
(
'/'
),
label
:
schemaName
+
'.'
+
tableName
,
label
:
schemaName
+
'.'
+
tableName
,
params
:
{
queryParams
:
queryParams
,
tableInfo
:
fullInfo
},
params
:
{
queryParams
:
queryParams
,
tableInfo
:
fullInfo
},
type
:
'metadata'
,
type
:
'metadata'
,
},
},
});
});
}
};
};
/**
/**
...
...
dinky-web/src/pages/DataStudio/LeftContainer/MetaData/service.tsx
View file @
3eafe155
...
@@ -3,13 +3,18 @@ import { l } from '@/utils/intl';
...
@@ -3,13 +3,18 @@ import { l } from '@/utils/intl';
/*--- 刷新 元数据表 ---*/
/*--- 刷新 元数据表 ---*/
export
async
function
showMetaDataTable
(
id
:
number
)
{
export
async
function
showMetaDataTable
(
id
:
number
)
{
return
(
await
handleGetOption
(
try
{
const
result
=
await
handleGetOption
(
'api/database/getSchemasAndTables'
,
'api/database/getSchemasAndTables'
,
l
(
'pages.metadata.DataSearch'
),
l
(
'pages.metadata.DataSearch'
),
{
id
:
id
},
{
id
:
id
},
)
);
).
datas
;
return
result
?.
datas
;
}
catch
(
e
)
{
console
.
error
(
e
)
return
null
;
}
}
}
/*--- 清理 元数据表缓存 ---*/
/*--- 清理 元数据表缓存 ---*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment