Add pending state to monitors and config screens
This commit is contained in:
1 parent
295146bbef
commit
02c2689e1e
5 files changed
+112
-109
No files matched your search
@@ -139,10 +139,10 @@ const StatusLabel = ({ status, text, customStyles }) => {
|
|||||||
bgColor: theme.palette.error.bg,
|
bgColor: theme.palette.error.bg,
|
||||||
borderColor: theme.palette.error.light,
|
borderColor: theme.palette.error.light,
|
||||||
},
|
},
|
||||||
unknown: {
|
pending: {
|
||||||
dotColor: theme.palette.unresolved.main,
|
dotColor: theme.palette.warning.main,
|
||||||
bgColor: theme.palette.unresolved.bg,
|
bgColor: theme.palette.warning.bg,
|
||||||
borderColor: theme.palette.unresolved.light,
|
borderColor: theme.palette.warning.light,
|
||||||
},
|
},
|
||||||
"cannot resolve": {
|
"cannot resolve": {
|
||||||
dotColor: theme.palette.unresolved.main,
|
dotColor: theme.palette.unresolved.main,
|
||||||
@@ -176,7 +176,7 @@ const StatusLabel = ({ status, text, customStyles }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
StatusLabel.propTypes = {
|
StatusLabel.propTypes = {
|
||||||
status: PropTypes.oneOf(["up", "down", "unknown", "cannot resolve"]),
|
status: PropTypes.oneOf(["up", "down", "pending", "cannot resolve"]),
|
||||||
text: PropTypes.string,
|
text: PropTypes.string,
|
||||||
customStyles: PropTypes.object,
|
customStyles: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ const Configure = () => {
|
|||||||
const [monitor, setMonitor] = useState({});
|
const [monitor, setMonitor] = useState({});
|
||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
const { monitorId } = useParams();
|
const { monitorId } = useParams();
|
||||||
console.log(monitor);
|
|
||||||
const idMap = {
|
const idMap = {
|
||||||
"monitor-url": "url",
|
"monitor-url": "url",
|
||||||
"monitor-name": "name",
|
"monitor-name": "name",
|
||||||
@@ -190,6 +189,18 @@ const Configure = () => {
|
|||||||
const parsedUrl = parseUrl(monitor?.url);
|
const parsedUrl = parseUrl(monitor?.url);
|
||||||
const protocol = parsedUrl?.protocol?.replace(":", "") || "";
|
const protocol = parsedUrl?.protocol?.replace(":", "") || "";
|
||||||
|
|
||||||
|
const statusColor = {
|
||||||
|
true: theme.palette.success.main,
|
||||||
|
false: theme.palette.error.main,
|
||||||
|
undefined: theme.palette.warning.main,
|
||||||
|
};
|
||||||
|
|
||||||
|
const statusMsg = {
|
||||||
|
true: "Your site is up.",
|
||||||
|
false: "Your site is down.",
|
||||||
|
undefined: "Pending...",
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="configure-monitor" gap={theme.spacing(12)}>
|
<Stack className="configure-monitor" gap={theme.spacing(12)}>
|
||||||
{Object.keys(monitor).length === 0 ? (
|
{Object.keys(monitor).length === 0 ? (
|
||||||
@@ -211,13 +222,7 @@ const Configure = () => {
|
|||||||
flex={1}
|
flex={1}
|
||||||
>
|
>
|
||||||
<Stack direction="row" gap={theme.spacing(2)}>
|
<Stack direction="row" gap={theme.spacing(2)}>
|
||||||
<PulseDot
|
<PulseDot color={statusColor[monitor?.status ?? undefined]} />
|
||||||
color={
|
|
||||||
monitor?.status
|
|
||||||
? theme.palette.success.main
|
|
||||||
: theme.palette.error.main
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Box>
|
<Box>
|
||||||
{parsedUrl?.host ? (
|
{parsedUrl?.host ? (
|
||||||
<Typography
|
<Typography
|
||||||
@@ -234,13 +239,9 @@ const Configure = () => {
|
|||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
lineHeight={theme.spacing(12)}
|
lineHeight={theme.spacing(12)}
|
||||||
sx={{
|
sx={{ color: statusColor[monitor?.status ?? undefined] }}
|
||||||
color: monitor?.status
|
|
||||||
? theme.palette.success.main
|
|
||||||
: theme.palette.error.text,
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
Your site is {monitor?.status ? "up" : "down"}.
|
{statusMsg[monitor?.status ?? undefined]}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { useEffect, useState, useCallback } from "react";
|
import { useEffect, useState, useCallback } from "react";
|
||||||
import {
|
import { Box, Button, Stack, Typography, useTheme } from "@mui/material";
|
||||||
Box,
|
|
||||||
Button,
|
|
||||||
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 { networkService } from "../../../main";
|
import { networkService } from "../../../main";
|
||||||
@@ -22,6 +15,7 @@ import SettingsIcon from "../../../assets/icons/settings-bold.svg?react";
|
|||||||
import PaginationTable from "./PaginationTable";
|
import PaginationTable from "./PaginationTable";
|
||||||
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
||||||
import PulseDot from "../../../Components/Animated/PulseDot";
|
import PulseDot from "../../../Components/Animated/PulseDot";
|
||||||
|
import SkeletonLayout from "./skeleton";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
const StatBox = ({ title, value }) => {
|
const StatBox = ({ title, value }) => {
|
||||||
@@ -71,76 +65,6 @@ StatBox.propTypes = {
|
|||||||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
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.spacing(20)} mt={theme.spacing(6)}>
|
|
||||||
<Stack direction="row" gap={theme.spacing(4)} mt={theme.spacing(4)}>
|
|
||||||
<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.spacing(4) }}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
<Skeleton
|
|
||||||
variant="rounded"
|
|
||||||
width="20%"
|
|
||||||
height={34}
|
|
||||||
sx={{ alignSelf: "flex-end" }}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
justifyContent="space-between"
|
|
||||||
gap={theme.spacing(12)}
|
|
||||||
>
|
|
||||||
<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.spacing(8)}
|
|
||||||
>
|
|
||||||
<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.spacing(8)}>
|
|
||||||
<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
|
||||||
@@ -195,6 +119,19 @@ const DetailsPage = ({ isAdmin }) => {
|
|||||||
}, [authToken, monitorId, monitor]);
|
}, [authToken, monitorId, monitor]);
|
||||||
|
|
||||||
let loading = Object.keys(monitor).length === 0;
|
let loading = Object.keys(monitor).length === 0;
|
||||||
|
|
||||||
|
const statusColor = {
|
||||||
|
true: theme.palette.success.main,
|
||||||
|
false: theme.palette.error.main,
|
||||||
|
undefined: theme.palette.warning.main,
|
||||||
|
};
|
||||||
|
|
||||||
|
const statusMsg = {
|
||||||
|
true: "Your site is up.",
|
||||||
|
false: "Your site is down.",
|
||||||
|
undefined: "Pending...",
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box className="monitor-details">
|
<Box className="monitor-details">
|
||||||
{loading ? (
|
{loading ? (
|
||||||
@@ -209,13 +146,7 @@ const DetailsPage = ({ isAdmin }) => {
|
|||||||
/>
|
/>
|
||||||
<Stack gap={theme.spacing(12)} mt={theme.spacing(12)}>
|
<Stack gap={theme.spacing(12)} mt={theme.spacing(12)}>
|
||||||
<Stack direction="row" gap={theme.spacing(2)}>
|
<Stack direction="row" gap={theme.spacing(2)}>
|
||||||
<PulseDot
|
<PulseDot color={statusColor[monitor?.status ?? undefined]} />
|
||||||
color={
|
|
||||||
monitor?.status
|
|
||||||
? theme.palette.success.main
|
|
||||||
: theme.palette.error.main
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Box>
|
<Box>
|
||||||
<Typography
|
<Typography
|
||||||
component="h1"
|
component="h1"
|
||||||
@@ -231,12 +162,10 @@ const DetailsPage = ({ isAdmin }) => {
|
|||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
sx={{
|
sx={{
|
||||||
color: monitor?.status
|
color: statusColor[monitor?.status ?? undefined],
|
||||||
? theme.palette.success.main
|
|
||||||
: theme.palette.success.text,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Your site is {monitor?.status ? "up" : "down"}.
|
{statusMsg[monitor?.status ?? undefined]}
|
||||||
</Typography>{" "}
|
</Typography>{" "}
|
||||||
Checking every {formatDurationRounded(monitor?.interval)}.
|
Checking every {formatDurationRounded(monitor?.interval)}.
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import { Box, Skeleton, Stack, useTheme } from "@mui/material";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders a skeleton layout.
|
||||||
|
*
|
||||||
|
* @returns {JSX.Element}
|
||||||
|
*/
|
||||||
|
const SkeletonLayout = () => {
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Skeleton variant="rounded" width="20%" height={34} />
|
||||||
|
<Stack gap={theme.spacing(20)} mt={theme.spacing(6)}>
|
||||||
|
<Stack direction="row" gap={theme.spacing(4)} mt={theme.spacing(4)}>
|
||||||
|
<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.spacing(4) }}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="20%"
|
||||||
|
height={34}
|
||||||
|
sx={{ alignSelf: "flex-end" }}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
gap={theme.spacing(12)}
|
||||||
|
>
|
||||||
|
<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.spacing(8)}
|
||||||
|
>
|
||||||
|
<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.spacing(8)}>
|
||||||
|
<Skeleton variant="rounded" width="20%" height={24} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={200} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={50} />
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SkeletonLayout;
|
||||||
@@ -66,7 +66,7 @@ export const buildData = (monitors, isAdmin, navigate) => {
|
|||||||
percentageColor,
|
percentageColor,
|
||||||
status:
|
status:
|
||||||
monitor.status === undefined
|
monitor.status === undefined
|
||||||
? "unknown"
|
? "pending"
|
||||||
: monitor.status === true
|
: monitor.status === true
|
||||||
? "up"
|
? "up"
|
||||||
: "down",
|
: "down",
|
||||||
|
|||||||
Reference in new issue
Block a user