-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Feat/status page pagespeed section #3452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
akashmannil
wants to merge
6
commits into
develop
Choose a base branch
from
feat/status-page-pagespeed-section
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6cea199
feat: statusPage - adding pagespeed section
41fa271
fix: changes fixing type errors and adding colorFn comment
c7d9331
adding changes to adhere to timescale db changes
866388c
fix: refactoring changes and removing unnecessary changes
5a8d043
fix: naming conventions changes and using more native props
0fc0132
fix: displaying valid metrics and removing type assertions
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
client/src/Pages/StatusPage/Status/Components/PageSpeedMetrics.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| import Typography from "@mui/material/Typography"; | ||
| import { Gauge } from "@/Components/design-elements"; | ||
| import { useTheme } from "@mui/material/styles"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import type { Monitor } from "@/Types/Monitor"; | ||
| import Grid from "@mui/material/Grid"; | ||
| import Box from "@mui/material/Box"; | ||
| import { LAYOUT, SPACING } from "@/Utils/Theme/constants"; | ||
| import { getPageSpeedGaugeColor } from "@/Utils/MonitorUtils"; | ||
|
|
||
| const GAUGE_RADIUS = 60; | ||
| const GAUGE_STROKE_WIDTH = 12; | ||
|
|
||
| interface StatusPageMonitor extends Monitor { | ||
| checks?: Monitor["recentChecks"]; | ||
| } | ||
|
|
||
| interface PageSpeedCheck { | ||
| performance: number; | ||
| accessibility: number; | ||
| bestPractices: number; | ||
| seo: number; | ||
| } | ||
|
|
||
| interface MetricConfig { | ||
| key: string; | ||
| label: string; | ||
| progress: number; | ||
| } | ||
|
|
||
| const MetricItem = ({ label, progress }: MetricConfig) => { | ||
| const theme = useTheme(); | ||
| return ( | ||
| <Grid | ||
| size={{ xs: 12, md: 3 }} | ||
| display="flex" | ||
| flexDirection="column" | ||
| alignItems="center" | ||
| textAlign="center" | ||
| gap={theme.spacing(SPACING.LG)} | ||
| padding={theme.spacing(LAYOUT.XS)} | ||
| sx={{ | ||
| borderRight: { xs: "none", md: `1px solid ${theme.palette.divider}` }, | ||
| borderBottom: { xs: `1px solid ${theme.palette.divider}`, md: "none" }, | ||
| "&:last-child": { | ||
| borderRight: "none", | ||
| borderBottom: "none", | ||
| paddingBottom: theme.spacing(SPACING.LG), | ||
| }, | ||
| }} | ||
| > | ||
| <Box | ||
| display="flex" | ||
| flexDirection="column" | ||
| alignItems="center" | ||
| > | ||
| <Gauge | ||
| progress={progress} | ||
| radius={GAUGE_RADIUS} | ||
| strokeWidth={GAUGE_STROKE_WIDTH} | ||
| colorFn={getPageSpeedGaugeColor} | ||
| /> | ||
| <Typography variant="body2">{label}</Typography> | ||
| </Box> | ||
| </Grid> | ||
| ); | ||
| }; | ||
|
|
||
| const buildMetrics = ( | ||
| check: PageSpeedCheck, | ||
| t: (key: string) => string | ||
| ): MetricConfig[] => [ | ||
| { | ||
| key: "performance", | ||
| label: t("pages.statusPages.monitorsList.pagespeed.performance"), | ||
| progress: check.performance, | ||
| }, | ||
| { | ||
| key: "accessibility", | ||
| label: t("pages.statusPages.monitorsList.pagespeed.accessibility"), | ||
| progress: check.accessibility, | ||
| }, | ||
| { | ||
| key: "bestPractices", | ||
| label: t("pages.statusPages.monitorsList.pagespeed.bestPractices"), | ||
| progress: check.bestPractices, | ||
| }, | ||
| { | ||
| key: "seo", | ||
| label: t("pages.statusPages.monitorsList.pagespeed.seo"), | ||
| progress: check.seo, | ||
| }, | ||
| ]; | ||
|
|
||
| export const PageSpeedMetrics = ({ monitor }: { monitor: StatusPageMonitor }) => { | ||
| const theme = useTheme(); | ||
| const { t } = useTranslation(); | ||
|
|
||
| const latestCheck = monitor.recentChecks?.[0] ?? monitor.checks?.[0]; | ||
|
|
||
| if (!latestCheck) { | ||
| return ( | ||
| <Typography | ||
| variant="body2" | ||
| color={theme.palette.text.secondary} | ||
| > | ||
| {t("pages.statusPages.monitorsList.noData")} | ||
| </Typography> | ||
| ); | ||
| } | ||
|
|
||
| const metrics = buildMetrics(latestCheck as PageSpeedCheck, t); | ||
|
|
||
| return ( | ||
| <Grid | ||
| container | ||
| alignItems="center" | ||
| padding={theme.spacing(LAYOUT.LG)} | ||
| flex={1} | ||
| > | ||
| {metrics.map((metric) => ( | ||
| <MetricItem | ||
| key={metric.key} | ||
| label={metric.label} | ||
| progress={metric.progress} | ||
| /> | ||
| ))} | ||
| </Grid> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.