migrate to new query
This commit is contained in:
1 parent
d574faa7d8
commit
853a28d316
2 files changed
+45
-32
No files matched your search
@@ -15,7 +15,8 @@ import { formatDateWithTz, toTimeStamp } from "../../../../Utils/timeUtils";
|
|||||||
|
|
||||||
const CustomLabels = ({ x, width, height, firstDataPoint, lastDataPoint, type }) => {
|
const CustomLabels = ({ x, width, height, firstDataPoint, lastDataPoint, type }) => {
|
||||||
const uiTimezone = useSelector((state) => state.ui.timezone);
|
const uiTimezone = useSelector((state) => state.ui.timezone);
|
||||||
const dateFormat = type === "day" ? "MMM D, h A" : "MMM D";
|
const formatString = type === "month" ? "YYYY-MM-DD" : "YYYY-MM-DD-HH";
|
||||||
|
const dateFormat = type === "day" ? "MMM D, h:mm A" : "MMM D";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -27,7 +28,7 @@ const CustomLabels = ({ x, width, height, firstDataPoint, lastDataPoint, type })
|
|||||||
fontSize={11}
|
fontSize={11}
|
||||||
>
|
>
|
||||||
{formatDateWithTz(
|
{formatDateWithTz(
|
||||||
toTimeStamp(firstDataPoint._id, "YYYY-MM-DD-HH"),
|
toTimeStamp(firstDataPoint._id, formatString),
|
||||||
dateFormat,
|
dateFormat,
|
||||||
uiTimezone
|
uiTimezone
|
||||||
)}
|
)}
|
||||||
@@ -39,8 +40,11 @@ const CustomLabels = ({ x, width, height, firstDataPoint, lastDataPoint, type })
|
|||||||
textAnchor="end"
|
textAnchor="end"
|
||||||
fontSize={11}
|
fontSize={11}
|
||||||
>
|
>
|
||||||
{lastDataPoint._id}
|
{formatDateWithTz(
|
||||||
{/* {formatDateWithTz(new Date(lastDataPoint.time), dateFormat, uiTimezone)} */}
|
toTimeStamp(lastDataPoint._id, formatString),
|
||||||
|
dateFormat,
|
||||||
|
uiTimezone
|
||||||
|
)}
|
||||||
</text>
|
</text>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -70,7 +74,6 @@ const UpBarChart = memo(({ data, type, onBarHover }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// TODO - REMOVE THIS LATER
|
// TODO - REMOVE THIS LATER
|
||||||
const reversedData = useMemo(() => [...data].reverse(), [data]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ResponsiveContainer
|
<ResponsiveContainer
|
||||||
@@ -81,7 +84,7 @@ const UpBarChart = memo(({ data, type, onBarHover }) => {
|
|||||||
<BarChart
|
<BarChart
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
data={reversedData}
|
data={data}
|
||||||
onMouseEnter={() => {
|
onMouseEnter={() => {
|
||||||
setChartHovered(true);
|
setChartHovered(true);
|
||||||
onBarHover({ time: null, totalChecks: 0, groupUptimePercentage: 0 });
|
onBarHover({ time: null, totalChecks: 0, groupUptimePercentage: 0 });
|
||||||
@@ -102,8 +105,8 @@ const UpBarChart = memo(({ data, type, onBarHover }) => {
|
|||||||
y={0}
|
y={0}
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
firstDataPoint={reversedData[0]}
|
firstDataPoint={data[0]}
|
||||||
lastDataPoint={reversedData[reversedData.length - 1]}
|
lastDataPoint={data[data.length - 1]}
|
||||||
type={type}
|
type={type}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
@@ -113,7 +116,7 @@ const UpBarChart = memo(({ data, type, onBarHover }) => {
|
|||||||
maxBarSize={7}
|
maxBarSize={7}
|
||||||
background={{ fill: "transparent" }}
|
background={{ fill: "transparent" }}
|
||||||
>
|
>
|
||||||
{reversedData.map((entry, index) => {
|
{data.map((entry, index) => {
|
||||||
let { main, light } = getColorRange(entry.groupUptimePercentage);
|
let { main, light } = getColorRange(entry.groupUptimePercentage);
|
||||||
return (
|
return (
|
||||||
<Cell
|
<Cell
|
||||||
@@ -157,9 +160,6 @@ const DownBarChart = memo(({ data, type, onBarHover }) => {
|
|||||||
const [chartHovered, setChartHovered] = useState(false);
|
const [chartHovered, setChartHovered] = useState(false);
|
||||||
const [hoveredBarIndex, setHoveredBarIndex] = useState(null);
|
const [hoveredBarIndex, setHoveredBarIndex] = useState(null);
|
||||||
|
|
||||||
// TODO - REMOVE THIS LATER
|
|
||||||
const reversedData = useMemo(() => [...data].reverse(), [data]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ResponsiveContainer
|
<ResponsiveContainer
|
||||||
width="100%"
|
width="100%"
|
||||||
@@ -169,10 +169,10 @@ const DownBarChart = memo(({ data, type, onBarHover }) => {
|
|||||||
<BarChart
|
<BarChart
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
data={reversedData}
|
data={data}
|
||||||
onMouseEnter={() => {
|
onMouseEnter={() => {
|
||||||
setChartHovered(true);
|
setChartHovered(true);
|
||||||
onBarHover({ time: null, totalIncidents: 0 });
|
onBarHover({ time: null, totalChecks: 0 });
|
||||||
}}
|
}}
|
||||||
onMouseLeave={() => {
|
onMouseLeave={() => {
|
||||||
setChartHovered(false);
|
setChartHovered(false);
|
||||||
@@ -190,18 +190,18 @@ const DownBarChart = memo(({ data, type, onBarHover }) => {
|
|||||||
y={0}
|
y={0}
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
firstDataPoint={reversedData[0]}
|
firstDataPoint={data[0]}
|
||||||
lastDataPoint={reversedData[reversedData.length - 1]}
|
lastDataPoint={data[data.length - 1]}
|
||||||
type={type}
|
type={type}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Bar
|
<Bar
|
||||||
dataKey="totalIncidents"
|
dataKey="avgResponseTime"
|
||||||
maxBarSize={7}
|
maxBarSize={7}
|
||||||
background={{ fill: "transparent" }}
|
background={{ fill: "transparent" }}
|
||||||
>
|
>
|
||||||
{reversedData.map((entry, index) => (
|
{data.map((entry, index) => (
|
||||||
<Cell
|
<Cell
|
||||||
key={`cell-${entry.time}`}
|
key={`cell-${entry.time}`}
|
||||||
fill={
|
fill={
|
||||||
@@ -209,7 +209,7 @@ const DownBarChart = memo(({ data, type, onBarHover }) => {
|
|||||||
? theme.palette.error.contrastText
|
? theme.palette.error.contrastText
|
||||||
: chartHovered
|
: chartHovered
|
||||||
? theme.palette.error.light
|
? theme.palette.error.light
|
||||||
: theme.palette.error.contrastText
|
: theme.palette.error.main
|
||||||
}
|
}
|
||||||
onMouseEnter={() => {
|
onMouseEnter={() => {
|
||||||
setHoveredBarIndex(index);
|
setHoveredBarIndex(index);
|
||||||
@@ -217,7 +217,7 @@ const DownBarChart = memo(({ data, type, onBarHover }) => {
|
|||||||
}}
|
}}
|
||||||
onMouseLeave={() => {
|
onMouseLeave={() => {
|
||||||
setHoveredBarIndex(null);
|
setHoveredBarIndex(null);
|
||||||
onBarHover({ time: null, totalIncidents: 0 });
|
onBarHover({ time: null, totalChecks: 0 });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import { formatDateWithTz, formatDurationSplit } from "../../../Utils/timeUtils"
|
|||||||
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
||||||
import IconBox from "../../../Components/IconBox";
|
import IconBox from "../../../Components/IconBox";
|
||||||
import StatBox from "../../../Components/StatBox";
|
import StatBox from "../../../Components/StatBox";
|
||||||
|
import { toTimeStamp } from "../../../Utils/timeUtils";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Details page component displaying monitor details and related information.
|
* Details page component displaying monitor details and related information.
|
||||||
* @component
|
* @component
|
||||||
@@ -103,6 +105,10 @@ const DetailsPage = () => {
|
|||||||
const [hoveredUptimeData, setHoveredUptimeData] = useState(null);
|
const [hoveredUptimeData, setHoveredUptimeData] = useState(null);
|
||||||
const [hoveredIncidentsData, setHoveredIncidentsData] = useState(null);
|
const [hoveredIncidentsData, setHoveredIncidentsData] = useState(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
console.log(hoveredUptimeData);
|
||||||
|
}, [hoveredUptimeData]);
|
||||||
|
|
||||||
const BREADCRUMBS = [
|
const BREADCRUMBS = [
|
||||||
{ name: "uptime", path: "/uptime" },
|
{ name: "uptime", path: "/uptime" },
|
||||||
{ name: "details", path: `/uptime/${monitorId}` },
|
{ name: "details", path: `/uptime/${monitorId}` },
|
||||||
@@ -307,7 +313,7 @@ const DetailsPage = () => {
|
|||||||
<Typography component="span">
|
<Typography component="span">
|
||||||
{hoveredUptimeData !== null
|
{hoveredUptimeData !== null
|
||||||
? hoveredUptimeData.totalChecks
|
? hoveredUptimeData.totalChecks
|
||||||
: monitor.dateRangeData[0].overallTotalChecks}
|
: (monitor.groupUpChecks[0]?.overallTotalChecks ?? 0)}
|
||||||
</Typography>
|
</Typography>
|
||||||
{hoveredUptimeData !== null && hoveredUptimeData.time !== null && (
|
{hoveredUptimeData !== null && hoveredUptimeData.time !== null && (
|
||||||
<Typography
|
<Typography
|
||||||
@@ -318,7 +324,10 @@ const DetailsPage = () => {
|
|||||||
color={theme.palette.text.tertiary}
|
color={theme.palette.text.tertiary}
|
||||||
>
|
>
|
||||||
{formatDateWithTz(
|
{formatDateWithTz(
|
||||||
hoveredUptimeData.time,
|
toTimeStamp(
|
||||||
|
hoveredUptimeData._id,
|
||||||
|
dateRange === "month" ? "YYYY-MM-DD" : "YYYY-MM-DD-HH"
|
||||||
|
),
|
||||||
dateFormat,
|
dateFormat,
|
||||||
uiTimezone
|
uiTimezone
|
||||||
)}
|
)}
|
||||||
@@ -331,14 +340,15 @@ const DetailsPage = () => {
|
|||||||
{hoveredUptimeData !== null
|
{hoveredUptimeData !== null
|
||||||
? Math.floor(hoveredUptimeData.groupUptimePercentage * 100)
|
? Math.floor(hoveredUptimeData.groupUptimePercentage * 100)
|
||||||
: Math.floor(
|
: Math.floor(
|
||||||
monitor?.dateRangeData[0].overallUptimePercentage * 100
|
monitor?.groupUpChecks[0]?.overallUptimePercentage ??
|
||||||
|
0 * 100
|
||||||
)}
|
)}
|
||||||
<Typography component="span">%</Typography>
|
<Typography component="span">%</Typography>
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
<UpBarChart
|
<UpBarChart
|
||||||
data={monitor?.dateRangeData}
|
data={monitor?.groupUpChecks}
|
||||||
type={dateRange}
|
type={dateRange}
|
||||||
onBarHover={setHoveredUptimeData}
|
onBarHover={setHoveredUptimeData}
|
||||||
/>
|
/>
|
||||||
@@ -354,8 +364,8 @@ const DetailsPage = () => {
|
|||||||
<Typography>Total Incidents</Typography>
|
<Typography>Total Incidents</Typography>
|
||||||
<Typography component="span">
|
<Typography component="span">
|
||||||
{hoveredIncidentsData !== null
|
{hoveredIncidentsData !== null
|
||||||
? hoveredIncidentsData.totalIncidents
|
? hoveredIncidentsData.totalChecks
|
||||||
: monitor?.periodIncidents}
|
: (monitor.groupDownChecks[0]?.overallTotalChecks ?? 0)}
|
||||||
</Typography>
|
</Typography>
|
||||||
{hoveredIncidentsData !== null &&
|
{hoveredIncidentsData !== null &&
|
||||||
hoveredIncidentsData.time !== null && (
|
hoveredIncidentsData.time !== null && (
|
||||||
@@ -367,18 +377,21 @@ const DetailsPage = () => {
|
|||||||
color={theme.palette.text.tertiary}
|
color={theme.palette.text.tertiary}
|
||||||
>
|
>
|
||||||
{formatDateWithTz(
|
{formatDateWithTz(
|
||||||
hoveredIncidentsData.time,
|
toTimeStamp(
|
||||||
|
hoveredIncidentsData._id,
|
||||||
|
dateRange === "month" ? "YYYY-MM-DD" : "YYYY-MM-DD-HH"
|
||||||
|
),
|
||||||
dateFormat,
|
dateFormat,
|
||||||
uiTimezone
|
uiTimezone
|
||||||
)}
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
{/* <DownBarChart
|
<DownBarChart
|
||||||
data={monitor?.aggregateData}
|
data={monitor?.groupDownChecks}
|
||||||
type={dateRange}
|
type={dateRange}
|
||||||
onBarHover={setHoveredIncidentsData}
|
onBarHover={setHoveredIncidentsData}
|
||||||
/> */}
|
/>
|
||||||
</ChartBox>
|
</ChartBox>
|
||||||
<ChartBox justifyContent="space-between">
|
<ChartBox justifyContent="space-between">
|
||||||
<Stack>
|
<Stack>
|
||||||
@@ -422,10 +435,10 @@ const DetailsPage = () => {
|
|||||||
History
|
History
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<PaginationTable
|
{/* <PaginationTable
|
||||||
monitorId={monitorId}
|
monitorId={monitorId}
|
||||||
dateRange={dateRange}
|
dateRange={dateRange}
|
||||||
/>
|
/> */}
|
||||||
</ChartBox>
|
</ChartBox>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
Reference in new issue
Block a user