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
227b6e9f
Unverified
Commit
227b6e9f
authored
Oct 19, 2023
by
Licho
Committed by
GitHub
Oct 19, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: Lineage render problem (#2408)
* fix: Lineage render problem * Spotless Apply --------- Co-authored-by:
leechor
<
leechor@users.noreply.github.com
>
parent
4fb43039
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
129 additions
and
49 deletions
+129
-49
index.tsx
dinky-web/src/components/LineageGraph/index.tsx
+34
-47
lineage-dag-ext.tsx
dinky-web/src/components/LineageGraph/lineage-dag-ext.tsx
+95
-0
index.tsx
...eb/src/pages/DataStudio/BottomContainer/Lineage/index.tsx
+0
-2
No files found.
dinky-web/src/components/LineageGraph/index.tsx
View file @
227b6e9f
import
{
Badge
,
Tooltip
,
Typography
}
from
'antd'
;
import
{
Badge
,
Tooltip
,
Typography
}
from
'antd'
;
import
LineageDagExt
from
'@/components/LineageGraph/lineage-dag-ext'
;
import
{
import
{
LineageDetailInfo
,
LineageDetailInfo
,
LineageRelations
,
LineageRelations
,
...
@@ -18,11 +19,8 @@ import {
...
@@ -18,11 +19,8 @@ import {
}
from
'@ant-design/icons'
;
}
from
'@ant-design/icons'
;
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
React
,
{
useEffect
}
from
'react'
;
import
React
,
{
useEffect
}
from
'react'
;
import
LineageDag
from
'react-lineage-dag'
;
import
'react-lineage-dag/dist/index.css'
;
import
'react-lineage-dag/dist/index.css'
;
const
{
Text
}
=
Typography
;
interface
LineageState
{
interface
LineageState
{
lineageData
:
LineageDetailInfo
;
lineageData
:
LineageDetailInfo
;
canvas
:
any
;
canvas
:
any
;
...
@@ -42,6 +40,20 @@ interface LineageState {
...
@@ -42,6 +40,20 @@ interface LineageState {
collapseUpstream
:
boolean
;
collapseUpstream
:
boolean
;
}
}
type
JobLineageProps
=
{
lineageData
:
LineageDetailInfo
;
refreshCallBack
:
()
=>
void
;
};
type
ITable
=
{
id
:
string
;
name
:
string
;
isCollapse
:
boolean
;
fields
:
LineageTableColumn
[];
};
const
{
Text
}
=
Typography
;
const
InitLineageState
:
LineageState
=
{
const
InitLineageState
:
LineageState
=
{
lineageData
:
{
lineageData
:
{
tables
:
[],
tables
:
[],
...
@@ -64,34 +76,10 @@ const InitLineageState: LineageState = {
...
@@ -64,34 +76,10 @@ const InitLineageState: LineageState = {
collapseUpstream
:
false
collapseUpstream
:
false
};
};
type
JobLineageProps
=
{
lineageData
:
LineageDetailInfo
;
refreshCallBack
:
()
=>
void
;
};
type
ITable
=
{
id
:
string
;
name
:
string
;
isCollapse
:
boolean
;
fields
:
LineageTableColumn
[];
};
const
LineageGraph
:
React
.
FC
<
JobLineageProps
>
=
(
props
)
=>
{
const
LineageGraph
:
React
.
FC
<
JobLineageProps
>
=
(
props
)
=>
{
const
{
lineageData
,
refreshCallBack
}
=
props
;
const
{
lineageData
,
refreshCallBack
}
=
props
;
const
[
lineageState
,
setLineageState
]
=
React
.
useState
<
LineageState
>
(
InitLineageState
);
const
[
lineageState
,
setLineageState
]
=
React
.
useState
<
LineageState
>
(
InitLineageState
);
useEffect
(()
=>
{
if
(
lineageData
)
{
setLineageState
((
prevState
)
=>
({
...
prevState
,
lineageData
:
lineageData
,
tables
:
buildLineageTables
(
lineageData
.
tables
),
relations
:
buildLineageRelations
(
lineageData
.
relations
)
}));
}
},
[
lineageData
,
lineageState
.
refresh
]);
const
buildLineageColumns
=
(
data
:
LineageDetailInfo
)
=>
{
const
buildLineageColumns
=
(
data
:
LineageDetailInfo
)
=>
{
return
[
return
[
{
{
...
@@ -99,13 +87,11 @@ const LineageGraph: React.FC<JobLineageProps> = (props) => {
...
@@ -99,13 +87,11 @@ const LineageGraph: React.FC<JobLineageProps> = (props) => {
width
:
'100'
,
width
:
'100'
,
render
:
(
text
:
any
,
record
:
any
,
index
:
number
)
=>
{
render
:
(
text
:
any
,
record
:
any
,
index
:
number
)
=>
{
return
(
return
(
<>
<
Badge
<
Badge
count=
{
index
+
1
}
count=
{
index
+
1
}
size=
{
'small'
}
size=
{
'small'
}
color=
{
index
<
10
?
'red'
:
index
<
20
?
'blue'
:
index
<
30
?
'gold'
:
'cyan'
}
color=
{
index
<
10
?
'red'
:
index
<
20
?
'blue'
:
index
<
30
?
'gold'
:
'cyan'
}
/>
/>
</>
);
);
}
}
},
},
...
@@ -143,26 +129,19 @@ const LineageGraph: React.FC<JobLineageProps> = (props) => {
...
@@ -143,26 +129,19 @@ const LineageGraph: React.FC<JobLineageProps> = (props) => {
}));
}));
};
};
function
findTableById
(
id
:
string
)
{
const
{
tables
}
=
lineageState
;
return
tables
.
find
((
item
)
=>
{
return
String
(
item
.
id
)
===
String
(
id
);
});
}
const
handleExpandField
=
(
nodeData
:
any
,
tables
:
ITable
[])
=>
{
const
handleExpandField
=
(
nodeData
:
any
,
tables
:
ITable
[])
=>
{
const
{
isCollapse
,
id
}
=
nodeData
;
const
{
isCollapse
,
id
}
=
nodeData
;
console
.
log
(
id
,
findTableById
(
id
),
tables
);
lineageState
.
tables
const
iTable
=
findTableById
(
id
);
.
filter
((
item
)
=>
item
.
id
===
id
)
if
(
iTable
)
{
.
forEach
((
item
)
=>
(
item
.
isCollapse
=
isCollapse
));
iTable
.
isCollapse
=
isCollapse
;
}
// todo: 待实现 展开字段
// todo: 待实现 展开字段
setLineageState
((
prevState
)
=>
({
...
prevState
,
expandField
:
!
prevState
.
expandField
}));
setLineageState
((
prevState
)
=>
({
...
prevState
,
expandField
:
!
prevState
.
expandField
}));
SuccessNotification
(
SuccessNotification
(
lineageState
.
expandField
?
l
(
'lineage.expandField'
)
:
l
(
'lineage.expandField'
)
lineageState
.
expandField
?
l
(
'lineage.expandField'
)
:
l
(
'lineage.expandField'
)
);
);
};
};
const
buildActionMenu
=
(
data
:
ITable
[])
=>
{
const
buildActionMenu
=
(
data
:
ITable
[])
=>
{
return
[
return
[
{
{
...
@@ -273,7 +252,7 @@ const LineageGraph: React.FC<JobLineageProps> = (props) => {
...
@@ -273,7 +252,7 @@ const LineageGraph: React.FC<JobLineageProps> = (props) => {
];
];
};
};
const
r
enderTitle
=
(
title
:
string
)
=>
{
const
R
enderTitle
=
(
title
:
string
)
=>
{
return
(
return
(
<
Text
<
Text
title=
{
title
}
title=
{
title
}
...
@@ -291,10 +270,19 @@ const LineageGraph: React.FC<JobLineageProps> = (props) => {
...
@@ -291,10 +270,19 @@ const LineageGraph: React.FC<JobLineageProps> = (props) => {
);
);
};
};
useEffect
(()
=>
{
if
(
lineageData
)
{
setLineageState
((
prevState
)
=>
({
...
prevState
,
lineageData
:
lineageData
,
tables
:
buildLineageTables
(
lineageData
.
tables
),
relations
:
buildLineageRelations
(
lineageData
.
relations
)
}));
}
},
[
lineageData
,
lineageState
.
refresh
]);
return
(
return
(
<>
<
LineageDagExt
<
LineageDag
delayDraw=
{
2000
}
tables=
{
buildLineageTables
(
lineageState
.
lineageData
.
tables
)
}
tables=
{
buildLineageTables
(
lineageState
.
lineageData
.
tables
)
}
relations=
{
buildLineageRelations
(
lineageState
.
lineageData
.
relations
)
}
relations=
{
buildLineageRelations
(
lineageState
.
lineageData
.
relations
)
}
columns=
{
buildLineageColumns
(
lineageState
.
lineageData
)
}
columns=
{
buildLineageColumns
(
lineageState
.
lineageData
)
}
...
@@ -305,7 +293,7 @@ const LineageGraph: React.FC<JobLineageProps> = (props) => {
...
@@ -305,7 +293,7 @@ const LineageGraph: React.FC<JobLineageProps> = (props) => {
setLineageState
((
prevState
)
=>
({
...
prevState
,
centerId
:
data
.
id
}))
setLineageState
((
prevState
)
=>
({
...
prevState
,
centerId
:
data
.
id
}))
}
}
config=
{
{
config=
{
{
titleRender
:
(
title
:
string
)
=>
r
enderTitle
(
title
),
titleRender
:
(
title
:
string
)
=>
R
enderTitle
(
title
),
minimap
:
{
enable
:
lineageState
.
showMinimap
},
minimap
:
{
enable
:
lineageState
.
showMinimap
},
enableHoverChain
:
true
,
enableHoverChain
:
true
,
showActionIcon
:
true
,
showActionIcon
:
true
,
...
@@ -346,7 +334,6 @@ const LineageGraph: React.FC<JobLineageProps> = (props) => {
...
@@ -346,7 +334,6 @@ const LineageGraph: React.FC<JobLineageProps> = (props) => {
}
}
}
}
actionMenu=
{
renderExtActionButton
()
}
actionMenu=
{
renderExtActionButton
()
}
/>
/>
</>
);
);
};
};
...
...
dinky-web/src/components/LineageGraph/lineage-dag-ext.tsx
0 → 100644
View file @
227b6e9f
import
LineageDag
from
'react-lineage-dag'
;
import
*
as
_
from
'lodash'
;
import
*
as
ReactDOM
from
'react-dom'
;
import
{
transformEdges
,
transformInitData
}
from
'react-lineage-dag/src/adaptor'
;
import
LineageCanvas
from
'react-lineage-dag/src/canvas/canvas'
;
export
default
class
LineageDagExt
extends
LineageDag
{
componentDidMount
()
{
let
root
=
ReactDOM
.
findDOMNode
(
this
)
as
HTMLElement
;
let
enableHoverChain
=
_
.
get
(
this
.
props
,
'config.enableHoverChain'
,
true
);
let
titleRender
=
_
.
get
(
this
.
props
,
'config.titleRender'
);
let
canvasObj
=
{
root
:
root
,
disLinkable
:
false
,
linkable
:
false
,
draggable
:
false
,
zoomable
:
true
,
moveable
:
true
,
theme
:
{
edge
:
{
type
:
'endpoint'
,
// shapeType: 'AdvancedBezier',
arrow
:
true
,
isExpandWidth
:
true
,
arrowPosition
:
1
,
arrowOffset
:
-
5
},
endpoint
:
{
limitNum
:
undefined
,
expandArea
:
{
left
:
0
,
right
:
0
,
top
:
0
,
botton
:
0
}
}
},
data
:
{
enableHoverChain
:
enableHoverChain
}
};
this
.
canvas
=
new
LineageCanvas
(
canvasObj
);
let
result
=
transformInitData
({
tables
:
this
.
props
.
tables
,
relations
:
this
.
props
.
relations
,
columns
:
this
.
props
.
columns
,
operator
:
this
.
props
.
operator
,
_titleRender
:
titleRender
,
_enableHoverChain
:
enableHoverChain
,
_emptyContent
:
this
.
props
.
emptyContent
,
_emptyWidth
:
this
.
props
.
emptyWidth
});
this
.
originEdges
=
result
.
edges
;
result
=
transformEdges
(
result
.
nodes
,
_
.
cloneDeep
(
result
.
edges
));
this
.
canvasData
=
{
nodes
:
result
.
nodes
,
edges
:
result
.
edges
};
let
minimap
=
_
.
get
(
this
,
'props.config.minimap'
,
{});
const
minimapCfg
=
_
.
assign
({},
minimap
.
config
,
{
events
:
[
'system.node.click'
,
'system.canvas.click'
]
});
if
(
minimap
&&
minimap
.
enable
)
{
this
.
canvas
.
setMinimap
(
true
,
minimapCfg
);
}
if
(
_
.
get
(
this
,
'props.config.gridMode'
))
{
this
.
canvas
.
setGridMode
(
true
,
_
.
assign
({},
_
.
get
(
this
,
'props.config.gridMode'
,
{})));
}
if
(
result
.
nodes
.
length
!==
0
)
{
this
.
canvas
.
focusCenterWithAnimate
();
this
.
_isFirstFocus
=
true
;
}
this
.
props
.
onLoaded
&&
this
.
props
.
onLoaded
(
this
.
canvas
);
this
.
canvas
.
on
(
'system.node.click'
,
(
data
)
=>
{
let
node
=
data
.
node
;
this
.
canvas
.
focus
(
node
.
id
);
});
this
.
canvas
.
on
(
'system.canvas.click'
,
()
=>
{
this
.
canvas
.
unfocus
();
});
}
}
dinky-web/src/pages/DataStudio/BottomContainer/Lineage/index.tsx
View file @
227b6e9f
...
@@ -54,7 +54,6 @@ const Lineage: React.FC<connect> = (props) => {
...
@@ -54,7 +54,6 @@ const Lineage: React.FC<connect> = (props) => {
},
[
activeKey
]);
},
[
activeKey
]);
return
(
return
(
<>
<
Card
hoverable
bodyStyle=
{
{
height
:
bottomHeight
-
50
}
}
style=
{
{
height
:
bottomHeight
}
}
>
<
Card
hoverable
bodyStyle=
{
{
height
:
bottomHeight
-
50
}
}
style=
{
{
height
:
bottomHeight
}
}
>
{
lineageData
&&
(
lineageData
.
tables
.
length
!==
0
||
lineageData
.
relations
.
length
!==
0
)
?
(
{
lineageData
&&
(
lineageData
.
tables
.
length
!==
0
||
lineageData
.
relations
.
length
!==
0
)
?
(
<
LineageGraph
lineageData=
{
lineageData
}
refreshCallBack=
{
queryLineageData
}
/>
<
LineageGraph
lineageData=
{
lineageData
}
refreshCallBack=
{
queryLineageData
}
/>
...
@@ -66,7 +65,6 @@ const Lineage: React.FC<connect> = (props) => {
...
@@ -66,7 +65,6 @@ const Lineage: React.FC<connect> = (props) => {
/>
/>
)
}
)
}
</
Card
>
</
Card
>
</>
);
);
};
};
...
...
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