Added greeting to pagespeed dashboard
This commit is contained in:
1 parent
d56ee2abb7
commit
4c68a55010
2 files changed
+79
-31
No files matched your search
@@ -1,14 +1,13 @@
|
|||||||
.page-speed h2.MuiTypography-root {
|
.page-speed h2.MuiTypography-root {
|
||||||
line-height: 1.1;
|
line-height: 1.1;
|
||||||
}
|
}
|
||||||
.page-speed h1.MuiTypography-root,
|
.page-speed h1.MuiTypography-root {
|
||||||
|
font-size: var(--env-var-font-size-large-plus);
|
||||||
|
}
|
||||||
.page-speed h2.MuiTypography-root {
|
.page-speed h2.MuiTypography-root {
|
||||||
font-size: var(--env-var-font-size-large);
|
font-size: var(--env-var-font-size-large);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.page-speed p.MuiTypography-root {
|
|
||||||
font-size: var(--env-var-font-size-medium);
|
|
||||||
}
|
|
||||||
.page-speed p:has(> span.MuiTypography-root),
|
.page-speed p:has(> span.MuiTypography-root),
|
||||||
.page-speed p.MuiTypography-root > span.MuiTypography-root {
|
.page-speed p.MuiTypography-root > span.MuiTypography-root {
|
||||||
font-size: var(--env-var-font-size-small-plus);
|
font-size: var(--env-var-font-size-small-plus);
|
||||||
@@ -20,5 +19,4 @@
|
|||||||
}
|
}
|
||||||
.page-speed:not(:has([class*="fallback__"])) button {
|
.page-speed:not(:has([class*="fallback__"])) button {
|
||||||
height: 34px;
|
height: 34px;
|
||||||
align-self: flex-end;
|
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ import Button from "../../Components/Button";
|
|||||||
import { useNavigate } from "react-router";
|
import { useNavigate } from "react-router";
|
||||||
import { getLastChecked } from "../../Utils/monitorUtils";
|
import { getLastChecked } from "../../Utils/monitorUtils";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
import Breadcrumbs from "../../Components/Breadcrumbs";
|
||||||
|
|
||||||
const Card = ({ data }) => {
|
const Card = ({ data }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -24,7 +25,7 @@ const Card = ({ data }) => {
|
|||||||
flexGrow={1}
|
flexGrow={1}
|
||||||
sx={{
|
sx={{
|
||||||
"&:hover > .MuiStack-root": {
|
"&:hover > .MuiStack-root": {
|
||||||
backgroundColor: "var(--primary-bg-accent)",
|
backgroundColor: theme.palette.background.accent,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -37,7 +38,10 @@ const Card = ({ data }) => {
|
|||||||
borderColor={theme.palette.border.light}
|
borderColor={theme.palette.border.light}
|
||||||
borderRadius={theme.shape.borderRadius}
|
borderRadius={theme.shape.borderRadius}
|
||||||
backgroundColor={theme.palette.background.main}
|
backgroundColor={theme.palette.background.main}
|
||||||
sx={{ cursor: "pointer" }}
|
sx={{
|
||||||
|
cursor: "pointer",
|
||||||
|
"& svg path": { stroke: theme.palette.other.icon, strokeWidth: 0.8 },
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<PageSpeedIcon
|
<PageSpeedIcon
|
||||||
style={{ width: theme.spacing(8), height: theme.spacing(8) }}
|
style={{ width: theme.spacing(8), height: theme.spacing(8) }}
|
||||||
@@ -56,7 +60,9 @@ const Card = ({ data }) => {
|
|||||||
text={data.status ? "Live (collecting data)" : "Inactive"}
|
text={data.status ? "Live (collecting data)" : "Inactive"}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Typography>{data.url.replace(/^https?:\/\//, "")}</Typography>
|
<Typography fontSize={13}>
|
||||||
|
{data.url.replace(/^https?:\/\//, "")}
|
||||||
|
</Typography>
|
||||||
<Typography mt={theme.spacing(12)}>
|
<Typography mt={theme.spacing(12)}>
|
||||||
<Typography component="span" fontWeight={600}>
|
<Typography component="span" fontWeight={600}>
|
||||||
Last checked:{" "}
|
Last checked:{" "}
|
||||||
@@ -142,7 +148,7 @@ const PageSpeed = ({ isAdmin }) => {
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
const { authToken, user } = useSelector((state) => state.auth);
|
||||||
const { monitors, isLoading } = useSelector(
|
const { monitors, isLoading } = useSelector(
|
||||||
(state) => state.pageSpeedMonitors
|
(state) => state.pageSpeedMonitors
|
||||||
);
|
);
|
||||||
@@ -154,10 +160,25 @@ const PageSpeed = ({ isAdmin }) => {
|
|||||||
// since monitor state is being added to redux persist, there's no reason to display skeletons on every render
|
// since monitor state is being added to redux persist, there's no reason to display skeletons on every render
|
||||||
let isActuallyLoading = isLoading && monitors.length === 0;
|
let isActuallyLoading = isLoading && monitors.length === 0;
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
|
const hour = now.getHours();
|
||||||
|
|
||||||
|
let greeting = "";
|
||||||
|
let emoji = "";
|
||||||
|
if (hour < 12) {
|
||||||
|
greeting = "morning";
|
||||||
|
emoji = "🌅";
|
||||||
|
} else if (hour < 18) {
|
||||||
|
greeting = "afternoon";
|
||||||
|
emoji = "🌞";
|
||||||
|
} else {
|
||||||
|
greeting = "evening";
|
||||||
|
emoji = "🌙";
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
className="page-speed"
|
className="page-speed"
|
||||||
pt={theme.spacing(20)}
|
|
||||||
sx={{
|
sx={{
|
||||||
':has(> [class*="fallback__"])': {
|
':has(> [class*="fallback__"])': {
|
||||||
position: "relative",
|
position: "relative",
|
||||||
@@ -173,37 +194,66 @@ const PageSpeed = ({ isAdmin }) => {
|
|||||||
{isActuallyLoading ? (
|
{isActuallyLoading ? (
|
||||||
<SkeletonLayout />
|
<SkeletonLayout />
|
||||||
) : monitors?.length !== 0 ? (
|
) : monitors?.length !== 0 ? (
|
||||||
<Stack
|
<Box
|
||||||
gap={theme.spacing(2)}
|
|
||||||
sx={{
|
sx={{
|
||||||
"& h1, & span.MuiTypography-root, & p": {
|
"& p": {
|
||||||
color: theme.palette.text.secondary,
|
color: theme.palette.text.secondary,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Stack
|
<Box mb={theme.spacing(12)}>
|
||||||
direction="row"
|
<Breadcrumbs list={[{ name: `pagespeed`, path: "/pagespeed" }]} />
|
||||||
justifyContent="space-between"
|
<Stack
|
||||||
mb={theme.spacing(12)}
|
direction="row"
|
||||||
>
|
justifyContent="space-between"
|
||||||
<Box>
|
alignItems="center"
|
||||||
<Typography component="h1">All page speed monitors</Typography>
|
mt={theme.spacing(5)}
|
||||||
<Typography mt={theme.spacing(2)}>
|
>
|
||||||
Click on one of the monitors to get more site speed information.
|
<Box>
|
||||||
</Typography>
|
<Typography
|
||||||
</Box>
|
component="h1"
|
||||||
<Button
|
lineHeight={1}
|
||||||
level="primary"
|
fontWeight={500}
|
||||||
label="Create new"
|
color={theme.palette.text.primary}
|
||||||
onClick={() => navigate("/pagespeed/create")}
|
>
|
||||||
/>
|
<Typography
|
||||||
</Stack>
|
component="span"
|
||||||
|
fontSize="inherit"
|
||||||
|
color={theme.palette.text.secondary}
|
||||||
|
>
|
||||||
|
Good {greeting},{" "}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
fontSize="inherit"
|
||||||
|
fontWeight="inherit"
|
||||||
|
>
|
||||||
|
{user.firstName} {emoji}
|
||||||
|
</Typography>
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
sx={{ opacity: 0.8 }}
|
||||||
|
lineHeight={1}
|
||||||
|
fontSize={14}
|
||||||
|
fontWeight={300}
|
||||||
|
color={theme.palette.text.secondary}
|
||||||
|
>
|
||||||
|
Here’s an overview of your pagespeed monitors.
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Button
|
||||||
|
level="primary"
|
||||||
|
label="Create new"
|
||||||
|
onClick={() => navigate("/pagespeed/create")}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
<Grid container spacing={theme.spacing(12)}>
|
<Grid container spacing={theme.spacing(12)}>
|
||||||
{monitors?.map((monitor) => (
|
{monitors?.map((monitor) => (
|
||||||
<Card data={monitor} key={`monitor-${monitor._id}`} />
|
<Card data={monitor} key={`monitor-${monitor._id}`} />
|
||||||
))}
|
))}
|
||||||
</Grid>
|
</Grid>
|
||||||
</Stack>
|
</Box>
|
||||||
) : (
|
) : (
|
||||||
<Fallback
|
<Fallback
|
||||||
title="pagespeed monitor"
|
title="pagespeed monitor"
|
||||||
|
|||||||
Reference in new issue
Block a user