diff --git a/dinky-web/src/components/CallBackButton/CircleBtn.tsx b/dinky-web/src/components/CallBackButton/CircleBtn.tsx
index 3435ddca66c..ab383b6a551 100644
--- a/dinky-web/src/components/CallBackButton/CircleBtn.tsx
+++ b/dinky-web/src/components/CallBackButton/CircleBtn.tsx
@@ -16,9 +16,9 @@
*
*/
+import { TabsItemType } from '@/pages/DataStudio/model';
import { Button } from 'antd';
import React from 'react';
-import {TabsItemType} from "@/pages/DataStudio/model";
export type CircleButtonProps = {
icon: React.ReactNode;
@@ -30,7 +30,7 @@ export type CircleButtonProps = {
export type CircleDataStudioButtonProps = {
icon: React.ReactNode;
loading?: boolean;
- onClick?: (panes:TabsItemType[],activeKey:string) => void;
+ onClick?: (panes: TabsItemType[], activeKey: string) => void;
title?: string;
key?: string;
};
diff --git a/dinky-web/src/components/FlinkDag/component/DagDataNode.tsx b/dinky-web/src/components/FlinkDag/component/DagDataNode.tsx
index 51ed6a7ffff..3f181ec9dab 100644
--- a/dinky-web/src/components/FlinkDag/component/DagDataNode.tsx
+++ b/dinky-web/src/components/FlinkDag/component/DagDataNode.tsx
@@ -98,13 +98,20 @@ const DagDataNode = (props: any) => {
{' '}
{l('devops.baseinfo.busy')}:
- {renderRatio((backpressure && backpressure.subtasks)?backpressure.subtasks[0]?.busyRatio:0, false)}
+ {renderRatio(
+ backpressure && backpressure.subtasks ? backpressure.subtasks[0]?.busyRatio : 0,
+ false
+ )}
{l('devops.baseinfo.backpressure')}:
-
+
@@ -113,7 +120,10 @@ const DagDataNode = (props: any) => {
{l('devops.baseinfo.idle')}:
- {renderRatio((backpressure && backpressure.subtasks)?backpressure.subtasks[0]?.idleRatio:0, true)}
+ {renderRatio(
+ backpressure && backpressure.subtasks ? backpressure.subtasks[0]?.idleRatio : 0,
+ true
+ )}
diff --git a/dinky-web/src/components/FlinkDag/index.tsx b/dinky-web/src/components/FlinkDag/index.tsx
index 0e48b2b92dc..19e134834f3 100644
--- a/dinky-web/src/components/FlinkDag/index.tsx
+++ b/dinky-web/src/components/FlinkDag/index.tsx
@@ -20,74 +20,72 @@
import DagDataNode from '@/components/FlinkDag/component/DagDataNode';
import DagPlanNode from '@/components/FlinkDag/component/DagPlanNode';
import {
- edgeConfig,
- graphConfig,
- layoutConfig,
- portConfig,
- zoomOptions
+ edgeConfig,
+ graphConfig,
+ layoutConfig,
+ portConfig,
+ zoomOptions
} 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, Select, Slider, Table, Tabs, TabsProps, Typography} from 'antd';
-import {useEffect, useRef, useState} from 'react';
+import { buildDag, regConnect, updateDag } from '@/components/FlinkDag/functions';
+import { getData } from '@/services/api';
+import { API_CONSTANTS } from '@/services/endpoints';
+import { Jobs } from '@/types/DevOps/data';
+import { DagreLayout } from '@antv/layout';
+import { Edge, Graph } from '@antv/x6';
+import { Rectangle } from '@antv/x6-geometry';
+import { Selection } from '@antv/x6-plugin-selection';
+import { register } from '@antv/x6-react-shape';
+import { Drawer, Select, Slider, Table, Tabs, TabsProps, Typography } from 'antd';
+import { useEffect, useRef, useState } from 'react';
import './index.css';
-import {getData} from "@/services/api";
-import {API_CONSTANTS} from "@/services/endpoints";
-import {Rectangle} from "@antv/x6-geometry";
-import {Options as GraphOptions} from "@antv/x6/src/graph/options";
-import path from "path";
export type DagProps = {
- job: Jobs.Job;
- onlyPlan?: boolean;
- checkPoints?: any;
+ job: Jobs.Job;
+ onlyPlan?: boolean;
+ checkPoints?: any;
};
-const {Paragraph} = Typography;
+const { Paragraph } = Typography;
const FlinkDag = (props: DagProps) => {
- const container = useRef(null);
-
- const {job, onlyPlan = false, checkPoints = {}} = props;
-
- const [graph, setGraph] = useState();
- const [currentJob, setCurrentJob] = useState();
- const [currentSelect, setCurrentSelect] = useState();
- const [open, setOpen] = useState(false);
- const [zoom, setZoom] = useState(1);
- let originPosition = {
- zoom: 1
- };
-
- const handleClose = () => {
- setOpen(false);
- setCurrentSelect(undefined);
- graph?.zoomToFit(zoomOptions);
- graph?.centerContent();
- };
-
- const initListen = (graph: Graph) => {
- graph.on('node:selected', ({cell}) => {
- if (!onlyPlan) {
- setOpen(true);
- setZoom(oldValue => {
- originPosition = {zoom: oldValue}
- return 1;
- })
- graph.zoomTo(1)
- setCurrentSelect(cell);
- graph.positionPoint(Rectangle.create(cell.getBBox()).getLeftMiddle(), '10%', '50%');
- }
- });
+ const container = useRef(null);
+
+ const { job, onlyPlan = false, checkPoints = {} } = props;
+
+ const [graph, setGraph] = useState();
+ const [currentJob, setCurrentJob] = useState();
+ const [currentSelect, setCurrentSelect] = useState();
+ const [open, setOpen] = useState(false);
+ const [zoom, setZoom] = useState(1);
+ let originPosition = {
+ zoom: 1
+ };
- graph.on('node:unselected', ({cell}) => {
- setZoom(originPosition.zoom)
- handleClose();
+ const handleClose = () => {
+ setOpen(false);
+ setCurrentSelect(undefined);
+ graph?.zoomToFit(zoomOptions);
+ graph?.centerContent();
+ };
+
+ const initListen = (graph: Graph) => {
+ graph.on('node:selected', ({ cell }) => {
+ if (!onlyPlan) {
+ setOpen(true);
+ setZoom((oldValue) => {
+ originPosition = { zoom: oldValue };
+ return 1;
});
- };
+ graph.zoomTo(1);
+ setCurrentSelect(cell);
+ graph.positionPoint(Rectangle.create(cell.getBBox()).getLeftMiddle(), '10%', '50%');
+ }
+ });
+
+ graph.on('node:unselected', ({ cell }) => {
+ setZoom(originPosition.zoom);
+ handleClose();
+ });
+ };
const initGraph = (flinkData: any) => {
register({
@@ -98,156 +96,193 @@ const FlinkDag = (props: DagProps) => {
ports: portConfig
});
- Edge.config(edgeConfig);
- Graph.registerConnector('curveConnector', regConnect, true);
- Graph.registerEdge('data-processing-curve', Edge, true);
+ Edge.config(edgeConfig);
+ Graph.registerConnector('curveConnector', regConnect, true);
+ Graph.registerEdge('data-processing-curve', Edge, true);
- const graph: Graph = new Graph({
- // @ts-ignore
- container: container.current,
- ...graphConfig
- });
+ const graph: Graph = new Graph({
+ // @ts-ignore
+ container: container.current,
+ ...graphConfig
+ });
- graph.use(
- new Selection({
- enabled: true,
- multiple: false,
- rubberband: false,
- showNodeSelectionBox: true
- })
- );
-
- // Adaptive layout
- const model = new DagreLayout(layoutConfig).layout(flinkData);
- graph.fromJSON(model);
-
- // Automatically zoom to fit
- graph.zoomToFit(zoomOptions);
- graph.on('scale', ({sx}) => setZoom(sx));
- graph.centerContent();
- graph?.zoomTo(zoom)
- updateDag(job?.vertices, graph);
- initListen(graph);
- return graph;
- };
+ graph.use(
+ new Selection({
+ enabled: true,
+ multiple: false,
+ rubberband: false,
+ showNodeSelectionBox: true
+ })
+ );
- useEffect(() => {
- const flinkData = buildDag(job?.plan);
- // Clean up old data
- if (graph) {
- graph.clearCells();
- }
- setGraph(initGraph(flinkData));
- setZoom(1 / flinkData.nodes.length + 0.5)
- }, [currentJob]);
+ // Adaptive layout
+ const model = new DagreLayout(layoutConfig).layout(flinkData);
+ graph.fromJSON(model);
- useEffect(() => {
- updateDag(job?.vertices, graph);
- if (currentJob != job?.jid) {
- setCurrentJob(job?.jid);
- }
- }, [job]);
+ // Automatically zoom to fit
+ graph.zoomToFit(zoomOptions);
+ graph.on('scale', ({ sx }) => setZoom(sx));
+ graph.centerContent();
+ graph?.zoomTo(zoom);
+ updateDag(job?.vertices, graph);
+ initListen(graph);
+ return graph;
+ };
+
+ useEffect(() => {
+ const flinkData = buildDag(job?.plan);
+ // Clean up old data
+ if (graph) {
+ graph.clearCells();
+ }
+ setGraph(initGraph(flinkData));
+ setZoom(1 / flinkData.nodes.length + 0.5);
+ }, [currentJob]);
+
+ useEffect(() => {
+ updateDag(job?.vertices, graph);
+ if (currentJob != job?.jid) {
+ setCurrentJob(job?.jid);
+ }
+ }, [job]);
+ useEffect(() => {
+ graph?.zoomTo(zoom);
+ }, [zoom]);
+
+ const renderCheckpoint = (id: string) => {
+ const [selectPath, setSelectPath] = useState('');
+ const key = id + selectPath;
+ const [itemChildren, setItemChildren] = useState({ [key]: [] as TabsProps['items'] });
+ const checkpointArray = ((checkPoints.history ?? []) as any[])
+ .filter((x) => x.status === 'COMPLETED')
+ .map((x) => {
+ return { checkpointType: x.checkpoint_type, path: x.external_path, id: x.id };
+ });
useEffect(() => {
- graph?.zoomTo(zoom)
- }, [zoom]);
-
- const renderCheckpoint = (id: string) => {
- const [selectPath, setSelectPath] = useState('');
- const key = id + selectPath;
- const [itemChildren, setItemChildren] = useState({[key]: [] as TabsProps['items']});
- const checkpointArray = ((checkPoints.history?? []) as any[]).filter(x => x.status === "COMPLETED").map(x => {
- return {checkpointType: x.checkpoint_type, path: x.external_path, id: x.id}
- });
- useEffect(() => {
- if (selectPath && id) {
- if (!itemChildren[key]) {
- getData(API_CONSTANTS.READ_CHECKPOINT, {path: selectPath, operatorId: id}).then(res => {
- const genData = Object.keys(res.datas).map(x => {
- const datum = res.datas[x];
- return {
- key: x,
- label: x,
- children:
- {
- return {
- key: y,
- label: y,
- children: {
- return {
- title: z,
- dataIndex: z,
- key: z,
- render: (text) => {text},
- }
- })}/>
- }
- })
- } tabBarStyle={{marginBlock: 0}} tabBarGutter={10}/>
- }
- })
- setItemChildren({...itemChildren, [key]: genData})
- })
- }
+ if (selectPath && id) {
+ if (!itemChildren[key]) {
+ getData(API_CONSTANTS.READ_CHECKPOINT, { path: selectPath, operatorId: id }).then(
+ (res) => {
+ const genData = Object.keys(res.datas).map((x) => {
+ const datum = res.datas[x];
+ return {
+ key: x,
+ label: x,
+ children: (
+ {
+ return {
+ key: y,
+ label: y,
+ children: (
+ {
+ return {
+ title: z,
+ dataIndex: z,
+ key: z,
+ render: (text) => (
+
+ {text}
+
+ )
+ };
+ })}
+ />
+ )
+ };
+ })}
+ tabBarStyle={{ marginBlock: 0 }}
+ tabBarGutter={10}
+ />
+ )
+ };
+ });
+ setItemChildren({ ...itemChildren, [key]: genData });
}
- }, [selectPath, id])
-
- return <>
-