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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
58 deletions
+57
-58
index.tsx
...web/src/pages/DataStudio/LeftContainer/MetaData/index.tsx
+45
-51
service.tsx
...b/src/pages/DataStudio/LeftContainer/MetaData/service.tsx
+12
-7
No files found.
dinky-web/src/pages/DataStudio/LeftContainer/MetaData/index.tsx
View file @
3eafe155
import
{
TagAlignLeft
}
from
'@/components/StyledComponents'
;
import
{
BtnRoute
}
from
'@/pages/DataStudio/route'
;
import
{
TagAlignLeft
}
from
'@/components/StyledComponents'
;
import
{
BtnRoute
}
from
'@/pages/DataStudio/route'
;
import
SchemaTree
from
'@/pages/RegCenter/DataSource/components/DataSourceDetail/SchemaTree'
;
import
{
DataSources
}
from
'@/types/RegCenter/data'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
DatabaseOutlined
,
TableOutlined
}
from
'@ant-design/icons'
;
import
{
Key
,
ProForm
,
ProFormSelect
}
from
'@ant-design/pro-components'
;
import
{
connect
}
from
'@umijs/max'
;
import
{
Spin
,
Tag
}
from
'antd'
;
import
{
useEffect
,
useState
}
from
'react'
;
import
{
StateType
,
STUDIO_MODEL
}
from
'../../model'
;
import
{
clearMetaDataTable
,
showMetaDataTable
}
from
'./service'
;
import
{
DataSources
}
from
'@/types/RegCenter/data'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
DatabaseOutlined
,
TableOutlined
}
from
'@ant-design/icons'
;
import
{
Key
,
ProForm
,
ProFormSelect
}
from
'@ant-design/pro-components'
;
import
{
connect
}
from
'@umijs/max'
;
import
{
Spin
,
Tag
}
from
'antd'
;
import
{
useEffect
,
useState
}
from
'react'
;
import
{
StateType
,
STUDIO_MODEL
}
from
'../../model'
;
import
{
clearMetaDataTable
,
showMetaDataTable
}
from
'./service'
;
const
MetaData
=
(
props
:
any
)
=>
{
const
{
...
...
@@ -32,28 +32,26 @@ const MetaData = (props: any) => {
setIsLoadingDatabase
(
false
);
return
;
}
setIsLoadingDatabase
(
true
);
const
tables
=
await
showMetaDataTable
(
databaseId
)
??
[]
setIsLoadingDatabase
(
false
);
await
showMetaDataTable
(
databaseId
).
then
((
res
)
=>
{
setIsLoadingDatabase
(
false
);
const
{
datas
:
tables
}
=
res
;
if
(
!
tables
)
return
;
for
(
let
table
of
tables
)
{
table
.
title
=
table
.
name
;
table
.
key
=
table
.
name
;
table
.
icon
=
<
DatabaseOutlined
/>;
table
.
children
=
table
.
tables
;
for
(
let
child
of
table
.
children
)
{
child
.
title
=
child
.
name
;
child
.
key
=
table
.
name
+
'.'
+
child
.
name
;
child
.
icon
=
<
TableOutlined
/>;
child
.
isLeaf
=
true
;
child
.
schema
=
table
.
name
;
child
.
table
=
child
.
name
;
}
for
(
let
table
of
tables
)
{
table
.
title
=
table
.
name
;
table
.
key
=
table
.
name
;
table
.
icon
=
<
DatabaseOutlined
/>;
table
.
children
=
table
.
tables
;
for
(
let
child
of
table
.
children
)
{
child
.
title
=
child
.
name
;
child
.
key
=
table
.
name
+
'.'
+
child
.
name
;
child
.
icon
=
<
TableOutlined
/>;
child
.
isLeaf
=
true
;
child
.
schema
=
table
.
name
;
child
.
table
=
child
.
name
;
}
setTreeData
(
tables
??
[]);
}
);
}
setTreeData
(
tables
);
};
useEffect
(()
=>
{
...
...
@@ -70,10 +68,7 @@ const MetaData = (props: any) => {
onRefreshTreeData
(
value
);
};
/**
* 刷新数据库列表
*/
const
refreshDataBase
=
()
=>
{
BtnRoute
[
'menu.datastudio.metadata'
][
0
].
onClick
=
()
=>
{
if
(
!
selectDatabaseId
)
return
;
setIsLoadingDatabase
(
true
);
clearMetaDataTable
(
selectDatabaseId
).
then
(()
=>
{
...
...
@@ -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
=
()
=>
{
return
dbData
.
map
(
...
...
@@ -109,7 +101,6 @@ const MetaData = (props: any) => {
* 树节点点击事件 添加tab页 并传递参数
* @param keys
* @param info
* @returns {Promise<void>}
*/
const
handleTreeNodeClick
=
async
(
keys
:
Key
[],
info
:
any
)
=>
{
// 选中的key
...
...
@@ -121,20 +112,23 @@ const MetaData = (props: any) => {
const
{
node
:
{
isLeaf
,
parentId
:
schemaName
,
name
:
tableName
,
fullInfo
},
}
=
info
;
if
(
isLeaf
)
{
const
queryParams
=
{
id
:
selectDatabaseId
,
schemaName
,
tableName
};
dispatch
({
type
:
STUDIO_MODEL
.
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
)
{
return
;
}
const
queryParams
=
{
id
:
selectDatabaseId
,
schemaName
,
tableName
};
dispatch
({
type
:
STUDIO_MODEL
.
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'
,
},
});
};
/**
...
...
dinky-web/src/pages/DataStudio/LeftContainer/MetaData/service.tsx
View file @
3eafe155
...
...
@@ -3,13 +3,18 @@ import { l } from '@/utils/intl';
/*--- 刷新 元数据表 ---*/
export
async
function
showMetaDataTable
(
id
:
number
)
{
return
(
await
handleGetOption
(
'api/database/getSchemasAndTables'
,
l
(
'pages.metadata.DataSearch'
),
{
id
:
id
},
)
).
datas
;
try
{
const
result
=
await
handleGetOption
(
'api/database/getSchemasAndTables'
,
l
(
'pages.metadata.DataSearch'
),
{
id
:
id
},
);
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