Unverified Commit 845e4c75 authored by gaoyan's avatar gaoyan Committed by GitHub

[Feature][Web] Add Flink Job Sql Dag (#2340)

* delete unuse log * refactor tag * add job Graph Dag * change getJob to refeshJob
parent 6575066a
...@@ -18,25 +18,30 @@ ...@@ -18,25 +18,30 @@
*/ */
import StatusTag from '@/components/JobTags/StatusTag'; import StatusTag from '@/components/JobTags/StatusTag';
import { Jobs } from '@/types/DevOps/data';
import { Card, Col, Row, Tag, Typography } from 'antd'; import { Card, Col, Row, Tag, Typography } from 'antd';
const { Text } = Typography; const { Text, Paragraph } = Typography;
const DagNode = (props: any) => { const DagDataNode = (props: any) => {
const { node } = props; const { node } = props;
const vertices: Jobs.JobVertices = node?.getData(); const data: any = node?.getData();
return ( return (
<Card <Card
style={{ width: '250px' }} style={{ width: '250px', padding: 0 }}
bordered={false} bordered={false}
size={'small'} size={'small'}
type={'inner'} type={'inner'}
hoverable={true} hoverable={true}
title={vertices.name} title={data.name}
extra={<Text keyboard>{vertices.parallelism}</Text>} extra={<Text keyboard>{data.parallelism}</Text>}
> >
<Paragraph ellipsis={{ tooltip: data.description }}>
<blockquote style={{ margin: 0 }}>
<Text type='secondary'>{data.description}</Text>
</blockquote>
</Paragraph>
<Row> <Row>
<Col span={15}> <Col span={15}>
<Text type='secondary'>BackPressure:</Text> <Text type='secondary'>BackPressure:</Text>
...@@ -51,7 +56,7 @@ const DagNode = (props: any) => { ...@@ -51,7 +56,7 @@ const DagNode = (props: any) => {
<Row> <Row>
<Col span={15}> <Col span={15}>
<Text type='secondary'>Status:</Text> <Text type='secondary'>Status:</Text>
<StatusTag status={vertices.status} bordered={false} animation={false} /> <StatusTag status={data.status} bordered={false} animation={false} />
</Col> </Col>
<Col span={8}> <Col span={8}>
<Text type='secondary'>Idle:50%</Text> <Text type='secondary'>Idle:50%</Text>
...@@ -60,4 +65,4 @@ const DagNode = (props: any) => { ...@@ -60,4 +65,4 @@ const DagNode = (props: any) => {
</Card> </Card>
); );
}; };
export default DagNode; export default DagDataNode;
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { Card, Typography } from 'antd';
const { Text, Paragraph } = Typography;
const DagPlanNode = (props: any) => {
const { node } = props;
const data: any = node?.getData();
return (
<Card
style={{ width: '250px', padding: 0 }}
bordered={false}
size={'small'}
type={'inner'}
hoverable={true}
title={data.description}
extra={<Text keyboard>{data.parallelism}</Text>}
>
<Paragraph ellipsis={{ tooltip: data.description, rows: 3 }}>
<blockquote>
<Text>{data.description}</Text>
</blockquote>
</Paragraph>
</Card>
);
};
export default DagPlanNode;
...@@ -17,32 +17,37 @@ ...@@ -17,32 +17,37 @@
* *
*/ */
import { JOB_STATUS } from '@/pages/DevOps/constants';
import { Jobs } from '@/types/DevOps/data'; import { Jobs } from '@/types/DevOps/data';
import { Graph, Path } from '@antv/x6'; import { Graph, Path } from '@antv/x6';
export const buildEdge = (job: Jobs.Job) => { export const buildDag = (job: Jobs.JobPlan) => {
const edges: any = []; const edges: any = [];
const nodes: any = [];
for (let node of job.plan.nodes) { if (!job) return { nodes: nodes, edges: edges };
if (node.inputs) {
const sources = node.inputs; job.nodes.forEach((node) => {
for (let i = 0; i < sources.length; i++) { nodes.push({
const plan_node = sources[i]; id: node.id,
edges.push({ shape: 'data-processing-dag-node',
attrs: { ports: [
line: { {
strokeDasharray: '5', id: `${node.id}-in`,
stroke: '#3471F9', group: 'in'
style: {
animation: 'running-line 30s infinite linear'
}
}, },
label: { {
text: plan_node.ship_strategy id: `${node.id}-out`,
group: 'out'
} }
}, ],
data: node
});
node.inputs?.forEach((plan_node) => {
edges.push({
label: plan_node.ship_strategy, label: plan_node.ship_strategy,
id: `${plan_node.id}-${i}`, id: `${node.id}-${plan_node.num}`,
shape: 'data-processing-curve', shape: 'data-processing-curve',
zIndex: -1, zIndex: -1,
source: { source: {
...@@ -55,56 +60,26 @@ export const buildEdge = (job: Jobs.Job) => { ...@@ -55,56 +60,26 @@ export const buildEdge = (job: Jobs.Job) => {
}, },
data: node data: node
}); });
} });
} });
}
return edges;
};
export const buildNode = (job: Jobs.Job) => {
const nodes: any = {};
for (let vertice of job.vertices) {
nodes[vertice.id] = {
id: vertice.id,
shape: 'data-processing-dag-node',
ports: [
{
id: `${vertice.id}-in`,
group: 'in'
},
{
id: `${vertice.id}-out`,
group: 'out'
}
],
data: vertice
};
}
return nodes;
};
export const buildData = (job: Jobs.Job) => { return { nodes: nodes, edges: edges };
const nodes = Object.values(buildNode(job));
return { nodes: nodes, edges: buildEdge(job) };
}; };
export const updateEdge = (job: Jobs.Job, graph?: Graph) => { export const updateDag = (job: Jobs.JobVertices[], graph?: Graph) => {
if (graph) { if (!job || !graph) return;
const nodes = buildNode(job);
graph.getCells().forEach((node) => { if (job && graph) {
const data = node.getData(); job.forEach((vertice) => {
if (nodes[data.id]) { const node = graph.getCellById(vertice.id);
console.log(nodes[data.id]); if (node) {
node.setData(nodes[data.id].data); node.setData({ ...node.getData(), ...vertice });
} }
}); });
graph.getEdges().forEach((edge) => { graph.getEdges().forEach((edge) => {
const node = edge.getSourceNode()?.getData(); const nodeData = edge.getSourceNode()?.getData();
if (nodeData.status == JOB_STATUS.RUNNING) {
if (node.status == 'RUNNING') {
edge.attr({ line: { stroke: '#3471F9' } }); edge.attr({ line: { stroke: '#3471F9' } });
edge.attr('line/strokeDasharray', 5); edge.attr('line/strokeDasharray', 5);
edge.attr('line/strokeWidth', 2); edge.attr('line/strokeWidth', 2);
...@@ -113,11 +88,11 @@ export const updateEdge = (job: Jobs.Job, graph?: Graph) => { ...@@ -113,11 +88,11 @@ export const updateEdge = (job: Jobs.Job, graph?: Graph) => {
edge.attr('line/strokeDasharray', 0); edge.attr('line/strokeDasharray', 0);
edge.attr('line/style/animation', ''); edge.attr('line/style/animation', '');
edge.attr('line/strokeWidth', 1); edge.attr('line/strokeWidth', 1);
if (node.status == 'FINISHED') { if (nodeData.status == JOB_STATUS.FINISHED) {
edge.attr('line/stroke', '#52c41a'); edge.attr('line/stroke', '#52c41a');
} else if (node.status == 'CANCELED') { } else if (nodeData.status == JOB_STATUS.CANCELED) {
edge.attr('line/stroke', '#ffe7ba'); edge.attr('line/stroke', '#ffe7ba');
} else if (node.status == 'FAILED') { } else if (nodeData.status == JOB_STATUS.FAILED) {
edge.attr('line/stroke', '#ff4d4f'); edge.attr('line/stroke', '#ff4d4f');
} else { } else {
edge.attr('line/stroke', '#bfbfbf'); edge.attr('line/stroke', '#bfbfbf');
......
...@@ -17,9 +17,10 @@ ...@@ -17,9 +17,10 @@
* *
*/ */
import DagNode from '@/components/FlinkDag/component/DagNode'; import DagDataNode from '@/components/FlinkDag/component/DagDataNode';
import DagPlanNode from '@/components/FlinkDag/component/DagPlanNode';
import { edgeConfig, graphConfig, layoutConfig, portConfig } from '@/components/FlinkDag/config'; import { edgeConfig, graphConfig, layoutConfig, portConfig } from '@/components/FlinkDag/config';
import { buildData, regConnect, updateEdge } from '@/components/FlinkDag/functions'; import { buildDag, regConnect, updateDag } from '@/components/FlinkDag/functions';
import { Jobs } from '@/types/DevOps/data'; import { Jobs } from '@/types/DevOps/data';
import { DagreLayout } from '@antv/layout'; import { DagreLayout } from '@antv/layout';
import { Edge, Graph } from '@antv/x6'; import { Edge, Graph } from '@antv/x6';
...@@ -27,9 +28,16 @@ import { register } from '@antv/x6-react-shape'; ...@@ -27,9 +28,16 @@ import { register } from '@antv/x6-react-shape';
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import './index.css'; import './index.css';
const FlinkDag = (props: { jobDetail: Jobs.JobInfoDetail }) => { export type DagProps = {
job: Jobs.Job;
onlyPlan?: boolean;
};
const FlinkDag = (props: DagProps) => {
const container = useRef(null); const container = useRef(null);
const job = props.jobDetail.jobDataDto.job;
const { job, onlyPlan = false } = props;
const [graph, setGraph] = useState<Graph>(); const [graph, setGraph] = useState<Graph>();
const [curentJob, setCurentJob] = useState<string>(); const [curentJob, setCurentJob] = useState<string>();
...@@ -38,7 +46,7 @@ const FlinkDag = (props: { jobDetail: Jobs.JobInfoDetail }) => { ...@@ -38,7 +46,7 @@ const FlinkDag = (props: { jobDetail: Jobs.JobInfoDetail }) => {
shape: 'data-processing-dag-node', shape: 'data-processing-dag-node',
width: 212, width: 212,
height: 48, height: 48,
component: DagNode, component: onlyPlan ? DagPlanNode : DagDataNode,
ports: portConfig ports: portConfig
}); });
...@@ -67,11 +75,12 @@ const FlinkDag = (props: { jobDetail: Jobs.JobInfoDetail }) => { ...@@ -67,11 +75,12 @@ const FlinkDag = (props: { jobDetail: Jobs.JobInfoDetail }) => {
}; };
graph.zoomToFit(zoomOptions); graph.zoomToFit(zoomOptions);
graph.centerContent(); graph.centerContent();
updateDag(job.vertices, graph);
return graph; return graph;
}; };
useEffect(() => { useEffect(() => {
const flinkData = buildData(job); const flinkData = buildDag(job.plan);
// Clean up old data // Clean up old data
if (graph) { if (graph) {
graph.clearCells(); graph.clearCells();
...@@ -80,7 +89,7 @@ const FlinkDag = (props: { jobDetail: Jobs.JobInfoDetail }) => { ...@@ -80,7 +89,7 @@ const FlinkDag = (props: { jobDetail: Jobs.JobInfoDetail }) => {
}, [curentJob]); }, [curentJob]);
useEffect(() => { useEffect(() => {
updateEdge(job, graph); updateDag(job.vertices, graph);
if (curentJob != job.jid) { if (curentJob != job.jid) {
setCurentJob(job.jid); setCurentJob(job.jid);
} }
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { StatusTagProps } from '@/components/JobTags/data';
import { JOB_LIFE_CYCLE } from '@/pages/DevOps/constants';
import { l } from '@/utils/intl';
import {
CameraOutlined,
CarryOutOutlined,
CloseCircleOutlined,
EditOutlined
} from '@ant-design/icons';
import { Tag } from 'antd';
/**
* Renders a tag for the job life cycle based on the provided step.
*
* @returns {JSX.Element} - The tag representing the job life cycle.
* @param props
*/
const JobLifeCycleTag = (props: StatusTagProps) => {
const { status, animation = true, bordered = true } = props;
const buildParam = () => {
switch (status) {
case JOB_LIFE_CYCLE.DEVELOP:
return {
icon: <EditOutlined />,
color: 'default',
text: l('global.table.lifecycle.dev')
};
case JOB_LIFE_CYCLE.RELEASE:
return {
icon: <CameraOutlined />,
color: 'green',
text: l('global.table.lifecycle.publish')
};
case JOB_LIFE_CYCLE.ONLINE:
return {
icon: <CarryOutOutlined />,
color: 'blue',
text: l('global.table.lifecycle.online')
};
default:
return {
icon: <CloseCircleOutlined />,
color: 'default',
text: status
};
}
};
const param = buildParam();
return (
<Tag icon={animation ? param.icon : undefined} color={param.color} bordered={bordered}>
{param.text}
</Tag>
);
};
export default JobLifeCycleTag;
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
* *
*/ */
import { StatusTagProps } from '@/components/JobTags/data';
import { JOB_STATUS } from '@/pages/DevOps/constants'; import { JOB_STATUS } from '@/pages/DevOps/constants';
import { import {
CheckCircleOutlined, CheckCircleOutlined,
...@@ -27,12 +28,12 @@ import { ...@@ -27,12 +28,12 @@ import {
} from '@ant-design/icons'; } from '@ant-design/icons';
import { Tag } from 'antd'; import { Tag } from 'antd';
export interface StatusTagProps { /**
status: string; * Renders a tag for the job status based on the provided status.
animation?: boolean; *
bordered?: boolean; * @returns {JSX.Element} - The tag representing the job status.
} * @param props
*/
const StatusTag = (props: StatusTagProps) => { const StatusTag = (props: StatusTagProps) => {
const { status, animation = true, bordered = true } = props; const { status, animation = true, bordered = true } = props;
...@@ -84,8 +85,8 @@ const StatusTag = (props: StatusTagProps) => { ...@@ -84,8 +85,8 @@ const StatusTag = (props: StatusTagProps) => {
default: default:
return { return {
icon: <CloseCircleOutlined />, icon: <CloseCircleOutlined />,
color: 'error', color: 'default',
text: 'FAILED' text: 'UNKNOWN Status'
}; };
} }
}; };
......
export interface StatusTagProps {
status?: any;
animation?: boolean;
bordered?: boolean;
}
const escape2Html = (str: string) => {
let arrEntities: Record<string, string> = {
lt: '<',
gt: '>',
nbsp: ' ',
amp: '&',
quot: '"'
};
return str.replace(/&(lt|gt|nbsp|amp|quot);/gi, function (all, t) {
return arrEntities[t];
});
};
const getRangeText = (str: string) => {
str = escape2Html(str);
// @ts-ignore
const canvas = getRangeText.canvas || (getRangeText.canvas = document.createElement('canvas'));
const context = canvas.getContext('2d');
context.font = '10px sans-serif';
let result = '';
let count = 1;
for (let i = 0, len = str.length; i < len; i++) {
result += str[i];
let width = context.measureText(result).width;
if (width >= 110 * count) {
result += '\r\n';
count++;
}
}
return result;
};
export const buildGraphData = (data: any) => {
const edges = [];
for (const i in data.nodes) {
data.nodes[i].id = data.nodes[i].id.toString();
data.nodes[i].value = {
title: data.nodes[i].pact,
items: [
{
text: getRangeText(data.nodes[i].description)
},
{
text: '\r\nParallelism: ',
value: '\r\n ' + data.nodes[i].parallelism
}
]
};
if (data.nodes[i].inputs) {
for (let j in data.nodes[i].inputs) {
edges.push({
source: data.nodes[i].inputs[j].id.toString(),
target: data.nodes[i].id.toString(),
value: data.nodes[i].inputs[j].ship_strategy
});
}
}
}
data.edges = edges;
return data;
};
import { FlowAnalysisGraph } from '@ant-design/charts'; import FlinkDag from '@/components/FlinkDag';
import { FlowAnalysisGraphConfig } from '@ant-design/graphs/es/components/flow-analysis-graph'; import { Jobs } from '@/types/DevOps/data';
import { Empty } from 'antd'; import { Empty } from 'antd';
import { StateType } from 'rmc-input-number'; import { StateType } from 'rmc-input-number';
import { connect } from 'umi'; import { connect } from 'umi';
const FlinkGraph = (props: any) => { const FlinkGraph = (props: { data: Jobs.JobPlan }) => {
const { data } = props; const { data } = props;
const config: FlowAnalysisGraphConfig = { const job = {
data, plan: data
height: 350, } as Jobs.Job;
nodeCfg: {
size: [160, 65],
items: {
autoEllipsis: false,
padding: [10],
containerStyle: {
fill: '#fff',
width: '100px'
},
style: (cfg, group, type) => {
const styles = {
value: {
fill: '#000'
},
text: {
fill: '#222',
width: '100px'
}
};
return styles[type];
}
},
nodeStateStyles: {
hover: {
stroke: '#1890ff',
lineWidth: 2
}
},
style: {
fill: '#40a9ff',
stroke: '#1890ff'
}
},
edgeCfg: {
type: 'polyline',
label: {
style: {
fill: '#666',
fontSize: 12,
fillOpacity: 1
}
},
endArrow: {
fill: '#333'
},
edgeStateStyles: {
hover: {
stroke: '#1890ff',
lineWidth: 2
}
}
},
markerCfg: (cfg) => {
const { edges } = data;
return {
position: 'right',
show: edges.find((item) => item.source === cfg.id),
collapsed: !edges.find((item) => item.source === cfg.id)
};
},
behaviors: ['drag-canvas', 'zoom-canvas', 'drag-node']
/*layout: {
rankdir: 'TB',
ranksepFunc: () => 20,
},*/
};
return ( return (
<>{data ? <FlowAnalysisGraph {...config} /> : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />}</> <>
{data ? (
<div style={{ width: '50wh', height: '50vh' }}>
<FlinkDag job={job} onlyPlan={true} />
</div>
) : (
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
)}
</>
); );
}; };
export default connect(({ Studio }: { Studio: StateType }) => ({}))(FlinkGraph); export default connect(({}: { Studio: StateType }) => ({}))(FlinkGraph);
...@@ -20,7 +20,6 @@ import { FlexCenterDiv } from '@/components/StyledComponents'; ...@@ -20,7 +20,6 @@ import { FlexCenterDiv } from '@/components/StyledComponents';
import { getCurrentData, getCurrentTab, mapDispatchToProps } from '@/pages/DataStudio/function'; import { getCurrentData, getCurrentTab, mapDispatchToProps } from '@/pages/DataStudio/function';
import Explain from '@/pages/DataStudio/HeaderContainer/Explain'; import Explain from '@/pages/DataStudio/HeaderContainer/Explain';
import FlinkGraph from '@/pages/DataStudio/HeaderContainer/FlinkGraph'; import FlinkGraph from '@/pages/DataStudio/HeaderContainer/FlinkGraph';
import { buildGraphData } from '@/pages/DataStudio/HeaderContainer/FlinkGraph/function';
import { import {
buildBreadcrumbItems, buildBreadcrumbItems,
projectCommonShow projectCommonShow
...@@ -245,7 +244,7 @@ const HeaderContainer = (props: any) => { ...@@ -245,7 +244,7 @@ const HeaderContainer = (props: any) => {
title: l('pages.datastudio.editor.explan.tip'), title: l('pages.datastudio.editor.explan.tip'),
width: '100%', width: '100%',
icon: null, icon: null,
content: <FlinkGraph data={buildGraphData(result.datas)} />, content: <FlinkGraph data={result.datas} />,
cancelButtonProps: { style: { display: 'none' } } cancelButtonProps: { style: { display: 'none' } }
}); });
} }
......
...@@ -35,7 +35,7 @@ const JobConfigTab = (props: JobProps) => { ...@@ -35,7 +35,7 @@ const JobConfigTab = (props: JobProps) => {
height: '40vh' height: '40vh'
}} }}
> >
<FlinkDag jobDetail={jobDetail} /> <FlinkDag job={jobDetail?.jobDataDto?.job} />
</ProCard> </ProCard>
<FlinkTable jobDetail={jobDetail} /> <FlinkTable jobDetail={jobDetail} />
......
import { TagJobStatus } from '@/pages/DevOps/function'; import StatusTag from '@/components/JobTags/StatusTag';
import { JobProps } from '@/pages/DevOps/JobDetail/data'; import { JobProps } from '@/pages/DevOps/JobDetail/data';
import { parseByteStr, parseMilliSecondStr, parseNumStr } from '@/utils/function'; import { parseByteStr, parseMilliSecondStr, parseNumStr } from '@/utils/function';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
...@@ -42,7 +42,7 @@ const FlinkTable = (props: JobProps): JSX.Element => { ...@@ -42,7 +42,7 @@ const FlinkTable = (props: JobProps): JSX.Element => {
dataIndex: 'status', dataIndex: 'status',
sorter: true, sorter: true,
render: (dom, entity) => { render: (dom, entity) => {
return <>{TagJobStatus(entity.status)}</>; return <StatusTag status={entity.status} />;
} }
}, },
{ {
......
import { TagJobStatus } from '@/pages/DevOps/function'; import StatusTag from '@/components/JobTags/StatusTag';
import { JobProps } from '@/pages/DevOps/JobDetail/data'; import { JobProps } from '@/pages/DevOps/JobDetail/data';
import { parseSecondStr } from '@/utils/function'; import { parseSecondStr } from '@/utils/function';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
...@@ -58,7 +58,7 @@ const JobDesc = (props: JobProps) => { ...@@ -58,7 +58,7 @@ const JobDesc = (props: JobProps) => {
<ProCard> <ProCard>
<Descriptions title={l('devops.jobinfo.config.JobBaseInfo')} bordered size='small'> <Descriptions title={l('devops.jobinfo.config.JobBaseInfo')} bordered size='small'>
<Descriptions.Item label={l('global.table.status')}> <Descriptions.Item label={l('global.table.status')}>
{TagJobStatus(jobDetail?.instance?.status)} <StatusTag status={jobDetail?.instance?.status} />
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label={l('devops.jobinfo.config.submitType')}> <Descriptions.Item label={l('devops.jobinfo.config.submitType')}>
......
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
* *
*/ */
import Lineage from '@/components/FlinkDag'; import JobLifeCycleTag from '@/components/JobTags/JobLifeCycleTag';
import { TagJobLifeCycle } from '@/pages/DevOps/function';
import CheckPoints from '@/pages/DevOps/JobDetail/CheckPointsTab'; import CheckPoints from '@/pages/DevOps/JobDetail/CheckPointsTab';
import JobLogsTab from '@/pages/DevOps/JobDetail/JobLogs/JobLogsTab'; import JobLogsTab from '@/pages/DevOps/JobDetail/JobLogs/JobLogsTab';
import JobMetrics from '@/pages/DevOps/JobDetail/JobMetrics'; import JobMetrics from '@/pages/DevOps/JobDetail/JobMetrics';
...@@ -72,14 +71,14 @@ const JobDetail = (props: any) => { ...@@ -72,14 +71,14 @@ const JobDetail = (props: any) => {
[OperatorEnum.JOB_VERSION]: <JobVersionTab jobDetail={jobInfoDetail} />, [OperatorEnum.JOB_VERSION]: <JobVersionTab jobDetail={jobInfoDetail} />,
[OperatorEnum.JOB_CHECKPOINTS]: <CheckPoints jobDetail={jobInfoDetail} />, [OperatorEnum.JOB_CHECKPOINTS]: <CheckPoints jobDetail={jobInfoDetail} />,
[OperatorEnum.JOB_METRICS]: <JobMetrics />, [OperatorEnum.JOB_METRICS]: <JobMetrics />,
[OperatorEnum.JOB_LINEAGE]: <Lineage jobDetail={jobInfoDetail} />, // [OperatorEnum.JOB_LINEAGE]: <Lineage jobDetail={jobInfoDetail} />,
[OperatorEnum.JOB_ALERT]: <CheckPoints jobDetail={jobInfoDetail} />, [OperatorEnum.JOB_ALERT]: <CheckPoints jobDetail={jobInfoDetail} />,
[OperatorEnum.JOB_GRAPH]: <JobOperatorGraph jobDetail={jobInfoDetail} /> [OperatorEnum.JOB_GRAPH]: <JobOperatorGraph jobDetail={jobInfoDetail} />
}; };
useRequest( useRequest(
{ {
url: API_CONSTANTS.GET_JOB_DETAIL, url: API_CONSTANTS.REFESH_JOB_DETAIL,
params: { id: id } params: { id: id }
}, },
{ {
...@@ -127,7 +126,7 @@ const JobDetail = (props: any) => { ...@@ -127,7 +126,7 @@ const JobDetail = (props: any) => {
return ( return (
<PageContainer <PageContainer
title={jobInfoDetail?.instance?.name} title={jobInfoDetail?.instance?.name}
subTitle={TagJobLifeCycle(jobInfoDetail?.instance?.step)} subTitle={<JobLifeCycleTag status={jobInfoDetail?.instance?.step} />}
ghost={false} ghost={false}
extra={<JobOperator jobDetail={jobInfoDetail} />} extra={<JobOperator jobDetail={jobInfoDetail} />}
onBack={() => window.history.back()} onBack={() => window.history.back()}
......
import { TagJobStatus } from '@/pages/DevOps/function'; import StatusTag from '@/components/JobTags/StatusTag';
import { queryList } from '@/services/api'; import { queryList } from '@/services/api';
import { API_CONSTANTS } from '@/services/endpoints'; import { API_CONSTANTS } from '@/services/endpoints';
import { Jobs } from '@/types/DevOps/data'; import { Jobs } from '@/types/DevOps/data';
...@@ -36,7 +36,7 @@ const JobHistoryList = (props: HistoryProps) => { ...@@ -36,7 +36,7 @@ const JobHistoryList = (props: HistoryProps) => {
{ {
title: l('global.table.status'), title: l('global.table.status'),
dataIndex: 'status', dataIndex: 'status',
render: (_: any, row: { status: string | undefined }) => TagJobStatus(row.status) render: (_: any, row: { status: string | undefined }) => <StatusTag status={row.status} />
}, },
{ {
title: l('global.table.useTime'), title: l('global.table.useTime'),
......
import { import JobLifeCycleTag from '@/components/JobTags/JobLifeCycleTag';
JOB_STATUS_FILTER, import StatusTag from '@/components/JobTags/StatusTag';
LIFECYCLE_FILTER, import { JOB_STATUS_FILTER, LIFECYCLE_FILTER } from '@/pages/DevOps/function';
TagJobLifeCycle,
TagJobStatus
} from '@/pages/DevOps/function';
import JobHistoryList from '@/pages/DevOps/JobList/components/JobHistoryList'; import JobHistoryList from '@/pages/DevOps/JobList/components/JobHistoryList';
import { queryList } from '@/services/api'; import { queryList } from '@/services/api';
import { PROTABLE_OPTIONS_PUBLIC } from '@/services/constants'; import { PROTABLE_OPTIONS_PUBLIC } from '@/services/constants';
...@@ -36,7 +33,7 @@ const JobList = () => { ...@@ -36,7 +33,7 @@ const JobList = () => {
hideInSearch: true, hideInSearch: true,
filterMultiple: false, filterMultiple: false,
dataIndex: 'step', dataIndex: 'step',
render: (_: any, row: { step: number }) => TagJobLifeCycle(row.step) render: (_: any, row: { step: number }) => <JobLifeCycleTag status={row.step} />
}, },
{ {
title: l('global.table.runmode'), title: l('global.table.runmode'),
...@@ -64,7 +61,7 @@ const JobList = () => { ...@@ -64,7 +61,7 @@ const JobList = () => {
filterMultiple: false, filterMultiple: false,
hideInSearch: true, hideInSearch: true,
dataIndex: 'status', dataIndex: 'status',
render: (_: any, row: Jobs.JobInstance) => TagJobStatus(row.status) render: (_: any, row: Jobs.JobInstance) => <StatusTag status={row.status} />
}, },
Table.EXPAND_COLUMN, Table.EXPAND_COLUMN,
{ {
......
...@@ -17,108 +17,6 @@ ...@@ -17,108 +17,6 @@
import { JOB_LIFE_CYCLE, JOB_STATUS } from '@/pages/DevOps/constants'; import { JOB_LIFE_CYCLE, JOB_STATUS } from '@/pages/DevOps/constants';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
import {
CameraOutlined,
CarryOutOutlined,
CheckCircleOutlined,
ClockCircleOutlined,
CloseCircleOutlined,
EditOutlined,
MinusCircleOutlined,
QuestionCircleOutlined,
SyncOutlined
} from '@ant-design/icons';
import { Tag } from 'antd';
/**
* Renders a tag for the job life cycle based on the provided step.
*
* @param {number} step - The step in the job life cycle.
* @returns {JSX.Element} - The tag representing the job life cycle.
*/
export const TagJobLifeCycle = (step?: number) => {
switch (step) {
case JOB_LIFE_CYCLE.DEVELOP:
return (
<Tag icon={<EditOutlined />} color='default'>
{l('global.table.lifecycle.dev')}
</Tag>
);
case JOB_LIFE_CYCLE.RELEASE:
return (
<Tag icon={<CameraOutlined />} color='green'>
{l('global.table.lifecycle.publish')}
</Tag>
);
case JOB_LIFE_CYCLE.ONLINE:
return (
<Tag icon={<CarryOutOutlined />} color='blue'>
{l('global.table.lifecycle.online')}
</Tag>
);
default:
return step;
}
};
/**
* Renders a tag for the job status based on the provided status.
*
* @param {string|undefined} status - The status of the job.
* @returns {JSX.Element} - The tag representing the job status.
*/
export const TagJobStatus = (status: string | undefined) => {
switch (status) {
case JOB_STATUS.RUNNING:
return (
<Tag icon={<SyncOutlined spin />} color='green'>
RUNNING
</Tag>
);
case JOB_STATUS.FINISHED:
return (
<Tag icon={<CheckCircleOutlined />} color='blue'>
FINISHED
</Tag>
);
case JOB_STATUS.CANCELED:
return (
<Tag icon={<MinusCircleOutlined />} color='orange'>
CANCELED
</Tag>
);
case JOB_STATUS.INITIALIZING:
return (
<Tag icon={<ClockCircleOutlined />} color='default'>
INITIALIZING
</Tag>
);
case JOB_STATUS.RESTARTING:
return (
<Tag icon={<ClockCircleOutlined />} color='default'>
RESTARTING
</Tag>
);
case JOB_STATUS.CREATED:
return (
<Tag icon={<ClockCircleOutlined />} color='default'>
CREATED
</Tag>
);
case JOB_STATUS.UNKNOWN:
return (
<Tag icon={<QuestionCircleOutlined />} color='default'>
UNKNOWN
</Tag>
);
default:
return (
<Tag icon={<CloseCircleOutlined />} color='error'>
FAILED
</Tag>
);
}
};
/** /**
* Generates an array of options for the life cycle filter. * Generates an array of options for the life cycle filter.
......
...@@ -84,7 +84,7 @@ const Job = () => { ...@@ -84,7 +84,7 @@ const Job = () => {
* @returns {Promise<any>} * @returns {Promise<any>}
*/ */
const getFlinkTaskDetail = async (id: number) => { const getFlinkTaskDetail = async (id: number) => {
return await getData(API_CONSTANTS.GET_JOB_DETAIL, { id: id }); return await getData(API_CONSTANTS.REFESH_JOB_DETAIL, { id: id });
}; };
/** /**
......
...@@ -216,6 +216,7 @@ export enum API_CONSTANTS { ...@@ -216,6 +216,7 @@ export enum API_CONSTANTS {
GET_JOB_LIST = '/api/jobInstance', GET_JOB_LIST = '/api/jobInstance',
GET_JOB_BY_ID = '/api/jobInstance/getOneById', GET_JOB_BY_ID = '/api/jobInstance/getOneById',
GET_JOB_DETAIL = '/api/jobInstance/getJobInfoDetail', GET_JOB_DETAIL = '/api/jobInstance/getJobInfoDetail',
REFESH_JOB_DETAIL = '/api/jobInstance/refreshJobInfoDetail',
GET_JOB_VERSION = '/api/task/version', GET_JOB_VERSION = '/api/task/version',
GET_JOBMANAGER_LOG = 'api/jobInstance/getJobManagerLog', GET_JOBMANAGER_LOG = 'api/jobInstance/getJobManagerLog',
GET_JOBMANAGER_STDOUT = 'api/jobInstance/getJobManagerStdOut', GET_JOBMANAGER_STDOUT = 'api/jobInstance/getJobManagerStdOut',
......
...@@ -93,6 +93,30 @@ declare namespace Jobs { ...@@ -93,6 +93,30 @@ declare namespace Jobs {
metrics: VetricsMetrics; metrics: VetricsMetrics;
}; };
export type JobNodeInput = {
num: number;
id: string;
ship_strategy: string;
exchange: string;
};
export type JobNode = {
id: string;
parallelism: number;
operator: string;
operator_strategy: string;
description: string;
inputs: JobNodeInput[];
optimizer_properties: any;
};
export type JobPlan = {
jid: string;
name: string;
type: string;
nodes: JobNode[];
};
export type Job = { export type Job = {
jid: string; jid: string;
name: string; name: string;
...@@ -106,8 +130,9 @@ declare namespace Jobs { ...@@ -106,8 +130,9 @@ declare namespace Jobs {
timestamps: any; timestamps: any;
vertices: JobVertices[]; vertices: JobVertices[];
'status-counts': any; 'status-counts': any;
plan: any; plan: JobPlan;
}; };
export type JobDataDtoItem = { export type JobDataDtoItem = {
id: number; id: number;
job: Job; job: Job;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment