-
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
Jan 30, 2024
1 parent
9c0e2e4
commit 1a314dc
Showing
7 changed files
with
225 additions
and
32 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,42 @@ | ||
.chart-donut { | ||
height: 105px; | ||
width: 105px; | ||
|
||
.pf-c-chart { | ||
.pf-c-chart-donut__label__title { | ||
font-size: 50px; // 20 // does not work | ||
background-color: blue; | ||
} | ||
} | ||
|
||
.pf-c-chart-donut__label__subtitle { | ||
font-size: 50px; // 12 // does not work | ||
fill: #6A6E73; | ||
background-color: green; | ||
} | ||
} | ||
|
||
.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; | ||
} | ||
} | ||
} | ||
|
||
// přidat mezeru pod chart když je menší obrazovka | ||
// ještě style z index.js | ||
// barva prázdného chart je nějaká čudná |
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
119 changes: 119 additions & 0 deletions
119
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,119 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { ChartDonut, ChartLabel, ChartLegend } 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, | ||
} = 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 | ||
constrainToVisibleArea | ||
data={chartData.map(d => ({ | ||
label: `${d.title} ${d.count} hosts`, | ||
y: d.count, | ||
}))} | ||
colorScale={total > 0 ? chartData.map(d => d.color) : ['#8A8D90']} | ||
subTitle={__('Systems')} | ||
title={chartDonutTitle} | ||
titleComponent={<ChartLabel />} | ||
subTitleComponent={<ChartLabel />} | ||
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} | ||
rowGu | ||
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 | ||
// style={{ | ||
// marginLeft: 8, | ||
// marginTop: 8, | ||
// }} | ||
> | ||
<DescriptionListGroup> | ||
<DescriptionListTerm | ||
// style={{ | ||
// fontWeight: 'normal', | ||
// }} | ||
> | ||
{__('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
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