Merge pull request #553 from bluewave-labs/feat/monitor-notfound

Redirect to notfound if monitor does not exist
This commit is contained in:
Alexander Holliday authored and GitHub committed 2024-08-06 16:22:20 -07:00
commit 0195d093d5
5 files changed
+37 -11

No files matched your search

@@ -62,6 +62,10 @@ const Configure = () => {
useEffect(() => { useEffect(() => {
const data = monitors.find((monitor) => monitor._id === monitorId); const data = monitors.find((monitor) => monitor._id === monitorId);
if (!data) {
console.error("Error fetching monitor of id: " + monitorId);
navigate("/not-found");
}
setMonitor({ setMonitor({
...data, ...data,
}); });
+15 -3
View File
@@ -12,7 +12,7 @@ import Button from "../../../Components/Button";
import WestRoundedIcon from "@mui/icons-material/WestRounded"; import WestRoundedIcon from "@mui/icons-material/WestRounded";
import GreenCheck from "../../../assets/icons/checkbox-green.svg?react"; import GreenCheck from "../../../assets/icons/checkbox-green.svg?react";
import RedCheck from "../../../assets/icons/checkbox-red.svg?react"; import RedCheck from "../../../assets/icons/checkbox-red.svg?react";
import SettingsIcon from "../../../assets/icons/settings.svg?react"; import SettingsIcon from "../../../assets/icons/settings-bold.svg?react";
import { import {
formatDuration, formatDuration,
formatDurationRounded, formatDurationRounded,
@@ -43,6 +43,7 @@ const DetailsPage = () => {
useEffect(() => { useEffect(() => {
const fetchMonitor = async () => { const fetchMonitor = async () => {
try {
const res = await axiosInstance.get( const res = await axiosInstance.get(
`/monitors/${monitorId}?sortOrder=asc`, `/monitors/${monitorId}?sortOrder=asc`,
{ {
@@ -74,7 +75,10 @@ const DetailsPage = () => {
/> />
), ),
}, },
{ id: idx + 1, data: new Date(check.createdAt).toLocaleString() }, {
id: idx + 1,
data: new Date(check.createdAt).toLocaleString(),
},
{ id: idx + 2, data: check.statusCode }, { id: idx + 2, data: check.statusCode },
], ],
}; };
@@ -82,6 +86,10 @@ const DetailsPage = () => {
}; };
setData(data); setData(data);
} catch (error) {
console.error("Error fetching monitor of id: " + monitorId);
navigate("/not-found");
}
}; };
fetchMonitor(); fetchMonitor();
}, [monitorId, authToken]); }, [monitorId, authToken]);
@@ -195,7 +203,11 @@ const DetailsPage = () => {
level="tertiary" level="tertiary"
label="Configure" label="Configure"
animate="rotate90" animate="rotate90"
img={<SettingsIcon />} img={
<SettingsIcon
style={{ width: theme.gap.mlplus, height: theme.gap.mlplus }}
/>
}
onClick={() => navigate(`/monitors/configure/${monitorId}`)} onClick={() => navigate(`/monitors/configure/${monitorId}`)}
sx={{ sx={{
ml: "auto", ml: "auto",
+1 -1
View File
@@ -9,7 +9,7 @@
.monitors h2.MuiTypography-root { .monitors h2.MuiTypography-root {
font-size: var(--env-var-font-size-large); font-size: var(--env-var-font-size-large);
} }
.monitors .MuiStack-root > button { .monitors .MuiStack-root > button:not(.MuiIconButton-root) {
font-size: var(--env-var-font-size-medium); font-size: var(--env-var-font-size-medium);
height: var(--env-var-height-2); height: var(--env-var-height-2);
min-width: fit-content; min-width: fit-content;
+16 -6
View File
@@ -41,16 +41,26 @@ import {
const Host = ({ params }) => { const Host = ({ params }) => {
return ( return (
<Stack direction="row" alignItems="center" className="host"> <Stack direction="row" alignItems="center" className="host">
<a <IconButton
href={params.url} aria-label="monitor link"
target="_blank"
rel="noreferrer"
onClick={(event) => { onClick={(event) => {
event.stopPropagation(); event.stopPropagation();
window.open(params.url, "_blank", "noreferrer");
}}
sx={{
"&:focus": {
outline: "none",
},
mr: "3px",
}} }}
> >
<OpenInNewPage /> <OpenInNewPage
</a> style={{
marginTop: "-1px",
marginRight: "-1px",
}}
/>
</IconButton>
<Box> <Box>
{params.title} {params.title}
<Typography component="span" sx={{ color: params.percentageColor }}> <Typography component="span" sx={{ color: params.percentageColor }}>
+1 -1
View File
@@ -1,3 +1,3 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg width="16" height="16" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13 5L13 1M13 1H9M13 1L7.66667 6.33333M5.66667 2.33333H4.2C3.0799 2.33333 2.51984 2.33333 2.09202 2.55132C1.71569 2.74307 1.40973 3.04903 1.21799 3.42535C1 3.85318 1 4.41323 1 5.53333V9.8C1 10.9201 1 11.4802 1.21799 11.908C1.40973 12.2843 1.71569 12.5903 2.09202 12.782C2.51984 13 3.0799 13 4.2 13H8.46667C9.58677 13 10.1468 13 10.5746 12.782C10.951 12.5903 11.2569 12.2843 11.4487 11.908C11.6667 11.4802 11.6667 10.9201 11.6667 9.8V8.33333" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/> <path d="M13 5L13 1M13 1H9M13 1L7.66667 6.33333M5.66667 2.33333H4.2C3.0799 2.33333 2.51984 2.33333 2.09202 2.55132C1.71569 2.74307 1.40973 3.04903 1.21799 3.42535C1 3.85318 1 4.41323 1 5.53333V9.8C1 10.9201 1 11.4802 1.21799 11.908C1.40973 12.2843 1.71569 12.5903 2.09202 12.782C2.51984 13 3.0799 13 4.2 13H8.46667C9.58677 13 10.1468 13 10.5746 12.782C10.951 12.5903 11.2569 12.2843 11.4487 11.908C11.6667 11.4802 11.6667 10.9201 11.6667 9.8V8.33333" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 620 B

After

Width:  |  Height:  |  Size: 620 B