Added skeletons to pagespeed pages
This commit is contained in:
1 parent
51bfc83903
commit
ea4cf6efd3
2 files changed
+487
-350
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
import { Box, Stack, Typography } from "@mui/material";
|
import { Box, Skeleton, Stack, Typography } from "@mui/material";
|
||||||
import { PieChart } from "@mui/x-charts/PieChart";
|
import { PieChart } from "@mui/x-charts/PieChart";
|
||||||
import { useDrawingArea } from "@mui/x-charts";
|
import { useDrawingArea } from "@mui/x-charts";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
@@ -136,17 +136,22 @@ const PageSpeedDetails = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchMonitor = async () => {
|
const fetchMonitor = async () => {
|
||||||
const res = await axiosInstance.get(
|
try {
|
||||||
`/monitors/${monitorId}?sortOrder=desc`,
|
const res = await axiosInstance.get(
|
||||||
{
|
`/monitors/${monitorId}?sortOrder=desc`,
|
||||||
headers: {
|
{
|
||||||
Authorization: `Bearer ${authToken}`,
|
headers: {
|
||||||
},
|
Authorization: `Bearer ${authToken}`,
|
||||||
}
|
},
|
||||||
);
|
}
|
||||||
|
);
|
||||||
|
|
||||||
setMonitor(res.data.data);
|
setMonitor(res.data.data);
|
||||||
setAudits(res.data.data.checks[0].audits);
|
setAudits(res.data.data.checks[0].audits);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching pagespeed monitor of id: " + monitorId);
|
||||||
|
navigate("/not-found");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchMonitor();
|
fetchMonitor();
|
||||||
@@ -244,61 +249,93 @@ const PageSpeedDetails = () => {
|
|||||||
const [highlightedItem, setHighLightedItem] = useState(null);
|
const [highlightedItem, setHighLightedItem] = useState(null);
|
||||||
const [expand, setExpand] = useState(false);
|
const [expand, setExpand] = useState(false);
|
||||||
|
|
||||||
|
let loading = Object.keys(monitor).length === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="page-speed-details" gap={theme.gap.large}>
|
<Stack className="page-speed-details" gap={theme.gap.large}>
|
||||||
<Button
|
{loading ? (
|
||||||
level="tertiary"
|
<Skeleton variant="rounded" width="15%" height={34} />
|
||||||
label="Back"
|
) : (
|
||||||
animate="slideLeft"
|
|
||||||
img={<WestRoundedIcon />}
|
|
||||||
onClick={() => navigate("/pagespeed")}
|
|
||||||
sx={{
|
|
||||||
width: "fit-content",
|
|
||||||
backgroundColor: theme.palette.otherColors.fillGray,
|
|
||||||
px: theme.gap.ml,
|
|
||||||
"& svg.MuiSvgIcon-root": {
|
|
||||||
mr: theme.gap.small,
|
|
||||||
fill: theme.palette.otherColors.slateGray,
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
gap={theme.gap.small}
|
|
||||||
justifyContent="space-between"
|
|
||||||
>
|
|
||||||
<GreenCheck />
|
|
||||||
<Box>
|
|
||||||
<Typography component="h1" mb={theme.gap.xs} sx={{ lineHeight: 1 }}>
|
|
||||||
{monitor?.url}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
component="span"
|
|
||||||
sx={{ color: "var(--env-var-color-17)" }}
|
|
||||||
>
|
|
||||||
Your pagespeed monitor is live.
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
<Button
|
<Button
|
||||||
level="tertiary"
|
level="tertiary"
|
||||||
label="Configure"
|
label="Back"
|
||||||
animate="rotate90"
|
animate="slideLeft"
|
||||||
img={
|
img={<WestRoundedIcon />}
|
||||||
<SettingsIcon
|
onClick={() => navigate("/pagespeed")}
|
||||||
style={{ width: theme.gap.mlplus, height: theme.gap.mlplus }}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
onClick={() => navigate(`/pagespeed/configure/${monitorId}`)}
|
|
||||||
sx={{
|
sx={{
|
||||||
ml: "auto",
|
width: "fit-content",
|
||||||
alignSelf: "flex-end",
|
|
||||||
backgroundColor: theme.palette.otherColors.fillGray,
|
backgroundColor: theme.palette.otherColors.fillGray,
|
||||||
px: theme.gap.medium,
|
px: theme.gap.ml,
|
||||||
"& svg": {
|
"& svg.MuiSvgIcon-root": {
|
||||||
mr: "6px",
|
mr: theme.gap.small,
|
||||||
|
fill: theme.palette.otherColors.slateGray,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
<Stack direction="row" gap={theme.gap.small}>
|
||||||
|
{loading ? (
|
||||||
|
<>
|
||||||
|
<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.gap.small }}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="15%"
|
||||||
|
height={34}
|
||||||
|
sx={{ alignSelf: "flex-end" }}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<GreenCheck />
|
||||||
|
<Box>
|
||||||
|
<Typography
|
||||||
|
component="h1"
|
||||||
|
mb={theme.gap.xs}
|
||||||
|
sx={{ lineHeight: 1 }}
|
||||||
|
>
|
||||||
|
{monitor?.url}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
sx={{ color: "var(--env-var-color-17)" }}
|
||||||
|
>
|
||||||
|
Your pagespeed monitor is live.
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Button
|
||||||
|
level="tertiary"
|
||||||
|
label="Configure"
|
||||||
|
animate="rotate90"
|
||||||
|
img={
|
||||||
|
<SettingsIcon
|
||||||
|
style={{ width: theme.gap.mlplus, height: theme.gap.mlplus }}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
onClick={() => navigate(`/pagespeed/configure/${monitorId}`)}
|
||||||
|
sx={{
|
||||||
|
ml: "auto",
|
||||||
|
alignSelf: "flex-end",
|
||||||
|
backgroundColor: theme.palette.otherColors.fillGray,
|
||||||
|
px: theme.gap.medium,
|
||||||
|
"& svg": {
|
||||||
|
mr: "6px",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
@@ -306,298 +343,346 @@ const PageSpeedDetails = () => {
|
|||||||
gap={theme.gap.xl}
|
gap={theme.gap.xl}
|
||||||
flexWrap="wrap"
|
flexWrap="wrap"
|
||||||
>
|
>
|
||||||
<StatBox
|
{loading ? (
|
||||||
icon={<LastCheckedIcon />}
|
<>
|
||||||
title="Last checked"
|
<Skeleton
|
||||||
value={
|
variant="rounded"
|
||||||
<>
|
width="30%"
|
||||||
{formatDate(getLastChecked(monitor?.checks, false))}{" "}
|
height={90}
|
||||||
<Typography
|
sx={{ flex: 1 }}
|
||||||
component="span"
|
/>
|
||||||
fontStyle="italic"
|
<Skeleton
|
||||||
sx={{ opacity: 0.8 }}
|
variant="rounded"
|
||||||
>
|
width="30%"
|
||||||
({formatDurationRounded(getLastChecked(monitor?.checks))} ago)
|
height={90}
|
||||||
</Typography>
|
sx={{ flex: 1 }}
|
||||||
</>
|
/>
|
||||||
}
|
<Skeleton
|
||||||
/>
|
variant="rounded"
|
||||||
<StatBox
|
width="30%"
|
||||||
icon={<ClockIcon />}
|
height={90}
|
||||||
title="Checks since"
|
sx={{ flex: 1 }}
|
||||||
value={
|
/>
|
||||||
<>
|
</>
|
||||||
{formatDate(new Date(monitor?.createdAt))}{" "}
|
) : (
|
||||||
<Typography
|
<>
|
||||||
component="span"
|
<StatBox
|
||||||
fontStyle="italic"
|
icon={<LastCheckedIcon />}
|
||||||
sx={{ opacity: 0.8 }}
|
title="Last checked"
|
||||||
>
|
value={
|
||||||
(
|
<>
|
||||||
{formatDurationRounded(
|
{formatDate(getLastChecked(monitor?.checks, false))}{" "}
|
||||||
new Date() - new Date(monitor?.createdAt)
|
<Typography
|
||||||
)}{" "}
|
component="span"
|
||||||
ago)
|
fontStyle="italic"
|
||||||
</Typography>
|
sx={{ opacity: 0.8 }}
|
||||||
</>
|
>
|
||||||
}
|
({formatDurationRounded(getLastChecked(monitor?.checks))}{" "}
|
||||||
></StatBox>
|
ago)
|
||||||
<StatBox
|
</Typography>
|
||||||
icon={<IntervalCheckIcon />}
|
</>
|
||||||
title="Checks every"
|
|
||||||
value={formatDurationRounded(monitor?.interval)}
|
|
||||||
></StatBox>
|
|
||||||
</Stack>
|
|
||||||
<Typography component="h2">Score history</Typography>
|
|
||||||
<Box height="300px">
|
|
||||||
<PageSpeedLineChart pageSpeedChecks={monitor?.checks?.slice(0, 25)} />
|
|
||||||
</Box>
|
|
||||||
<Typography component="h2">Performance report</Typography>
|
|
||||||
<Stack direction="row" alignItems="center" overflow="hidden">
|
|
||||||
<Stack
|
|
||||||
alignItems="center"
|
|
||||||
textAlign="center"
|
|
||||||
minWidth="300px"
|
|
||||||
flex={1}
|
|
||||||
px={theme.gap.xl}
|
|
||||||
py={theme.gap.ml}
|
|
||||||
>
|
|
||||||
<Box onMouseLeave={() => setExpand(false)}>
|
|
||||||
{expand ? (
|
|
||||||
<PieChart
|
|
||||||
series={[
|
|
||||||
{
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
value: 100,
|
|
||||||
color: colorMap.bg,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
outerRadius: 67,
|
|
||||||
cx: pieSize.width / 2,
|
|
||||||
},
|
|
||||||
...pieData,
|
|
||||||
]}
|
|
||||||
width={pieSize.width}
|
|
||||||
height={pieSize.height}
|
|
||||||
margin={{ left: 0, top: 0, right: 0, bottom: 0 }}
|
|
||||||
onHighlightChange={setHighLightedItem}
|
|
||||||
slotProps={{
|
|
||||||
legend: { hidden: true },
|
|
||||||
}}
|
|
||||||
tooltip={{ trigger: "none" }}
|
|
||||||
sx={{
|
|
||||||
"&:has(.MuiPieArcLabel-faded) .pie-label": {
|
|
||||||
fill: "rgba(0,0,0,0) !important",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<PieCenterLabel
|
|
||||||
value={performance}
|
|
||||||
color={colorMap.text}
|
|
||||||
setExpand={setExpand}
|
|
||||||
/>
|
|
||||||
{pieData?.map((pie) => (
|
|
||||||
<PieValueLabel
|
|
||||||
key={pie.id}
|
|
||||||
value={Math.round(pie.data[0].value * 10) / 10}
|
|
||||||
startAngle={pie.startAngle}
|
|
||||||
endAngle={pie.endAngle}
|
|
||||||
color={pie.data[0].color}
|
|
||||||
highlighted={highlightedItem?.seriesId === pie.id}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</PieChart>
|
|
||||||
) : (
|
|
||||||
<PieChart
|
|
||||||
series={[
|
|
||||||
{
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
value: 100,
|
|
||||||
color: colorMap.bg,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
outerRadius: 67,
|
|
||||||
cx: pieSize.width / 2,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
value: performance,
|
|
||||||
color: colorMap.stroke,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
innerRadius: 63,
|
|
||||||
outerRadius: 70,
|
|
||||||
paddingAngle: 5,
|
|
||||||
cornerRadius: 2,
|
|
||||||
startAngle: 0,
|
|
||||||
endAngle: (performance / 100) * 360,
|
|
||||||
cx: pieSize.width / 2,
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
width={pieSize.width}
|
|
||||||
height={pieSize.height}
|
|
||||||
margin={{ left: 0, top: 0, right: 0, bottom: 0 }}
|
|
||||||
tooltip={{ trigger: "none" }}
|
|
||||||
>
|
|
||||||
<PieCenterLabel
|
|
||||||
value={performance}
|
|
||||||
color={colorMap.text}
|
|
||||||
setExpand={setExpand}
|
|
||||||
/>
|
|
||||||
</PieChart>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
<Typography mt={theme.gap.medium}>
|
|
||||||
Values are estimated and may vary.{" "}
|
|
||||||
<Typography
|
|
||||||
component="span"
|
|
||||||
sx={{
|
|
||||||
color: theme.palette.primary.main,
|
|
||||||
fontWeight: 500,
|
|
||||||
textDecoration: "underline",
|
|
||||||
cursor: "pointer",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
See calculator
|
|
||||||
</Typography>
|
|
||||||
</Typography>
|
|
||||||
</Stack>
|
|
||||||
<Box
|
|
||||||
px={theme.gap.xl}
|
|
||||||
py={theme.gap.ml}
|
|
||||||
height="100%"
|
|
||||||
flex={1}
|
|
||||||
sx={{
|
|
||||||
borderLeft: `solid 1px ${theme.palette.otherColors.graishWhite}`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
mb={theme.gap.medium}
|
|
||||||
pb={theme.gap.ml}
|
|
||||||
color={theme.palette.secondary.main}
|
|
||||||
textAlign="center"
|
|
||||||
sx={{
|
|
||||||
borderBottom: `solid 1px ${theme.palette.otherColors.graishWhite}`,
|
|
||||||
borderBottomStyle: "dashed",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
The{" "}
|
|
||||||
<Typography
|
|
||||||
component="span"
|
|
||||||
sx={{
|
|
||||||
color: theme.palette.primary.main,
|
|
||||||
fontWeight: 500,
|
|
||||||
textDecoration: "underline",
|
|
||||||
cursor: "pointer",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
performance score is calculated
|
|
||||||
</Typography>{" "}
|
|
||||||
directly from these{" "}
|
|
||||||
<Typography component="span" fontWeight={600}>
|
|
||||||
metrics
|
|
||||||
</Typography>
|
|
||||||
.
|
|
||||||
</Typography>
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
flexWrap="wrap"
|
|
||||||
pt={theme.gap.ml}
|
|
||||||
gap={theme.gap.ml}
|
|
||||||
>
|
|
||||||
{Object.keys(audits).map((key) => {
|
|
||||||
if (key === "_id") return;
|
|
||||||
|
|
||||||
let audit = audits[key];
|
|
||||||
let metricParams = getColors(audit.score * 100);
|
|
||||||
|
|
||||||
let shape = (
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
width: theme.gap.medium,
|
|
||||||
height: theme.gap.medium,
|
|
||||||
borderRadius: "50%",
|
|
||||||
backgroundColor: metricParams.stroke,
|
|
||||||
}}
|
|
||||||
></Box>
|
|
||||||
);
|
|
||||||
if (metricParams.shape === "square")
|
|
||||||
shape = (
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
width: theme.gap.medium,
|
|
||||||
height: theme.gap.medium,
|
|
||||||
backgroundColor: metricParams.stroke,
|
|
||||||
}}
|
|
||||||
></Box>
|
|
||||||
);
|
|
||||||
else if (metricParams.shape === "triangle")
|
|
||||||
shape = (
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
width: 0,
|
|
||||||
height: 0,
|
|
||||||
ml: `calc((${theme.gap.medium} - ${theme.gap.small}) / -2)`,
|
|
||||||
borderLeft: `${theme.gap.small} solid transparent`,
|
|
||||||
borderRight: `${theme.gap.small} solid transparent`,
|
|
||||||
borderBottom: `${theme.gap.medium} solid ${metricParams.stroke}`,
|
|
||||||
}}
|
|
||||||
></Box>
|
|
||||||
);
|
|
||||||
|
|
||||||
// Find the position where the number ends and the unit begins
|
|
||||||
const match = audit.displayValue.match(/(\d+\.?\d*)\s*([a-zA-Z]+)/);
|
|
||||||
let value;
|
|
||||||
let unit;
|
|
||||||
if (match) {
|
|
||||||
value = match[1];
|
|
||||||
unit = match[2];
|
|
||||||
} else {
|
|
||||||
value = audit.displayValue;
|
|
||||||
}
|
}
|
||||||
|
/>
|
||||||
return (
|
<StatBox
|
||||||
<Stack
|
icon={<ClockIcon />}
|
||||||
className="metric"
|
title="Checks since"
|
||||||
key={`${key}-box`}
|
value={
|
||||||
direction="row"
|
<>
|
||||||
gap={theme.gap.small}
|
{formatDate(new Date(monitor?.createdAt))}{" "}
|
||||||
>
|
<Typography
|
||||||
{shape}
|
component="span"
|
||||||
<Box>
|
fontStyle="italic"
|
||||||
<Typography sx={{ lineHeight: 1 }}>
|
sx={{ opacity: 0.8 }}
|
||||||
{audit.title}
|
>
|
||||||
</Typography>
|
(
|
||||||
<Typography
|
{formatDurationRounded(
|
||||||
component="span"
|
new Date() - new Date(monitor?.createdAt)
|
||||||
sx={{
|
)}{" "}
|
||||||
color: metricParams.text,
|
ago)
|
||||||
fontSize: "16px",
|
</Typography>
|
||||||
fontWeight: 600,
|
</>
|
||||||
}}
|
}
|
||||||
>
|
></StatBox>
|
||||||
{value}
|
<StatBox
|
||||||
<Typography
|
icon={<IntervalCheckIcon />}
|
||||||
component="span"
|
title="Checks every"
|
||||||
ml="2px"
|
value={formatDurationRounded(monitor?.interval)}
|
||||||
sx={{
|
></StatBox>
|
||||||
color: theme.palette.secondary.main,
|
</>
|
||||||
fontSize: "13px",
|
)}
|
||||||
}}
|
|
||||||
>
|
|
||||||
{unit}
|
|
||||||
</Typography>
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Stack>
|
|
||||||
</Box>
|
|
||||||
</Stack>
|
</Stack>
|
||||||
|
{loading ? (
|
||||||
|
<>
|
||||||
|
<Skeleton variant="rounded" width="25%" height={24} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={300} />
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Typography component="h2">Score history</Typography>
|
||||||
|
<Box height="300px">
|
||||||
|
<PageSpeedLineChart
|
||||||
|
pageSpeedChecks={monitor?.checks?.slice(0, 25)}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{loading ? (
|
||||||
|
<>
|
||||||
|
<Skeleton variant="rounded" width="25%" height={24} />
|
||||||
|
<Skeleton variant="rounded" width="100%" height={300} />
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Typography component="h2">Performance report</Typography>
|
||||||
|
<Stack direction="row" alignItems="center" overflow="hidden">
|
||||||
|
<Stack
|
||||||
|
alignItems="center"
|
||||||
|
textAlign="center"
|
||||||
|
minWidth="300px"
|
||||||
|
flex={1}
|
||||||
|
px={theme.gap.xl}
|
||||||
|
py={theme.gap.ml}
|
||||||
|
>
|
||||||
|
<Box onMouseLeave={() => setExpand(false)}>
|
||||||
|
{expand ? (
|
||||||
|
<PieChart
|
||||||
|
series={[
|
||||||
|
{
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
value: 100,
|
||||||
|
color: colorMap.bg,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
outerRadius: 67,
|
||||||
|
cx: pieSize.width / 2,
|
||||||
|
},
|
||||||
|
...pieData,
|
||||||
|
]}
|
||||||
|
width={pieSize.width}
|
||||||
|
height={pieSize.height}
|
||||||
|
margin={{ left: 0, top: 0, right: 0, bottom: 0 }}
|
||||||
|
onHighlightChange={setHighLightedItem}
|
||||||
|
slotProps={{
|
||||||
|
legend: { hidden: true },
|
||||||
|
}}
|
||||||
|
tooltip={{ trigger: "none" }}
|
||||||
|
sx={{
|
||||||
|
"&:has(.MuiPieArcLabel-faded) .pie-label": {
|
||||||
|
fill: "rgba(0,0,0,0) !important",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PieCenterLabel
|
||||||
|
value={performance}
|
||||||
|
color={colorMap.text}
|
||||||
|
setExpand={setExpand}
|
||||||
|
/>
|
||||||
|
{pieData?.map((pie) => (
|
||||||
|
<PieValueLabel
|
||||||
|
key={pie.id}
|
||||||
|
value={Math.round(pie.data[0].value * 10) / 10}
|
||||||
|
startAngle={pie.startAngle}
|
||||||
|
endAngle={pie.endAngle}
|
||||||
|
color={pie.data[0].color}
|
||||||
|
highlighted={highlightedItem?.seriesId === pie.id}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</PieChart>
|
||||||
|
) : (
|
||||||
|
<PieChart
|
||||||
|
series={[
|
||||||
|
{
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
value: 100,
|
||||||
|
color: colorMap.bg,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
outerRadius: 67,
|
||||||
|
cx: pieSize.width / 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
value: performance,
|
||||||
|
color: colorMap.stroke,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
innerRadius: 63,
|
||||||
|
outerRadius: 70,
|
||||||
|
paddingAngle: 5,
|
||||||
|
cornerRadius: 2,
|
||||||
|
startAngle: 0,
|
||||||
|
endAngle: (performance / 100) * 360,
|
||||||
|
cx: pieSize.width / 2,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
width={pieSize.width}
|
||||||
|
height={pieSize.height}
|
||||||
|
margin={{ left: 0, top: 0, right: 0, bottom: 0 }}
|
||||||
|
tooltip={{ trigger: "none" }}
|
||||||
|
>
|
||||||
|
<PieCenterLabel
|
||||||
|
value={performance}
|
||||||
|
color={colorMap.text}
|
||||||
|
setExpand={setExpand}
|
||||||
|
/>
|
||||||
|
</PieChart>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
<Typography mt={theme.gap.medium}>
|
||||||
|
Values are estimated and may vary.{" "}
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
sx={{
|
||||||
|
color: theme.palette.primary.main,
|
||||||
|
fontWeight: 500,
|
||||||
|
textDecoration: "underline",
|
||||||
|
cursor: "pointer",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
See calculator
|
||||||
|
</Typography>
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
<Box
|
||||||
|
px={theme.gap.xl}
|
||||||
|
py={theme.gap.ml}
|
||||||
|
height="100%"
|
||||||
|
flex={1}
|
||||||
|
sx={{
|
||||||
|
borderLeft: `solid 1px ${theme.palette.otherColors.graishWhite}`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
mb={theme.gap.medium}
|
||||||
|
pb={theme.gap.ml}
|
||||||
|
color={theme.palette.secondary.main}
|
||||||
|
textAlign="center"
|
||||||
|
sx={{
|
||||||
|
borderBottom: `solid 1px ${theme.palette.otherColors.graishWhite}`,
|
||||||
|
borderBottomStyle: "dashed",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
The{" "}
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
sx={{
|
||||||
|
color: theme.palette.primary.main,
|
||||||
|
fontWeight: 500,
|
||||||
|
textDecoration: "underline",
|
||||||
|
cursor: "pointer",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
performance score is calculated
|
||||||
|
</Typography>{" "}
|
||||||
|
directly from these{" "}
|
||||||
|
<Typography component="span" fontWeight={600}>
|
||||||
|
metrics
|
||||||
|
</Typography>
|
||||||
|
.
|
||||||
|
</Typography>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
flexWrap="wrap"
|
||||||
|
pt={theme.gap.ml}
|
||||||
|
gap={theme.gap.ml}
|
||||||
|
>
|
||||||
|
{Object.keys(audits).map((key) => {
|
||||||
|
if (key === "_id") return;
|
||||||
|
|
||||||
|
let audit = audits[key];
|
||||||
|
let metricParams = getColors(audit.score * 100);
|
||||||
|
|
||||||
|
let shape = (
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
width: theme.gap.medium,
|
||||||
|
height: theme.gap.medium,
|
||||||
|
borderRadius: "50%",
|
||||||
|
backgroundColor: metricParams.stroke,
|
||||||
|
}}
|
||||||
|
></Box>
|
||||||
|
);
|
||||||
|
if (metricParams.shape === "square")
|
||||||
|
shape = (
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
width: theme.gap.medium,
|
||||||
|
height: theme.gap.medium,
|
||||||
|
backgroundColor: metricParams.stroke,
|
||||||
|
}}
|
||||||
|
></Box>
|
||||||
|
);
|
||||||
|
else if (metricParams.shape === "triangle")
|
||||||
|
shape = (
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
width: 0,
|
||||||
|
height: 0,
|
||||||
|
ml: `calc((${theme.gap.medium} - ${theme.gap.small}) / -2)`,
|
||||||
|
borderLeft: `${theme.gap.small} solid transparent`,
|
||||||
|
borderRight: `${theme.gap.small} solid transparent`,
|
||||||
|
borderBottom: `${theme.gap.medium} solid ${metricParams.stroke}`,
|
||||||
|
}}
|
||||||
|
></Box>
|
||||||
|
);
|
||||||
|
|
||||||
|
// Find the position where the number ends and the unit begins
|
||||||
|
const match = audit.displayValue.match(
|
||||||
|
/(\d+\.?\d*)\s*([a-zA-Z]+)/
|
||||||
|
);
|
||||||
|
let value;
|
||||||
|
let unit;
|
||||||
|
if (match) {
|
||||||
|
value = match[1];
|
||||||
|
unit = match[2];
|
||||||
|
} else {
|
||||||
|
value = audit.displayValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack
|
||||||
|
className="metric"
|
||||||
|
key={`${key}-box`}
|
||||||
|
direction="row"
|
||||||
|
gap={theme.gap.small}
|
||||||
|
>
|
||||||
|
{shape}
|
||||||
|
<Box>
|
||||||
|
<Typography sx={{ lineHeight: 1 }}>
|
||||||
|
{audit.title}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
sx={{
|
||||||
|
color: metricParams.text,
|
||||||
|
fontSize: "16px",
|
||||||
|
fontWeight: 600,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{value}
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
ml="2px"
|
||||||
|
sx={{
|
||||||
|
color: theme.palette.secondary.main,
|
||||||
|
fontSize: "13px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{unit}
|
||||||
|
</Typography>
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
|
</Stack>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Box, Grid, Stack, Typography } from "@mui/material";
|
import { Box, Grid, Skeleton, Stack, Typography } from "@mui/material";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { formatDate, formatDurationRounded } from "../../Utils/timeUtils";
|
import { formatDate, formatDurationRounded } from "../../Utils/timeUtils";
|
||||||
@@ -63,14 +63,66 @@ const PageSpeed = () => {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
const { authToken } = useSelector((state) => state.auth);
|
||||||
const { monitors } = useSelector((state) => state.pageSpeedMonitors);
|
const { monitors, isLoading } = useSelector(
|
||||||
|
(state) => state.pageSpeedMonitors
|
||||||
|
);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(getPageSpeedByUserId(authToken));
|
dispatch(getPageSpeedByUserId(authToken));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box className="page-speed">
|
<Box className="page-speed">
|
||||||
{monitors?.length !== 0 ? (
|
{isLoading ? (
|
||||||
|
<Stack gap={theme.gap.xs}>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="space-between"
|
||||||
|
mb={theme.gap.large}
|
||||||
|
>
|
||||||
|
<Box width="80%">
|
||||||
|
<Skeleton variant="rounded" width="25%" height={24} />
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="50%"
|
||||||
|
height={19.5}
|
||||||
|
sx={{ mt: theme.gap.xs }}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="20%"
|
||||||
|
height={34}
|
||||||
|
sx={{ alignSelf: "flex-end" }}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
<Stack direction="row" flexWrap="wrap" gap={theme.gap.large}>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={120}
|
||||||
|
sx={{ flex: "35%" }}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={120}
|
||||||
|
sx={{ flex: "35%" }}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={120}
|
||||||
|
sx={{ flex: "35%" }}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={120}
|
||||||
|
sx={{ flex: "35%" }}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
) : monitors?.length !== 0 ? (
|
||||||
<Stack gap={theme.gap.xs}>
|
<Stack gap={theme.gap.xs}>
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
|
|||||||
Reference in new issue
Block a user