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

[Optimization][web] Optimization home page (#2043)

* 优化home 布局 & 美化
parent b88158b8
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
"rc-menu": "^9.8.4", "rc-menu": "^9.8.4",
"rc-util": "^5.33.0", "rc-util": "^5.33.0",
"react": "^18.2.0", "react": "^18.2.0",
"react-countup": "^6.4.2",
"react-dev-inspector": "^1.8.1", "react-dev-inspector": "^1.8.1",
"react-dom": "^18.0.0", "react-dom": "^18.0.0",
"react-helmet-async": "^1.3.0", "react-helmet-async": "^1.3.0",
......
/*
*
* 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 CountUp from "react-countup";
import React from "react";
const CountFormatter = ({value}:{value:number}) => <CountUp duration={2} redraw enableScrollSpy scrollSpyOnce preserveValue end={value} />;
export default CountFormatter;
\ No newline at end of file
This diff is collapsed.
...@@ -164,4 +164,26 @@ export default { ...@@ -164,4 +164,26 @@ export default {
'global.notifaction.iknow': 'I understand', 'global.notifaction.iknow': 'I understand',
'global.notifaction.full-error': 'Complete error message', 'global.notifaction.full-error': 'Complete error message',
'global.item': 'Pieces',
'global.bout': 'Times',
'global.week.sunday': 'Sunday',
'global.week.monday': 'Monday',
'global.week.tuesday': 'Tuesday',
'global.week.wednesday': 'Wednesday',
'global.week.thursday': 'Thursday',
'global.week.friday': 'Friday',
'global.week.saturday': 'Saturday',
'global.month.january': 'January',
'global.month.february': 'February',
'global.month.march': 'March',
'global.month.april': 'April',
'global.month.may': 'May',
'global.month.june': 'June',
'global.month.july': 'July',
'global.month.august': 'August',
'global.month.september': 'September',
'global.month.october': 'October',
'global.month.november': 'November',
'global.month.december': 'December',
}; };
...@@ -52,6 +52,42 @@ export default { ...@@ -52,6 +52,42 @@ export default {
'about.communityRules.5': 'about.communityRules.5':
' Register who is using Dinky, and can enter the enterprise user group to provide technical support. ', ' Register who is using Dinky, and can enter the enterprise user group to provide technical support. ',
//-------------------------------- Home --------------------------------
'home.job.metrics': 'Job Monitoring',
'home.job.running.status': 'Current Job Running Status',
'home.server.load': 'Server Load',
'home.job.running': 'Currently Running',
'home.job.finished': 'Completed Today',
'home.job.recovery': 'Recovery Today',
'home.job.online': 'Online Today',
'home.job.failed': 'Failed Today',
'home.job.recovery.rate': 'Recovery Rate',
'home.job.running.dayonday': 'Day on Day Ratio',
'home.job.instance': 'Task Instance',
'home.server.load.excellent': 'Excellent',
'home.server.load.good': 'Good',
'home.server.load.bad': 'Bad',
'home.job.failed.unhandle': 'Currently Unhandled Failure',
'home.job.failed.handle': 'Handled',
'home.job.failed.rank': 'Rank',
'home.job.failed.name': 'Job Name',
'home.job.failed.time': 'Abnormal Time',
'home.develop': 'Data Develop',
'home.job.batch': 'Batch Job',
'home.job.stream': 'Streaming Job',
'home.job.total': 'Number of Jobs',
'home.job.type': 'Job Type',
'home.job.rate': 'Proportion of Jobs',
'home.develop.re.ci': 'Flink Cluster Instance',
'home.develop.re.cc': 'Cluster Configuration',
'home.develop.re.ds': 'Data Source',
'home.develop.re.gv': 'Global Variables',
'home.develop.re.ai': 'Alarm Instance',
'home.develop.re.ag': 'Alarm Group',
'home.develop.re.git': 'Git Project',
//-------------------------------- devops -------------------------------- //-------------------------------- devops --------------------------------
// devops // devops
......
...@@ -160,4 +160,27 @@ export default { ...@@ -160,4 +160,27 @@ export default {
'global.notifaction.iknow': '我知道了', 'global.notifaction.iknow': '我知道了',
'global.notifaction.full-error': '完整错误信息', 'global.notifaction.full-error': '完整错误信息',
'global.item': '个',
'global.bout': '次',
'global.week.sunday': '星期日',
'global.week.monday': '星期一',
'global.week.tuesday': '星期二',
'global.week.wednesday': '星期三',
'global.week.thursday': '星期四',
'global.week.friday': '星期五',
'global.week.saturday': '星期六',
'global.month.january': '一月',
'global.month.february': '二月',
'global.month.march': '三月',
'global.month.april': '四月',
'global.month.may': '五月',
'global.month.june': '六月',
'global.month.july': '七月',
'global.month.august': '八月',
'global.month.september': '九月',
'global.month.october': '十月',
'global.month.november': '十一月',
'global.month.december': '十二月',
}; };
...@@ -48,6 +48,40 @@ export default { ...@@ -48,6 +48,40 @@ export default {
'about.communityRules.4': '群提问题请礼貌并且说明【版本、执行模式、操作描述、截图】。', 'about.communityRules.4': '群提问题请礼貌并且说明【版本、执行模式、操作描述、截图】。',
'about.communityRules.5': ' 登记谁在使用 Dinky,可进入企业用户群提供技术支持。', 'about.communityRules.5': ' 登记谁在使用 Dinky,可进入企业用户群提供技术支持。',
//-------------------------------- Home --------------------------------
'home.job.metrics': ' 作业监控',
'home.job.running.status': '当前作业运行状态',
'home.server.load': '服务器负载',
'home.job.running': '当前运行',
'home.job.finished': '今日完成',
'home.job.recovery': '今日恢复',
'home.job.online': '今日上线',
'home.job.failed': '今日失败',
'home.job.recovery.rate': '恢复占比',
'home.job.running.dayonday': '日环比',
'home.job.instance': '任务实例',
'home.server.load.excellent': '优秀',
'home.server.load.good': '良好',
'home.server.load.bad': '较差',
'home.job.failed.unhandle': '当前未处理失败',
'home.job.failed.handle': '已处理',
'home.job.failed.rank': '排名',
'home.job.failed.name': '任务名称',
'home.job.failed.time': '已异常时间',
'home.develop': ' 数据开发',
'home.job.batch': '批作业',
'home.job.stream': '流作业',
'home.job.total': '作业数',
'home.job.type': '作业类型',
'home.job.rate': '作业占比',
'home.develop.re.ci': 'Flink 集群实例',
'home.develop.re.cc': '集群配置',
'home.develop.re.ds': '数据源',
'home.develop.re.gv': '全局变量',
'home.develop.re.ai': '告警实例',
'home.develop.re.ag': '告警组',
'home.develop.re.git': 'Git 项目',
//-------------------------------- devops -------------------------------- //-------------------------------- devops --------------------------------
// devops // devops
......
/*
*
* 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 React from "react";
import {ProCard, StatisticCard} from "@ant-design/pro-components";
import CountFormatter from "@/components/CountFormatter";
import {BatchJobIcon, StreamingJobIcon} from "@/components/Icons/HomeIcon";
import {imgStyle} from "@/pages/Home/constants";
import {l} from "@/utils/intl";
export const BatchStreamProportion: React.FC = () => {
return <ProCard split={'vertical'} size={'small'}>
<StatisticCard.Group bodyStyle={{alignContent:'center'}}>
<StatisticCard
statistic={{
title: l('home.job.batch'),
value: 11,
suffix: l('global.item'),
icon: <BatchJobIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/>
}}
/>
<StatisticCard.Divider/>
<StatisticCard
statistic={{
title: l('home.job.stream'),
value: 233,
suffix: l('global.item'),
icon: <StreamingJobIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/>
}}
/>
</StatisticCard.Group>
</ProCard>;
}
export default BatchStreamProportion;
\ No newline at end of file
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
*/ */
import React, {useState, useEffect} from 'react'; import React, {useState, useEffect} from 'react';
import {Heatmap, G2} from '@ant-design/plots'; import {Heatmap, G2, HeatmapConfig} from '@ant-design/plots';
import {WEEK_LIST} from "@/pages/Home/constants";
const DevHeatmap = () => { const DevHeatmap = () => {
const [data, setData] = useState([]); const [data, setData] = useState([]);
...@@ -89,7 +90,7 @@ const DevHeatmap = () => { ...@@ -89,7 +90,7 @@ const DevHeatmap = () => {
return group; return group;
}, },
}); });
const config = { const config :HeatmapConfig = {
data, data,
height: 200, height: 200,
autoFit: false, autoFit: false,
...@@ -101,7 +102,7 @@ const DevHeatmap = () => { ...@@ -101,7 +102,7 @@ const DevHeatmap = () => {
meta: { meta: {
day: { day: {
type: 'cat', type: 'cat',
values: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'], values: WEEK_LIST,
}, },
week: { week: {
type: 'cat', type: 'cat',
......
...@@ -20,12 +20,19 @@ ...@@ -20,12 +20,19 @@
import React, {useState, useEffect} from 'react'; import React, {useState, useEffect} from 'react';
import {StatisticCard} from '@ant-design/pro-components'; import {StatisticCard} from '@ant-design/pro-components';
import RcResizeObserver from 'rc-resize-observer'; import RcResizeObserver from 'rc-resize-observer';
import {
AlertGroupIcon,
AlertInstanceIcon, ClusterConfigIcon,
ClusterInstanceIcon,
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";
const imgStyle = {
display: 'block',
width: 42,
height: 42,
};
const ResourceView = () => { const ResourceView = () => {
...@@ -41,86 +48,67 @@ const ResourceView = () => { ...@@ -41,86 +48,67 @@ const ResourceView = () => {
<StatisticCard.Group direction={responsive ? 'column' : 'row'}> <StatisticCard.Group direction={responsive ? 'column' : 'row'}>
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: 'Flink 集群实例', title: l('home.develop.re.ci'),
value: 2176, value: 2176,
icon: ( icon:<ClusterInstanceIcon style={imgStyle}/>,
<img formatter: (value)=> <CountFormatter value={Number(value)}/>
style={imgStyle}
src="https://gw.alipayobjects.com/mdn/rms_7bc6d8/afts/img/A*dr_0RKvVzVwAAAAAAAAAAABkARQnAQ"
alt="icon"
/>
),
}} }}
/> />
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: '集群配置', title: l('home.develop.re.cc'),
value: 475, value: 475,
icon: ( icon: <ClusterConfigIcon style={imgStyle}/>,
<img formatter: (value)=> <CountFormatter value={Number(value)}/>
style={imgStyle}
src="https://gw.alipayobjects.com/mdn/rms_7bc6d8/afts/img/A*-jVKQJgA1UgAAAAAAAAAAABkARQnAQ"
alt="icon"
/>
),
}} }}
/> />
</StatisticCard.Group> </StatisticCard.Group>
<StatisticCard.Group direction={responsive ? 'column' : 'row'}> <StatisticCard.Group direction={responsive ? 'column' : 'row'}>
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: '数据源', title: l('home.develop.re.ds'),
value: 87, value: 87,
icon: ( icon: <DatabaseIcon style={imgStyle}/>,
<img formatter: (value)=> <CountFormatter value={Number(value)}/>
style={imgStyle}
src="https://gw.alipayobjects.com/mdn/rms_7bc6d8/afts/img/A*FPlYQoTNlBEAAAAAAAAAAABkARQnAQ"
alt="icon"
/>
),
}} }}
/> />
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: '全局变量', title: l('home.develop.re.gv'),
value: 1754, value: 1754,
icon: ( icon: <GlobalVarIcon style={imgStyle}/>,
<img formatter: (value)=> <CountFormatter value={Number(value)}/>
style={imgStyle}
src="https://gw.alipayobjects.com/mdn/rms_7bc6d8/afts/img/A*pUkAQpefcx8AAAAAAAAAAABkARQnAQ"
alt="icon"
/>
),
}} }}
/> />
</StatisticCard.Group> </StatisticCard.Group>
<StatisticCard.Group direction={responsive ? 'column' : 'row'}> <StatisticCard.Group direction={responsive ? 'column' : 'row'}>
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: '告警实例', title: l('home.develop.re.ai'),
value: 87, value: 87,
icon: ( icon: <AlertInstanceIcon style={imgStyle}/>,
<img formatter: (value)=> <CountFormatter value={Number(value)}/>
style={imgStyle}
src="https://gw.alipayobjects.com/mdn/rms_7bc6d8/afts/img/A*FPlYQoTNlBEAAAAAAAAAAABkARQnAQ"
alt="icon"
/>
),
}} }}
/> />
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: '告警组', title: l('home.develop.re.ag'),
value: 1754, value: 1754,
icon: ( icon: <AlertGroupIcon style={imgStyle}/>,
<img formatter: (value)=> <CountFormatter value={Number(value)}/>
style={imgStyle} }}
src="https://gw.alipayobjects.com/mdn/rms_7bc6d8/afts/img/A*pUkAQpefcx8AAAAAAAAAAABkARQnAQ"
alt="icon"
/> />
), </StatisticCard.Group>
<StatisticCard.Group direction={responsive ? 'column' : 'row'}>
<StatisticCard
statistic={{
title: l('home.develop.re.git'),
value: 220,
icon: <GitIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/>
}} }}
/> />
</StatisticCard.Group> </StatisticCard.Group>
</RcResizeObserver> </RcResizeObserver>
); );
......
...@@ -18,51 +18,65 @@ ...@@ -18,51 +18,65 @@
*/ */
import React from 'react'; import React from 'react';
import {Radar} from '@ant-design/plots'; import {Radar, RadarConfig} from '@ant-design/plots';
import {l} from "@/utils/intl";
type TaskDialectSummary = {
type: string;
count: number;
rate: number;
}
const TaskDialectRadar = () => { const TaskDialectRadar = () => {
// 数据更新于 2021.01.09 // 数据更新于 2021.01.09
const data = [ const data : TaskDialectSummary[] = [
{ {
name: 'FlinkSQL', type: 'FlinkSQL',
star: 10371, count: 10371,
rate: 0.01,
}, },
{ {
name: 'FlinkJar', type: 'FlinkJar',
star: 7380, count: 7380,
rate: 0.01,
}, },
{ {
name: 'K8SApplication', type: 'K8SApplication',
star: 7414, count: 7414,
rate: 0.01,
}, },
{ {
name: 'Doris', type: 'Doris',
star: 2140, count: 2140,
rate: 0.01,
}, },
{ {
name: 'FlinkSQLEnv', type: 'FlinkSQLEnv',
star: 660, count: 660,
rate: 0.01,
}, },
{ {
name: 'Java', type: 'Java',
star: 885, count: 885,
rate: 0.01,
}, },
{ {
name: 'Mysql', type: 'Mysql',
star: 1626, count: 1626,
rate: 0.01,
}, },
]; ];
const config = { const config:RadarConfig = {
data: data.map((d) => ({...d, star: Math.sqrt(d.star)})), data: data.map((d) => ({...d, count: Math.sqrt(d.count)})),
xField: 'name', xField: 'type',
yField: 'star', yField: 'count',
autoFit: true,
appendPadding: [0, 10, 0, 10], appendPadding: [0, 10, 0, 10],
meta: { meta: {
star: { count: {
alias: 'star 数量', alias: l('home.job.total'),
min: 0, min: 0,
nice: true, nice: true,
formatter: (v) => Number(v).toFixed(2), formatter: (v) => Number(v),
}, },
}, },
xAxis: { xAxis: {
......
...@@ -18,12 +18,14 @@ ...@@ -18,12 +18,14 @@
*/ */
import {ProCard} from '@ant-design/pro-components'; import {ProCard} from '@ant-design/pro-components';
import {Badge, Col, Row} from 'antd'; import {Badge} from 'antd';
import RcResizeObserver from 'rc-resize-observer'; import RcResizeObserver from 'rc-resize-observer';
import React, {useState} from 'react'; import React, {useState} from 'react';
import DevHeatmap from "@/pages/Home/DevOverView/DevHeatmap"; import DevHeatmap from "@/pages/Home/DevOverView/DevHeatmap";
import TaskDialectRadar from "@/pages/Home/DevOverView/TaskDialectRadar"; import TaskDialectRadar from "@/pages/Home/DevOverView/TaskDialectRadar";
import ResourceView from "@/pages/Home/DevOverView/ResourceView"; import ResourceView from "@/pages/Home/DevOverView/ResourceView";
import BatchStreamProportion from "@/pages/Home/DevOverView/BatchStreamProportion";
import {l} from "@/utils/intl";
const DevOverView: React.FC = () => { const DevOverView: React.FC = () => {
const [split, setSplit] = useState<'vertical' | 'horizontal' | undefined>('vertical'); const [split, setSplit] = useState<'vertical' | 'horizontal' | undefined>('vertical');
...@@ -36,23 +38,29 @@ const DevOverView: React.FC = () => { ...@@ -36,23 +38,29 @@ const DevOverView: React.FC = () => {
}} }}
> >
<ProCard <ProCard
title={<><Badge status="processing"/> 数据开发</>} title={<><Badge status="processing"/>{l('home.develop')}</>}
headerBordered headerBordered
bordered bordered
size="small" size="small"
split={split} split={split}
> >
<Row> <ProCard split="vertical">
<Col span={12}> <ProCard split="horizontal" colSpan={'40%'}>
<ProCard>
<BatchStreamProportion/>
</ProCard>
<ProCard >
<DevHeatmap/> <DevHeatmap/>
</Col> </ProCard>
<Col span={6}> </ProCard>
<ProCard colSpan={'30%'} >
<TaskDialectRadar/> <TaskDialectRadar/>
</Col> </ProCard>
<Col span={6}> <ProCard>
<ResourceView/> <ResourceView/>
</Col> </ProCard>
</Row> </ProCard>
</ProCard> </ProCard>
</RcResizeObserver> </RcResizeObserver>
); );
......
...@@ -19,10 +19,12 @@ ...@@ -19,10 +19,12 @@
import {Space, Table} from 'antd'; import {Space, Table} from 'antd';
import React, {useState} from 'react'; import React, {useState} from 'react';
import type {ColumnsType} from 'antd/es/table'; import {ProColumns, ProTable, StatisticCard} from "@ant-design/pro-components";
import {StatisticCard} from "@ant-design/pro-components";
import styles from "@/global.less"; import styles from "@/global.less";
import {Progress} from "@ant-design/plots"; import {Progress, ProgressConfig} from "@ant-design/plots";
import CountFormatter from "@/components/CountFormatter";
import {l} from "@/utils/intl";
import {parseMilliSecondStr, parseSecondStr} from "@/utils/function";
const {Statistic} = StatisticCard; const {Statistic} = StatisticCard;
...@@ -34,73 +36,93 @@ interface DataType { ...@@ -34,73 +36,93 @@ interface DataType {
const JobErrorView: React.FC = () => { const JobErrorView: React.FC = () => {
const [data, setData] = useState([ const [ data, setData] = useState<DataType[]>([
{ {
"rank": 1, "rank": 1,
"name": '任务1', "name": '任务1',
"value": '10 分钟' "value": 10000
}, },
{ {
"rank": 2, "rank": 2,
"name": '任务2', "name": '任务2',
"value": '10 分钟' "value": 20000
}, },
{ {
"rank": 3, "rank": 3,
"name": '任务3', "name": '任务3',
"value": '10 分钟' "value": 30000
}, },
{ {
"rank": 4, "rank": 4,
"name": '任务4', "name": '任务4',
"value": '10 分钟' "value": 40000
}, },
{ {
"rank": 5, "rank": 5,
"name": '任务5', "name": '任务5',
"value": '10 分钟' "value": 50000
},
{
"rank": 6,
"name": '任务6',
"value": 60000
},
{
"rank": 7,
"name": '任务7',
"value": 70000
},
{
"rank": 8,
"name": '任务8',
"value": 80000
}, },
]); ]);
const columns: ColumnsType<DataType> = [ const columns: ProColumns<DataType>[] = [
{ {
title: '排名', title: l('home.job.failed.rank'),
dataIndex: 'rank', dataIndex: 'rank',
valueType: 'indexBorder',
}, },
{ {
title: '任务名', title: l('home.job.failed.name'),
dataIndex: 'name', dataIndex: 'name',
}, },
{ {
title: '已异常时间', title: l('home.job.failed.time'),
dataIndex: 'value', dataIndex: 'value',
render:(_:any,record: DataType) => {
return <>{parseMilliSecondStr(record.value)}</>
}
}, },
]; ];
const config = { const config : ProgressConfig = {
height: 50, height: 50,
width: 200, width: 200,
autoFit: false, autoFit: false,
percent: 0.7, percent: 0.7,
color: ['#5B8FF9', '#E8EDF3'], color: ['#5B8FF9', '#acaeb0'],
}; };
return <> return <>
<StatisticCard <StatisticCard
chartPlacement="right" chartPlacement="right"
statistic={{ statistic={{
title: '当前未处理失败', title: l('home.job.failed.unhandle'),
value: 3, value: 3,
suffix: '个', suffix: l('global.item'),
formatter: (value)=> <CountFormatter value={Number(value)}/>,
description: ( description: (
<Space> <Space>
<Statistic <Statistic
title="今日失败" title={l('home.job.failed')}
value='10 ' value='10 '
suffix='个' suffix={l('global.item')}
/> />
<Statistic <Statistic
title="已处理" title={l('home.job.failed.handle')}
value="70%" value="70%"
/> />
</Space> </Space>
...@@ -112,7 +134,15 @@ const JobErrorView: React.FC = () => { ...@@ -112,7 +134,15 @@ const JobErrorView: React.FC = () => {
</div> </div>
} }
/> />
<Table columns={columns} dataSource={data} pagination={false} size="small"/> <ProTable
columns={columns}
scroll={{y: 230}}
dataSource={data}
search={false}
toolBarRender={false}
pagination={false}
size="small"
/>
</>; </>;
}; };
......
...@@ -19,21 +19,23 @@ ...@@ -19,21 +19,23 @@
import {StatisticCard} from '@ant-design/pro-components'; import {StatisticCard} from '@ant-design/pro-components';
import React from 'react'; import React from 'react';
import {TinyColumn} from '@ant-design/plots'; import {TinyColumn, TinyColumnConfig} from '@ant-design/plots';
import styles from "@/global.less"; import styles from "@/global.less";
import CountFormatter from "@/components/CountFormatter";
import {l} from "@/utils/intl";
const {Statistic} = StatisticCard; const {Statistic} = StatisticCard;
const JobFinishedView: React.FC = () => { const JobFinishedView: React.FC = () => {
const data = [274, 337, 81, 497, 666, 219, 269]; const data = [274, 337, 81, 497, 666, 219, 269];
const config = { const config :TinyColumnConfig = {
height: 80, height: 80,
width: 220, width: 220,
autoFit: false, autoFit: false,
data, data,
tooltip: { tooltip: {
customContent: function (x, data) { customContent: function (x: any, data: { data: { y: number; }; }[]) {
return `NO.${x}: ${data[0]?.data?.y.toFixed(2)}`; return `NO.${x}: ${data[0]?.data?.y.toFixed(2)}`;
}, },
}, },
...@@ -43,12 +45,13 @@ const JobFinishedView: React.FC = () => { ...@@ -43,12 +45,13 @@ const JobFinishedView: React.FC = () => {
<StatisticCard <StatisticCard
chartPlacement="right" chartPlacement="right"
statistic={{ statistic={{
title: '今日完成', title: l('home.job.finished'),
value: 123, value: 123,
suffix: '次', suffix: l('global.bout'),
formatter: (value)=> <CountFormatter value={Number(value)}/>,
description: ( description: (
<Statistic <Statistic
title="日环比" title={l('home.job.running.dayonday')}
value="3.57 %" value="3.57 %"
trend="up" trend="up"
/> />
......
...@@ -19,15 +19,17 @@ ...@@ -19,15 +19,17 @@
import {StatisticCard} from '@ant-design/pro-components'; import {StatisticCard} from '@ant-design/pro-components';
import React from 'react'; import React from 'react';
import {RingProgress} from '@ant-design/plots'; import {RingProgress, RingProgressConfig} from '@ant-design/plots';
import {Space} from "antd"; import {Space} from "antd";
import styles from '@/global.less'; import styles from '@/global.less';
import CountFormatter from "@/components/CountFormatter";
import {l} from "@/utils/intl";
const {Statistic} = StatisticCard; const {Statistic} = StatisticCard;
const JobRecoveryView: React.FC = () => { const JobRecoveryView: React.FC = () => {
const config = { const config : RingProgressConfig = {
height: 80, height: 80,
width: 80, width: 80,
autoFit: false, autoFit: false,
...@@ -39,18 +41,19 @@ const JobRecoveryView: React.FC = () => { ...@@ -39,18 +41,19 @@ const JobRecoveryView: React.FC = () => {
<StatisticCard <StatisticCard
chartPlacement="right" chartPlacement="right"
statistic={{ statistic={{
title: '今日恢复', title: l('home.job.recovery'),
value: 2, value: 2,
suffix: '个', suffix: l('global.item'),
formatter: (value)=> <CountFormatter value={Number(value)}/>,
description: ( description: (
<Space> <Space>
<Statistic <Statistic
title="今日上线" title={l('home.job.online')}
value='5 ' value='5 '
suffix='个' suffix={l('global.item')}
/> />
<Statistic <Statistic
title="恢复占比" title={l('home.job.recovery.rate')}
value="40 %" value="40 %"
/> />
</Space> </Space>
......
...@@ -19,8 +19,10 @@ ...@@ -19,8 +19,10 @@
import {StatisticCard} from '@ant-design/pro-components'; import {StatisticCard} from '@ant-design/pro-components';
import React from 'react'; import React from 'react';
import {TinyArea} from '@ant-design/plots'; import {TinyArea, TinyAreaConfig} from '@ant-design/plots';
import styles from "@/global.less"; import styles from "@/global.less";
import CountFormatter from "@/components/CountFormatter";
import {l} from "@/utils/intl";
const {Statistic} = StatisticCard; const {Statistic} = StatisticCard;
...@@ -29,7 +31,7 @@ const JobRunView: React.FC = () => { ...@@ -29,7 +31,7 @@ const JobRunView: React.FC = () => {
const data = [ const data = [
264, 417, 438, 887, 309, 397, 550, 575, 563, 430, 525, 592, 492, 467, 513, 546, 983, 340, 539, 243, 226, 192, 264, 417, 438, 887, 309, 397, 550, 575, 563, 430, 525, 592, 492, 467, 513, 546, 983, 340, 539, 243, 226, 192,
]; ];
const config = { const config:TinyAreaConfig = {
height: 80, height: 80,
width: 220, width: 220,
autoFit: false, autoFit: false,
...@@ -44,9 +46,10 @@ const JobRunView: React.FC = () => { ...@@ -44,9 +46,10 @@ const JobRunView: React.FC = () => {
<StatisticCard <StatisticCard
chartPlacement="right" chartPlacement="right"
statistic={{ statistic={{
title: '当前运行', title: l('home.job.running'),
value: 20, value: 20,
suffix: '个', suffix: l('global.item'),
formatter: (value)=> <CountFormatter value={Number(value)}/>,
description: ( description: (
<Statistic <Statistic
title="已守护" title="已守护"
......
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
*/ */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Pie } from '@ant-design/plots'; import {Pie, PieConfig} from '@ant-design/plots';
import {getStatusCount} from "@/pages/Home/service"; import {getStatusCount} from "@/pages/Home/service";
import {Home} from "@/types/Home/data"; import {Home} from "@/types/Home/data.d";
import {l} from "@/utils/intl";
const JobStatusPie = () => { const JobStatusPie = () => {
const [jobStatusData, setJobStatusData] = useState<Home.PieItem[]>([]); const [jobStatusData, setJobStatusData] = useState<Home.PieItem[]>([]);
...@@ -57,7 +57,7 @@ const JobStatusPie = () => { ...@@ -57,7 +57,7 @@ const JobStatusPie = () => {
}); });
}; };
const config = { const config :PieConfig = {
appendPadding: 10, appendPadding: 10,
data: jobStatusData, data: jobStatusData,
angleField: 'value', angleField: 'value',
...@@ -83,7 +83,7 @@ const JobStatusPie = () => { ...@@ -83,7 +83,7 @@ const JobStatusPie = () => {
style: { style: {
fontSize: '16px', fontSize: '16px',
}, },
customHtml: 'Job Instance', customHtml: ()=> l('home.job.instance')
}, },
content: { content: {
style: { style: {
...@@ -92,7 +92,7 @@ const JobStatusPie = () => { ...@@ -92,7 +92,7 @@ const JobStatusPie = () => {
textOverflow: 'ellipsis', textOverflow: 'ellipsis',
fontSize: '24px', fontSize: '24px',
}, },
content: jobCount, content: String(jobCount),
}, },
}, },
}; };
......
...@@ -18,14 +18,15 @@ ...@@ -18,14 +18,15 @@
*/ */
import React from 'react'; import React from 'react';
import { Gauge } from '@ant-design/plots'; import {Gauge, GaugeConfig} from '@ant-design/plots';
import {l} from "@/utils/intl";
const LoadScoreGauge = () => { const LoadScoreGauge = () => {
const ticks = [0, 1 / 3, 2 / 3, 1]; const ticks = [0, 1 / 3, 2 / 3, 1];
const color = ['#30BF78', '#FAAD14', '#F4664A']; const color = ['#30BF78', '#FAAD14', '#F4664A'];
const config = { const config: GaugeConfig = {
padding: 15, padding: 15,
percent: 0.25, percent: 0.25,
type: 'meter', type: 'meter',
...@@ -50,14 +51,13 @@ const LoadScoreGauge = () => { ...@@ -50,14 +51,13 @@ const LoadScoreGauge = () => {
title: { title: {
formatter: ({ percent }) => { formatter: ({ percent }) => {
if (percent < ticks[1]) { if (percent < ticks[1]) {
return 'Excellent'; return l('home.server.load.excellent');
} }
if (percent < ticks[2]) { if (percent < ticks[2]) {
return 'Good'; return l('home.server.load.good');
} }
return l('home.server.load.bad');
return 'Poor';
}, },
style: ({ percent }) => { style: ({ percent }) => {
return { return {
......
...@@ -27,8 +27,7 @@ import JobErrorView from "@/pages/Home/JobOverView/JobErrorView"; ...@@ -27,8 +27,7 @@ import JobErrorView from "@/pages/Home/JobOverView/JobErrorView";
import JobRunView from "@/pages/Home/JobOverView/JobRunView"; import JobRunView from "@/pages/Home/JobOverView/JobRunView";
import JobFinishedView from "@/pages/Home/JobOverView/JobFinishedView"; import JobFinishedView from "@/pages/Home/JobOverView/JobFinishedView";
import JobRecoveryView from "@/pages/Home/JobOverView/JobRecoveryView"; import JobRecoveryView from "@/pages/Home/JobOverView/JobRecoveryView";
import {l} from "@/utils/intl";
const {Statistic} = StatisticCard;
const JobOverView: React.FC = () => { const JobOverView: React.FC = () => {
const [split, setSplit] = useState<'vertical' | 'horizontal' | undefined>('vertical'); const [split, setSplit] = useState<'vertical' | 'horizontal' | undefined>('vertical');
...@@ -41,14 +40,13 @@ const JobOverView: React.FC = () => { ...@@ -41,14 +40,13 @@ const JobOverView: React.FC = () => {
}} }}
> >
<ProCard <ProCard
title={<><Badge status="processing"/> 作业监控</>} title={<><Badge status="processing"/>{l('home.job.metrics')}</>}
headerBordered headerBordered
bordered bordered
size="small" size="small"
split={split} split={split}
> >
<ProCard split={split}> <ProCard split={split}>
<ProCard split="horizontal">
<ProCard split="horizontal"> <ProCard split="horizontal">
<ProCard bodyStyle={{padding: '0 12px'}}> <ProCard bodyStyle={{padding: '0 12px'}}>
<JobRunView/> <JobRunView/>
...@@ -60,22 +58,18 @@ const JobOverView: React.FC = () => { ...@@ -60,22 +58,18 @@ const JobOverView: React.FC = () => {
<JobRecoveryView/> <JobRecoveryView/>
</ProCard> </ProCard>
</ProCard> </ProCard>
</ProCard> <ProCard title={l('home.job.running.status')}>
<ProCard title="当前作业运行状态">
<JobStatusPie/> <JobStatusPie/>
</ProCard> </ProCard>
</ProCard> </ProCard>
<ProCard split={split}> <ProCard split={split}>
<ProCard title="Dinky 负载状况"> <ProCard title={l('home.server.load')}>
<LoadScoreGauge/> <LoadScoreGauge/>
</ProCard> </ProCard>
<ProCard split="horizontal">
<ProCard split="horizontal"> <ProCard split="horizontal">
<JobErrorView/> <JobErrorView/>
</ProCard> </ProCard>
</ProCard> </ProCard>
</ProCard>
</ProCard> </ProCard>
</RcResizeObserver> </RcResizeObserver>
); );
......
/*
*
* 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 {l} from "@/utils/intl";
export const imgStyle = {
display: 'block',
width: 42,
height: 42,
};
export const MONTH_LIST :any = {
'01': l('global.month.january'),
'02': l('global.month.february'),
'03': l('global.month.march'),
'04': l('global.month.april'),
'05': l('global.month.may'),
'06': l('global.month.june'),
'07': l('global.month.july'),
'08': l('global.month.august'),
'09': l('global.month.september'),
'10': l('global.month.october'),
'11': l('global.month.november'),
'12': l('global.month.december'),
};
export const WEEK_LIST :any = [
l('global.week.sunday'),
l('global.week.monday'),
l('global.week.tuesday'),
l('global.week.wednesday'),
l('global.week.thursday'),
l('global.week.friday'),
l('global.week.saturday')
];
\ No newline at end of file
...@@ -345,6 +345,18 @@ export const parseSecondStr = (s_time: number) => { ...@@ -345,6 +345,18 @@ export const parseSecondStr = (s_time: number) => {
return time; return time;
}; };
/**
* Generate MilliSecond time string
* @param {number} second_time
* @returns {any}
*/
export function parseMilliSecondStr(second_time: number) {
if (((second_time / 1000) % 60) < 1) {
return second_time + l('global.time.millisecond');
}
return parseSecondStr(second_time / 1000);
}
/** /**
* build tree data * build tree data
......
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