Unverified Commit 496e1182 authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

fix devops's bug (#2353)

* fix devops's graph's bug * Spotless Apply --------- Co-authored-by: 's avatarzhu-mingye <zhu-mingye@users.noreply.github.com>
parent f4183616
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
import StatusTag from '@/components/JobTags/StatusTag'; import StatusTag from '@/components/JobTags/StatusTag';
import { l } from '@/utils/intl';
import { Card, Col, Row, Tag, Typography } from 'antd'; import { Card, Col, Row, Tag, Typography } from 'antd';
const { Text, Paragraph } = Typography; const { Text, Paragraph } = Typography;
...@@ -28,7 +29,7 @@ const DagDataNode = (props: any) => { ...@@ -28,7 +29,7 @@ const DagDataNode = (props: any) => {
return ( return (
<Card <Card
style={{ width: '250px', padding: 0 }} style={{ width: '250px', padding: 0, margin: 0, height: 140 }}
bordered={false} bordered={false}
size={'small'} size={'small'}
type={'inner'} type={'inner'}
...@@ -43,23 +44,27 @@ const DagDataNode = (props: any) => { ...@@ -43,23 +44,27 @@ const DagDataNode = (props: any) => {
</Paragraph> </Paragraph>
<Row> <Row>
<Col span={15}> <Col span={16}>
<Text type='secondary'>BackPressure:</Text> <Text type='secondary'>
{l('devops.baseinfo.backpressure')}:
<Tag bordered={false} color='success'> <Tag bordered={false} color='success'>
OK OK
</Tag> </Tag>
</Text>
</Col> </Col>
<Col span={8}> <Col span={8}>
<Text type='secondary'>Busy:97%</Text> <Text type='secondary'> {l('devops.baseinfo.busy')}:97%</Text>
</Col> </Col>
</Row> </Row>
<Row> <Row>
<Col span={15}> <Col span={16}>
<Text type='secondary'>Status:</Text> <Text type='secondary'>
{l('devops.baseinfo.status')}:
<StatusTag status={data.status} bordered={false} animation={false} /> <StatusTag status={data.status} bordered={false} animation={false} />
</Text>
</Col> </Col>
<Col span={8}> <Col span={8}>
<Text type='secondary'>Idle:50%</Text> <Text type='secondary'>{l('devops.baseinfo.idle')}:50%</Text>
</Col> </Col>
</Row> </Row>
</Card> </Card>
......
...@@ -27,7 +27,7 @@ const DagPlanNode = (props: any) => { ...@@ -27,7 +27,7 @@ const DagPlanNode = (props: any) => {
return ( return (
<Card <Card
style={{ width: '250px', padding: 0 }} style={{ width: '250px', padding: 0, margin: 0, height: 140 }}
bordered={false} bordered={false}
size={'small'} size={'small'}
type={'inner'} type={'inner'}
......
...@@ -47,23 +47,25 @@ const FlinkDag = (props: DagProps) => { ...@@ -47,23 +47,25 @@ const FlinkDag = (props: DagProps) => {
const { job, onlyPlan = false } = props; const { job, onlyPlan = false } = props;
const [graph, setGraph] = useState<Graph>(); const [graph, setGraph] = useState<Graph>();
const [curentJob, setCurentJob] = useState<string>(); const [currentJob, setCurrentJob] = useState<string>();
const [curentSelect, setCurentSelect] = useState<any>(); const [currentSelect, setCurrentSelect] = useState<any>();
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const handleClose = () => {
setOpen(false);
setCurrentSelect(undefined);
graph?.zoomToFit(zoomOptions);
graph?.centerContent();
};
const initListen = (graph: Graph) => { const initListen = (graph: Graph) => {
graph.on('node:selected', ({ cell }) => { graph.on('node:selected', ({ cell }) => {
setOpen(true); setOpen(true);
setCurentSelect(cell); setCurrentSelect(cell);
graph.positionCell(cell, 'center'); graph.positionCell(cell, 'center');
}); });
graph.on('node:unselected', ({ cell }) => { graph.on('node:unselected', ({ cell }) => handleClose());
setOpen(false);
setCurentSelect(undefined);
graph.zoomToFit(zoomOptions);
graph.centerContent();
});
}; };
const initGraph = (flinkData: any) => { const initGraph = (flinkData: any) => {
...@@ -101,44 +103,40 @@ const FlinkDag = (props: DagProps) => { ...@@ -101,44 +103,40 @@ const FlinkDag = (props: DagProps) => {
// Automatically zoom to fit // Automatically zoom to fit
graph.zoomToFit(zoomOptions); graph.zoomToFit(zoomOptions);
graph.centerContent(); graph.centerContent();
updateDag(job.vertices, graph); updateDag(job?.vertices, graph);
initListen(graph); initListen(graph);
return graph; return graph;
}; };
useEffect(() => { useEffect(() => {
const flinkData = buildDag(job.plan); const flinkData = buildDag(job?.plan);
// Clean up old data // Clean up old data
if (graph) { if (graph) {
graph.clearCells(); graph.clearCells();
} }
setGraph(initGraph(flinkData)); setGraph(initGraph(flinkData));
}, [curentJob]); }, [currentJob]);
useEffect(() => { useEffect(() => {
updateDag(job.vertices, graph); updateDag(job?.vertices, graph);
if (curentJob != job.jid) { if (currentJob != job?.jid) {
setCurentJob(job.jid); setCurrentJob(job?.jid);
} }
}, [job]); }, [job]);
return ( return (
<> <>
<div <div style={{ height: '100%', width: '100%' }} ref={container} />
style={{
height: '100%',
width: '100%'
}}
ref={container}
/>
<Drawer <Drawer
title={curentSelect?.name} title={currentSelect?.data?.id}
open={open} open={open}
getContainer={false} getContainer={false}
size={'large'} width={'35%'}
mask={false} mask={false}
onClose={() => handleClose()}
destroyOnClose={true}
> >
<p>{curentSelect?.getData().description}</p> <p>{currentSelect?.getData().description}</p>
</Drawer> </Drawer>
</> </>
); );
......
...@@ -106,6 +106,9 @@ export default { ...@@ -106,6 +106,9 @@ export default {
'devops.baseinfo.tasks': 'Operator', 'devops.baseinfo.tasks': 'Operator',
'devops.baseinfo.writebytes': 'Send Bytes', 'devops.baseinfo.writebytes': 'Send Bytes',
'devops.baseinfo.writerecords': 'Send Records', 'devops.baseinfo.writerecords': 'Send Records',
'devops.baseinfo.backpressure': 'BackPressure',
'devops.baseinfo.busy': 'Busy',
'devops.baseinfo.idle': 'Idle',
'devops.jobinfo.ck.checkpoint_type': 'Type', 'devops.jobinfo.ck.checkpoint_type': 'Type',
'devops.jobinfo.ck.duration': 'Duration', 'devops.jobinfo.ck.duration': 'Duration',
'devops.jobinfo.ck.external_path': 'Storage Location', 'devops.jobinfo.ck.external_path': 'Storage Location',
......
...@@ -100,6 +100,9 @@ export default { ...@@ -100,6 +100,9 @@ export default {
'devops.baseinfo.tasks': '算子', 'devops.baseinfo.tasks': '算子',
'devops.baseinfo.writebytes': '发送字节', 'devops.baseinfo.writebytes': '发送字节',
'devops.baseinfo.writerecords': '发送记录', 'devops.baseinfo.writerecords': '发送记录',
'devops.baseinfo.backpressure': '反压',
'devops.baseinfo.busy': '繁忙',
'devops.baseinfo.idle': '空闲',
'devops.jobinfo.ck.checkpoint_type': '类型', 'devops.jobinfo.ck.checkpoint_type': '类型',
'devops.jobinfo.ck.duration': '耗时', 'devops.jobinfo.ck.duration': '耗时',
'devops.jobinfo.ck.external_path': '存储位置', 'devops.jobinfo.ck.external_path': '存储位置',
......
...@@ -42,9 +42,9 @@ const ResourceView = () => { ...@@ -42,9 +42,9 @@ const ResourceView = () => {
const [data, setData] = useState<ResourceOverView>(); const [data, setData] = useState<ResourceOverView>();
useEffect(() => { useEffect(() => {
queryDataByParams(API_CONSTANTS.GET_RESOURCE_OVERVIEW).then((res) => { queryDataByParams(API_CONSTANTS.GET_RESOURCE_OVERVIEW).then((res) =>
setData(res); setData(res as ResourceOverView)
}); );
}, []); }, []);
return ( return (
......
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