-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #37122 - Update system status chart in job invocations detail page
- Loading branch information
kmalyjur
committed
Feb 5, 2024
1 parent
45c0639
commit 9da75ee
Showing
6 changed files
with
217 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
.chart-donut { | ||
height: 105px; | ||
width: 105px; | ||
margin-bottom: 15px; | ||
|
||
.chart-title tspan { | ||
font-size: 20px !important; | ||
} | ||
|
||
.chart-subtitle tspan { | ||
font-size: 12px !important; | ||
fill: #6A6E73 !important; | ||
} | ||
} | ||
|
||
.chart-legend { | ||
height: 105px; | ||
width: 270px; | ||
|
||
.legend-title { | ||
font-weight: bold; | ||
font-size: 14px; | ||
margin-left: 8px; | ||
margin-bottom: 0; | ||
} | ||
|
||
.pf-c-description-list { | ||
margin-left: 8px; | ||
margin-top: 8px; | ||
|
||
.pf-c-description-list__term .pf-c-description-list__text { | ||
font-weight: normal; | ||
} | ||
} | ||
} | ||
|
||
.pf-c-divider { | ||
max-height: 105px !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
webpack/JobInvocationDetail/JobInvocationSystemStatusChart.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { | ||
ChartDonut, | ||
ChartLabel, | ||
ChartLegend, | ||
ChartTooltip, | ||
} from '@patternfly/react-charts'; | ||
import { | ||
DescriptionList, | ||
DescriptionListTerm, | ||
DescriptionListGroup, | ||
DescriptionListDescription, | ||
FlexItem, | ||
Text, | ||
} from '@patternfly/react-core'; | ||
import { translate as __ } from 'foremanReact/common/I18n'; | ||
import './JobInvocationDetail.scss'; | ||
|
||
const JobInvocationSystemStatusChart = ({ | ||
data, | ||
isAlreadyStarted, | ||
formattedStartDate, | ||
}) => { | ||
const { | ||
succeeded, | ||
failed, | ||
pending, | ||
cancelled, | ||
total, | ||
total_hosts: totalHosts, // includes scheduled | ||
} = data; | ||
const chartData = [ | ||
{ title: __('Succeeded:'), count: succeeded, color: '#3E8635' }, | ||
{ title: __('Failed:'), count: failed, color: '#C9190B' }, | ||
{ title: __('In Progress:'), count: pending, color: '#2B9AF3' }, | ||
{ title: __('Canceled:'), count: cancelled, color: '#6A6E73' }, | ||
]; | ||
const chartDonutTitle = () => { | ||
if (total > 0) return `${succeeded.toString()}/${total}`; | ||
if (totalHosts > 0) return `0/${totalHosts}`; | ||
return '0'; | ||
}; | ||
|
||
return ( | ||
<> | ||
<FlexItem className="chart-donut"> | ||
<ChartDonut | ||
allowTooltip | ||
constrainToVisibleArea | ||
data={ | ||
total > 0 | ||
? chartData.map(d => ({ | ||
label: `${d.title} ${d.count} hosts`, | ||
y: d.count, | ||
})) | ||
: [{ label: `Scheduled: ${totalHosts} hosts`, y: 1 }] | ||
} | ||
colorScale={total > 0 ? chartData.map(d => d.color) : ['#8A8D90']} | ||
labelComponent={ | ||
<ChartTooltip pointerLength={0} constrainToVisibleArea /> | ||
} | ||
title={chartDonutTitle} | ||
titleComponent={<ChartLabel className="chart-title" />} | ||
subTitle={__('Systems')} | ||
subTitleComponent={<ChartLabel className="chart-subtitle" />} | ||
padding={{ | ||
bottom: 0, | ||
left: 0, | ||
right: 0, | ||
top: 0, | ||
}} | ||
width={105} | ||
height={105} | ||
/> | ||
</FlexItem> | ||
<FlexItem className="chart-legend"> | ||
<Text className="legend-title">{__('System status')}</Text> | ||
{isAlreadyStarted ? ( | ||
<ChartLegend | ||
orientation="vertical" | ||
itemsPerRow={2} | ||
gutter={25} | ||
rowGutter={7} | ||
padding={{ | ||
bottom: 0, | ||
left: 15, | ||
right: 0, | ||
top: 0, | ||
}} | ||
data={chartData.map(d => ({ | ||
name: `${d.title} ${d.count}`, | ||
symbol: { type: 'circle' }, | ||
}))} | ||
colorScale={chartData.map(d => d.color)} | ||
width={270} | ||
height={105} | ||
/> | ||
) : ( | ||
<DescriptionList> | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>{__('Scheduled at:')}</DescriptionListTerm> | ||
<DescriptionListDescription> | ||
{formattedStartDate} | ||
</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
</DescriptionList> | ||
)} | ||
</FlexItem> | ||
</> | ||
); | ||
}; | ||
|
||
JobInvocationSystemStatusChart.propTypes = { | ||
data: PropTypes.object.isRequired, | ||
isAlreadyStarted: PropTypes.bool.isRequired, | ||
formattedStartDate: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default JobInvocationSystemStatusChart; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters