update details page to use new queries
This commit is contained in:
1 parent
9ac563bf8c
commit
3d71e7759b
11 files changed
+131
-81
No files matched your search
@@ -8,10 +8,10 @@ import ConfigButton from "./ConfigButton";
|
|||||||
import SkeletonLayout from "./skeleton";
|
import SkeletonLayout from "./skeleton";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
const MonitorStatusHeader = ({ path, shouldRender = true, isAdmin, monitor }) => {
|
const MonitorStatusHeader = ({ path, isLoading = false, isAdmin, monitor }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { statusColor, statusMsg, determineState } = useUtils();
|
const { statusColor, determineState } = useUtils();
|
||||||
if (!shouldRender) {
|
if (isLoading) {
|
||||||
return <SkeletonLayout />;
|
return <SkeletonLayout />;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ const MonitorStatusHeader = ({ path, shouldRender = true, isAdmin, monitor }) =>
|
|||||||
|
|
||||||
MonitorStatusHeader.propTypes = {
|
MonitorStatusHeader.propTypes = {
|
||||||
path: PropTypes.string.isRequired,
|
path: PropTypes.string.isRequired,
|
||||||
shouldRender: PropTypes.bool,
|
isLoading: PropTypes.bool,
|
||||||
isAdmin: PropTypes.bool,
|
isAdmin: PropTypes.bool,
|
||||||
monitor: PropTypes.object,
|
monitor: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import SkeletonLayout from "./skeleton";
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
const MonitorTimeFrameHeader = ({
|
const MonitorTimeFrameHeader = ({
|
||||||
shouldRender = true,
|
isLoading = false,
|
||||||
hasDateRange = true,
|
hasDateRange = true,
|
||||||
dateRange,
|
dateRange,
|
||||||
setDateRange,
|
setDateRange,
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
if (!shouldRender) {
|
if (isLoading) {
|
||||||
return <SkeletonLayout />;
|
return <SkeletonLayout />;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ const MonitorTimeFrameHeader = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
MonitorTimeFrameHeader.propTypes = {
|
MonitorTimeFrameHeader.propTypes = {
|
||||||
shouldRender: PropTypes.bool,
|
isLoading: PropTypes.bool,
|
||||||
hasDateRange: PropTypes.bool,
|
hasDateRange: PropTypes.bool,
|
||||||
dateRange: PropTypes.string,
|
dateRange: PropTypes.string,
|
||||||
setDateRange: PropTypes.func,
|
setDateRange: PropTypes.func,
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { networkService } from "../main";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import { createToast } from "../Utils/toastUtils";
|
||||||
|
|
||||||
|
export const useFetchUptimeMonitorDetails = ({ monitorId, dateRange }) => {
|
||||||
|
const [networkError, setNetworkError] = useState(false);
|
||||||
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
const [monitor, setMonitor] = useState(undefined);
|
||||||
|
const [monitorStats, setMonitorStats] = useState(undefined);
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchMonitors = async () => {
|
||||||
|
try {
|
||||||
|
const res = await networkService.getUptimeDetailsById({
|
||||||
|
monitorId: monitorId,
|
||||||
|
dateRange: dateRange,
|
||||||
|
normalize: true,
|
||||||
|
});
|
||||||
|
const { monitorData, monitorStats } = res?.data?.data ?? {};
|
||||||
|
setMonitor(monitorData);
|
||||||
|
setMonitorStats(monitorStats);
|
||||||
|
} catch (error) {
|
||||||
|
setNetworkError(true);
|
||||||
|
createToast({ body: error.message });
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fetchMonitors();
|
||||||
|
}, [dateRange, monitorId, navigate]);
|
||||||
|
return [monitor, monitorStats, isLoading, networkError];
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useFetchUptimeMonitorDetails;
|
||||||
@@ -27,7 +27,7 @@ const StatusPagesTable = ({ data }) => {
|
|||||||
row.type === "distributed"
|
row.type === "distributed"
|
||||||
? `/status/distributed/public/${row.url}`
|
? `/status/distributed/public/${row.url}`
|
||||||
: `/status/uptime/public/${row.url}`;
|
: `/status/uptime/public/${row.url}`;
|
||||||
window.open(url, "_blank", "noopener,noreferrer")
|
window.open(url, "_blank", "noopener,noreferrer");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
render: (row) => {
|
render: (row) => {
|
||||||
|
|||||||
@@ -12,29 +12,23 @@ import SkeletonLayout from "./skeleton";
|
|||||||
import { formatDateWithTz } from "../../../../../Utils/timeUtils";
|
import { formatDateWithTz } from "../../../../../Utils/timeUtils";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
const ChartBoxes = ({
|
const ChartBoxes = ({
|
||||||
shouldRender = true,
|
isLoading = false,
|
||||||
monitor,
|
monitorData,
|
||||||
dateRange,
|
dateRange,
|
||||||
uiTimezone,
|
uiTimezone,
|
||||||
dateFormat,
|
dateFormat,
|
||||||
hoveredUptimeData,
|
|
||||||
setHoveredUptimeData,
|
|
||||||
hoveredIncidentsData,
|
|
||||||
setHoveredIncidentsData,
|
|
||||||
}) => {
|
}) => {
|
||||||
|
// Local state
|
||||||
|
const [hoveredUptimeData, setHoveredUptimeData] = useState(null);
|
||||||
|
const [hoveredIncidentsData, setHoveredIncidentsData] = useState(null);
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
if (isLoading) {
|
||||||
if (!shouldRender) {
|
|
||||||
return <SkeletonLayout />;
|
return <SkeletonLayout />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const totalUpChecks = monitor?.upChecks?.totalChecks ?? 0;
|
|
||||||
const totalDownChecks = monitor?.downChecks?.totalChecks ?? 0;
|
|
||||||
const denominator =
|
|
||||||
totalUpChecks + totalDownChecks > 0 ? totalUpChecks + totalDownChecks : 1;
|
|
||||||
const groupedUptimePercentage = (totalUpChecks / denominator) * 100;
|
|
||||||
const noIncidentsMessage = "Great. No Incidents, yet!";
|
const noIncidentsMessage = "Great. No Incidents, yet!";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -46,7 +40,7 @@ const ChartBoxes = ({
|
|||||||
<ChartBox
|
<ChartBox
|
||||||
icon={<UptimeIcon />}
|
icon={<UptimeIcon />}
|
||||||
header="Uptime"
|
header="Uptime"
|
||||||
isEmpty={monitor?.uptimePercentage === 0 && !monitor?.upChecks?.length}
|
isEmpty={false} // TODO
|
||||||
>
|
>
|
||||||
<Stack
|
<Stack
|
||||||
width={"100%"}
|
width={"100%"}
|
||||||
@@ -58,7 +52,7 @@ const ChartBoxes = ({
|
|||||||
<Typography component="span">
|
<Typography component="span">
|
||||||
{hoveredUptimeData !== null
|
{hoveredUptimeData !== null
|
||||||
? hoveredUptimeData.totalChecks
|
? hoveredUptimeData.totalChecks
|
||||||
: (monitor?.groupedUpChecks?.reduce((count, checkGroup) => {
|
: (monitorData?.groupedUpChecks?.reduce((count, checkGroup) => {
|
||||||
return count + checkGroup.totalChecks;
|
return count + checkGroup.totalChecks;
|
||||||
}, 0) ?? 0)}
|
}, 0) ?? 0)}
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -81,7 +75,7 @@ const ChartBoxes = ({
|
|||||||
<Typography component="span">
|
<Typography component="span">
|
||||||
{hoveredUptimeData !== null
|
{hoveredUptimeData !== null
|
||||||
? Math.floor(hoveredUptimeData?.avgResponseTime ?? 0)
|
? Math.floor(hoveredUptimeData?.avgResponseTime ?? 0)
|
||||||
: Math.floor(groupedUptimePercentage)}
|
: Math.floor(monitorData?.groupedUptimePercentage * 100 ?? 0)}
|
||||||
<Typography component="span">
|
<Typography component="span">
|
||||||
{hoveredUptimeData !== null ? " ms" : " %"}
|
{hoveredUptimeData !== null ? " ms" : " %"}
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -89,7 +83,7 @@ const ChartBoxes = ({
|
|||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
<UpBarChart
|
<UpBarChart
|
||||||
monitor={monitor}
|
groupedUpChecks={monitorData?.groupedUpChecks}
|
||||||
type={dateRange}
|
type={dateRange}
|
||||||
onBarHover={setHoveredUptimeData}
|
onBarHover={setHoveredUptimeData}
|
||||||
/>
|
/>
|
||||||
@@ -98,14 +92,14 @@ const ChartBoxes = ({
|
|||||||
icon={<IncidentsIcon />}
|
icon={<IncidentsIcon />}
|
||||||
header="Incidents"
|
header="Incidents"
|
||||||
noDataMessage={noIncidentsMessage}
|
noDataMessage={noIncidentsMessage}
|
||||||
isEmpty={monitor?.groupedDownChecks?.length === 0}
|
isEmpty={monitorData?.groupedDownChecks?.length === 0}
|
||||||
>
|
>
|
||||||
<Stack width={"100%"}>
|
<Stack width={"100%"}>
|
||||||
<Box position="relative">
|
<Box position="relative">
|
||||||
<Typography component="span">
|
<Typography component="span">
|
||||||
{hoveredIncidentsData !== null
|
{hoveredIncidentsData !== null
|
||||||
? hoveredIncidentsData.totalChecks
|
? hoveredIncidentsData.totalChecks
|
||||||
: (monitor?.groupedDownChecks?.reduce((count, checkGroup) => {
|
: (monitorData?.groupedDownChecks?.reduce((count, checkGroup) => {
|
||||||
return count + checkGroup.totalChecks;
|
return count + checkGroup.totalChecks;
|
||||||
}, 0) ?? 0)}
|
}, 0) ?? 0)}
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -123,7 +117,7 @@ const ChartBoxes = ({
|
|||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
<DownBarChart
|
<DownBarChart
|
||||||
monitor={monitor}
|
groupedDownChecks={monitorData?.groupedDownChecks}
|
||||||
type={dateRange}
|
type={dateRange}
|
||||||
onBarHover={setHoveredIncidentsData}
|
onBarHover={setHoveredIncidentsData}
|
||||||
/>
|
/>
|
||||||
@@ -132,7 +126,7 @@ const ChartBoxes = ({
|
|||||||
icon={<AverageResponseIcon />}
|
icon={<AverageResponseIcon />}
|
||||||
header="Average Response Time"
|
header="Average Response Time"
|
||||||
>
|
>
|
||||||
<ResponseGaugeChart avgResponseTime={monitor?.avgResponseTime ?? 0} />
|
<ResponseGaugeChart avgResponseTime={monitorData?.groupedAvgResponseTime ?? 0} />
|
||||||
</ChartBox>
|
</ChartBox>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
@@ -141,8 +135,8 @@ const ChartBoxes = ({
|
|||||||
export default ChartBoxes;
|
export default ChartBoxes;
|
||||||
|
|
||||||
ChartBoxes.propTypes = {
|
ChartBoxes.propTypes = {
|
||||||
shouldRender: PropTypes.bool,
|
isLoading: PropTypes.bool,
|
||||||
monitor: PropTypes.object,
|
monitorData: PropTypes.object,
|
||||||
dateRange: PropTypes.string.isRequired,
|
dateRange: PropTypes.string.isRequired,
|
||||||
uiTimezone: PropTypes.string.isRequired,
|
uiTimezone: PropTypes.string.isRequired,
|
||||||
dateFormat: PropTypes.string.isRequired,
|
dateFormat: PropTypes.string.isRequired,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { ResponsiveContainer, BarChart, XAxis, Bar, Cell } from "recharts";
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import CustomLabels from "./CustomLabels";
|
import CustomLabels from "./CustomLabels";
|
||||||
|
|
||||||
const DownBarChart = memo(({ monitor, type, onBarHover }) => {
|
const DownBarChart = memo(({ groupedDownChecks = [], type, onBarHover }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
const [chartHovered, setChartHovered] = useState(false);
|
const [chartHovered, setChartHovered] = useState(false);
|
||||||
@@ -19,7 +19,7 @@ const DownBarChart = memo(({ monitor, type, onBarHover }) => {
|
|||||||
<BarChart
|
<BarChart
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
data={monitor?.groupedDownChecks}
|
data={groupedDownChecks}
|
||||||
onMouseEnter={() => {
|
onMouseEnter={() => {
|
||||||
setChartHovered(true);
|
setChartHovered(true);
|
||||||
onBarHover({ time: null, totalChecks: 0 });
|
onBarHover({ time: null, totalChecks: 0 });
|
||||||
@@ -40,10 +40,8 @@ const DownBarChart = memo(({ monitor, type, onBarHover }) => {
|
|||||||
y={0}
|
y={0}
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
firstDataPoint={monitor?.groupedDownChecks?.[0] ?? {}}
|
firstDataPoint={groupedDownChecks?.[0] ?? {}}
|
||||||
lastDataPoint={
|
lastDataPoint={groupedDownChecks?.[groupedDownChecks?.length - 1] ?? {}}
|
||||||
monitor?.groupedDownChecks?.[monitor?.groupedDownChecks?.length - 1] ?? {}
|
|
||||||
}
|
|
||||||
type={type}
|
type={type}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
@@ -53,7 +51,7 @@ const DownBarChart = memo(({ monitor, type, onBarHover }) => {
|
|||||||
maxBarSize={7}
|
maxBarSize={7}
|
||||||
background={{ fill: "transparent" }}
|
background={{ fill: "transparent" }}
|
||||||
>
|
>
|
||||||
{monitor?.groupedDownChecks?.map((entry, index) => {
|
{groupedDownChecks?.map((entry, index) => {
|
||||||
return (
|
return (
|
||||||
<Cell
|
<Cell
|
||||||
key={`cell-${entry.time}`}
|
key={`cell-${entry.time}`}
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import ResponseTimeIcon from "../../../../../assets/icons/response-time-icon.svg
|
|||||||
import SkeletonLayout from "./ResponseTimeChartSkeleton";
|
import SkeletonLayout from "./ResponseTimeChartSkeleton";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
const ResponseTImeChart = ({ shouldRender = true, monitor, dateRange }) => {
|
const ResponseTImeChart = ({ isLoading = false, groupedChecks = [], dateRange }) => {
|
||||||
if (!shouldRender) {
|
if (isLoading) {
|
||||||
return <SkeletonLayout />;
|
return <SkeletonLayout />;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ const ResponseTImeChart = ({ shouldRender = true, monitor, dateRange }) => {
|
|||||||
header="Response Times"
|
header="Response Times"
|
||||||
>
|
>
|
||||||
<MonitorDetailsAreaChart
|
<MonitorDetailsAreaChart
|
||||||
checks={monitor?.groupedChecks ?? []}
|
checks={groupedChecks}
|
||||||
dateRange={dateRange}
|
dateRange={dateRange}
|
||||||
/>
|
/>
|
||||||
</ChartBox>
|
</ChartBox>
|
||||||
@@ -23,8 +23,8 @@ const ResponseTImeChart = ({ shouldRender = true, monitor, dateRange }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ResponseTImeChart.propTypes = {
|
ResponseTImeChart.propTypes = {
|
||||||
shouldRender: PropTypes.bool,
|
isLoading: PropTypes.bool,
|
||||||
monitor: PropTypes.object,
|
groupedChecks: PropTypes.array,
|
||||||
dateRange: PropTypes.string,
|
dateRange: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const getThemeColor = (responseTime) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const UpBarChart = memo(({ monitor, type, onBarHover }) => {
|
const UpBarChart = memo(({ groupedUpChecks = [], type, onBarHover }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const [chartHovered, setChartHovered] = useState(false);
|
const [chartHovered, setChartHovered] = useState(false);
|
||||||
const [hoveredBarIndex, setHoveredBarIndex] = useState(null);
|
const [hoveredBarIndex, setHoveredBarIndex] = useState(null);
|
||||||
@@ -28,7 +28,7 @@ const UpBarChart = memo(({ monitor, type, onBarHover }) => {
|
|||||||
<BarChart
|
<BarChart
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
data={monitor?.groupedUpChecks}
|
data={groupedUpChecks}
|
||||||
onMouseEnter={() => {
|
onMouseEnter={() => {
|
||||||
setChartHovered(true);
|
setChartHovered(true);
|
||||||
onBarHover({ time: null, totalChecks: 0, avgResponseTime: 0 });
|
onBarHover({ time: null, totalChecks: 0, avgResponseTime: 0 });
|
||||||
@@ -49,10 +49,8 @@ const UpBarChart = memo(({ monitor, type, onBarHover }) => {
|
|||||||
y={0}
|
y={0}
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
firstDataPoint={monitor?.groupedUpChecks?.[0]}
|
firstDataPoint={groupedUpChecks?.[0]}
|
||||||
lastDataPoint={
|
lastDataPoint={groupedUpChecks?.[groupedUpChecks?.length - 1]}
|
||||||
monitor?.groupedUpChecks?.[monitor?.groupedUpChecks?.length - 1]
|
|
||||||
}
|
|
||||||
type={type}
|
type={type}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
@@ -62,7 +60,7 @@ const UpBarChart = memo(({ monitor, type, onBarHover }) => {
|
|||||||
maxBarSize={7}
|
maxBarSize={7}
|
||||||
background={{ fill: "transparent" }}
|
background={{ fill: "transparent" }}
|
||||||
>
|
>
|
||||||
{monitor?.groupedUpChecks?.map((entry, index) => {
|
{groupedUpChecks?.map((entry, index) => {
|
||||||
const themeColor = getThemeColor(entry.avgResponseTime);
|
const themeColor = getThemeColor(entry.avgResponseTime);
|
||||||
return (
|
return (
|
||||||
<Cell
|
<Cell
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { formatDateWithTz } from "../../../../../Utils/timeUtils";
|
import { formatDateWithTz } from "../../../../../Utils/timeUtils";
|
||||||
import SkeletonLayout from "./skeleton";
|
import SkeletonLayout from "./skeleton";
|
||||||
const ResponseTable = ({
|
const ResponseTable = ({
|
||||||
shouldRender = true,
|
isLoading = false,
|
||||||
checks = [],
|
checks = [],
|
||||||
checksCount,
|
checksCount,
|
||||||
uiTimezone,
|
uiTimezone,
|
||||||
@@ -17,8 +17,12 @@ const ResponseTable = ({
|
|||||||
rowsPerPage,
|
rowsPerPage,
|
||||||
setRowsPerPage,
|
setRowsPerPage,
|
||||||
}) => {
|
}) => {
|
||||||
|
<<<<<<< Updated upstream
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
if (!shouldRender) {
|
if (!shouldRender) {
|
||||||
|
=======
|
||||||
|
if (isLoading) {
|
||||||
|
>>>>>>> Stashed changes
|
||||||
return <SkeletonLayout />;
|
return <SkeletonLayout />;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +82,7 @@ const ResponseTable = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
ResponseTable.propTypes = {
|
ResponseTable.propTypes = {
|
||||||
shouldRender: PropTypes.bool,
|
isLoading: PropTypes.bool,
|
||||||
checks: PropTypes.array,
|
checks: PropTypes.array,
|
||||||
checksCount: PropTypes.number,
|
checksCount: PropTypes.number,
|
||||||
uiTimezone: PropTypes.string.isRequired,
|
uiTimezone: PropTypes.string.isRequired,
|
||||||
|
|||||||
@@ -1,23 +1,36 @@
|
|||||||
import StatusBoxes from "../../../../../Components/StatusBoxes";
|
import StatusBoxes from "../../../../../Components/StatusBoxes";
|
||||||
import StatBox from "../../../../../Components/StatBox";
|
import StatBox from "../../../../../Components/StatBox";
|
||||||
|
|
||||||
|
import PropTypes from "prop-types";
|
||||||
import { getHumanReadableDuration } from "../../../../../Utils/timeUtils";
|
import { getHumanReadableDuration } from "../../../../../Utils/timeUtils";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { Typography } from "@mui/material";
|
import { Typography } from "@mui/material";
|
||||||
import useUtils from "../../../Monitors/Hooks/useUtils";
|
import useUtils from "../../../Monitors/Hooks/useUtils";
|
||||||
|
|
||||||
const UptimeStatusBoxes = ({ shouldRender, monitor, certificateExpiry }) => {
|
const UptimeStatusBoxes = ({
|
||||||
|
isLoading = false,
|
||||||
|
monitor,
|
||||||
|
monitorStats,
|
||||||
|
certificateExpiry,
|
||||||
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { determineState } = useUtils();
|
const { determineState } = useUtils();
|
||||||
|
|
||||||
const { time: streakTime, units: streakUnits } = getHumanReadableDuration(
|
// Determine time since last failure
|
||||||
monitor?.uptimeStreak
|
const timeOfLastFailure = monitorStats?.timeOfLastFailure;
|
||||||
);
|
const timeSinceLastFailure = timeOfLastFailure > 0 ? Date.now() - timeOfLastFailure : 0;
|
||||||
|
|
||||||
const { time: lastCheckTime, units: lastCheckUnits } = getHumanReadableDuration(
|
// Determine time since last check
|
||||||
monitor?.timeSinceLastCheck
|
const timeOfLastCheck = monitorStats?.lastCheckTimestamp;
|
||||||
);
|
const timeSinceLastCheck = Date.now() - timeOfLastCheck;
|
||||||
|
|
||||||
|
const { time: streakTime, units: streakUnits } =
|
||||||
|
getHumanReadableDuration(timeSinceLastFailure);
|
||||||
|
|
||||||
|
const { time: lastCheckTime, units: lastCheckUnits } =
|
||||||
|
getHumanReadableDuration(timeSinceLastCheck);
|
||||||
return (
|
return (
|
||||||
<StatusBoxes shouldRender={shouldRender}>
|
<StatusBoxes shouldRender={!isLoading}>
|
||||||
<StatBox
|
<StatBox
|
||||||
gradient={true}
|
gradient={true}
|
||||||
status={determineState(monitor)}
|
status={determineState(monitor)}
|
||||||
@@ -43,7 +56,7 @@ const UptimeStatusBoxes = ({ shouldRender, monitor, certificateExpiry }) => {
|
|||||||
heading="last response time"
|
heading="last response time"
|
||||||
subHeading={
|
subHeading={
|
||||||
<>
|
<>
|
||||||
{monitor?.latestResponseTime}
|
{monitorStats?.lastResponseTime}
|
||||||
<Typography component="span">{"ms"}</Typography>
|
<Typography component="span">{"ms"}</Typography>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
@@ -64,4 +77,11 @@ const UptimeStatusBoxes = ({ shouldRender, monitor, certificateExpiry }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UptimeStatusBoxes.propTypes = {
|
||||||
|
shouldRender: PropTypes.bool,
|
||||||
|
monitor: PropTypes.object,
|
||||||
|
monitorStats: PropTypes.object,
|
||||||
|
certificateExpiry: PropTypes.string,
|
||||||
|
};
|
||||||
|
|
||||||
export default UptimeStatusBoxes;
|
export default UptimeStatusBoxes;
|
||||||
@@ -16,7 +16,7 @@ import { useParams } from "react-router-dom";
|
|||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
||||||
import useMonitorFetch from "./Hooks/useMonitorFetch";
|
import useFetchUptimeMonitorDetails from "../../../Hooks/useFetchUptimeMonitorDetails";
|
||||||
import useCertificateFetch from "./Hooks/useCertificateFetch";
|
import useCertificateFetch from "./Hooks/useCertificateFetch";
|
||||||
import useChecksFetch from "./Hooks/useChecksFetch";
|
import useChecksFetch from "./Hooks/useChecksFetch";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -36,8 +36,7 @@ const UptimeDetails = () => {
|
|||||||
|
|
||||||
// Local state
|
// Local state
|
||||||
const [dateRange, setDateRange] = useState("recent");
|
const [dateRange, setDateRange] = useState("recent");
|
||||||
const [hoveredUptimeData, setHoveredUptimeData] = useState(null);
|
|
||||||
const [hoveredIncidentsData, setHoveredIncidentsData] = useState(null);
|
|
||||||
const [page, setPage] = useState(0);
|
const [page, setPage] = useState(0);
|
||||||
const [rowsPerPage, setRowsPerPage] = useState(5);
|
const [rowsPerPage, setRowsPerPage] = useState(5);
|
||||||
|
|
||||||
@@ -49,10 +48,13 @@ const UptimeDetails = () => {
|
|||||||
const isAdmin = useIsAdmin();
|
const isAdmin = useIsAdmin();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const [monitor, monitorIsLoading, monitorNetworkError] = useMonitorFetch({
|
const [monitorData, monitorStats, monitorIsLoading, monitorNetworkError] =
|
||||||
monitorId,
|
useFetchUptimeMonitorDetails({
|
||||||
dateRange,
|
monitorId,
|
||||||
});
|
dateRange,
|
||||||
|
});
|
||||||
|
|
||||||
|
const monitor = monitorData?.monitor;
|
||||||
|
|
||||||
const [certificateExpiry, certificateIsLoading] = useCertificateFetch({
|
const [certificateExpiry, certificateIsLoading] = useCertificateFetch({
|
||||||
monitor,
|
monitor,
|
||||||
@@ -62,7 +64,6 @@ const UptimeDetails = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const monitorType = monitor?.type;
|
const monitorType = monitor?.type;
|
||||||
|
|
||||||
const [checks, checksCount, checksAreLoading, checksNetworkError] = useChecksFetch({
|
const [checks, checksCount, checksAreLoading, checksNetworkError] = useChecksFetch({
|
||||||
monitorId,
|
monitorId,
|
||||||
monitorType,
|
monitorType,
|
||||||
@@ -71,6 +72,8 @@ const UptimeDetails = () => {
|
|||||||
rowsPerPage,
|
rowsPerPage,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("render");
|
||||||
|
|
||||||
// Handlers
|
// Handlers
|
||||||
const handlePageChange = (_, newPage) => {
|
const handlePageChange = (_, newPage) => {
|
||||||
setPage(newPage);
|
setPage(newPage);
|
||||||
@@ -119,38 +122,35 @@ const UptimeDetails = () => {
|
|||||||
<MonitorStatusHeader
|
<MonitorStatusHeader
|
||||||
path={"uptime"}
|
path={"uptime"}
|
||||||
isAdmin={isAdmin}
|
isAdmin={isAdmin}
|
||||||
shouldRender={!monitorIsLoading}
|
isLoading={monitorIsLoading}
|
||||||
monitor={monitor}
|
monitor={monitor}
|
||||||
/>
|
/>
|
||||||
<UptimeStatusBoxes
|
<UptimeStatusBoxes
|
||||||
shouldRender={!monitorIsLoading}
|
isLoading={monitorIsLoading}
|
||||||
monitor={monitor}
|
monitor={monitor}
|
||||||
|
monitorStats={monitorStats}
|
||||||
certificateExpiry={certificateExpiry}
|
certificateExpiry={certificateExpiry}
|
||||||
/>
|
/>
|
||||||
<MonitorTimeFrameHeader
|
<MonitorTimeFrameHeader
|
||||||
shouldRender={!monitorIsLoading}
|
isLoading={monitorIsLoading}
|
||||||
hasDateRange={true}
|
hasDateRange={true}
|
||||||
dateRange={dateRange}
|
dateRange={dateRange}
|
||||||
setDateRange={setDateRange}
|
setDateRange={setDateRange}
|
||||||
/>
|
/>
|
||||||
<ChartBoxes
|
<ChartBoxes
|
||||||
shouldRender={!monitorIsLoading}
|
isLoading={monitorIsLoading}
|
||||||
monitor={monitor}
|
monitorData={monitorData}
|
||||||
uiTimezone={uiTimezone}
|
uiTimezone={uiTimezone}
|
||||||
dateRange={dateRange}
|
dateRange={dateRange}
|
||||||
dateFormat={dateFormat}
|
dateFormat={dateFormat}
|
||||||
hoveredUptimeData={hoveredUptimeData}
|
|
||||||
setHoveredUptimeData={setHoveredUptimeData}
|
|
||||||
hoveredIncidentsData={hoveredIncidentsData}
|
|
||||||
setHoveredIncidentsData={setHoveredIncidentsData}
|
|
||||||
/>
|
/>
|
||||||
<ResponseTimeChart
|
<ResponseTimeChart
|
||||||
shouldRender={!monitorIsLoading}
|
isLoading={monitorIsLoading}
|
||||||
monitor={monitor}
|
groupedChecks={monitorData?.groupedChecks}
|
||||||
dateRange={dateRange}
|
dateRange={dateRange}
|
||||||
/>
|
/>
|
||||||
<ResponseTable
|
<ResponseTable
|
||||||
shouldRender={!checksAreLoading}
|
isLoading={checksAreLoading}
|
||||||
checks={checks}
|
checks={checks}
|
||||||
uiTimezone={uiTimezone}
|
uiTimezone={uiTimezone}
|
||||||
page={page}
|
page={page}
|
||||||
|
|||||||
Reference in new issue
Block a user