Merge pull request #3136 from bluewave-labs/fix/various-ui-ux-fixes
fix: various UI/UX improvements for infrastructure pages
This commit is contained in:
7 files changed
+38
-33
No files matched your search
@@ -129,7 +129,9 @@ const CreateInfrastructureMonitor = () => {
|
|||||||
const onSubmit = async (event) => {
|
const onSubmit = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const form = buildForm(infrastructureMonitor, https);
|
const form = buildForm(infrastructureMonitor, https);
|
||||||
const error = validateForm(form);
|
// When editing, exclude URL from validation since it's disabled and can't be changed
|
||||||
|
const formToValidate = isCreate ? form : { ...form, url: monitor.url };
|
||||||
|
const error = validateForm(formToValidate);
|
||||||
if (error) {
|
if (error) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -205,14 +207,14 @@ const CreateInfrastructureMonitor = () => {
|
|||||||
<></>
|
<></>
|
||||||
)}
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
{!isCreate && (
|
{!isCreate && monitor && (
|
||||||
<MonitorStatusHeader
|
<MonitorStatusHeader
|
||||||
monitor={monitor}
|
monitor={monitor}
|
||||||
infrastructureMonitor={infrastructureMonitor}
|
infrastructureMonitor={infrastructureMonitor}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
{!isCreate && (
|
{!isCreate && monitor && (
|
||||||
<MonitorActionButtons
|
<MonitorActionButtons
|
||||||
monitor={monitor}
|
monitor={monitor}
|
||||||
isBusy={isBusy}
|
isBusy={isBusy}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import { useTheme } from "@emotion/react";
|
|||||||
import { useHardwareUtils } from "../../Hooks/useHardwareUtils.jsx";
|
import { useHardwareUtils } from "../../Hooks/useHardwareUtils.jsx";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
const BaseContainer = ({ children, sx = {} }) => {
|
const BaseContainer = ({ children, sx = {}, shouldExpand = false }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { getDimensions } = useHardwareUtils();
|
const { getDimensions } = useHardwareUtils();
|
||||||
return (
|
return (
|
||||||
@@ -22,7 +22,7 @@ const BaseContainer = ({ children, sx = {} }) => {
|
|||||||
sx={{
|
sx={{
|
||||||
padding: `${theme.spacing(getDimensions().baseBoxPaddingVertical)} ${theme.spacing(getDimensions().baseBoxPaddingHorizontal)}`,
|
padding: `${theme.spacing(getDimensions().baseBoxPaddingVertical)} ${theme.spacing(getDimensions().baseBoxPaddingHorizontal)}`,
|
||||||
minWidth: 200,
|
minWidth: 200,
|
||||||
width: 225,
|
width: shouldExpand ? "100%" : 225,
|
||||||
backgroundColor: theme.palette.primary.main,
|
backgroundColor: theme.palette.primary.main,
|
||||||
border: 1,
|
border: 1,
|
||||||
borderStyle: "solid",
|
borderStyle: "solid",
|
||||||
@@ -38,6 +38,7 @@ const BaseContainer = ({ children, sx = {} }) => {
|
|||||||
BaseContainer.propTypes = {
|
BaseContainer.propTypes = {
|
||||||
children: PropTypes.node.isRequired,
|
children: PropTypes.node.isRequired,
|
||||||
sx: PropTypes.object,
|
sx: PropTypes.object,
|
||||||
|
shouldExpand: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default BaseContainer;
|
export default BaseContainer;
|
||||||
@@ -17,21 +17,26 @@ const Gauge = ({
|
|||||||
valueThree,
|
valueThree,
|
||||||
metricFour,
|
metricFour,
|
||||||
valueFour,
|
valueFour,
|
||||||
|
shouldExpand = false,
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
const valueStyle = {
|
const valueStyle = {
|
||||||
borderRadius: theme.spacing(2),
|
borderRadius: theme.spacing(2),
|
||||||
backgroundColor: theme.palette.tertiary.main,
|
backgroundColor: theme.palette.tertiary.main,
|
||||||
width: "40%",
|
minWidth: "40%",
|
||||||
|
maxWidth: "60%",
|
||||||
mb: theme.spacing(2),
|
mb: theme.spacing(2),
|
||||||
mt: theme.spacing(2),
|
mt: theme.spacing(2),
|
||||||
pr: theme.spacing(2),
|
pr: theme.spacing(2),
|
||||||
textAlign: "right",
|
textAlign: "right",
|
||||||
|
overflow: "hidden",
|
||||||
|
textOverflow: "ellipsis",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseContainer>
|
<BaseContainer shouldExpand={shouldExpand}>
|
||||||
<Stack
|
<Stack
|
||||||
direction="column"
|
direction="column"
|
||||||
gap={theme.spacing(2)}
|
gap={theme.spacing(2)}
|
||||||
@@ -116,6 +121,7 @@ Gauge.propTypes = {
|
|||||||
valueThree: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
valueThree: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
||||||
metricFour: PropTypes.string,
|
metricFour: PropTypes.string,
|
||||||
valueFour: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
valueFour: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
||||||
|
shouldExpand: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Gauge;
|
export default Gauge;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
// Components
|
// Components
|
||||||
import { Stack } from "@mui/material";
|
import { Box } from "@mui/material";
|
||||||
import Gauge from "./Gauge.jsx";
|
import Gauge from "./Gauge.jsx";
|
||||||
import SkeletonLayout from "./skeleton.jsx";
|
import SkeletonLayout from "./skeleton.jsx";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
@@ -65,16 +65,23 @@ const Gauges = ({ isLoading = false, monitor }) => {
|
|||||||
valueTwo: formatBytes(disk.total_bytes, true),
|
valueTwo: formatBytes(disk.total_bytes, true),
|
||||||
metricThree: t("device"),
|
metricThree: t("device"),
|
||||||
valueThree: formatDeviceName(disk.device),
|
valueThree: formatDeviceName(disk.device),
|
||||||
metricFour: t("mountpoint"),
|
metricFour: t("mountedOn"),
|
||||||
valueFour: formatMountpoint(disk.mountpoint),
|
valueFour: formatMountpoint(disk.mountpoint),
|
||||||
})),
|
})),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Only expand gauges to fill row when there are 4 or more
|
||||||
|
const shouldExpand = gauges.length >= 4;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Box
|
||||||
direction="row"
|
sx={{
|
||||||
flexWrap="wrap"
|
display: "grid",
|
||||||
gap={theme.spacing(8)}
|
gridTemplateColumns: shouldExpand
|
||||||
|
? "repeat(auto-fill, minmax(200px, 1fr))"
|
||||||
|
: "repeat(auto-fill, 225px)",
|
||||||
|
gap: theme.spacing(4),
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{gauges.map((gauge) => {
|
{gauges.map((gauge) => {
|
||||||
return (
|
return (
|
||||||
@@ -90,10 +97,11 @@ const Gauges = ({ isLoading = false, monitor }) => {
|
|||||||
valueThree={gauge.valueThree}
|
valueThree={gauge.valueThree}
|
||||||
metricFour={gauge.metricFour}
|
metricFour={gauge.metricFour}
|
||||||
valueFour={gauge.valueFour}
|
valueFour={gauge.valueFour}
|
||||||
|
shouldExpand={shouldExpand}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</Stack>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -123,14 +123,7 @@ const useHardwareUtils = () => {
|
|||||||
const formatDeviceName = (device) => {
|
const formatDeviceName = (device) => {
|
||||||
const deviceStr = String(device || "");
|
const deviceStr = String(device || "");
|
||||||
|
|
||||||
// Extract the last part of the path (after last '/')
|
// Show full device path
|
||||||
const parts = deviceStr.split("/");
|
|
||||||
const lastPart = parts[parts.length - 1];
|
|
||||||
|
|
||||||
// If there's more than one part, show with "..." prefix
|
|
||||||
const displayText = parts.length > 1 ? `.../${lastPart}` : deviceStr;
|
|
||||||
|
|
||||||
// Always show tooltip with full device path
|
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={deviceStr}
|
title={deviceStr}
|
||||||
@@ -149,7 +142,7 @@ const useHardwareUtils = () => {
|
|||||||
maxWidth: "100%",
|
maxWidth: "100%",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{displayText}
|
{deviceStr}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
@@ -181,14 +174,7 @@ const useHardwareUtils = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract the last part of the path (after last '/')
|
// Show full mountpoint path
|
||||||
const parts = mountpointStr.split("/");
|
|
||||||
const lastPart = parts[parts.length - 1];
|
|
||||||
|
|
||||||
// If there's more than one part, show with "..." prefix
|
|
||||||
const displayText = parts.length > 1 ? `.../${lastPart}` : mountpointStr;
|
|
||||||
|
|
||||||
// Always show tooltip with full mountpoint path
|
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={mountpointStr}
|
title={mountpointStr}
|
||||||
@@ -207,7 +193,7 @@ const useHardwareUtils = () => {
|
|||||||
maxWidth: "100%",
|
maxWidth: "100%",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{displayText}
|
{mountpointStr}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -193,6 +193,8 @@
|
|||||||
"total": "Total",
|
"total": "Total",
|
||||||
"cores": "Cores",
|
"cores": "Cores",
|
||||||
"frequency": "Frequency",
|
"frequency": "Frequency",
|
||||||
|
"device": "Device",
|
||||||
|
"mountedOn": "Mounted on",
|
||||||
"status": "Status",
|
"status": "Status",
|
||||||
"cpuPhysical": "CPU (Physical)",
|
"cpuPhysical": "CPU (Physical)",
|
||||||
"cpuLogical": "CPU (Logical)",
|
"cpuLogical": "CPU (Logical)",
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class MonitorController {
|
|||||||
await getHardwareDetailsByIdQueryValidation.validateAsync(req.query);
|
await getHardwareDetailsByIdQueryValidation.validateAsync(req.query);
|
||||||
|
|
||||||
const monitorId = requireString(req?.params?.monitorId, "Monitor ID");
|
const monitorId = requireString(req?.params?.monitorId, "Monitor ID");
|
||||||
const dateRange = requireString(req?.query?.dateRange, "dateRange");
|
const dateRange = optionalString(req?.query?.dateRange, "dateRange") || "recent";
|
||||||
const teamId = requireTeamId(req?.user?.teamId);
|
const teamId = requireTeamId(req?.user?.teamId);
|
||||||
|
|
||||||
const monitor = await this.monitorService.getHardwareDetailsById({
|
const monitor = await this.monitorService.getHardwareDetailsById({
|
||||||
|
|||||||
Reference in new issue
Block a user