Unverified Commit 1a149673 authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

added flink job metrics layout (#2072)

parent a1302cc6
/*
*
* 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 {useState} from "react";
import {PageLoading, ProFormSelect} from "@ant-design/pro-components";
import {Tag} from "antd";
type JobMetrics = {
taskId: number
flinkJobId: string
jobName: string
}
const templateData: JobMetrics[] = [
{
taskId: 1,
flinkJobId: '6327183eghjshajdkahsjdhasjkdhksjageqyw',
jobName: 'job1',
},
{
taskId: 2,
flinkJobId: '6327132893829shajdkahsjdhashksjageqyw',
jobName: 'job2',
}
]
const Job = () => {
const [data, setData] = useState<JobMetrics[]>(templateData);
const [selectTaskId, setSelectTaskId] = useState<number>(0);
const [loading, setLoading] = useState<boolean>(false);
// useEffect(() => {
// getDataByParams(API_CONSTANTS.JOB_METRICS, {taskId: selectTaskId}).then((res) => {
// setData(res.data);
// });
// }, []);
const buildSelectDataOptions = (metrics: JobMetrics[]) => metrics.map((item) => {
let label = <div style={{alignItems: 'center',alignContent: 'center'}}>
<Tag color={'processing'}>Flink JobId: {item.flinkJobId}</Tag>
<Tag color={'success'}>TaskId: {item.taskId}</Tag>
<Tag color={'success'}>TaskName: {item.jobName}</Tag>
</div>;
return {
key: item.taskId,
label: label,
value: item.taskId,
};
})
const handleSelectChange = (value: number) => {
setLoading(true);
setSelectTaskId(value);
setTimeout(() => {
setLoading(false);
}, 2000);
};
return <>
<ProFormSelect
name="job"
label="Job"
placeholder={'Select a job'}
options={buildSelectDataOptions(data)}
fieldProps={{
onChange: (value) => handleSelectChange(value)
}}
/>
<>
{
(selectTaskId !== 0 && selectTaskId !== undefined) &&
<>
{loading ? <PageLoading/> : <>
you choose the task id: {selectTaskId}
</>}
</>
}
</>
</>
}
export default Job;
\ No newline at end of file
...@@ -41,7 +41,7 @@ const CPU: React.FC<CpuProps> = (props) => { ...@@ -41,7 +41,7 @@ const CPU: React.FC<CpuProps> = (props) => {
const config: AreaConfig = { const config: AreaConfig = {
animation: false, animation: false,
data: dataList, data: dataList,
height: 200, height: 150,
yField: 'value', yField: 'value',
xField: 'time', xField: 'time',
xAxis: { xAxis: {
......
...@@ -39,7 +39,7 @@ const Heap: React.FC<HeapProps> = (props) => { ...@@ -39,7 +39,7 @@ const Heap: React.FC<HeapProps> = (props) => {
const config: AreaConfig = { const config: AreaConfig = {
data:dataList, data:dataList,
animation:false, animation:false,
height: 200, height: 150,
yField: 'value', yField: 'value',
xField: 'time', xField: 'time',
xAxis: { xAxis: {
......
...@@ -39,7 +39,7 @@ const NonHeap: React.FC<NonHeapProps> = (props) => { ...@@ -39,7 +39,7 @@ const NonHeap: React.FC<NonHeapProps> = (props) => {
const config: AreaConfig = { const config: AreaConfig = {
data: dataList, data: dataList,
animation: false, animation: false,
height: 200, height: 150,
yField: 'value', yField: 'value',
xField: 'time', xField: 'time',
xAxis: { xAxis: {
......
...@@ -44,7 +44,7 @@ const Thread: React.FC<ThreadProps> = (props) => { ...@@ -44,7 +44,7 @@ const Thread: React.FC<ThreadProps> = (props) => {
const config: AreaConfig = { const config: AreaConfig = {
data: dataListAll, data: dataListAll,
animation: false, animation: false,
height: 200, height: 150,
xField: 'time', xField: 'time',
yField: 'value', yField: 'value',
seriesField: 'name', seriesField: 'name',
......
...@@ -166,8 +166,8 @@ const Server = () => { ...@@ -166,8 +166,8 @@ const Server = () => {
<GlobalFilter custom={custom} dateRange={dateRange} endTime={endTime} startTime={startTime} <GlobalFilter custom={custom} dateRange={dateRange} endTime={endTime} startTime={startTime}
handleDateRadioChange={handleDateRadioChange} handleRangeChange={handleRangeChange}/> handleDateRadioChange={handleDateRadioChange} handleRangeChange={handleRangeChange}/>
</ProCard> </ProCard>
<ProCard style={{height: '88vh'}} ghost wrap size={'small'} split={'vertical'}> <ProCard ghost wrap size={'small'} split={'vertical'}>
<ProCard style={{height: '20vh'}} split={'vertical'}> <ProCard style={{height: '16vh'}} split={'vertical'}>
<ProCard title={<Space><CPUIcon style={imgStyle}/>CPU</Space>} extra={dataRecord?.cpuLastValue + "%"}> <ProCard title={<Space><CPUIcon style={imgStyle}/>CPU</Space>} extra={dataRecord?.cpuLastValue + "%"}>
<CPU data={data}/> <CPU data={data}/>
</ProCard> </ProCard>
......
...@@ -20,10 +20,21 @@ ...@@ -20,10 +20,21 @@
import React from "react"; import React from "react";
import Server from "@/pages/Metrics/Server"; import Server from "@/pages/Metrics/Server";
import {PageContainer} from "@ant-design/pro-components"; import {PageContainer, ProCard} from "@ant-design/pro-components";
import Job from "./Job";
export default () => { export default () => {
return <PageContainer title={false}> return <PageContainer title={false}>
<Server/> <ProCard style={{height:'93vh'}} split={'horizontal'} size={'small'} wrap >
<ProCard split={'horizontal'} style={{height: '22vh'}}>
<Server/>
</ProCard>
<ProCard.Divider/>
<ProCard split={'horizontal'} wrap>
<Job/>
</ProCard>
</ProCard>
</PageContainer>; </PageContainer>;
} }
...@@ -198,7 +198,8 @@ export const API_CONSTANTS = { ...@@ -198,7 +198,8 @@ export const API_CONSTANTS = {
// monitor // monitor
MONITOR_GET_SYSTEM_DATA:"/api/monitor/getSysData", MONITOR_GET_SYSTEM_DATA:"/api/monitor/getSysData",
MONITOR_GET_LAST_DATA:"/api/monitor/getLastUpdateData" MONITOR_GET_LAST_DATA:"/api/monitor/getLastUpdateData",
JOB_METRICS: "/api/monitor/jobMetrics",
}; };
......
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