diff --git a/client/package-lock.json b/client/package-lock.json
index 7f5397b7f..a378fa5c2 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -26,7 +26,6 @@
"joi": "17.13.3",
"lucide-react": "^0.562.0",
"mui-color-input": "^6.0.0",
- "pretty-ms": "9.3.0",
"react": "18.3.1",
"react-dom": "^18.2.0",
"react-hook-form": "7.63.0",
@@ -38,7 +37,7 @@
"react-toastify": "^10.0.5",
"recharts": "2.15.2",
"redux-persist": "6.0.0",
- "swr": "2.3.6",
+ "swr": "^2.3.6",
"vite-plugin-svgr": "^4.2.0",
"zod": "4.1.11"
},
@@ -5780,18 +5779,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/parse-ms": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-4.0.0.tgz",
- "integrity": "sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw==",
- "license": "MIT",
- "engines": {
- "node": ">=18"
- },
- "funding": {
- "url": "https://github.com/sponsors/sindresorhus"
- }
- },
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
@@ -5919,21 +5906,6 @@
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
- "node_modules/pretty-ms": {
- "version": "9.3.0",
- "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-9.3.0.tgz",
- "integrity": "sha512-gjVS5hOP+M3wMm5nmNOucbIrqudzs9v/57bWRHQWLYklXqoXKrVfYW2W9+glfGsqtPgpiz5WwyEEB+ksXIx3gQ==",
- "license": "MIT",
- "dependencies": {
- "parse-ms": "^4.0.0"
- },
- "engines": {
- "node": ">=18"
- },
- "funding": {
- "url": "https://github.com/sponsors/sindresorhus"
- }
- },
"node_modules/prop-types": {
"version": "15.8.1",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
diff --git a/client/package.json b/client/package.json
index 7c5acb441..360e4911d 100644
--- a/client/package.json
+++ b/client/package.json
@@ -31,7 +31,6 @@
"joi": "17.13.3",
"lucide-react": "^0.562.0",
"mui-color-input": "^6.0.0",
- "pretty-ms": "9.3.0",
"react": "18.3.1",
"react-dom": "^18.2.0",
"react-hook-form": "7.63.0",
diff --git a/client/src/Components/v2/design-elements/MonitorStatus.tsx b/client/src/Components/v2/design-elements/MonitorStatus.tsx
index 0ecb77df8..3d5e81845 100644
--- a/client/src/Components/v2/design-elements/MonitorStatus.tsx
+++ b/client/src/Components/v2/design-elements/MonitorStatus.tsx
@@ -34,7 +34,6 @@ export const MonitorStatus = ({ monitor }: { monitor: Monitor }) => {
>
;
+
+export interface ConfigItem {
+ id: string;
+ text: string;
+ palette: PaletteColorKey;
+}
+
+const config: Record = {
+ seo: {
+ id: "seo",
+ text: "SEO",
+ palette: "primary",
+ },
+ performance: {
+ id: "performance",
+ text: "performance",
+ palette: "success",
+ },
+ bestPractices: {
+ id: "bestPractices",
+ text: "best practices",
+ palette: "warning",
+ },
+ accessibility: {
+ id: "accessibility",
+ text: "accessibility",
+ palette: "error",
+ },
+};
+
+export const HistogramPageSpeedDetails = ({
+ checks,
+ range,
+}: {
+ checks: Check[];
+ range: string;
+}) => {
+ const theme = useTheme();
+ return (
+
+ }
+ title="Score history"
+ >
+
+
+ (
+
+ )}
+ />
+
+ }
+ />
+
+ {Object.values(config).map(({ id, palette }) => {
+ const startColor = theme.palette[palette].main;
+ const endColor = theme.palette[palette].light;
+
+ return (
+
+
+
+
+ );
+ })}
+
+ {Object.keys(config).map((key) => {
+ const { palette } = config[key];
+ const strokeColor = theme.palette[palette].main;
+ const bgColor = theme.palette.primary.main;
+
+ return (
+
+ );
+ })}
+
+
+
+ );
+};
diff --git a/client/src/Components/v2/monitors/charts/HistogramPageSpeedDetailsTooltip.tsx b/client/src/Components/v2/monitors/charts/HistogramPageSpeedDetailsTooltip.tsx
new file mode 100644
index 000000000..7219ba821
--- /dev/null
+++ b/client/src/Components/v2/monitors/charts/HistogramPageSpeedDetailsTooltip.tsx
@@ -0,0 +1,78 @@
+import Box from "@mui/material/Box";
+import Stack from "@mui/material/Stack";
+import Typography from "@mui/material/Typography";
+import { useTheme } from "@mui/material/styles";
+import { formatDateWithTz } from "@/Utils/TimeUtils";
+import type { ConfigItem } from "@/Components/v2/monitors";
+import type { TooltipProps } from "recharts";
+import { useSelector } from "react-redux";
+import type { RootState } from "@/Types/state";
+
+interface HistogramPageSpeedScoresTooltipProps
+ extends Partial> {
+ config: Record;
+}
+export const HistogramPageSpeedScoresTooltip = ({
+ active,
+ payload,
+ label,
+ config,
+}: HistogramPageSpeedScoresTooltipProps) => {
+ const theme = useTheme();
+ const uiTimezone = useSelector((state: RootState) => state.ui.timezone);
+
+ if (active && payload && payload.length) {
+ return (
+
+
+ {formatDateWithTz(label, "ddd, MMMM D, YYYY, h:mm A", uiTimezone)}
+
+ {Object.keys(config)
+ .reverse()
+ .map((key) => {
+ const { palette } = config[key];
+ const dotColor = theme.palette[palette].main;
+
+ return (
+
+
+
+ {config[key].text}
+
+ {Math.floor(payload[0].payload[key])}
+
+ );
+ })}
+
+ );
+ }
+ return null;
+};
diff --git a/client/src/Components/v2/monitors/charts/PiePagespeed.tsx b/client/src/Components/v2/monitors/charts/PiePageSpeed.tsx
similarity index 80%
rename from client/src/Components/v2/monitors/charts/PiePagespeed.tsx
rename to client/src/Components/v2/monitors/charts/PiePageSpeed.tsx
index cbc6b3106..1c58bb3f7 100644
--- a/client/src/Components/v2/monitors/charts/PiePagespeed.tsx
+++ b/client/src/Components/v2/monitors/charts/PiePageSpeed.tsx
@@ -1,5 +1,6 @@
import { BaseChart } from "@/Components/v2/design-elements";
import { FileText } from "lucide-react";
+import type { Check, CheckAudits } from "@/Types/Check";
import { Pie, PieChart, ResponsiveContainer, Label } from "recharts";
import Typography from "@mui/material/Typography";
import Box from "@mui/material/Box";
@@ -29,19 +30,20 @@ const CenterLabel = ({ viewBox, value }: any) => {
);
};
-export const PiePageSpeed = ({ latestCheck }: { latestCheck: any }) => {
+export const PiePageSpeed = ({ latestCheck }: { latestCheck?: Check }) => {
const { t } = useTranslation();
const theme = useTheme();
const [hoverTitle, setHoverTitle] = useState(null);
+ if (!latestCheck) return null;
const LABELS: Record = {
- FCP: t("common.charts.pageSpeed.fcp"),
- SI: t("common.charts.pageSpeed.si"),
- LCP: t("common.charts.pageSpeed.lcp"),
- TBT: t("common.charts.pageSpeed.tbt"),
- CLS: t("common.charts.pageSpeed.cls"),
+ FCP: t("pages.pageSpeed.charts.common.fcp"),
+ SI: t("pages.pageSpeed.charts.common.si"),
+ LCP: t("pages.pageSpeed.charts.common.lcp"),
+ TBT: t("pages.pageSpeed.charts.common.tbt"),
+ CLS: t("pages.pageSpeed.charts.common.cls"),
};
- const metrics = [
+ const metrics: { key: keyof CheckAudits; color: string; weight: number }[] = [
{ key: "fcp", color: alpha("#1DE9B6", 0.6), weight: 0.1 },
{ key: "si", color: alpha("#7C4DFF", 0.6), weight: 0.1 },
{ key: "lcp", color: alpha("#FFB200", 0.6), weight: 0.25 },
@@ -50,7 +52,8 @@ export const PiePageSpeed = ({ latestCheck }: { latestCheck: any }) => {
];
const scores = metrics.flatMap(({ key, color, weight }) => {
- const val = Math.floor((latestCheck?.[key] ?? 0) * 100);
+ const audit = latestCheck?.audits?.[key];
+ const val = Math.floor((audit?.score ?? 0) * 100);
const inverse = 100 - val;
return [
{
@@ -71,12 +74,11 @@ export const PiePageSpeed = ({ latestCheck }: { latestCheck: any }) => {
});
const totalScore =
- (latestCheck?.fcp || 0) * 0.1 +
- (latestCheck?.si || 0) * 0.1 +
- (latestCheck?.lcp || 0) * 0.25 +
- (latestCheck?.tbt || 0) * 0.3 +
- (latestCheck?.cls || 0) * 0.25;
-
+ (latestCheck.audits?.fcp?.score || 0) * 0.1 +
+ (latestCheck.audits?.si?.score || 0) * 0.1 +
+ (latestCheck.audits?.lcp?.score || 0) * 0.25 +
+ (latestCheck.audits?.tbt?.score || 0) * 0.3 +
+ (latestCheck.audits?.cls?.score || 0) * 0.25;
const pageSpeedPalette = getPageSpeedPalette(Math.floor(totalScore * 100));
const score = [
@@ -95,7 +97,7 @@ export const PiePageSpeed = ({ latestCheck }: { latestCheck: any }) => {
strokeWidth={1.5}
/>
}
- title={t("common.charts.pageSpeed.title")}
+ title={t("pages.pageSpeed.charts.pie.title")}
>
{
+ const { t } = useTranslation();
+ const theme = useTheme();
+ const palette = getPageSpeedPalette(value);
+ return (
+
+
+ {label}
+
+ {`${value}%`}
+ {`${t("pages.pageSpeed.charts.legend.weight")}: ${weight}%`}
+
+
+
+
+ );
+};
+
+export const PiePageSpeedLegend = ({ latestCheck }: { latestCheck?: Check }) => {
+ const theme = useTheme();
+ const { t } = useTranslation();
+
+ if (!latestCheck) {
+ return null;
+ }
+ return (
+
+ }
+ title={t("pages.pageSpeed.charts.legend.title")}
+ >
+
+
+
+
+
+
+
+
+ );
+};
diff --git a/client/src/Components/v2/monitors/index.tsx b/client/src/Components/v2/monitors/index.tsx
index f8e59270d..4efaae65c 100644
--- a/client/src/Components/v2/monitors/index.tsx
+++ b/client/src/Components/v2/monitors/index.tsx
@@ -5,4 +5,7 @@ export * from "./charts/RadialAvgResponse";
export * from "./charts/HistogramDetails";
export * from "./charts/HistogramPageSpeed";
export * from "./charts/HistogramPageSpeedTooltip";
-export * from "./charts/PiePagespeed";
+export * from "./charts/PiePageSpeed";
+export * from "./charts/PiePageSpeedLegend";
+export * from "./charts/HistogramPageSpeedDetails";
+export * from "./charts/HistogramPageSpeedDetailsTooltip";
diff --git a/client/src/Pages/PageSpeed/Details/index.tsx b/client/src/Pages/PageSpeed/Details/index.tsx
index ce40d9b2f..f6c672e77 100644
--- a/client/src/Pages/PageSpeed/Details/index.tsx
+++ b/client/src/Pages/PageSpeed/Details/index.tsx
@@ -1,7 +1,62 @@
import { BasePage } from "@/Components/v2/design-elements";
+import type { PageSpeedDetailsResponse } from "@/Types/Monitor";
+import { HeaderMonitorControls } from "@/Components/v2/common";
+import Stack from "@mui/material/Stack";
+import {
+ HistogramPageSpeedDetails,
+ PiePageSpeed,
+ PiePageSpeedLegend,
+ MonitorStatBoxes,
+} from "@/Components/v2/monitors";
+
+import { useIsAdmin } from "@/Hooks/useIsAdmin";
+import { useGet } from "@/Hooks/UseApi";
+import { useParams } from "react-router-dom";
+import { useTheme } from "@mui/material";
const PageSpeedDetails = () => {
- return PageSpeed Details - Work in Progress;
-};
+ const { monitorId } = useParams();
+ const isAdmin = useIsAdmin();
+ const theme = useTheme();
+ const {
+ data: monitorData,
+ isLoading,
+ error,
+ refetch,
+ } = useGet(
+ monitorId ? `/monitors/pagespeed/details/${monitorId}?dateRange=day` : null
+ );
+ const monitor = monitorData?.monitor;
+ const monitorStats = monitorData?.monitorStats || null;
+
+ return (
+
+
+
+
+
+
+
+
+
+ );
+};
export default PageSpeedDetails;
diff --git a/client/src/Routes/index.jsx b/client/src/Routes/index.jsx
index 3c2873ffa..45715a488 100644
--- a/client/src/Routes/index.jsx
+++ b/client/src/Routes/index.jsx
@@ -133,7 +133,13 @@ const Routes = () => {
/>
}
+ element={
+ <>
+
+
+
+ >
+ }
/>