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
67bd6278
Unverified
Commit
67bd6278
authored
Oct 06, 2023
by
gaoyan
Committed by
GitHub
Oct 06, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature][Web]add dag select drawer (#2351)
* add dag select drawer * add dag select drawer
parent
20272b32
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
35 deletions
+70
-35
config.ts
dinky-web/src/components/FlinkDag/config.ts
+9
-0
index.tsx
dinky-web/src/components/FlinkDag/index.tsx
+61
-35
No files found.
dinky-web/src/components/FlinkDag/config.ts
View file @
67bd6278
...
@@ -166,3 +166,12 @@ export const layoutConfig: DagreLayoutOptions = {
...
@@ -166,3 +166,12 @@ export const layoutConfig: DagreLayoutOptions = {
nodesep
:
40
,
nodesep
:
40
,
controlPoints
:
true
controlPoints
:
true
};
};
export
const
zoomOptions
=
{
padding
:
{
left
:
50
,
right
:
50
,
top
:
50
,
bottom
:
50
}
};
dinky-web/src/components/FlinkDag/index.tsx
View file @
67bd6278
...
@@ -19,16 +19,22 @@
...
@@ -19,16 +19,22 @@
import
DagDataNode
from
'@/components/FlinkDag/component/DagDataNode'
;
import
DagDataNode
from
'@/components/FlinkDag/component/DagDataNode'
;
import
DagPlanNode
from
'@/components/FlinkDag/component/DagPlanNode'
;
import
DagPlanNode
from
'@/components/FlinkDag/component/DagPlanNode'
;
import
{
edgeConfig
,
graphConfig
,
layoutConfig
,
portConfig
}
from
'@/components/FlinkDag/config'
;
import
{
import
{
buildDag
,
regConnect
,
updateDag
}
from
'@/components/FlinkDag/functions'
;
edgeConfig
,
import
{
Jobs
}
from
'@/types/DevOps/data'
;
graphConfig
,
import
{
DagreLayout
}
from
'@antv/layout'
;
layoutConfig
,
import
{
Edge
,
Graph
}
from
'@antv/x6'
;
portConfig
,
import
{
register
}
from
'@antv/x6-react-shape'
;
zoomOptions
import
{
useEffect
,
useRef
,
useState
}
from
'react'
;
}
from
'@/components/FlinkDag/config'
;
import
{
buildDag
,
regConnect
,
updateDag
}
from
'@/components/FlinkDag/functions'
;
import
{
Jobs
}
from
'@/types/DevOps/data'
;
import
{
DagreLayout
}
from
'@antv/layout'
;
import
{
Edge
,
Graph
}
from
'@antv/x6'
;
import
{
Selection
}
from
'@antv/x6-plugin-selection'
;
import
{
register
}
from
'@antv/x6-react-shape'
;
import
{
Drawer
}
from
'antd'
;
import
{
useEffect
,
useRef
,
useState
}
from
'react'
;
import
'./index.css'
;
import
'./index.css'
;
import
{
Slider
}
from
"antd"
;
import
{
z
}
from
"@umijs/utils/compiled/zod"
;
export
type
DagProps
=
{
export
type
DagProps
=
{
job
:
Jobs
.
Job
;
job
:
Jobs
.
Job
;
...
@@ -38,17 +44,33 @@ export type DagProps = {
...
@@ -38,17 +44,33 @@ export type DagProps = {
const
FlinkDag
=
(
props
:
DagProps
)
=>
{
const
FlinkDag
=
(
props
:
DagProps
)
=>
{
const
container
=
useRef
(
null
);
const
container
=
useRef
(
null
);
const
{
job
,
onlyPlan
=
false
}
=
props
;
const
{
job
,
onlyPlan
=
false
}
=
props
;
const
[
graph
,
setGraph
]
=
useState
<
Graph
>
();
const
[
graph
,
setGraph
]
=
useState
<
Graph
>
();
const
[
zoom
,
setZoom
]
=
useState
<
number
>
(
1
);
const
[
curentJob
,
setCurentJob
]
=
useState
<
string
>
();
const
[
currentJob
,
setCurrentJob
]
=
useState
<
string
>
();
const
[
curentSelect
,
setCurentSelect
]
=
useState
<
any
>
();
const
[
open
,
setOpen
]
=
useState
(
false
);
const
initListen
=
(
graph
:
Graph
)
=>
{
graph
.
on
(
'node:selected'
,
({
cell
})
=>
{
setOpen
(
true
);
setCurentSelect
(
cell
);
graph
.
positionCell
(
cell
,
'center'
);
});
graph
.
on
(
'node:unselected'
,
({
cell
})
=>
{
setOpen
(
false
);
setCurentSelect
(
undefined
);
graph
.
zoomToFit
(
zoomOptions
);
graph
.
centerContent
();
});
};
const
initGraph
=
(
flinkData
:
any
)
=>
{
const
initGraph
=
(
flinkData
:
any
)
=>
{
register
({
register
({
shape
:
'data-processing-dag-node'
,
shape
:
'data-processing-dag-node'
,
width
:
212
,
width
:
250
,
height
:
48
,
height
:
140
,
component
:
onlyPlan
?
DagPlanNode
:
DagDataNode
,
component
:
onlyPlan
?
DagPlanNode
:
DagDataNode
,
ports
:
portConfig
ports
:
portConfig
});
});
...
@@ -63,23 +85,24 @@ const FlinkDag = (props: DagProps) => {
...
@@ -63,23 +85,24 @@ const FlinkDag = (props: DagProps) => {
...
graphConfig
...
graphConfig
});
});
graph
.
use
(
new
Selection
({
enabled
:
true
,
multiple
:
false
,
rubberband
:
false
,
showNodeSelectionBox
:
true
})
);
// Adaptive layout
// Adaptive layout
const
dagreLayout
=
new
DagreLayout
(
layoutConfig
);
const
model
=
new
DagreLayout
(
layoutConfig
).
layout
(
flinkData
);
const
model
=
dagreLayout
.
layout
(
flinkData
);
graph
.
fromJSON
(
model
);
graph
.
fromJSON
(
model
);
// Automatically zoom to fit
// Automatically zoom to fit
const
zoomOptions
=
{
padding
:
{
left
:
50
,
right
:
50
,
bottom
:
100
},
};
graph
.
zoomToFit
(
zoomOptions
);
graph
.
zoomToFit
(
zoomOptions
);
graph
.
centerContent
();
graph
.
centerContent
();
graph
.
on
(
'scale'
,
({
sx
})
=>
setZoom
(
sx
))
updateDag
(
job
.
vertices
,
graph
);
updateDag
(
job
.
vertices
,
graph
);
initListen
(
graph
);
return
graph
;
return
graph
;
};
};
...
@@ -90,23 +113,17 @@ const FlinkDag = (props: DagProps) => {
...
@@ -90,23 +113,17 @@ const FlinkDag = (props: DagProps) => {
graph
.
clearCells
();
graph
.
clearCells
();
}
}
setGraph
(
initGraph
(
flinkData
));
setGraph
(
initGraph
(
flinkData
));
},
[
currentJob
]);
},
[
curentJob
]);
useEffect
(()
=>
{
graph
?.
zoomTo
(
zoom
)
},
[
zoom
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
updateDag
(
job
.
vertices
,
graph
);
updateDag
(
job
.
vertices
,
graph
);
if
(
cur
rentJob
!=
job
.
jid
)
{
if
(
cu
rentJob
!=
job
.
jid
)
{
setCur
rentJob
(
job
.
jid
);
setCu
rentJob
(
job
.
jid
);
}
}
},
[
job
]);
},
[
job
]);
return
(
return
(
<
span
>
<>
<
div
style=
{
{
height
:
200
,
position
:
"absolute"
,
top
:
"50%"
,
right
:
12
,
marginTop
:
-
100
,
zIndex
:
999999999
}
}
>
<
Slider
vertical
value=
{
zoom
}
min=
{
0.5
}
max=
{
1.5
}
tooltip=
{
{
open
:
false
}
}
step=
{
0.01
}
onChange=
{
setZoom
}
/>
</
div
>
<
div
<
div
style=
{
{
style=
{
{
height
:
'100%'
,
height
:
'100%'
,
...
@@ -114,7 +131,16 @@ const FlinkDag = (props: DagProps) => {
...
@@ -114,7 +131,16 @@ const FlinkDag = (props: DagProps) => {
}
}
}
}
ref=
{
container
}
ref=
{
container
}
/>
/>
</
span
>
<
Drawer
title=
{
curentSelect
?.
name
}
open=
{
open
}
getContainer=
{
false
}
size=
{
'large'
}
mask=
{
false
}
>
<
p
>
{
curentSelect
?.
getData
().
description
}
</
p
>
</
Drawer
>
</>
);
);
};
};
...
...
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