Merge pull request #564 from bluewave-labs/feat/loading-skeletons
Loading skeletons
This commit is contained in:
8 files changed
+425
-52
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { Typography, ButtonGroup, Stack, Box } from "@mui/material";
|
import { Typography, ButtonGroup, Stack, Box, Skeleton } from "@mui/material";
|
||||||
import WestRoundedIcon from "@mui/icons-material/WestRounded";
|
import WestRoundedIcon from "@mui/icons-material/WestRounded";
|
||||||
import Button from "../../Components/Button";
|
import Button from "../../Components/Button";
|
||||||
import axiosInstance from "../../Utils/axiosConfig";
|
import axiosInstance from "../../Utils/axiosConfig";
|
||||||
@@ -12,12 +12,39 @@ import Select from "../../Components/Inputs/Select";
|
|||||||
|
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders a skeleton layout.
|
||||||
|
*
|
||||||
|
* @returns {JSX.Element}
|
||||||
|
*/
|
||||||
|
const SkeletonLayout = () => {
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Stack direction="row" alignItems="center" gap={theme.gap.medium}>
|
||||||
|
<Skeleton variant="rounded" width={150} height={34} />
|
||||||
|
<Skeleton variant="rounded" width="15%" height={34} />
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="20%"
|
||||||
|
height={34}
|
||||||
|
sx={{ ml: "auto" }}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
<Skeleton variant="rounded" width="100%" height={300} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={100} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const Incidents = () => {
|
const Incidents = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const authState = useSelector((state) => state.auth);
|
const authState = useSelector((state) => state.auth);
|
||||||
const [monitors, setMonitors] = useState({});
|
const [monitors, setMonitors] = useState({});
|
||||||
const [selectedMonitor, setSelectedMonitor] = useState("0");
|
const [selectedMonitor, setSelectedMonitor] = useState("0");
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
// TODO do something with these filters
|
// TODO do something with these filters
|
||||||
const [filter, setFilter] = useState("all");
|
const [filter, setFilter] = useState("all");
|
||||||
@@ -34,6 +61,7 @@ const Incidents = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchIncidents = async () => {
|
const fetchIncidents = async () => {
|
||||||
|
setLoading(true);
|
||||||
const res = await axiosInstance.get(
|
const res = await axiosInstance.get(
|
||||||
`/monitors/user/${authState.user._id}?status=false`,
|
`/monitors/user/${authState.user._id}?status=false`,
|
||||||
{
|
{
|
||||||
@@ -51,6 +79,7 @@ const Incidents = () => {
|
|||||||
}, {});
|
}, {});
|
||||||
setMonitors(monitorLookup);
|
setMonitors(monitorLookup);
|
||||||
}
|
}
|
||||||
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchIncidents();
|
fetchIncidents();
|
||||||
@@ -92,8 +121,8 @@ const Incidents = () => {
|
|||||||
data: <StatusLabel status="down" text="Down" />,
|
data: <StatusLabel status="down" text="Down" />,
|
||||||
},
|
},
|
||||||
{ id: idx + 1, data: new Date(incident.createdAt).toLocaleString() },
|
{ id: idx + 1, data: new Date(incident.createdAt).toLocaleString() },
|
||||||
{ id: idx + 2, data: incident.statusCode },
|
{ id: idx + 2, data: monitors[incident.monitorId].name },
|
||||||
{ id: idx + 3, data: monitors[incident.monitorId].name },
|
{ id: idx + 3, data: incident.statusCode },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -102,7 +131,9 @@ const Incidents = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack className="incidents" gap={theme.gap.large}>
|
<Stack className="incidents" gap={theme.gap.large}>
|
||||||
{hasAnyIncidents ? (
|
{loading ? (
|
||||||
|
<SkeletonLayout />
|
||||||
|
) : hasAnyIncidents ? (
|
||||||
<>
|
<>
|
||||||
<Stack direction="row" alignItems="center" gap={theme.gap.medium}>
|
<Stack direction="row" alignItems="center" gap={theme.gap.medium}>
|
||||||
<Typography component="h1">Incident history for: </Typography>
|
<Typography component="h1">Incident history for: </Typography>
|
||||||
@@ -155,8 +186,7 @@ const Incidents = () => {
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<Stack alignItems="center" mt={theme.gap.xxl} gap={theme.gap.small}>
|
<Box>
|
||||||
<Typography>No incidents, yet.</Typography>
|
|
||||||
<Button
|
<Button
|
||||||
level="tertiary"
|
level="tertiary"
|
||||||
label="Back"
|
label="Back"
|
||||||
@@ -165,15 +195,25 @@ const Incidents = () => {
|
|||||||
onClick={() => navigate(-1)}
|
onClick={() => navigate(-1)}
|
||||||
sx={{
|
sx={{
|
||||||
backgroundColor: theme.palette.otherColors.fillGray,
|
backgroundColor: theme.palette.otherColors.fillGray,
|
||||||
mb: theme.gap.medium,
|
|
||||||
px: theme.gap.ml,
|
px: theme.gap.ml,
|
||||||
|
mb: theme.gap.ml,
|
||||||
"& svg.MuiSvgIcon-root": {
|
"& svg.MuiSvgIcon-root": {
|
||||||
mr: theme.gap.small,
|
mr: theme.gap.small,
|
||||||
fill: theme.palette.otherColors.slateGray,
|
fill: theme.palette.otherColors.slateGray,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
<Box
|
||||||
|
padding={theme.gap.xxl}
|
||||||
|
gap={theme.gap.small}
|
||||||
|
border={1}
|
||||||
|
borderRadius={`${theme.shape.borderRadius}px`}
|
||||||
|
borderColor={theme.palette.otherColors.graishWhite}
|
||||||
|
backgroundColor={theme.palette.otherColors.white}
|
||||||
|
>
|
||||||
|
<Typography textAlign="center">No incidents, yet.</Typography>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useDispatch, useSelector } from "react-redux";
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import Button from "../../../Components/Button";
|
import Button from "../../../Components/Button";
|
||||||
import Field from "../../../Components/Inputs/Field";
|
import Field from "../../../Components/Inputs/Field";
|
||||||
import { Box, Modal, Stack, Typography } from "@mui/material";
|
import { Box, Modal, Skeleton, Stack, Typography } from "@mui/material";
|
||||||
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";
|
||||||
@@ -36,6 +36,54 @@ const parseUrl = (url) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders a skeleton layout.
|
||||||
|
*
|
||||||
|
* @returns {JSX.Element}
|
||||||
|
*/
|
||||||
|
const SkeletonLayout = () => {
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Skeleton variant="rounded" width="15%" height={34} />
|
||||||
|
<Stack gap={theme.gap.xl} mt={theme.gap.medium}>
|
||||||
|
<Stack direction="row" gap={theme.gap.small} mt={theme.gap.small}>
|
||||||
|
<Skeleton
|
||||||
|
variant="circular"
|
||||||
|
style={{ minWidth: 24, minHeight: 24 }}
|
||||||
|
/>
|
||||||
|
<Box width="80%">
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="50%"
|
||||||
|
height={24}
|
||||||
|
sx={{ mb: theme.gap.small }}
|
||||||
|
/>
|
||||||
|
<Skeleton variant="rounded" width="50%" height={18} />
|
||||||
|
</Box>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
gap={theme.gap.medium}
|
||||||
|
sx={{
|
||||||
|
ml: "auto",
|
||||||
|
alignSelf: "flex-end",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Skeleton variant="rounded" width={150} height={34} />
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
<Skeleton variant="rounded" width="100%" height={200} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={200} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={200} />
|
||||||
|
<Stack direction="row" justifyContent="flex-end">
|
||||||
|
<Skeleton variant="rounded" width="15%" height={34} />
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure page displays monitor configurations and allows for editing actions.
|
* Configure page displays monitor configurations and allows for editing actions.
|
||||||
* @component
|
* @component
|
||||||
@@ -47,7 +95,7 @@ const Configure = () => {
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { user, authToken } = useSelector((state) => state.auth);
|
const { user, authToken } = useSelector((state) => state.auth);
|
||||||
const { monitors } = useSelector((state) => state.uptimeMonitors);
|
const { monitors } = useSelector((state) => state.uptimeMonitors);
|
||||||
const [monitor, setMonitor] = useState();
|
const [monitor, setMonitor] = useState({});
|
||||||
const [duration, setDuration] = useState(0);
|
const [duration, setDuration] = useState(0);
|
||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
const { monitorId } = useParams();
|
const { monitorId } = useParams();
|
||||||
@@ -164,8 +212,14 @@ const Configure = () => {
|
|||||||
|
|
||||||
var lastChecked = formatDurationRounded(getLastChecked(monitor?.checks));
|
var lastChecked = formatDurationRounded(getLastChecked(monitor?.checks));
|
||||||
|
|
||||||
|
let loading = Object.keys(monitor).length === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box className="configure-monitor">
|
<Box className="configure-monitor">
|
||||||
|
{loading ? (
|
||||||
|
<SkeletonLayout />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<Button
|
<Button
|
||||||
level="tertiary"
|
level="tertiary"
|
||||||
label="Back"
|
label="Back"
|
||||||
@@ -174,7 +228,6 @@ const Configure = () => {
|
|||||||
onClick={() => navigate(-1)}
|
onClick={() => navigate(-1)}
|
||||||
sx={{
|
sx={{
|
||||||
backgroundColor: "#f4f4f4",
|
backgroundColor: "#f4f4f4",
|
||||||
mb: theme.gap.medium,
|
|
||||||
px: theme.gap.ml,
|
px: theme.gap.ml,
|
||||||
"& svg.MuiSvgIcon-root": {
|
"& svg.MuiSvgIcon-root": {
|
||||||
mr: theme.gap.small,
|
mr: theme.gap.small,
|
||||||
@@ -182,7 +235,14 @@ const Configure = () => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<form className="configure-monitor-form" noValidate spellCheck="false">
|
<form
|
||||||
|
className="configure-monitor-form"
|
||||||
|
noValidate
|
||||||
|
spellCheck="false"
|
||||||
|
style={{
|
||||||
|
marginTop: theme.gap.medium,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Stack direction="row" gap={theme.gap.small} mt={theme.gap.small}>
|
<Stack direction="row" gap={theme.gap.small} mt={theme.gap.small}>
|
||||||
{monitor?.status ? <GreenCheck /> : <RedCheck />}
|
{monitor?.status ? <GreenCheck /> : <RedCheck />}
|
||||||
<Box>
|
<Box>
|
||||||
@@ -254,8 +314,8 @@ const Configure = () => {
|
|||||||
<Box>
|
<Box>
|
||||||
<Typography component="h2">General settings</Typography>
|
<Typography component="h2">General settings</Typography>
|
||||||
<Typography component="p" sx={{ mt: theme.gap.small }}>
|
<Typography component="p" sx={{ mt: theme.gap.small }}>
|
||||||
Here you can select the URL of the host, together with the type of
|
Here you can select the URL of the host, together with the
|
||||||
monitor.
|
type of monitor.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.gap.xl}>
|
<Stack gap={theme.gap.xl}>
|
||||||
@@ -372,6 +432,8 @@ const Configure = () => {
|
|||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</form>
|
</form>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<Modal
|
<Modal
|
||||||
aria-labelledby="modal-delete-monitor"
|
aria-labelledby="modal-delete-monitor"
|
||||||
aria-describedby="delete-monitor-confirmation"
|
aria-describedby="delete-monitor-confirmation"
|
||||||
|
|||||||
@@ -42,9 +42,6 @@
|
|||||||
padding: var(--env-var-spacing-1) 18px;
|
padding: var(--env-var-spacing-1) 18px;
|
||||||
background-color: var(--env-var-color-8);
|
background-color: var(--env-var-color-8);
|
||||||
}
|
}
|
||||||
.monitor-details .stat-box:not(:first-of-type) {
|
|
||||||
margin-left: var(--env-var-spacing-2);
|
|
||||||
}
|
|
||||||
.monitor-details .stat-box h6.MuiTypography-root {
|
.monitor-details .stat-box h6.MuiTypography-root {
|
||||||
margin-bottom: var(--env-var-spacing-1);
|
margin-bottom: var(--env-var-spacing-1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { Box, Stack, Typography, useTheme } from "@mui/material";
|
import { Box, Skeleton, Stack, Typography, useTheme } from "@mui/material";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { useNavigate, useParams } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
import axiosInstance from "../../../Utils/axiosConfig";
|
import axiosInstance from "../../../Utils/axiosConfig";
|
||||||
@@ -30,6 +30,81 @@ const StatBox = ({ title, value }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StatBox.propTypes = {
|
||||||
|
title: PropTypes.string,
|
||||||
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders a skeleton layout.
|
||||||
|
*
|
||||||
|
* @returns {JSX.Element}
|
||||||
|
*/
|
||||||
|
const SkeletonLayout = () => {
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Skeleton variant="rounded" width="20%" height={34} />
|
||||||
|
<Stack gap={theme.gap.xl} mt={theme.gap.medium}>
|
||||||
|
<Stack direction="row" gap={theme.gap.small} mt={theme.gap.small}>
|
||||||
|
<Skeleton
|
||||||
|
variant="circular"
|
||||||
|
style={{ minWidth: 24, minHeight: 24 }}
|
||||||
|
/>
|
||||||
|
<Box width="80%">
|
||||||
|
<Skeleton variant="rounded" width="50%" height={24} />
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="50%"
|
||||||
|
height={18}
|
||||||
|
sx={{ mt: theme.gap.small }}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="20%"
|
||||||
|
height={34}
|
||||||
|
sx={{ alignSelf: "flex-end" }}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
gap={theme.gap.large}
|
||||||
|
>
|
||||||
|
<Skeleton variant="rounded" width="100%" height={80} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={80} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={80} />
|
||||||
|
</Stack>
|
||||||
|
<Box>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
mb={theme.gap.ml}
|
||||||
|
>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="20%"
|
||||||
|
height={24}
|
||||||
|
sx={{ alignSelf: "flex-end" }}
|
||||||
|
/>
|
||||||
|
<Skeleton variant="rounded" width="20%" height={34} />
|
||||||
|
</Stack>
|
||||||
|
<Box sx={{ height: "200px" }}>
|
||||||
|
<Skeleton variant="rounded" width="100%" height="100%" />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<Stack gap={theme.gap.ml}>
|
||||||
|
<Skeleton variant="rounded" width="20%" height={24} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={200} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={50} />
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Details page component displaying monitor details and related information.
|
* Details page component displaying monitor details and related information.
|
||||||
* @component
|
* @component
|
||||||
@@ -158,8 +233,14 @@ const DetailsPage = () => {
|
|||||||
}, 0);
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let loading = Object.keys(monitor).length === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box className="monitor-details">
|
<Box className="monitor-details">
|
||||||
|
{loading ? (
|
||||||
|
<SkeletonLayout />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<Button
|
<Button
|
||||||
level="tertiary"
|
level="tertiary"
|
||||||
label="Back to Monitors"
|
label="Back to Monitors"
|
||||||
@@ -168,7 +249,6 @@ const DetailsPage = () => {
|
|||||||
onClick={() => navigate("/monitors")}
|
onClick={() => navigate("/monitors")}
|
||||||
sx={{
|
sx={{
|
||||||
backgroundColor: "#f4f4f4",
|
backgroundColor: "#f4f4f4",
|
||||||
mb: theme.gap.medium,
|
|
||||||
px: theme.gap.ml,
|
px: theme.gap.ml,
|
||||||
"& svg.MuiSvgIcon-root": {
|
"& svg.MuiSvgIcon-root": {
|
||||||
mr: theme.gap.small,
|
mr: theme.gap.small,
|
||||||
@@ -176,7 +256,7 @@ const DetailsPage = () => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Stack gap={theme.gap.xl}>
|
<Stack gap={theme.gap.xl} mt={theme.gap.medium}>
|
||||||
<Stack direction="row" gap={theme.gap.small} mt={theme.gap.small}>
|
<Stack direction="row" gap={theme.gap.small} mt={theme.gap.small}>
|
||||||
{monitor?.status ? <GreenCheck /> : <RedCheck />}
|
{monitor?.status ? <GreenCheck /> : <RedCheck />}
|
||||||
<Box>
|
<Box>
|
||||||
@@ -194,8 +274,8 @@ const DetailsPage = () => {
|
|||||||
>
|
>
|
||||||
Your site is {monitor?.status ? "up" : "down"}.
|
Your site is {monitor?.status ? "up" : "down"}.
|
||||||
</Typography>{" "}
|
</Typography>{" "}
|
||||||
Checking every {formatDurationRounded(monitor?.interval)}. Last
|
Checking every {formatDurationRounded(monitor?.interval)}.
|
||||||
time checked{" "}
|
Last time checked{" "}
|
||||||
{formatDurationRounded(getLastChecked(monitor?.checks))} ago.
|
{formatDurationRounded(getLastChecked(monitor?.checks))} ago.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -205,7 +285,10 @@ const DetailsPage = () => {
|
|||||||
animate="rotate90"
|
animate="rotate90"
|
||||||
img={
|
img={
|
||||||
<SettingsIcon
|
<SettingsIcon
|
||||||
style={{ width: theme.gap.mlplus, height: theme.gap.mlplus }}
|
style={{
|
||||||
|
minWidth: theme.gap.mlplus,
|
||||||
|
minHeight: theme.gap.mlplus,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
onClick={() => navigate(`/monitors/configure/${monitorId}`)}
|
onClick={() => navigate(`/monitors/configure/${monitorId}`)}
|
||||||
@@ -220,7 +303,11 @@ const DetailsPage = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack direction="row" justifyContent="space-between">
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
gap={theme.gap.large}
|
||||||
|
>
|
||||||
<StatBox
|
<StatBox
|
||||||
title="Currently up for"
|
title="Currently up for"
|
||||||
value={formatDuration(calculateUptimeDuration(monitor.checks))}
|
value={formatDuration(calculateUptimeDuration(monitor.checks))}
|
||||||
@@ -229,7 +316,10 @@ const DetailsPage = () => {
|
|||||||
title="Last checked"
|
title="Last checked"
|
||||||
value={`${formatDuration(getLastChecked(monitor.checks))} ago`}
|
value={`${formatDuration(getLastChecked(monitor.checks))} ago`}
|
||||||
/>
|
/>
|
||||||
<StatBox title="Incidents" value={countIncidents(monitor.checks)} />
|
<StatBox
|
||||||
|
title="Incidents"
|
||||||
|
value={countIncidents(monitor.checks)}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box>
|
<Box>
|
||||||
<Stack
|
<Stack
|
||||||
@@ -265,28 +355,28 @@ const DetailsPage = () => {
|
|||||||
onClick={() => setFilter("month")}
|
onClick={() => setFilter("month")}
|
||||||
sx={{
|
sx={{
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
filter === "month" && theme.palette.otherColors.fillGray,
|
filter === "month" &&
|
||||||
|
theme.palette.otherColors.fillGray,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box sx={{ height: "200px" }}>
|
<Box sx={{ height: "200px" }}>
|
||||||
<MonitorDetailsAreaChart checks={monitor.checks} filter={filter} />
|
<MonitorDetailsAreaChart
|
||||||
|
checks={monitor.checks}
|
||||||
|
filter={filter}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Box>
|
<Stack gap={theme.gap.ml}>
|
||||||
<Typography component="h2" mb={theme.gap.ml}>
|
<Typography component="h2">History</Typography>
|
||||||
History
|
|
||||||
</Typography>
|
|
||||||
<BasicTable data={data} paginated={true} reversed={true} />
|
<BasicTable data={data} paginated={true} reversed={true} />
|
||||||
</Box>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
StatBox.propTypes = {
|
|
||||||
title: PropTypes.string,
|
|
||||||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
||||||
};
|
|
||||||
export default DetailsPage;
|
export default DetailsPage;
|
||||||
@@ -22,6 +22,7 @@ import {
|
|||||||
Menu,
|
Menu,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
Modal,
|
Modal,
|
||||||
|
Skeleton,
|
||||||
Stack,
|
Stack,
|
||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
@@ -71,6 +72,38 @@ const Host = ({ params }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders a skeleton layout.
|
||||||
|
*
|
||||||
|
* @returns {JSX.Element}
|
||||||
|
*/
|
||||||
|
const SkeletonLayout = () => {
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Stack direction="row" justifyContent="space-between" alignItems="center">
|
||||||
|
<Skeleton variant="rounded" width="50%" height={36} />
|
||||||
|
<Skeleton variant="rounded" width="15%" height={36} />
|
||||||
|
</Stack>
|
||||||
|
<Stack
|
||||||
|
gap={theme.gap.large}
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
>
|
||||||
|
<Skeleton variant="rounded" width="100%" height={100} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={100} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={100} />
|
||||||
|
</Stack>
|
||||||
|
<Stack gap={theme.gap.large} p={theme.gap.xl} backgroundColor="#f9fafb">
|
||||||
|
<Skeleton variant="rounded" width="50%" height={25} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={300} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={100} />
|
||||||
|
</Stack>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const Monitors = () => {
|
const Monitors = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -204,9 +237,19 @@ const Monitors = () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let loading = monitorState.isLoading && monitorState.monitors.length === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="monitors" gap={theme.gap.large}>
|
<Stack className="monitors" gap={theme.gap.large}>
|
||||||
<Stack direction="row" justifyContent="space-between" alignItems="center">
|
{loading ? (
|
||||||
|
<SkeletonLayout />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
alignItems="center"
|
||||||
|
>
|
||||||
<Typography component="h1">
|
<Typography component="h1">
|
||||||
Hello, {authState.user.firstName}
|
Hello, {authState.user.firstName}
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -230,10 +273,11 @@ const Monitors = () => {
|
|||||||
<Stack
|
<Stack
|
||||||
gap={theme.gap.large}
|
gap={theme.gap.large}
|
||||||
p={theme.gap.xl}
|
p={theme.gap.xl}
|
||||||
|
border={1}
|
||||||
|
borderColor={theme.palette.otherColors.graishWhite}
|
||||||
|
backgroundColor={theme.palette.otherColors.white}
|
||||||
sx={{
|
sx={{
|
||||||
border: `solid 1px ${theme.palette.otherColors.graishWhite}`,
|
|
||||||
borderRadius: `${theme.shape.borderRadius}px`,
|
borderRadius: `${theme.shape.borderRadius}px`,
|
||||||
backgroundColor: theme.palette.otherColors.white,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Stack direction="row" alignItems="center">
|
<Stack direction="row" alignItems="center">
|
||||||
@@ -245,6 +289,8 @@ const Monitors = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
<BasicTable data={data} paginated={true} />
|
<BasicTable data={data} paginated={true} />
|
||||||
</Stack>
|
</Stack>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<Menu
|
<Menu
|
||||||
className="actions-menu"
|
className="actions-menu"
|
||||||
anchorEl={anchorEl}
|
anchorEl={anchorEl}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Box, Stack, Typography } from "@mui/material";
|
import { Box, Skeleton, Stack, Typography } from "@mui/material";
|
||||||
import { PieChart } from "@mui/x-charts/PieChart";
|
import { PieChart } from "@mui/x-charts/PieChart";
|
||||||
import { useDrawingArea } from "@mui/x-charts";
|
import { useDrawingArea } from "@mui/x-charts";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
@@ -126,6 +126,53 @@ const PieValueLabel = ({ value, startAngle, endAngle, color, highlighted }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders a skeleton layout.
|
||||||
|
*
|
||||||
|
* @returns {JSX.Element}
|
||||||
|
*/
|
||||||
|
const SkeletonLayout = () => {
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Skeleton variant="rounded" width="15%" height={34} />
|
||||||
|
<Stack direction="row" gap={theme.gap.small}>
|
||||||
|
<Skeleton variant="circular" style={{ minWidth: 24, minHeight: 24 }} />
|
||||||
|
<Box width="80%">
|
||||||
|
<Skeleton variant="rounded" width="50%" height={24} />
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="50%"
|
||||||
|
height={18}
|
||||||
|
sx={{ mt: theme.gap.small }}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="15%"
|
||||||
|
height={34}
|
||||||
|
sx={{ alignSelf: "flex-end" }}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
gap={theme.gap.xl}
|
||||||
|
flexWrap="wrap"
|
||||||
|
>
|
||||||
|
<Skeleton variant="rounded" width="30%" height={90} sx={{ flex: 1 }} />
|
||||||
|
<Skeleton variant="rounded" width="30%" height={90} sx={{ flex: 1 }} />
|
||||||
|
<Skeleton variant="rounded" width="30%" height={90} sx={{ flex: 1 }} />
|
||||||
|
</Stack>
|
||||||
|
<Skeleton variant="rounded" width="25%" height={24} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={300} />
|
||||||
|
<Skeleton variant="rounded" width="25%" height={24} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={300} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const PageSpeedDetails = () => {
|
const PageSpeedDetails = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -136,6 +183,7 @@ const PageSpeedDetails = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchMonitor = async () => {
|
const fetchMonitor = async () => {
|
||||||
|
try {
|
||||||
const res = await axiosInstance.get(
|
const res = await axiosInstance.get(
|
||||||
`/monitors/${monitorId}?sortOrder=desc`,
|
`/monitors/${monitorId}?sortOrder=desc`,
|
||||||
{
|
{
|
||||||
@@ -147,6 +195,10 @@ const PageSpeedDetails = () => {
|
|||||||
|
|
||||||
setMonitor(res.data.data);
|
setMonitor(res.data.data);
|
||||||
setAudits(res.data.data.checks[0].audits);
|
setAudits(res.data.data.checks[0].audits);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching pagespeed monitor of id: " + monitorId);
|
||||||
|
navigate("/not-found");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchMonitor();
|
fetchMonitor();
|
||||||
@@ -244,8 +296,14 @@ const PageSpeedDetails = () => {
|
|||||||
const [highlightedItem, setHighLightedItem] = useState(null);
|
const [highlightedItem, setHighLightedItem] = useState(null);
|
||||||
const [expand, setExpand] = useState(false);
|
const [expand, setExpand] = useState(false);
|
||||||
|
|
||||||
|
let loading = Object.keys(monitor).length === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="page-speed-details" gap={theme.gap.large}>
|
<Stack className="page-speed-details" gap={theme.gap.large}>
|
||||||
|
{loading ? (
|
||||||
|
<SkeletonLayout />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<Button
|
<Button
|
||||||
level="tertiary"
|
level="tertiary"
|
||||||
label="Back"
|
label="Back"
|
||||||
@@ -262,14 +320,14 @@ const PageSpeedDetails = () => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Stack
|
<Stack direction="row" gap={theme.gap.small}>
|
||||||
direction="row"
|
|
||||||
gap={theme.gap.small}
|
|
||||||
justifyContent="space-between"
|
|
||||||
>
|
|
||||||
<GreenCheck />
|
<GreenCheck />
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component="h1" mb={theme.gap.xs} sx={{ lineHeight: 1 }}>
|
<Typography
|
||||||
|
component="h1"
|
||||||
|
mb={theme.gap.xs}
|
||||||
|
sx={{ lineHeight: 1 }}
|
||||||
|
>
|
||||||
{monitor?.url}
|
{monitor?.url}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
@@ -317,7 +375,8 @@ const PageSpeedDetails = () => {
|
|||||||
fontStyle="italic"
|
fontStyle="italic"
|
||||||
sx={{ opacity: 0.8 }}
|
sx={{ opacity: 0.8 }}
|
||||||
>
|
>
|
||||||
({formatDurationRounded(getLastChecked(monitor?.checks))} ago)
|
({formatDurationRounded(getLastChecked(monitor?.checks))}{" "}
|
||||||
|
ago)
|
||||||
</Typography>
|
</Typography>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
@@ -350,7 +409,9 @@ const PageSpeedDetails = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
<Typography component="h2">Score history</Typography>
|
<Typography component="h2">Score history</Typography>
|
||||||
<Box height="300px">
|
<Box height="300px">
|
||||||
<PageSpeedLineChart pageSpeedChecks={monitor?.checks?.slice(0, 25)} />
|
<PageSpeedLineChart
|
||||||
|
pageSpeedChecks={monitor?.checks?.slice(0, 25)}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Typography component="h2">Performance report</Typography>
|
<Typography component="h2">Performance report</Typography>
|
||||||
<Stack direction="row" alignItems="center" overflow="hidden">
|
<Stack direction="row" alignItems="center" overflow="hidden">
|
||||||
@@ -549,7 +610,9 @@ const PageSpeedDetails = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Find the position where the number ends and the unit begins
|
// Find the position where the number ends and the unit begins
|
||||||
const match = audit.displayValue.match(/(\d+\.?\d*)\s*([a-zA-Z]+)/);
|
const match = audit.displayValue.match(
|
||||||
|
/(\d+\.?\d*)\s*([a-zA-Z]+)/
|
||||||
|
);
|
||||||
let value;
|
let value;
|
||||||
let unit;
|
let unit;
|
||||||
if (match) {
|
if (match) {
|
||||||
@@ -598,6 +661,8 @@ const PageSpeedDetails = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Box, Grid, Stack, Typography } from "@mui/material";
|
import { Box, Grid, Skeleton, Stack, Typography } from "@mui/material";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { formatDate, formatDurationRounded } from "../../Utils/timeUtils";
|
import { formatDate, formatDurationRounded } from "../../Utils/timeUtils";
|
||||||
@@ -57,20 +57,89 @@ const Card = ({ data }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders a skeleton layout.
|
||||||
|
*
|
||||||
|
* @returns {JSX.Element}
|
||||||
|
*/
|
||||||
|
const SkeletonLayout = () => {
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack gap={theme.gap.xs}>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
mb={theme.gap.large}
|
||||||
|
>
|
||||||
|
<Box width="80%">
|
||||||
|
<Skeleton variant="rounded" width="25%" height={24} />
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="50%"
|
||||||
|
height={19.5}
|
||||||
|
sx={{ mt: theme.gap.xs }}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="20%"
|
||||||
|
height={34}
|
||||||
|
sx={{ alignSelf: "flex-end" }}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
<Stack direction="row" flexWrap="wrap" gap={theme.gap.large}>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={120}
|
||||||
|
sx={{ flex: "35%" }}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={120}
|
||||||
|
sx={{ flex: "35%" }}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={120}
|
||||||
|
sx={{ flex: "35%" }}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={120}
|
||||||
|
sx={{ flex: "35%" }}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const PageSpeed = () => {
|
const PageSpeed = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
const { authToken } = useSelector((state) => state.auth);
|
||||||
const { monitors } = useSelector((state) => state.pageSpeedMonitors);
|
const { monitors, isLoading } = useSelector(
|
||||||
|
(state) => state.pageSpeedMonitors
|
||||||
|
);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(getPageSpeedByUserId(authToken));
|
dispatch(getPageSpeedByUserId(authToken));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// will show skeletons only on initial load
|
||||||
|
// since monitor state is being added to redux persist, there's no reason to display skeletons on every render
|
||||||
|
let isActuallyLoading = isLoading && monitors.length === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box className="page-speed">
|
<Box className="page-speed">
|
||||||
{monitors?.length !== 0 ? (
|
{isActuallyLoading ? (
|
||||||
|
<SkeletonLayout />
|
||||||
|
) : monitors?.length !== 0 ? (
|
||||||
<Stack gap={theme.gap.xs}>
|
<Stack gap={theme.gap.xs}>
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
|
|||||||
@@ -161,6 +161,10 @@ button:focus-visible {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body .MuiSkeleton-root {
|
||||||
|
background-color: var(--env-var-color-15);
|
||||||
|
}
|
||||||
|
|
||||||
@media (prefers-color-scheme: light) {
|
@media (prefers-color-scheme: light) {
|
||||||
:root {
|
:root {
|
||||||
color: #213547;
|
color: #213547;
|
||||||
|
|||||||
Reference in new issue
Block a user