Prettier Adjustment
This commit is contained in:
1 parent
607944988b
commit
1347ccda89
2 files changed
+163
-163
No files matched your search
@@ -124,84 +124,84 @@ ColoredLabel.propTypes = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const StatusLabel = ({ status, text, hasDot = true, customStyles }) => {
|
const StatusLabel = ({ status, text, hasDot = true, customStyles }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const colors = {
|
const colors = {
|
||||||
up: {
|
up: {
|
||||||
dotColor: theme.palette.success.main,
|
dotColor: theme.palette.success.main,
|
||||||
bgColor: theme.palette.success.bg,
|
bgColor: theme.palette.success.bg,
|
||||||
borderColor: theme.palette.success.light,
|
borderColor: theme.palette.success.light,
|
||||||
},
|
},
|
||||||
down: {
|
down: {
|
||||||
dotColor: theme.palette.error.text,
|
dotColor: theme.palette.error.text,
|
||||||
bgColor: theme.palette.error.bg,
|
bgColor: theme.palette.error.bg,
|
||||||
borderColor: theme.palette.error.light,
|
borderColor: theme.palette.error.light,
|
||||||
},
|
},
|
||||||
paused: {
|
paused: {
|
||||||
dotColor: theme.palette.warning.main,
|
dotColor: theme.palette.warning.main,
|
||||||
bgColor: theme.palette.warning.bg,
|
bgColor: theme.palette.warning.bg,
|
||||||
borderColor: theme.palette.warning.light,
|
borderColor: theme.palette.warning.light,
|
||||||
},
|
},
|
||||||
pending: {
|
pending: {
|
||||||
dotColor: theme.palette.warning.main,
|
dotColor: theme.palette.warning.main,
|
||||||
bgColor: theme.palette.warning.bg,
|
bgColor: theme.palette.warning.bg,
|
||||||
borderColor: theme.palette.warning.light,
|
borderColor: theme.palette.warning.light,
|
||||||
},
|
},
|
||||||
400: {
|
400: {
|
||||||
dotColor: theme.palette.warning.main,
|
dotColor: theme.palette.warning.main,
|
||||||
bgColor: theme.palette.warning.bg,
|
bgColor: theme.palette.warning.bg,
|
||||||
borderColor: theme.palette.warning.light,
|
borderColor: theme.palette.warning.light,
|
||||||
},
|
},
|
||||||
500: {
|
500: {
|
||||||
dotColor: theme.palette.warning.main,
|
dotColor: theme.palette.warning.main,
|
||||||
bgColor: theme.palette.warning.bg,
|
bgColor: theme.palette.warning.bg,
|
||||||
borderColor: theme.palette.warning.light,
|
borderColor: theme.palette.warning.light,
|
||||||
},
|
},
|
||||||
"cannot resolve": {
|
"cannot resolve": {
|
||||||
dotColor: theme.palette.unresolved.main,
|
dotColor: theme.palette.unresolved.main,
|
||||||
bgColor: theme.palette.unresolved.bg,
|
bgColor: theme.palette.unresolved.bg,
|
||||||
borderColor: theme.palette.unresolved.light,
|
borderColor: theme.palette.unresolved.light,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Look up the color for the status
|
// Look up the color for the status
|
||||||
const { borderColor, bgColor, dotColor } = colors[status] || colors["cannot resolve"];
|
const { borderColor, bgColor, dotColor } = colors[status] || colors["cannot resolve"];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseLabel
|
<BaseLabel
|
||||||
label={text}
|
label={text}
|
||||||
styles={{
|
styles={{
|
||||||
color: dotColor,
|
color: dotColor,
|
||||||
backgroundColor: bgColor,
|
backgroundColor: bgColor,
|
||||||
borderColor: borderColor,
|
borderColor: borderColor,
|
||||||
...customStyles,
|
...customStyles,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{hasDot && (
|
{hasDot && (
|
||||||
<Box
|
<Box
|
||||||
width={7}
|
width={7}
|
||||||
height={7}
|
height={7}
|
||||||
bgcolor={dotColor}
|
bgcolor={dotColor}
|
||||||
borderRadius="50%"
|
borderRadius="50%"
|
||||||
marginRight="5px"
|
marginRight="5px"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</BaseLabel>
|
</BaseLabel>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
StatusLabel.propTypes = {
|
StatusLabel.propTypes = {
|
||||||
status: PropTypes.oneOf([
|
status: PropTypes.oneOf([
|
||||||
"up",
|
"up",
|
||||||
"down",
|
"down",
|
||||||
"paused",
|
"paused",
|
||||||
"pending",
|
"pending",
|
||||||
"400",
|
"400",
|
||||||
"500",
|
"500",
|
||||||
"cannot resolve",
|
"cannot resolve",
|
||||||
]),
|
]),
|
||||||
text: PropTypes.string,
|
text: PropTypes.string,
|
||||||
hasDot: PropTypes.bool,
|
hasDot: PropTypes.bool,
|
||||||
customStyles: PropTypes.object,
|
customStyles: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
export { ColoredLabel, StatusLabel };
|
export { ColoredLabel, StatusLabel };
|
||||||
@@ -129,97 +129,97 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
|||||||
p: theme.spacing(30),
|
p: theme.spacing(30),
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{checks?.length === 0 && selectedMonitor === "0" ? (
|
{checks?.length === 0 && selectedMonitor === "0" ? (
|
||||||
<Box sx={{ ...sharedStyles }}>
|
<Box sx={{ ...sharedStyles }}>
|
||||||
<Box
|
<Box
|
||||||
textAlign="center"
|
textAlign="center"
|
||||||
pb={theme.spacing(20)}
|
pb={theme.spacing(20)}
|
||||||
>
|
>
|
||||||
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
||||||
</Box>
|
</Box>
|
||||||
<Typography
|
<Typography
|
||||||
textAlign="center"
|
textAlign="center"
|
||||||
color={theme.palette.text.secondary}
|
color={theme.palette.text.secondary}
|
||||||
>
|
>
|
||||||
No incidents recorded yet.
|
No incidents recorded yet.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
) : checks?.length === 0 ? (
|
) : checks?.length === 0 ? (
|
||||||
<Box sx={{ ...sharedStyles }}>
|
<Box sx={{ ...sharedStyles }}>
|
||||||
<Box
|
<Box
|
||||||
textAlign="center"
|
textAlign="center"
|
||||||
pb={theme.spacing(20)}
|
pb={theme.spacing(20)}
|
||||||
>
|
>
|
||||||
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
||||||
</Box>
|
</Box>
|
||||||
<Typography
|
<Typography
|
||||||
textAlign="center"
|
textAlign="center"
|
||||||
color={theme.palette.text.secondary}
|
color={theme.palette.text.secondary}
|
||||||
>
|
>
|
||||||
The monitor you have selected has no recorded incidents yet.
|
The monitor you have selected has no recorded incidents yet.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<TableContainer component={Paper}>
|
<TableContainer component={Paper}>
|
||||||
<Table>
|
<Table>
|
||||||
<TableHead>
|
<TableHead>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell>Monitor Name</TableCell>
|
<TableCell>Monitor Name</TableCell>
|
||||||
<TableCell>Status</TableCell>
|
<TableCell>Status</TableCell>
|
||||||
<TableCell>Date & Time</TableCell>
|
<TableCell>Date & Time</TableCell>
|
||||||
<TableCell>Status Code</TableCell>
|
<TableCell>Status Code</TableCell>
|
||||||
<TableCell>Message</TableCell>
|
<TableCell>Message</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{checks.map((check) => {
|
{checks.map((check) => {
|
||||||
const status = check.status === true ? "up" : "down";
|
const status = check.status === true ? "up" : "down";
|
||||||
const formattedDate = formatDateWithTz(
|
const formattedDate = formatDateWithTz(
|
||||||
check.createdAt,
|
check.createdAt,
|
||||||
"YYYY-MM-DD HH:mm:ss A",
|
"YYYY-MM-DD HH:mm:ss A",
|
||||||
uiTimezone
|
uiTimezone
|
||||||
);
|
);
|
||||||
const getGenericStatus = (status) => {
|
const getGenericStatus = (status) => {
|
||||||
if (typeof status === "number" && status >= 100 && status < 600) {
|
if (typeof status === "number" && status >= 100 && status < 600) {
|
||||||
return Math.floor(status / 100) * 100;
|
return Math.floor(status / 100) * 100;
|
||||||
}
|
}
|
||||||
return "cannot resolve";
|
return "cannot resolve";
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow key={check._id}>
|
<TableRow key={check._id}>
|
||||||
<TableCell>{monitors[check.monitorId]?.name}</TableCell>
|
<TableCell>{monitors[check.monitorId]?.name}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<StatusLabel
|
<StatusLabel
|
||||||
status={status}
|
status={status}
|
||||||
text={status}
|
text={status}
|
||||||
customStyles={{ textTransform: "capitalize" }}
|
customStyles={{ textTransform: "capitalize" }}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>{formattedDate}</TableCell>
|
<TableCell>{formattedDate}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<StatusLabel
|
<StatusLabel
|
||||||
status={getGenericStatus(check.statusCode)}
|
status={getGenericStatus(check.statusCode)}
|
||||||
text={String(check.statusCode || "N/A")}
|
text={String(check.statusCode || "N/A")}
|
||||||
hasDot={false}
|
hasDot={false}
|
||||||
customStyles={{ textTransform: "capitalize" }}
|
customStyles={{ textTransform: "capitalize" }}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>{check.message}</TableCell>
|
<TableCell>{check.message}</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</TableContainer>
|
</TableContainer>
|
||||||
{paginationComponent}
|
{paginationComponent}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
IncidentTable.propTypes = {
|
IncidentTable.propTypes = {
|
||||||
|
|||||||
Reference in new issue
Block a user