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