add loading states, skeletons, fix map tooltip
This commit is contained in:
1 parent
ea1a717ad0
commit
d852388202
10 files changed
+96
-20
No files matched your search
@@ -73,9 +73,12 @@ const CustomToolTip = ({ active, payload, label, dateRange }) => {
|
|||||||
component="span"
|
component="span"
|
||||||
sx={{ opacity: 0.8 }}
|
sx={{ opacity: 0.8 }}
|
||||||
>
|
>
|
||||||
Response Time
|
Response time:
|
||||||
</Typography>{" "}
|
</Typography>
|
||||||
<Typography component="span">
|
<Typography
|
||||||
|
ml={theme.spacing(4)}
|
||||||
|
component="span"
|
||||||
|
>
|
||||||
{Math.floor(responseTime)}
|
{Math.floor(responseTime)}
|
||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
|
|||||||
+13
-10
@@ -24,15 +24,10 @@ const CustomToolTip = ({ active, payload, label }) => {
|
|||||||
? payload[0]?.payload?.originalAvgResponseTime
|
? payload[0]?.payload?.originalAvgResponseTime
|
||||||
: (payload[0]?.payload?.avgResponseTime ?? 0);
|
: (payload[0]?.payload?.avgResponseTime ?? 0);
|
||||||
return (
|
return (
|
||||||
<ChartBox
|
|
||||||
icon={<ResponseTimeIcon />}
|
|
||||||
header="Response Times"
|
|
||||||
sx={{ padding: 0 }}
|
|
||||||
>
|
|
||||||
<Box
|
<Box
|
||||||
className="area-tooltip"
|
className="area-tooltip"
|
||||||
sx={{
|
sx={{
|
||||||
backgroundColor: theme.palette.background.main,
|
backgroundColor: theme.palette.primary.main,
|
||||||
border: 1,
|
border: 1,
|
||||||
borderColor: theme.palette.primary.lowContrast,
|
borderColor: theme.palette.primary.lowContrast,
|
||||||
borderRadius: theme.shape.borderRadius,
|
borderRadius: theme.shape.borderRadius,
|
||||||
@@ -74,9 +69,12 @@ const CustomToolTip = ({ active, payload, label }) => {
|
|||||||
component="span"
|
component="span"
|
||||||
sx={{ opacity: 0.8 }}
|
sx={{ opacity: 0.8 }}
|
||||||
>
|
>
|
||||||
Response Time
|
Response time
|
||||||
</Typography>{" "}
|
</Typography>
|
||||||
<Typography component="span">
|
<Typography
|
||||||
|
ml={theme.spacing(4)}
|
||||||
|
component="span"
|
||||||
|
>
|
||||||
{Math.floor(responseTime)}
|
{Math.floor(responseTime)}
|
||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
@@ -90,7 +88,6 @@ const CustomToolTip = ({ active, payload, label }) => {
|
|||||||
</Box>
|
</Box>
|
||||||
{/* Display original value */}
|
{/* Display original value */}
|
||||||
</Box>
|
</Box>
|
||||||
</ChartBox>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -143,6 +140,11 @@ const DistributedUptimeResponseChart = ({ checks }) => {
|
|||||||
|
|
||||||
if (checks.length === 0) return null;
|
if (checks.length === 0) return null;
|
||||||
return (
|
return (
|
||||||
|
<ChartBox
|
||||||
|
icon={<ResponseTimeIcon />}
|
||||||
|
header="Response Times"
|
||||||
|
sx={{ padding: 0 }}
|
||||||
|
>
|
||||||
<ResponsiveContainer
|
<ResponsiveContainer
|
||||||
width="100%"
|
width="100%"
|
||||||
minWidth={25}
|
minWidth={25}
|
||||||
@@ -212,6 +214,7 @@ const DistributedUptimeResponseChart = ({ checks }) => {
|
|||||||
/>
|
/>
|
||||||
</AreaChart>
|
</AreaChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
|
</ChartBox>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { Stack, Skeleton } from "@mui/material";
|
||||||
|
|
||||||
|
export const SkeletonLayout = () => {
|
||||||
|
return (
|
||||||
|
<Stack>
|
||||||
|
<Skeleton
|
||||||
|
variant="rectangular"
|
||||||
|
height={"90vh"}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SkeletonLayout;
|
||||||
@@ -68,6 +68,9 @@ const useSubscribeToDetails = ({ monitorId, dateRange }) => {
|
|||||||
dateRange: dateRange,
|
dateRange: dateRange,
|
||||||
normalize: true,
|
normalize: true,
|
||||||
onUpdate: (data) => {
|
onUpdate: (data) => {
|
||||||
|
if (isLoading === true) {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
if (networkError === true) {
|
if (networkError === true) {
|
||||||
setNetworkError(false);
|
setNetworkError(false);
|
||||||
}
|
}
|
||||||
@@ -87,6 +90,7 @@ const useSubscribeToDetails = ({ monitorId, dateRange }) => {
|
|||||||
setRetryCount(0); // Reset retry count on successful connection
|
setRetryCount(0); // Reset retry count on successful connection
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: () => {
|
||||||
|
setIsLoading(false);
|
||||||
setNetworkError(true);
|
setNetworkError(true);
|
||||||
setConnectionStatus("down");
|
setConnectionStatus("down");
|
||||||
},
|
},
|
||||||
@@ -94,8 +98,6 @@ const useSubscribeToDetails = ({ monitorId, dateRange }) => {
|
|||||||
return cleanup;
|
return cleanup;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setNetworkError(true);
|
setNetworkError(true);
|
||||||
} finally {
|
|
||||||
setIsLoading(false);
|
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
authToken,
|
authToken,
|
||||||
@@ -105,6 +107,7 @@ const useSubscribeToDetails = ({ monitorId, dateRange }) => {
|
|||||||
setConnectionStatus,
|
setConnectionStatus,
|
||||||
networkError,
|
networkError,
|
||||||
devices,
|
devices,
|
||||||
|
isLoading,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import MonitorHeader from "./Components/MonitorHeader";
|
|||||||
import MonitorTimeFrameHeader from "../../../Components/MonitorTimeFrameHeader";
|
import MonitorTimeFrameHeader from "../../../Components/MonitorTimeFrameHeader";
|
||||||
import GenericFallback from "../../../Components/GenericFallback";
|
import GenericFallback from "../../../Components/GenericFallback";
|
||||||
import MonitorCreateHeader from "../../../Components/MonitorCreateHeader";
|
import MonitorCreateHeader from "../../../Components/MonitorCreateHeader";
|
||||||
|
import SkeletonLayout from "./Components/Skeleton";
|
||||||
//Utils
|
//Utils
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -35,6 +35,10 @@ const DistributedUptimeDetails = () => {
|
|||||||
{ name: "Details", path: `/distributed-uptime/${monitorId}` },
|
{ name: "Details", path: `/distributed-uptime/${monitorId}` },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return <SkeletonLayout />;
|
||||||
|
}
|
||||||
|
|
||||||
if (networkError) {
|
if (networkError) {
|
||||||
return (
|
return (
|
||||||
<GenericFallback>
|
<GenericFallback>
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { Stack, Skeleton } from "@mui/material";
|
||||||
|
|
||||||
|
export const SkeletonLayout = () => {
|
||||||
|
return (
|
||||||
|
<Stack>
|
||||||
|
<Skeleton
|
||||||
|
variant="rectangular"
|
||||||
|
height={"90vh"}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SkeletonLayout;
|
||||||
@@ -32,6 +32,10 @@ const useSubscribeToMonitors = () => {
|
|||||||
field: null,
|
field: null,
|
||||||
order: null,
|
order: null,
|
||||||
onUpdate: (data) => {
|
onUpdate: (data) => {
|
||||||
|
if (isLoading === true) {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
|
||||||
const res = data.monitors;
|
const res = data.monitors;
|
||||||
const { monitors, filteredMonitors, summary } = res;
|
const { monitors, filteredMonitors, summary } = res;
|
||||||
const mappedMonitors = filteredMonitors.map((monitor) =>
|
const mappedMonitors = filteredMonitors.map((monitor) =>
|
||||||
@@ -41,6 +45,9 @@ const useSubscribeToMonitors = () => {
|
|||||||
setMonitorsSummary(summary);
|
setMonitorsSummary(summary);
|
||||||
setFilteredMonitors(mappedMonitors);
|
setFilteredMonitors(mappedMonitors);
|
||||||
},
|
},
|
||||||
|
onError: () => {
|
||||||
|
setIsLoading(false);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return cleanup;
|
return cleanup;
|
||||||
@@ -49,8 +56,6 @@ const useSubscribeToMonitors = () => {
|
|||||||
body: error.message,
|
body: error.message,
|
||||||
});
|
});
|
||||||
setNetworkError(true);
|
setNetworkError(true);
|
||||||
} finally {
|
|
||||||
setIsLoading(false);
|
|
||||||
}
|
}
|
||||||
}, [authToken, user, getMonitorWithPercentage, theme]);
|
}, [authToken, user, getMonitorWithPercentage, theme]);
|
||||||
return [isLoading, networkError, monitors, monitorsSummary, filteredMonitors];
|
return [isLoading, networkError, monitors, monitorsSummary, filteredMonitors];
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import GenericFallback from "../../../Components/GenericFallback";
|
|||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
||||||
import { useSubscribeToMonitors } from "./Hooks/useSubscribeToMonitors";
|
import { useSubscribeToMonitors } from "./Hooks/useSubscribeToMonitors";
|
||||||
|
import SkeletonLayout from "./Components/Skeleton";
|
||||||
// Constants
|
// Constants
|
||||||
const BREADCRUMBS = [{ name: `Distributed Uptime`, path: "/distributed-uptime" }];
|
const BREADCRUMBS = [{ name: `Distributed Uptime`, path: "/distributed-uptime" }];
|
||||||
|
|
||||||
@@ -21,6 +22,10 @@ const DistributedUptimeMonitors = () => {
|
|||||||
const [isLoading, networkError, monitors, monitorsSummary, filteredMonitors] =
|
const [isLoading, networkError, monitors, monitorsSummary, filteredMonitors] =
|
||||||
useSubscribeToMonitors();
|
useSubscribeToMonitors();
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return <SkeletonLayout />;
|
||||||
|
}
|
||||||
|
|
||||||
if (networkError) {
|
if (networkError) {
|
||||||
return (
|
return (
|
||||||
<GenericFallback>
|
<GenericFallback>
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { Stack, Skeleton } from "@mui/material";
|
||||||
|
|
||||||
|
export const SkeletonLayout = () => {
|
||||||
|
return (
|
||||||
|
<Stack>
|
||||||
|
<Skeleton
|
||||||
|
variant="rectangular"
|
||||||
|
height={"90vh"}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SkeletonLayout;
|
||||||
@@ -11,6 +11,7 @@ import ControlsHeader from "../../StatusPage/Status/Components/ControlsHeader";
|
|||||||
import MonitorTimeFrameHeader from "../../../Components/MonitorTimeFrameHeader";
|
import MonitorTimeFrameHeader from "../../../Components/MonitorTimeFrameHeader";
|
||||||
import GenericFallback from "../../../Components/GenericFallback";
|
import GenericFallback from "../../../Components/GenericFallback";
|
||||||
import Dialog from "../../../Components/Dialog";
|
import Dialog from "../../../Components/Dialog";
|
||||||
|
import SkeletonLayout from "./Components/Skeleton";
|
||||||
//Utils
|
//Utils
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -46,6 +47,7 @@ const DistributedUptimeStatus = () => {
|
|||||||
// Constants
|
// Constants
|
||||||
const BREADCRUMBS = [
|
const BREADCRUMBS = [
|
||||||
{ name: "Distributed Uptime", path: "/distributed-uptime" },
|
{ name: "Distributed Uptime", path: "/distributed-uptime" },
|
||||||
|
{ name: "details", path: `/distributed-uptime/${monitorId}` },
|
||||||
{ name: "status", path: `` },
|
{ name: "status", path: `` },
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -59,7 +61,11 @@ const DistributedUptimeStatus = () => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (networkError) {
|
if (isLoading || statusPageIsLoading) {
|
||||||
|
return <SkeletonLayout />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (networkError || statusPageNetworkError) {
|
||||||
return (
|
return (
|
||||||
<GenericFallback>
|
<GenericFallback>
|
||||||
<Typography
|
<Typography
|
||||||
@@ -74,7 +80,11 @@ const DistributedUptimeStatus = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof monitor === "undefined" || monitor.totalChecks === 0) {
|
if (
|
||||||
|
typeof statusPage === "undefined" ||
|
||||||
|
typeof monitor === "undefined" ||
|
||||||
|
monitor.totalChecks === 0
|
||||||
|
) {
|
||||||
return (
|
return (
|
||||||
<Stack gap={theme.spacing(10)}>
|
<Stack gap={theme.spacing(10)}>
|
||||||
<Breadcrumbs list={BREADCRUMBS} />
|
<Breadcrumbs list={BREADCRUMBS} />
|
||||||
@@ -93,6 +103,7 @@ const DistributedUptimeStatus = () => {
|
|||||||
>
|
>
|
||||||
{!isPublic && <Breadcrumbs list={BREADCRUMBS} />}
|
{!isPublic && <Breadcrumbs list={BREADCRUMBS} />}
|
||||||
<ControlsHeader
|
<ControlsHeader
|
||||||
|
shouldShow={!isPublic}
|
||||||
statusPage={statusPage}
|
statusPage={statusPage}
|
||||||
isDeleting={isDeleting}
|
isDeleting={isDeleting}
|
||||||
isDeleteOpen={isDeleteOpen}
|
isDeleteOpen={isDeleteOpen}
|
||||||
|
|||||||
Reference in new issue
Block a user