-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes: fixes UI of infrastructure details page UI #1291 #1361
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,15 @@ const MAXIMUM_VALUE = 100; | |
*/ | ||
const CustomGauge = ({ progress = 0, radius = 70, strokeWidth = 15, threshold = 50 }) => { | ||
const theme = useTheme(); | ||
const BOX_STYLE = { | ||
borderRadius: "50%", | ||
boxShadow: "0px 2px 4px -3px #20202040", | ||
padding:"6px", | ||
alignItems:"center", | ||
display:"flex", | ||
backgroundColor:theme.palette.background.main | ||
}; | ||
|
||
// Calculate the length of the stroke for the circle | ||
const { circumference, totalSize, strokeLength } = useMemo( | ||
() => ({ | ||
|
@@ -62,6 +71,7 @@ const CustomGauge = ({ progress = 0, radius = 70, strokeWidth = 15, threshold = | |
className="radial-chart" | ||
width={radius} | ||
height={radius} | ||
sx={BOX_STYLE} | ||
> | ||
<svg | ||
viewBox={`0 0 ${totalSize} ${totalSize}`} | ||
|
@@ -70,7 +80,7 @@ const CustomGauge = ({ progress = 0, radius = 70, strokeWidth = 15, threshold = | |
> | ||
<circle | ||
className="radial-chart-base" | ||
stroke={theme.palette.background.fill} | ||
stroke={theme.palette.background.stroke} | ||
strokeWidth={strokeWidth} | ||
fill="none" | ||
cx={totalSize / 2} // Center the circle | ||
|
@@ -100,6 +110,7 @@ const CustomGauge = ({ progress = 0, radius = 70, strokeWidth = 15, threshold = | |
transform: "translate(-50%, -50%)", | ||
...theme.typography.body2, | ||
fill: theme.typography.body2.color, | ||
fontSize: "20px", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion That hardcoded font size is making me weak! Instead of hardcoding the font size, consider using the theme's typography system for better consistency. - fontSize: "20px",
+ fontSize: theme.typography.h6.fontSize,
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This font size should reference the project's fonts |
||
}} | ||
> | ||
{`${progressWithinRange.toFixed(1)}%`} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,9 @@ import { | |
import PropTypes from "prop-types"; | ||
|
||
const BASE_BOX_PADDING_VERTICAL = 4; | ||
const BASE_BOX_PADDING_HORIZONTAL = 8; | ||
const BASE_BOX_PADDING_HORIZONTAL = 4; | ||
const TYPOGRAPHY_PADDING = 8; | ||
const TEXT_FONT_SIZE = 13; | ||
pratikshelar546 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/** | ||
* Converts bytes to gigabytes | ||
* @param {number} bytes - Number of bytes to convert | ||
|
@@ -75,11 +76,12 @@ const BaseBox = ({ children, sx = {} }) => { | |
height: "100%", | ||
padding: `${theme.spacing(BASE_BOX_PADDING_VERTICAL)} ${theme.spacing(BASE_BOX_PADDING_HORIZONTAL)}`, | ||
minWidth: 200, | ||
width: 225, | ||
width: 200, | ||
backgroundColor: theme.palette.background.main, | ||
border: 1, | ||
borderStyle: "solid", | ||
borderColor: theme.palette.border.light, | ||
borderRadius: theme.spacing(2), | ||
...sx, | ||
}} | ||
> | ||
|
@@ -101,10 +103,25 @@ BaseBox.propTypes = { | |
* @returns {React.ReactElement} Stat box component | ||
*/ | ||
const StatBox = ({ heading, subHeading }) => { | ||
const theme = useTheme(); | ||
return ( | ||
<BaseBox> | ||
<Typography component="h2">{heading}</Typography> | ||
<Typography>{subHeading}</Typography> | ||
<BaseBox | ||
sx={{ | ||
padding: `${theme.spacing(8)} ${theme.spacing(6)}`, | ||
}} | ||
> | ||
<Typography | ||
component="h2" | ||
fontSize={TEXT_FONT_SIZE} | ||
> | ||
{heading} | ||
</Typography> | ||
<Typography | ||
fontSize="16px" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded values for font size are a no go, please reference font sizes from the theme |
||
fontWeight="600" | ||
> | ||
{subHeading} | ||
</Typography> | ||
</BaseBox> | ||
); | ||
}; | ||
|
@@ -127,41 +144,66 @@ StatBox.propTypes = { | |
*/ | ||
const GaugeBox = ({ value, heading, metricOne, valueOne, metricTwo, valueTwo }) => { | ||
const theme = useTheme(); | ||
|
||
const value_style = { | ||
width: " 80px", | ||
textAlign: "end", | ||
borderRadius: "4px", | ||
padding: "3px", | ||
backgroundColor: theme.palette.background.textCard, | ||
fontSize: TEXT_FONT_SIZE, | ||
fontWeight: "600" | ||
}; | ||
return ( | ||
<BaseBox> | ||
<Stack | ||
direction="column" | ||
gap={theme.spacing(2)} | ||
alignItems="center" | ||
> | ||
<CustomGauge | ||
progress={value} | ||
radius={100} | ||
color={theme.palette.primary.main} | ||
/> | ||
<Typography component="h2">{heading}</Typography> | ||
<Stack | ||
alignItems="center" | ||
width="100%" | ||
gap={theme.spacing(8)} | ||
padding={`${theme.spacing(14)} ${theme.spacing(5)} ${theme.spacing(7)} ${theme.spacing(5)}`} | ||
borderRadius={`${theme.spacing(4)} ${theme.spacing(4)} ${theme.spacing(0)} ${theme.spacing(0)}`} | ||
sx={{ backgroundColor: `${theme.palette.background.gauge}` }} | ||
> | ||
<CustomGauge | ||
progress={value} | ||
radius={120} | ||
color={theme.palette.primary.main} | ||
/> | ||
<Typography | ||
component="h2" | ||
fontWeight="600" | ||
fontSize={TEXT_FONT_SIZE} | ||
> | ||
{heading} | ||
</Typography> | ||
</Stack> | ||
<Box | ||
sx={{ | ||
width: "100%", | ||
borderTop: `1px solid ${theme.palette.border.light}`, | ||
padding: `${theme.spacing(6)} ${theme.spacing(3)} ${theme.spacing(3)} ${theme.spacing(3)}`, | ||
}} | ||
> | ||
<Stack | ||
justifyContent={"space-between"} | ||
direction="row" | ||
gap={theme.spacing(2)} | ||
> | ||
<Typography>{metricOne}</Typography> | ||
<Typography>{valueOne}</Typography> | ||
<Typography fontSize={TEXT_FONT_SIZE}>{metricOne} </Typography> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Font size should come from project's theme |
||
<Typography sx={value_style}>{valueOne}</Typography> | ||
</Stack> | ||
<Stack | ||
justifyContent={"space-between"} | ||
direction="row" | ||
marginTop={theme.spacing(3)} | ||
gap={theme.spacing(2)} | ||
> | ||
<Typography>{metricTwo}</Typography> | ||
<Typography>{valueTwo}</Typography> | ||
<Typography fontSize={TEXT_FONT_SIZE}>{metricTwo}</Typography> | ||
<Typography sx={value_style}>{valueTwo}</Typography> | ||
</Stack> | ||
</Box> | ||
</Stack> | ||
|
@@ -193,7 +235,7 @@ const InfrastructureDetails = () => { | |
const [monitor, setMonitor] = useState(null); | ||
const { authToken } = useSelector((state) => state.auth); | ||
const [dateRange, setDateRange] = useState("all"); | ||
const { statusColor, determineState } = useUtils(); | ||
const { statusColor, determineState, statusMsg } = useUtils(); | ||
// These calculations are needed because ResponsiveContainer | ||
// doesn't take padding of parent/siblings into account | ||
// when calculating height. | ||
|
@@ -482,27 +524,35 @@ const InfrastructureDetails = () => { | |
<Stack | ||
direction="row" | ||
gap={theme.spacing(8)} | ||
alignItems="center" | ||
> | ||
<Box> | ||
<PulseDot color={statusColor[determineState(monitor)]} /> | ||
</Box> | ||
<Typography | ||
alignSelf="end" | ||
alignSelf="center" | ||
component="h1" | ||
variant="h1" | ||
> | ||
{monitor.name} | ||
</Typography> | ||
<Typography alignSelf="end">{monitor.url || "..."}</Typography> | ||
<Typography alignSelf="center">{monitor.url || "..."}</Typography> | ||
<Box sx={{ flexGrow: 1 }} /> | ||
<Typography alignSelf="end"> | ||
<Typography | ||
alignSelf="center" | ||
color={statusColor[determineState(monitor)]} | ||
> | ||
{statusMsg[determineState(monitor)]} | ||
</Typography> | ||
<Typography alignSelf="center"> | ||
Checking every {formatDurationRounded(monitor?.interval)} | ||
</Typography> | ||
<Typography alignSelf="end"> | ||
<Typography alignSelf="center"> | ||
Last checked {formatDurationSplit(monitor?.lastChecked).time}{" "} | ||
{formatDurationSplit(monitor?.lastChecked).format} ago | ||
</Typography> | ||
</Stack> | ||
|
||
<Stack | ||
direction="row" | ||
flexWrap="wrap" | ||
|
@@ -544,8 +594,15 @@ const InfrastructureDetails = () => { | |
}} | ||
> | ||
{areaChartConfigs.map((config) => { | ||
console.log(config); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be removed |
||
|
||
Comment on lines
+597
to
+598
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove debug console.log statement Debug statements should not be committed to production code. Apply this change: - console.log(config);
- |
||
return ( | ||
<BaseBox key={`${config.type}-${config.diskIndex ?? ""}`}> | ||
<BaseBox | ||
key={`${config.type}-${config.diskIndex ?? ""}`} | ||
sx={{ | ||
padding: `${theme.spacing(8)} ${theme.spacing(6)}`, | ||
}} | ||
> | ||
<Typography | ||
component="h2" | ||
padding={theme.spacing(8)} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,10 @@ const typographyLevels = { | |
|
||
/* TODO Review color palette and semantic colors */ | ||
const paletteColors = { | ||
transparent: "#00000000", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we nee to add a transparent color? Background color 'transparent' would solve that, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can accommodate that request. However, I was utilizing a transparent color in the |
||
white: "#FFFFFF", | ||
white200:"#F6F6F6", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is basically the same as gray 100, use that instead |
||
grey25: "#FCFCFC", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is almost the same as gray 90, use that instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure |
||
gray50: "#FEFEFE", | ||
gray60: "#FEFDFE", | ||
gray70: "#FDFDFD", | ||
|
@@ -35,6 +38,7 @@ const paletteColors = { | |
gray880: "#0C0C0E", | ||
gray890: "#09090B", | ||
blueGray20: "#E8F0FE", | ||
blueGray50: "#CDE2FF", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please confirm color choices with @marcelluscaio There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a print of the element where this color is being applied? For the other colors, please use the ones that already exist, and instead of creating new references, use an existing reference for that color. The idea is that here we are not aware of where the color is being called (so avoid calling them 'stroke' or There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
blueGray150: "#667085", | ||
blueGray200: "#475467", | ||
blueGray400: "#344054", | ||
|
@@ -183,6 +187,18 @@ const semanticColors = { | |
light: paletteColors.gray100, | ||
dark: paletteColors.gray850, | ||
}, | ||
stroke: { | ||
light: paletteColors.blueGray50, | ||
dark: paletteColors.gray800, | ||
}, | ||
gauge: { | ||
light: paletteColors.grey25, | ||
dark: paletteColors.transparent | ||
}, | ||
textcard:{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
light:paletteColors.white200, | ||
dark:paletteColors.transparent | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again to be confirmed with @marcelluscaio |
||
}, | ||
text: { | ||
primary: { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Styling must be consistent throughout the app, the theme should be used to apply styles to something like this