Added skeletons to monitor pages
This commit is contained in:
1 parent
0195d093d5
commit
ecb6f6204c
5 files changed
+507
-325
No files matched your search
@@ -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";
|
||||||
@@ -47,7 +47,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,53 +164,88 @@ 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">
|
||||||
<Button
|
{loading ? (
|
||||||
level="tertiary"
|
<Skeleton variant="rounded" width="15%" height={34} />
|
||||||
label="Back"
|
) : (
|
||||||
animate="slideLeft"
|
<Button
|
||||||
img={<WestRoundedIcon />}
|
level="tertiary"
|
||||||
onClick={() => navigate(-1)}
|
label="Back"
|
||||||
sx={{
|
animate="slideLeft"
|
||||||
backgroundColor: "#f4f4f4",
|
img={<WestRoundedIcon />}
|
||||||
mb: theme.gap.medium,
|
onClick={() => navigate(-1)}
|
||||||
px: theme.gap.ml,
|
sx={{
|
||||||
"& svg.MuiSvgIcon-root": {
|
backgroundColor: "#f4f4f4",
|
||||||
mr: theme.gap.small,
|
px: theme.gap.ml,
|
||||||
fill: theme.palette.otherColors.slateGray,
|
"& svg.MuiSvgIcon-root": {
|
||||||
},
|
mr: theme.gap.small,
|
||||||
|
fill: theme.palette.otherColors.slateGray,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<form
|
||||||
|
className="configure-monitor-form"
|
||||||
|
noValidate
|
||||||
|
spellCheck="false"
|
||||||
|
style={{
|
||||||
|
marginTop: theme.gap.medium,
|
||||||
}}
|
}}
|
||||||
/>
|
>
|
||||||
<form className="configure-monitor-form" noValidate spellCheck="false">
|
|
||||||
<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 />}
|
{loading ? (
|
||||||
<Box>
|
<Skeleton
|
||||||
{parsedUrl?.host ? (
|
variant="circular"
|
||||||
<Typography
|
style={{ minWidth: 24, minHeight: 24 }}
|
||||||
component="h1"
|
/>
|
||||||
mb={theme.gap.small}
|
) : monitor?.status ? (
|
||||||
sx={{ lineHeight: 1 }}
|
<GreenCheck />
|
||||||
>
|
) : (
|
||||||
{parsedUrl.host || "..."}
|
<RedCheck />
|
||||||
</Typography>
|
)}
|
||||||
|
<Box width="80%">
|
||||||
|
{loading ? (
|
||||||
|
<>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="50%"
|
||||||
|
height={24}
|
||||||
|
sx={{ mb: theme.gap.small }}
|
||||||
|
/>
|
||||||
|
<Skeleton variant="rounded" width="50%" height={18} />
|
||||||
|
</>
|
||||||
) : (
|
) : (
|
||||||
""
|
<>
|
||||||
|
{parsedUrl?.host ? (
|
||||||
|
<Typography
|
||||||
|
component="h1"
|
||||||
|
mb={theme.gap.small}
|
||||||
|
sx={{ lineHeight: 1 }}
|
||||||
|
>
|
||||||
|
{parsedUrl.host || "..."}
|
||||||
|
</Typography>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
|
)}
|
||||||
|
<Typography lineHeight={parsedUrl?.host ? 1 : theme.gap.large}>
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
sx={{
|
||||||
|
color: monitor?.status
|
||||||
|
? "var(--env-var-color-17)"
|
||||||
|
: "var(--env-var-color-24)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Your site is {monitor?.status ? "up" : "down"}.
|
||||||
|
</Typography>{" "}
|
||||||
|
Checking every {duration}.{" "}
|
||||||
|
{lastChecked ? `Last time checked ${lastChecked} ago.` : ""}
|
||||||
|
</Typography>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
<Typography lineHeight={parsedUrl?.host ? 1 : theme.gap.large}>
|
|
||||||
<Typography
|
|
||||||
component="span"
|
|
||||||
sx={{
|
|
||||||
color: monitor?.status
|
|
||||||
? "var(--env-var-color-17)"
|
|
||||||
: "var(--env-var-color-24)",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Your site is {monitor?.status ? "up" : "down"}.
|
|
||||||
</Typography>{" "}
|
|
||||||
Checking every {duration}.{" "}
|
|
||||||
{lastChecked ? `Last time checked ${lastChecked} ago.` : ""}
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
</Box>
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
@@ -220,156 +255,178 @@ const Configure = () => {
|
|||||||
alignSelf: "flex-end",
|
alignSelf: "flex-end",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button
|
{loading ? (
|
||||||
level="tertiary"
|
<>
|
||||||
label="Pause"
|
<Skeleton variant="rounded" width={150} height={34} />
|
||||||
animate="rotate180"
|
</>
|
||||||
img={<PauseCircleOutlineIcon />}
|
|
||||||
sx={{
|
|
||||||
backgroundColor: "#f4f4f4",
|
|
||||||
pl: theme.gap.small,
|
|
||||||
pr: theme.gap.medium,
|
|
||||||
"& svg": {
|
|
||||||
mr: theme.gap.xs,
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
level="error"
|
|
||||||
label="Remove"
|
|
||||||
sx={{
|
|
||||||
boxShadow: "none",
|
|
||||||
px: theme.gap.ml,
|
|
||||||
}}
|
|
||||||
onClick={() => setIsOpen(true)}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
|
||||||
<Stack
|
|
||||||
className="config-box"
|
|
||||||
direction="row"
|
|
||||||
justifyContent="space-between"
|
|
||||||
gap={theme.gap.xxl}
|
|
||||||
>
|
|
||||||
<Box>
|
|
||||||
<Typography component="h2">General settings</Typography>
|
|
||||||
<Typography component="p" sx={{ mt: theme.gap.small }}>
|
|
||||||
Here you can select the URL of the host, together with the type of
|
|
||||||
monitor.
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
<Stack gap={theme.gap.xl}>
|
|
||||||
<Field
|
|
||||||
type={monitor?.type === "http" ? "url" : "text"}
|
|
||||||
https={protocol === "https"}
|
|
||||||
id="monitor-url"
|
|
||||||
label="URL to monitor"
|
|
||||||
placeholder="google.com"
|
|
||||||
value={parsedUrl?.host || monitor?.url || ""}
|
|
||||||
disabled={true}
|
|
||||||
error={errors["url"]}
|
|
||||||
/>
|
|
||||||
<Field
|
|
||||||
type="text"
|
|
||||||
id="monitor-name"
|
|
||||||
label="Friendly name"
|
|
||||||
isOptional={true}
|
|
||||||
placeholder="Google"
|
|
||||||
value={monitor?.name || ""}
|
|
||||||
onChange={handleChange}
|
|
||||||
error={errors["name"]}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
|
||||||
<Stack
|
|
||||||
className="config-box"
|
|
||||||
direction="row"
|
|
||||||
justifyContent="space-between"
|
|
||||||
gap={theme.gap.xxl}
|
|
||||||
>
|
|
||||||
<Box>
|
|
||||||
<Typography component="h2">Incident notifications</Typography>
|
|
||||||
<Typography component="p" mt={theme.gap.small}>
|
|
||||||
When there is an incident, notify users.
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
<Stack gap={theme.gap.medium}>
|
|
||||||
<Typography component="p" mt={theme.gap.small}>
|
|
||||||
When there is a new incident,
|
|
||||||
</Typography>
|
|
||||||
<Checkbox
|
|
||||||
id="notify-sms"
|
|
||||||
label="Notify via SMS (coming soon)"
|
|
||||||
isChecked={false}
|
|
||||||
value=""
|
|
||||||
onChange={() => console.log("disabled")}
|
|
||||||
isDisabled={true}
|
|
||||||
/>
|
|
||||||
<Checkbox
|
|
||||||
id="notify-email-default"
|
|
||||||
label={`Notify via email (to ${user.email})`}
|
|
||||||
isChecked={
|
|
||||||
monitor?.notifications?.some(
|
|
||||||
(notification) => notification.type === "email"
|
|
||||||
) || false
|
|
||||||
}
|
|
||||||
value={user?.email}
|
|
||||||
onChange={(event) => handleChange(event)}
|
|
||||||
/>
|
|
||||||
<Checkbox
|
|
||||||
id="notify-email"
|
|
||||||
label="Also notify via email to multiple addresses (coming soon)"
|
|
||||||
isChecked={false}
|
|
||||||
value=""
|
|
||||||
onChange={() => console.log("disabled")}
|
|
||||||
isDisabled={true}
|
|
||||||
/>
|
|
||||||
{monitor?.notifications?.some(
|
|
||||||
(notification) => notification.type === "emails"
|
|
||||||
) ? (
|
|
||||||
<Box mx={`calc(${theme.gap.ml} * 2)`}>
|
|
||||||
<Field
|
|
||||||
id="notify-email-list"
|
|
||||||
type="text"
|
|
||||||
placeholder="name@gmail.com"
|
|
||||||
value=""
|
|
||||||
onChange={() => console.log("disabled")}
|
|
||||||
/>
|
|
||||||
<Typography mt={theme.gap.small}>
|
|
||||||
You can separate multiple emails with a comma
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
) : (
|
) : (
|
||||||
""
|
<>
|
||||||
|
<Button
|
||||||
|
level="tertiary"
|
||||||
|
label="Pause"
|
||||||
|
animate="rotate180"
|
||||||
|
img={<PauseCircleOutlineIcon />}
|
||||||
|
sx={{
|
||||||
|
backgroundColor: "#f4f4f4",
|
||||||
|
pl: theme.gap.small,
|
||||||
|
pr: theme.gap.medium,
|
||||||
|
"& svg": {
|
||||||
|
mr: theme.gap.xs,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
level="error"
|
||||||
|
label="Remove"
|
||||||
|
sx={{
|
||||||
|
boxShadow: "none",
|
||||||
|
px: theme.gap.ml,
|
||||||
|
}}
|
||||||
|
onClick={() => setIsOpen(true)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack
|
{loading ? (
|
||||||
className="config-box"
|
<>
|
||||||
direction="row"
|
<Skeleton variant="rounded" width="100%" height={200} />
|
||||||
justifyContent="space-between"
|
<Skeleton variant="rounded" width="100%" height={200} />
|
||||||
gap={theme.gap.xxl}
|
<Skeleton variant="rounded" width="100%" height={200} />
|
||||||
>
|
</>
|
||||||
<Box>
|
) : (
|
||||||
<Typography component="h2">Advanced settings</Typography>
|
<>
|
||||||
</Box>
|
<Stack
|
||||||
<Stack gap={theme.gap.xl}>
|
className="config-box"
|
||||||
<Select
|
direction="row"
|
||||||
id="monitor-interval-configure"
|
justifyContent="space-between"
|
||||||
label="Check frequency"
|
gap={theme.gap.xxl}
|
||||||
value={monitor?.interval / MS_PER_MINUTE || 1}
|
>
|
||||||
onChange={(event) => handleChange(event, "interval")}
|
<Box>
|
||||||
items={frequencies}
|
<Typography component="h2">General settings</Typography>
|
||||||
/>
|
<Typography component="p" sx={{ mt: theme.gap.small }}>
|
||||||
</Stack>
|
Here you can select the URL of the host, together with the
|
||||||
</Stack>
|
type of monitor.
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Stack gap={theme.gap.xl}>
|
||||||
|
<Field
|
||||||
|
type={monitor?.type === "http" ? "url" : "text"}
|
||||||
|
https={protocol === "https"}
|
||||||
|
id="monitor-url"
|
||||||
|
label="URL to monitor"
|
||||||
|
placeholder="google.com"
|
||||||
|
value={parsedUrl?.host || monitor?.url || ""}
|
||||||
|
disabled={true}
|
||||||
|
error={errors["url"]}
|
||||||
|
/>
|
||||||
|
<Field
|
||||||
|
type="text"
|
||||||
|
id="monitor-name"
|
||||||
|
label="Friendly name"
|
||||||
|
isOptional={true}
|
||||||
|
placeholder="Google"
|
||||||
|
value={monitor?.name || ""}
|
||||||
|
onChange={handleChange}
|
||||||
|
error={errors["name"]}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
<Stack
|
||||||
|
className="config-box"
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
gap={theme.gap.xxl}
|
||||||
|
>
|
||||||
|
<Box>
|
||||||
|
<Typography component="h2">Incident notifications</Typography>
|
||||||
|
<Typography component="p" mt={theme.gap.small}>
|
||||||
|
When there is an incident, notify users.
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Stack gap={theme.gap.medium}>
|
||||||
|
<Typography component="p" mt={theme.gap.small}>
|
||||||
|
When there is a new incident,
|
||||||
|
</Typography>
|
||||||
|
<Checkbox
|
||||||
|
id="notify-sms"
|
||||||
|
label="Notify via SMS (coming soon)"
|
||||||
|
isChecked={false}
|
||||||
|
value=""
|
||||||
|
onChange={() => console.log("disabled")}
|
||||||
|
isDisabled={true}
|
||||||
|
/>
|
||||||
|
<Checkbox
|
||||||
|
id="notify-email-default"
|
||||||
|
label={`Notify via email (to ${user.email})`}
|
||||||
|
isChecked={
|
||||||
|
monitor?.notifications?.some(
|
||||||
|
(notification) => notification.type === "email"
|
||||||
|
) || false
|
||||||
|
}
|
||||||
|
value={user?.email}
|
||||||
|
onChange={(event) => handleChange(event)}
|
||||||
|
/>
|
||||||
|
<Checkbox
|
||||||
|
id="notify-email"
|
||||||
|
label="Also notify via email to multiple addresses (coming soon)"
|
||||||
|
isChecked={false}
|
||||||
|
value=""
|
||||||
|
onChange={() => console.log("disabled")}
|
||||||
|
isDisabled={true}
|
||||||
|
/>
|
||||||
|
{monitor?.notifications?.some(
|
||||||
|
(notification) => notification.type === "emails"
|
||||||
|
) ? (
|
||||||
|
<Box mx={`calc(${theme.gap.ml} * 2)`}>
|
||||||
|
<Field
|
||||||
|
id="notify-email-list"
|
||||||
|
type="text"
|
||||||
|
placeholder="name@gmail.com"
|
||||||
|
value=""
|
||||||
|
onChange={() => console.log("disabled")}
|
||||||
|
/>
|
||||||
|
<Typography mt={theme.gap.small}>
|
||||||
|
You can separate multiple emails with a comma
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
<Stack
|
||||||
|
className="config-box"
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
gap={theme.gap.xxl}
|
||||||
|
>
|
||||||
|
<Box>
|
||||||
|
<Typography component="h2">Advanced settings</Typography>
|
||||||
|
</Box>
|
||||||
|
<Stack gap={theme.gap.xl}>
|
||||||
|
<Select
|
||||||
|
id="monitor-interval-configure"
|
||||||
|
label="Check frequency"
|
||||||
|
value={monitor?.interval / MS_PER_MINUTE || 1}
|
||||||
|
onChange={(event) => handleChange(event, "interval")}
|
||||||
|
items={frequencies}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<Stack direction="row" justifyContent="flex-end">
|
<Stack direction="row" justifyContent="flex-end">
|
||||||
<Button
|
{loading ? (
|
||||||
level="primary"
|
<Skeleton variant="rounded" width="15%" height={34} />
|
||||||
label="Save"
|
) : (
|
||||||
sx={{ px: theme.gap.large }}
|
<Button
|
||||||
onClick={handleSubmit}
|
level="primary"
|
||||||
/>
|
label="Save"
|
||||||
|
sx={{ px: theme.gap.large }}
|
||||||
|
onClick={handleSubmit}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</form>
|
</form>
|
||||||
<Modal
|
<Modal
|
||||||
|
|||||||
@@ -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,11 @@ const StatBox = ({ title, value }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StatBox.propTypes = {
|
||||||
|
title: PropTypes.string,
|
||||||
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Details page component displaying monitor details and related information.
|
* Details page component displaying monitor details and related information.
|
||||||
* @component
|
* @component
|
||||||
@@ -158,78 +163,135 @@ const DetailsPage = () => {
|
|||||||
}, 0);
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let loading = Object.keys(monitor).length === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box className="monitor-details">
|
<Box className="monitor-details">
|
||||||
<Button
|
{loading ? (
|
||||||
level="tertiary"
|
<Skeleton variant="rounded" width="20%" height={34} />
|
||||||
label="Back to Monitors"
|
) : (
|
||||||
animate="slideLeft"
|
<Button
|
||||||
img={<WestRoundedIcon />}
|
level="tertiary"
|
||||||
onClick={() => navigate("/monitors")}
|
label="Back to Monitors"
|
||||||
sx={{
|
animate="slideLeft"
|
||||||
backgroundColor: "#f4f4f4",
|
img={<WestRoundedIcon />}
|
||||||
mb: theme.gap.medium,
|
onClick={() => navigate("/monitors")}
|
||||||
px: theme.gap.ml,
|
sx={{
|
||||||
"& svg.MuiSvgIcon-root": {
|
backgroundColor: "#f4f4f4",
|
||||||
mr: theme.gap.small,
|
px: theme.gap.ml,
|
||||||
fill: theme.palette.otherColors.slateGray,
|
"& svg.MuiSvgIcon-root": {
|
||||||
},
|
mr: theme.gap.small,
|
||||||
}}
|
fill: theme.palette.otherColors.slateGray,
|
||||||
/>
|
},
|
||||||
<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 />}
|
{loading ? (
|
||||||
<Box>
|
<Skeleton
|
||||||
<Typography component="h1" sx={{ lineHeight: 1 }}>
|
variant="circular"
|
||||||
{monitor.url?.replace(/^https?:\/\//, "") || "..."}
|
style={{ minWidth: 24, minHeight: 24 }}
|
||||||
</Typography>
|
/>
|
||||||
<Typography mt={theme.gap.small}>
|
) : monitor?.status ? (
|
||||||
<Typography
|
<GreenCheck />
|
||||||
component="span"
|
) : (
|
||||||
sx={{
|
<RedCheck />
|
||||||
color: monitor?.status
|
)}
|
||||||
? "var(--env-var-color-17)"
|
<Box width="80%">
|
||||||
: "var(--env-var-color-24)",
|
{loading ? (
|
||||||
}}
|
<>
|
||||||
>
|
<Skeleton variant="rounded" width="50%" height={24} />
|
||||||
Your site is {monitor?.status ? "up" : "down"}.
|
<Skeleton
|
||||||
</Typography>{" "}
|
variant="rounded"
|
||||||
Checking every {formatDurationRounded(monitor?.interval)}. Last
|
width="50%"
|
||||||
time checked{" "}
|
height={18}
|
||||||
{formatDurationRounded(getLastChecked(monitor?.checks))} ago.
|
sx={{ mt: theme.gap.small }}
|
||||||
</Typography>
|
/>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Typography component="h1" sx={{ lineHeight: 1 }}>
|
||||||
|
{monitor.url?.replace(/^https?:\/\//, "") || "..."}
|
||||||
|
</Typography>
|
||||||
|
<Typography mt={theme.gap.small}>
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
sx={{
|
||||||
|
color: monitor?.status
|
||||||
|
? "var(--env-var-color-17)"
|
||||||
|
: "var(--env-var-color-24)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Your site is {monitor?.status ? "up" : "down"}.
|
||||||
|
</Typography>{" "}
|
||||||
|
Checking every {formatDurationRounded(monitor?.interval)}.
|
||||||
|
Last time checked{" "}
|
||||||
|
{formatDurationRounded(getLastChecked(monitor?.checks))} ago.
|
||||||
|
</Typography>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
<Button
|
{loading ? (
|
||||||
level="tertiary"
|
<Skeleton
|
||||||
label="Configure"
|
variant="rounded"
|
||||||
animate="rotate90"
|
width="20%"
|
||||||
img={
|
height={34}
|
||||||
<SettingsIcon
|
sx={{ alignSelf: "flex-end" }}
|
||||||
style={{ width: theme.gap.mlplus, height: theme.gap.mlplus }}
|
/>
|
||||||
/>
|
) : (
|
||||||
}
|
<Button
|
||||||
onClick={() => navigate(`/monitors/configure/${monitorId}`)}
|
level="tertiary"
|
||||||
sx={{
|
label="Configure"
|
||||||
ml: "auto",
|
animate="rotate90"
|
||||||
alignSelf: "flex-end",
|
img={
|
||||||
backgroundColor: "#f4f4f4",
|
<SettingsIcon
|
||||||
px: theme.gap.medium,
|
style={{
|
||||||
"& svg": {
|
minWidth: theme.gap.mlplus,
|
||||||
mr: "6px",
|
minHeight: theme.gap.mlplus,
|
||||||
},
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
}
|
||||||
|
onClick={() => navigate(`/monitors/configure/${monitorId}`)}
|
||||||
|
sx={{
|
||||||
|
ml: "auto",
|
||||||
|
alignSelf: "flex-end",
|
||||||
|
backgroundColor: "#f4f4f4",
|
||||||
|
px: theme.gap.medium,
|
||||||
|
"& svg": {
|
||||||
|
mr: "6px",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack direction="row" justifyContent="space-between">
|
<Stack
|
||||||
<StatBox
|
direction="row"
|
||||||
title="Currently up for"
|
justifyContent="space-between"
|
||||||
value={formatDuration(calculateUptimeDuration(monitor.checks))}
|
gap={theme.gap.large}
|
||||||
/>
|
>
|
||||||
<StatBox
|
{loading ? (
|
||||||
title="Last checked"
|
<>
|
||||||
value={`${formatDuration(getLastChecked(monitor.checks))} ago`}
|
<Skeleton variant="rounded" width="100%" height={80} />
|
||||||
/>
|
<Skeleton variant="rounded" width="100%" height={80} />
|
||||||
<StatBox title="Incidents" value={countIncidents(monitor.checks)} />
|
<Skeleton variant="rounded" width="100%" height={80} />
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<StatBox
|
||||||
|
title="Currently up for"
|
||||||
|
value={formatDuration(calculateUptimeDuration(monitor.checks))}
|
||||||
|
/>
|
||||||
|
<StatBox
|
||||||
|
title="Last checked"
|
||||||
|
value={`${formatDuration(getLastChecked(monitor.checks))} ago`}
|
||||||
|
/>
|
||||||
|
<StatBox
|
||||||
|
title="Incidents"
|
||||||
|
value={countIncidents(monitor.checks)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box>
|
<Box>
|
||||||
<Stack
|
<Stack
|
||||||
@@ -237,56 +299,82 @@ const DetailsPage = () => {
|
|||||||
justifyContent="space-between"
|
justifyContent="space-between"
|
||||||
mb={theme.gap.ml}
|
mb={theme.gap.ml}
|
||||||
>
|
>
|
||||||
<Typography component="h2" mb={theme.gap.small}>
|
{loading ? (
|
||||||
Response Times
|
<>
|
||||||
</Typography>
|
<Skeleton
|
||||||
<ButtonGroup>
|
variant="rounded"
|
||||||
<Button
|
width="20%"
|
||||||
level="secondary"
|
height={24}
|
||||||
label="Day"
|
sx={{ alignSelf: "flex-end" }}
|
||||||
onClick={() => setFilter("day")}
|
/>
|
||||||
sx={{
|
<Skeleton variant="rounded" width="20%" height={34} />
|
||||||
backgroundColor:
|
</>
|
||||||
filter === "day" && theme.palette.otherColors.fillGray,
|
) : (
|
||||||
}}
|
<>
|
||||||
/>
|
<Typography component="h2" mb={theme.gap.small}>
|
||||||
<Button
|
Response Times
|
||||||
level="secondary"
|
</Typography>
|
||||||
label="Week"
|
<ButtonGroup>
|
||||||
onClick={() => setFilter("week")}
|
<Button
|
||||||
sx={{
|
level="secondary"
|
||||||
backgroundColor:
|
label="Day"
|
||||||
filter === "week" && theme.palette.otherColors.fillGray,
|
onClick={() => setFilter("day")}
|
||||||
}}
|
sx={{
|
||||||
/>
|
backgroundColor:
|
||||||
<Button
|
filter === "day" && theme.palette.otherColors.fillGray,
|
||||||
level="secondary"
|
}}
|
||||||
label="Month"
|
/>
|
||||||
onClick={() => setFilter("month")}
|
<Button
|
||||||
sx={{
|
level="secondary"
|
||||||
backgroundColor:
|
label="Week"
|
||||||
filter === "month" && theme.palette.otherColors.fillGray,
|
onClick={() => setFilter("week")}
|
||||||
}}
|
sx={{
|
||||||
/>
|
backgroundColor:
|
||||||
</ButtonGroup>
|
filter === "week" && theme.palette.otherColors.fillGray,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
level="secondary"
|
||||||
|
label="Month"
|
||||||
|
onClick={() => setFilter("month")}
|
||||||
|
sx={{
|
||||||
|
backgroundColor:
|
||||||
|
filter === "month" &&
|
||||||
|
theme.palette.otherColors.fillGray,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</ButtonGroup>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box sx={{ height: "200px" }}>
|
<Box sx={{ height: "200px" }}>
|
||||||
<MonitorDetailsAreaChart checks={monitor.checks} filter={filter} />
|
{loading ? (
|
||||||
|
<Skeleton variant="rounded" width="100%" height="100%" />
|
||||||
|
) : (
|
||||||
|
<MonitorDetailsAreaChart
|
||||||
|
checks={monitor.checks}
|
||||||
|
filter={filter}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Box>
|
<Stack gap={theme.gap.ml}>
|
||||||
<Typography component="h2" mb={theme.gap.ml}>
|
{loading ? (
|
||||||
History
|
<>
|
||||||
</Typography>
|
<Skeleton variant="rounded" width="20%" height={24} />
|
||||||
<BasicTable data={data} paginated={true} reversed={true} />
|
<Skeleton variant="rounded" width="100%" height={200} />
|
||||||
</Box>
|
<Skeleton variant="rounded" width="100%" height={50} />
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Typography component="h2">History</Typography>
|
||||||
|
<BasicTable data={data} paginated={true} reversed={true} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</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";
|
||||||
@@ -204,46 +205,81 @@ 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">
|
<Stack direction="row" justifyContent="space-between" alignItems="center">
|
||||||
<Typography component="h1">
|
{loading ? (
|
||||||
Hello, {authState.user.firstName}
|
<>
|
||||||
</Typography>
|
<Skeleton variant="rounded" width="50%" height={36} />
|
||||||
<Button
|
<Skeleton variant="rounded" width="15%" height={36} />
|
||||||
level="primary"
|
</>
|
||||||
label="Create new monitor"
|
) : (
|
||||||
onClick={() => {
|
<>
|
||||||
navigate("/monitors/create");
|
<Typography component="h1">
|
||||||
}}
|
Hello, {authState.user.firstName}
|
||||||
/>
|
</Typography>
|
||||||
|
<Button
|
||||||
|
level="primary"
|
||||||
|
label="Create new monitor"
|
||||||
|
onClick={() => {
|
||||||
|
navigate("/monitors/create");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack
|
<Stack
|
||||||
gap={theme.gap.large}
|
gap={theme.gap.large}
|
||||||
direction="row"
|
direction="row"
|
||||||
justifyContent="space-between"
|
justifyContent="space-between"
|
||||||
>
|
>
|
||||||
<ServerStatus title="Up" value={up} state="up" />
|
{loading ? (
|
||||||
<ServerStatus title="Down" value={down} state="down" />
|
<>
|
||||||
<ServerStatus title="Paused" value={0} state="pause" />
|
<Skeleton variant="rounded" width="100%" height={100} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={100} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={100} />
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<ServerStatus title="Up" value={up} state="up" />
|
||||||
|
<ServerStatus title="Down" value={down} state="down" />
|
||||||
|
<ServerStatus title="Paused" value={0} state="pause" />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack
|
<Stack
|
||||||
gap={theme.gap.large}
|
gap={theme.gap.large}
|
||||||
p={theme.gap.xl}
|
p={theme.gap.xl}
|
||||||
|
border={1}
|
||||||
|
borderColor={
|
||||||
|
loading ? "#f9fafb" : theme.palette.otherColors.graishWhite
|
||||||
|
}
|
||||||
|
backgroundColor={loading ? "#f9fafb" : "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">
|
{loading ? (
|
||||||
<Typography component="h2">Current monitors</Typography>
|
<Skeleton variant="rounded" width="50%" height={25} />
|
||||||
<Box className="current-monitors-counter">
|
) : (
|
||||||
{monitorState.monitors.length}
|
<Stack direction="row" alignItems="center">
|
||||||
</Box>
|
<Typography component="h2">Current monitors</Typography>
|
||||||
{/* TODO - add search bar */}
|
<Box className="current-monitors-counter">
|
||||||
</Stack>
|
{monitorState.monitors.length}
|
||||||
<BasicTable data={data} paginated={true} />
|
</Box>
|
||||||
|
{/* TODO - add search bar */}
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
{loading ? (
|
||||||
|
<>
|
||||||
|
<Skeleton variant="rounded" width="100%" height={400} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={100} />
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<BasicTable data={data} paginated={true} />
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Menu
|
<Menu
|
||||||
className="actions-menu"
|
className="actions-menu"
|
||||||
|
|||||||
@@ -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