Unverified Commit 0b3d323c authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

[Feature][admin,web]support some home overview (#2067)

* support some home overview * support some home overview * format code * format code
parent 7f878326
/*
*
* 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.
*
*/
package org.dinky.controller;
import org.dinky.assertion.Asserts;
import org.dinky.data.model.HomeResource;
import org.dinky.data.model.JobModelOverview;
import org.dinky.data.model.JobStatusOverView;
import org.dinky.data.model.JobTypeOverView;
import org.dinky.data.result.Result;
import org.dinky.service.HomeService;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@RestController
@RequestMapping("/api/home")
@RequiredArgsConstructor
public class HomeController {
private final HomeService homeService;
/**
* query resource overview
*
* @return {@link Result}<{@link HomeResource}>
*/
@GetMapping("/getResourceOverview")
public Result<HomeResource> getResourceOverview() {
HomeResource resourceOverview = homeService.getResourceOverview();
if (Asserts.isNull(resourceOverview)) {
return Result.failed();
}
return Result.succeed(resourceOverview);
}
/**
* query job status overview
*
* @return {@link Result}<{@link JobStatusOverView}>
*/
@GetMapping("/getJobStatusOverView")
public Result<JobStatusOverView> getJobStatusOverView() {
JobStatusOverView jobStatusOverView = homeService.getJobStatusOverView();
if (Asserts.isNull(jobStatusOverView)) {
return Result.failed();
}
return Result.succeed(jobStatusOverView);
}
/**
* query job type overview
*
* @return {@link Result}<{@link JobTypeOverView}>
*/
@GetMapping("/getJobTypeOverview")
public Result<List<JobTypeOverView>> getJobTypeOverView() {
List<JobTypeOverView> jobTypeOverView = homeService.getJobTypeOverView();
if (Asserts.isNull(jobTypeOverView)) {
return Result.failed();
}
return Result.succeed(jobTypeOverView);
}
/**
* query job model overview , eg: batch: 1, streaming: 2
*
* @return {@link Result}<{@link JobModelOverview}>
*/
@GetMapping("/getJobModelOverview")
public Result<JobModelOverview> getJobModelOverview() {
JobModelOverview jobModelOverview = homeService.getJobModelOverview();
if (Asserts.isNull(jobModelOverview)) {
return Result.failed();
}
return Result.succeed(jobModelOverview);
}
}
/*
*
* 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.
*
*/
package org.dinky.data.model;
import lombok.Data;
@Data
public class HomeResource {
/** flink instance count */
private Integer flinkClusterCount;
/** flink config count */
private Integer flinkConfigCount;
/** data source count */
private Integer dbSourceCount;
/** global var count */
private Integer globalVarCount;
/** alert instance count */
private Integer alertInstanceCount;
/** alert group count */
private Integer alertGroupCount;
/** git project count */
private Integer gitProjectCount;
}
/*
*
* 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.
*
*/
package org.dinky.data.model;
import lombok.Data;
@Data
public class JobModelOverview {
/** BATCH_JOB_COUNT */
private Integer batchJobCount;
/** STREAMING_JOB_COUNT */
private Integer streamingJobCount;
}
/*
*
* 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.
*
*/
package org.dinky.data.model;
import lombok.Data;
@Data
public class JobStatusOverView {
private Integer jobRunningCount;
private Integer jobFinishedCount;
private Integer jobRecoveredCount;
private Integer jobOnlineCount;
private Integer jobOfflineCount;
private Integer jobErrorCount;
}
/*
*
* 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.
*
*/
package org.dinky.data.model;
import lombok.Data;
@Data
public class JobTypeOverView {
/** JOB TYPE eg: FlinkJar Mysql etc. */
private String jobType;
/** JOB TYPE COUNT */
private Integer jobTypeCount;
/** JOB TYPE RATE */
private Double rate;
}
/*
*
* 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.
*
*/
package org.dinky.service;
import org.dinky.data.model.HomeResource;
import org.dinky.data.model.JobModelOverview;
import org.dinky.data.model.JobStatusOverView;
import org.dinky.data.model.JobTypeOverView;
import java.util.List;
public interface HomeService {
/**
* query resource overview
*
* @return {@link HomeResource}
*/
HomeResource getResourceOverview();
/**
* query job status overview
*
* @return {@link JobStatusOverView}
*/
JobStatusOverView getJobStatusOverView();
/**
* query job type overview
*
* @return {@link JobTypeOverView}
*/
List<JobTypeOverView> getJobTypeOverView();
/**
* query job model overview
*
* @return {@link JobModelOverview}
*/
JobModelOverview getJobModelOverview();
}
/*
*
* 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.
*
*/
package org.dinky.service.impl;
import org.dinky.data.model.HomeResource;
import org.dinky.data.model.JobModelOverview;
import org.dinky.data.model.JobStatusOverView;
import org.dinky.data.model.JobTypeOverView;
import org.dinky.data.model.Task;
import org.dinky.service.AlertGroupService;
import org.dinky.service.AlertInstanceService;
import org.dinky.service.ClusterConfigurationService;
import org.dinky.service.ClusterInstanceService;
import org.dinky.service.DataBaseService;
import org.dinky.service.FragmentVariableService;
import org.dinky.service.GitProjectService;
import org.dinky.service.HomeService;
import org.dinky.service.TaskService;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class HomeServiceImpl implements HomeService {
private final ClusterInstanceService clusterInstanceService;
private final ClusterConfigurationService clusterConfigurationService;
private final DataBaseService dataBaseService;
private final FragmentVariableService fragmentVariableService;
private final GitProjectService gitProjectService;
private final AlertGroupService alertGroupService;
private final AlertInstanceService alertInstanceService;
private final TaskService taskService;
@Override
public HomeResource getResourceOverview() {
HomeResource homeResource = new HomeResource();
homeResource.setFlinkClusterCount(clusterInstanceService.list().size());
homeResource.setFlinkConfigCount(clusterConfigurationService.list().size());
homeResource.setDbSourceCount(dataBaseService.list().size());
homeResource.setGlobalVarCount(fragmentVariableService.list().size());
homeResource.setGitProjectCount(gitProjectService.list().size());
homeResource.setAlertGroupCount(alertGroupService.list().size());
homeResource.setAlertInstanceCount(alertInstanceService.list().size());
return homeResource;
}
@Override
public JobStatusOverView getJobStatusOverView() {
JobStatusOverView jobStatusOverView = new JobStatusOverView();
// todo: query job status
return jobStatusOverView;
}
@Override
public List<JobTypeOverView> getJobTypeOverView() {
List<JobTypeOverView> jobTypeOverViews = new ArrayList<>();
taskService
.list()
.forEach(
task -> {
JobTypeOverView jobTypeOverView = new JobTypeOverView();
jobTypeOverView.setJobType(task.getDialect());
LambdaQueryWrapper<Task> taskLambdaQueryWrapper =
new LambdaQueryWrapper<Task>()
.eq(Task::getDialect, task.getDialect());
List<Task> taskList = taskService.list(taskLambdaQueryWrapper);
jobTypeOverView.setJobTypeCount(taskList.size());
jobTypeOverView.setRate(
taskList.size() * 1D / taskService.list().size());
jobTypeOverViews.add(jobTypeOverView);
});
return jobTypeOverViews;
}
@Override
public JobModelOverview getJobModelOverview() {
JobModelOverview jobModelOverview = new JobModelOverview();
// todo: query job model 1: get job model 2: get job model count
return jobModelOverview;
}
}
......@@ -62,7 +62,7 @@ export default {
'menu.settings.systemlog': 'System Log',
'menu.settings.process': 'Process List',
'menu.settings.services': 'Servers List',
'menu.metrics': 'Dashboard',
'menu.metrics': 'Metrics',
'menu.about': 'About',
'menu.version': 'Version: {version}',
};
......@@ -600,4 +600,14 @@ export default {
'sys.info.logList.tips': 'Click left log file to viewing',
// metrics
'metrics.filter.60seconds': '60 Seconds',
'metrics.filter.5minutes': '5 Minutes',
'metrics.filter.10minutes': '10 Minutes',
'metrics.filter.1hour': '1 Hours',
'metrics.filter.2hours': '2 Hours',
'metrics.filter.5hours': '5 Hours',
'metrics.filter.custom': 'Custom',
'metrics.filter.custom.range': 'DateTime Range',
};
......@@ -602,4 +602,15 @@ export default {
// system info of log
'sys.info.logList.tips': '点击左侧日志文件查看',
// metrics
'metrics.filter.60seconds': '60秒',
'metrics.filter.5minutes': '5分钟',
'metrics.filter.10minutes': '10分钟',
'metrics.filter.1hour': '1小时',
'metrics.filter.2hours': '2小时',
'metrics.filter.5hours': '5小时',
'metrics.filter.custom': '自定义',
'metrics.filter.custom.range': '日期时间范围',
};
......@@ -27,17 +27,35 @@ import {
DatabaseIcon, GitIcon,
GlobalVarIcon
} from "@/components/Icons/HomeIcon";
import {DatabaseTwoTone} from "@ant-design/icons";
import {imgStyle} from "@/pages/Home/constants";
import CountFormatter from "@/components/CountFormatter";
import {l} from "@/utils/intl";
import {queryDataByParams} from "@/services/BusinessCrud";
import {API_CONSTANTS} from "@/services/constants";
type ResourceView ={
flinkClusterCount: number;
flinkConfigCount: number;
dbSourceCount: number;
globalVarCount: number;
alertInstanceCount: number;
alertGroupCount: number;
gitProjectCount: number;
}
const ResourceView = () => {
const [responsive, setResponsive] = useState(false);
const [data, setData] = useState<ResourceView>();
useEffect(() => {
queryDataByParams(API_CONSTANTS.GET_RESOURCE_OVERVIEW).then((res) => {
console.log(res);
setData(res);
});
}, [])
return (
<RcResizeObserver
key="resize-observer"
......@@ -49,7 +67,7 @@ const ResourceView = () => {
<StatisticCard
statistic={{
title: l('home.develop.re.ci'),
value: 2176,
value: data?.flinkClusterCount || 0,
icon:<ClusterInstanceIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/>
}}
......@@ -57,7 +75,7 @@ const ResourceView = () => {
<StatisticCard
statistic={{
title: l('home.develop.re.cc'),
value: 475,
value: data?.flinkConfigCount || 0,
icon: <ClusterConfigIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/>
}}
......@@ -67,7 +85,7 @@ const ResourceView = () => {
<StatisticCard
statistic={{
title: l('home.develop.re.ds'),
value: 87,
value: data?.dbSourceCount || 0,
icon: <DatabaseIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/>
}}
......@@ -75,7 +93,7 @@ const ResourceView = () => {
<StatisticCard
statistic={{
title: l('home.develop.re.gv'),
value: 1754,
value: data?.globalVarCount || 0,
icon: <GlobalVarIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/>
}}
......@@ -85,7 +103,7 @@ const ResourceView = () => {
<StatisticCard
statistic={{
title: l('home.develop.re.ai'),
value: 87,
value: data?.alertInstanceCount || 0,
icon: <AlertInstanceIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/>
}}
......@@ -93,7 +111,7 @@ const ResourceView = () => {
<StatisticCard
statistic={{
title: l('home.develop.re.ag'),
value: 1754,
value: data?.alertGroupCount || 0,
icon: <AlertGroupIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/>
}}
......@@ -103,7 +121,7 @@ const ResourceView = () => {
<StatisticCard
statistic={{
title: l('home.develop.re.git'),
value: 220,
value: data?.gitProjectCount || 0,
icon: <GitIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/>
}}
......
......@@ -17,84 +17,56 @@
*
*/
import React from 'react';
import React, {useEffect, useState} from 'react';
import {Radar, RadarConfig} from '@ant-design/plots';
import {l} from "@/utils/intl";
import {queryDataByParams} from "@/services/BusinessCrud";
import {API_CONSTANTS} from "@/services/constants";
type TaskDialectSummary = {
type: string;
count: number;
jobType: string;
jobTypeCount: number;
rate: number;
}
const TaskDialectRadar = () => {
// 数据更新于 2021.01.09
const data : TaskDialectSummary[] = [
{
type: 'FlinkSQL',
count: 10371,
rate: 0.01,
},
{
type: 'FlinkJar',
count: 7380,
rate: 0.01,
},
{
type: 'K8SApplication',
count: 7414,
rate: 0.01,
},
{
type: 'Doris',
count: 2140,
rate: 0.01,
},
{
type: 'FlinkSQLEnv',
count: 660,
rate: 0.01,
},
{
type: 'Java',
count: 885,
rate: 0.01,
},
{
type: 'Mysql',
count: 1626,
rate: 0.01,
},
];
const config:RadarConfig = {
data: data.map((d) => ({...d, count: Math.sqrt(d.count)})),
xField: 'type',
yField: 'count',
autoFit: true,
appendPadding: [0, 10, 0, 10],
meta: {
count: {
alias: l('home.job.total'),
min: 0,
nice: true,
formatter: (v) => Number(v),
},
},
xAxis: {
tickLine: null,
},
yAxis: {
label: false,
grid: {
alternateColor: 'rgba(0, 0, 0, 0.04)',
},
},
// 开启辅助点
point: {
size: 2,
},
area: {},
};
return <div style={{height: '35vh'}}><Radar {...config} /></div>;
const [data, setData] = useState<TaskDialectSummary[]>([]);
useEffect(() => {
queryDataByParams(API_CONSTANTS.GET_JOB_TYPE_OVERVIEW).then((res) => {
setData(res);
})
}, [])
const config: RadarConfig = {
data: data,
xField: 'jobType',
yField: 'jobTypeCount',
autoFit: true,
appendPadding: [0, 10, 0, 10],
meta: {
jobTypeCount: {
alias: l('home.job.total'),
min: 0,
nice: true,
formatter: (v) => Number(v),
},
},
yAxis: {
label: false,
grid: {
alternateColor: 'rgba(0, 0, 0, 0.04)',
},
},
// 开启辅助点
point: {
size: 2,
},
area: {},
};
return <div style={{height: '35vh'}}><Radar {...config} /></div>;
};
export default TaskDialectRadar
......@@ -37,9 +37,6 @@ const CPU: React.FC<CpuProps> = (props) => {
return {time: x.heartTime, value: Number( x.content.jvm.cpuUsed.toFixed(2))};
})
useEffect(() => {
}, []);
const config: AreaConfig = {
animation: false,
......@@ -55,13 +52,6 @@ const CPU: React.FC<CpuProps> = (props) => {
min:0,
max:100
},
// slider: {
// start: 0,
// end: 1,
// trendCfg: {
// isArea: true,
// },
// },
};
return <Area {...config} />;
......
......@@ -21,6 +21,7 @@
import {LightFilter, ProFormDateTimeRangePicker, ProFormRadio} from "@ant-design/pro-components";
import React from "react";
import {DATE_RANGE_OPTIONS} from "@/pages/Metrics/Server/constants";
import {l} from "@/utils/intl";
type GlobalFilterProps = {
custom: boolean;
......@@ -47,7 +48,7 @@ const GlobalFilter: React.FC<GlobalFilterProps> = (props) => {
/>
{dateRange=="custom"?<ProFormDateTimeRangePicker
name="datetimeRanger"
label="日期时间范围"
label={l('metrics.filter.custom.range')}
allowClear={false}
initialValue={[startTime, endTime]}
fieldProps={{
......
......@@ -34,8 +34,6 @@ const Heap: React.FC<HeapProps> = (props) => {
const dataList: Heap[] = data.map(x => {
return {time: x.heartTime, value: Number((x.content.jvm.heapUsed/(1024*1024)).toFixed(0))};
})
useEffect(() => {
}, []);
const config: AreaConfig = {
......@@ -52,10 +50,6 @@ const Heap: React.FC<HeapProps> = (props) => {
min:0,
max:max
},
// slider: {
// start: 0.1,
// end: 0.9,
// },
};
return <Area {...config} />;
......
......@@ -17,9 +17,10 @@
*
*/
import {useEffect, useState} from "react";
import React, {useEffect, useState} from "react";
import {Area, AreaConfig} from "@ant-design/plots";
import {MetricsDataType} from "@/pages/Metrics/Server/data";
type NonHeapProps = {
data: MetricsDataType[];
max: number;
......@@ -29,17 +30,15 @@ type NonHeap = {
value: string | number;
}
const NonHeap: React.FC<NonHeapProps> = (props) => {
const {data,max} = props;
const {data, max} = props;
const dataList: NonHeap[] = data.map(x => {
return {time: x.heartTime, value: Number((x.content.jvm.nonHeapMax/(1024*1024)).toFixed(0))};
return {time: x.heartTime, value: Number((x.content.jvm.nonHeapMax / (1024 * 1024)).toFixed(0))};
})
useEffect(() => {
}, []);
const config: AreaConfig = {
data:dataList,
animation:false,
data: dataList,
animation: false,
height: 200,
yField: 'value',
xField: 'time',
......@@ -47,14 +46,10 @@ const NonHeap: React.FC<NonHeapProps> = (props) => {
type: 'time',
mask: 'HH:mm:ss',
},
yAxis:{
min:0,
max:max
yAxis: {
min: 0,
max: max
},
// slider: {
// start: 0.1,
// end: 0.9,
// },
};
return <Area {...config} />;
......
......@@ -28,29 +28,26 @@ type ThreadProps = {
type Thread = {
time: Date;
value: string | number;
name:string
name: string
}
const Thread: React.FC<ThreadProps> = (props) => {
const {data} = props;
const dataList: Thread[] = data.map(x => {
return {time: x.heartTime, value: x.content.jvm.threadPeakCount,name:"Peak"};
return {time: x.heartTime, value: x.content.jvm.threadPeakCount, name: "Peak"};
})
const dataList2: Thread[] = data.map(x => {
return {time: x.heartTime, value: x.content.jvm.threadCount,name:"Count"};
return {time: x.heartTime, value: x.content.jvm.threadCount, name: "Count"};
})
const dataListAll = dataList.concat(dataList2);
useEffect(() => {
}, []);
const config: AreaConfig = {
data:dataListAll,
animation:false,
data: dataListAll,
animation: false,
height: 200,
xField: 'time',
yField: 'value',
seriesField: 'name',
isStack:false,
xAxis: {
type: 'time',
mask: 'HH:mm:ss',
......
......@@ -18,40 +18,42 @@
*/
import {l} from "@/utils/intl";
export const DATE_RANGE_OPTIONS =(disable:boolean)=> [
{
value: '60s',
label: '60秒',
label: l('metrics.filter.60seconds'),
disable:!disable
},
{
value: '5min',
label: '5分钟',
label: l('metrics.filter.5minutes'),
disable:!disable
},
{
value: '10min',
label: '10分钟',
label: l('metrics.filter.10minutes'),
disable:!disable
},
{
value: '1h',
label: '1小时',
label: l('metrics.filter.1hour'),
disable:!disable
},
{
value: '2h',
label: '2小时',
label: l('metrics.filter.2hours'),
disable:!disable
},
{
value: '5h',
label: '5小时',
label: l('metrics.filter.5hours'),
disable:!disable
},
{
value: 'custom',
label: '自定义',
label: l('metrics.filter.custom'),
disable:disable
},
]
/*
*
* 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.
*
*/
export type MetricsDataType = {
content: {
jvm: JVMType,
cpu: CPUType,
mem: MemoryType,
},
metricsTotal: number,
model: string,
heartTime: Date,
content: {
jvm: JVMType,
cpu: CPUType,
mem: MemoryType,
},
metricsTotal: number,
model: string,
heartTime: Date,
}
type JVMType = {
total: number,
max: number,
free: number,
cpuUsed: number,
nonHeapMax: number,
nonHeapUsed: number,
heapMax: number,
heapUsed: number,
threadPeakCount: number,
threadCount: number,
version: string,
home: string,
total: number,
max: number,
free: number,
cpuUsed: number,
nonHeapMax: number,
nonHeapUsed: number,
heapMax: number,
heapUsed: number,
threadPeakCount: number,
threadCount: number,
version: string,
home: string,
}
type CPUType = {
cpuNum: number,
sys: number,
wait: number,
free: number,
cpuNum: number,
sys: number,
wait: number,
free: number,
}
type MemoryType = {
total: number,
used: number,
free: number,
total: number,
used: number,
free: number,
}
......@@ -24,7 +24,7 @@
* @param {number} minutes | sub minutes
* @returns {Date} | return the time before several minutes
*/
export const getSubMinTime = (currentTime : Date ,minutes: number) => {
export const getSubMinTime = (currentTime: Date, minutes: number) => {
const pastTime = new Date(currentTime.getTime() - minutes * 60000);
return pastTime;
};
......@@ -37,13 +37,13 @@ export const getSubMinTime = (currentTime : Date ,minutes: number) => {
* @param {boolean} isStart | is start time , if true , the time is 00:00:00.000 if false , the time is 23:59:59.999
* @returns {Date} | return the time before several days
*/
export const getSubDateTime = (currentTime : Date , day: number,isStart: boolean) => {
export const getSubDateTime = (currentTime: Date, day: number, isStart: boolean) => {
const pastTime = new Date(
currentTime.getFullYear(),
currentTime.getMonth(),
currentTime.getDate() - day,
(isStart? 0: 23), (isStart? 0: 59), (isStart? 0: 59), (isStart? 0: 999)
(isStart ? 0 : 23), (isStart ? 0 : 59), (isStart ? 0 : 59), (isStart ? 0 : 999)
);
return pastTime;
};
......@@ -55,12 +55,12 @@ export const getSubDateTime = (currentTime : Date , day: number,isStart: boolean
* @param {boolean} isFirst | is first day of month, if true , the time is 00:00:00.000 if false , the time is 23:59:59.999
* @returns {Date} | return the first day / last day of current month
*/
export const getDayOfMonth = (currentTime : Date , isFirst: boolean) => {
export const getDayOfMonth = (currentTime: Date, isFirst: boolean) => {
const pastTime = new Date(
currentTime.getFullYear(),
currentTime.getMonth() + (isFirst ? 0 : 1),
(isFirst? 1: 0),
(isFirst? 0: 23), (isFirst? 0: 59), (isFirst? 0: 59), (isFirst? 0: 999)
currentTime.getMonth() + (isFirst ? 0 : 1),
(isFirst ? 1 : 0),
(isFirst ? 0 : 23), (isFirst ? 0 : 59), (isFirst ? 0 : 59), (isFirst ? 0 : 999)
);
return pastTime;
}
......@@ -130,7 +130,6 @@ const Server = () => {
setEndTime(currentTime)
break;
case '5min':
console.log('5min')
setStartTime(getSubMinTime(currentTime, 5))
setEndTime(currentTime)
break;
......
......@@ -191,6 +191,10 @@ export const API_CONSTANTS = {
// -- home
GET_STATUS_COUNT: "api/jobInstance/getStatusCount",
GET_RESOURCE_OVERVIEW: "/api/home/getResourceOverview",
GET_JOB_STATUS_OVERVIEW: "/api/home/getJobStatusOverview",
GET_JOB_TYPE_OVERVIEW: "/api/home/getJobTypeOverview",
GET_JOB_MODEL_OVERVIEW: "/api/home/getJobModelOverview",
// monitor
MONITOR_GET_SYSTEM_DATA:"/api/monitor/getSysData",
......
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