add sharing feature

This commit is contained in:
Alex Holliday committed 2025-02-20 15:18:14 -08:00
1 parent aa1cd5313e
commit b0cadf66bf
3 files changed
+49 -37

No files matched your search

@@ -5,7 +5,6 @@ import { useTheme } from "@mui/material/styles";
import maplibregl from "maplibre-gl"; import maplibregl from "maplibre-gl";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import buildStyle from "./buildStyle"; import buildStyle from "./buildStyle";
import { ColContainer } from "../../../../../Components/StandardContainer";
const DistributedUptimeMap = ({ width = "100%", checks }) => { const DistributedUptimeMap = ({ width = "100%", checks }) => {
const mapContainer = useRef(null); const mapContainer = useRef(null);
@@ -29,12 +28,17 @@ const DistributedUptimeMap = ({ width = "100%", checks }) => {
useEffect(() => { useEffect(() => {
if (mapContainer.current && !map.current) { if (mapContainer.current && !map.current) {
const initialStyle = buildStyle(initialTheme.current, initialMode.current); const initialStyle = buildStyle(initialTheme.current, initialMode.current);
map.current = new maplibregl.Map({ map.current = new maplibregl.Map({
container: mapContainer.current, container: mapContainer.current,
style: initialStyle, style: initialStyle,
center: [0, 20], center: [0, 20],
zoom: 0.8, zoom: 0.8,
attributionControl: false, attributionControl: false,
canvasContextAttributes: {
antialias: true,
preserveDrawingBuffer: true,
},
}); });
} }
map.current.on("load", () => { map.current.on("load", () => {
@@ -4,19 +4,17 @@ import { Stack, Typography } from "@mui/material";
import PulseDot from "../../../../../Components/Animated/PulseDot"; import PulseDot from "../../../../../Components/Animated/PulseDot";
import LastUpdate from "../LastUpdate"; import LastUpdate from "../LastUpdate";
import ChatBot from "../Chatbot"; import ChatBot from "../Chatbot";
import ShareComponent from "../../../../../Components/ShareComponent";
// Utils // Utils
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
const StatusHeader = ({ monitor, connectionStatus }) => { const StatusHeader = ({ monitor, connectionStatus, elementToCapture }) => {
console.log(monitor);
const theme = useTheme(); const theme = useTheme();
const COLOR_MAP = { const COLOR_MAP = {
up: theme.palette.distributedStatusHeader.up, up: theme.palette.successSecondary.main,
down: theme.palette.distributedStatusHeader.down, down: theme.palette.error.lowContrast,
}; };
const MSG_MAP = { const MSG_MAP = {
@@ -35,43 +33,48 @@ const StatusHeader = ({ monitor, connectionStatus }) => {
<ColContainer backgroundColor={bgColor}> <ColContainer backgroundColor={bgColor}>
<Stack <Stack
direction="row" direction="row"
justifyContent="space-between"
gap={theme.spacing(8)} gap={theme.spacing(8)}
> >
<PulseDot color={PULSE_COLOR[connectionStatus]} /> <Stack
<Stack> direction="row"
<Stack gap={theme.spacing(8)}
direction="row" >
gap={theme.spacing(8)} <PulseDot color={PULSE_COLOR[connectionStatus]} />
> <Stack>
<Typography <Stack
variant="h1" direction="row"
color={theme.palette.distributedStatusHeader.textPrimary} gap={theme.spacing(8)}
> >
{MSG_MAP[connectionStatus]} <Typography
</Typography> variant="h1"
color={theme.palette.success.lowContrast}
>
{MSG_MAP[connectionStatus]}
</Typography>
<Typography
variant="body2"
borderRadius={theme.spacing(8)}
padding={theme.spacing(4)}
backgroundColor={theme.palette.successSecondary.lowContrast}
color={theme.palette.success.lowContrast}
>
Uptime: {(monitor.totalUptime * 100).toFixed(2)}%
</Typography>
</Stack>
<Typography <Typography
variant="body2" variant="body2"
borderRadius={theme.spacing(8)} color={theme.palette.success.lowContrast}
padding={theme.spacing(4)}
backgroundColor={
theme.palette.distributedStatusHeader.textPrimaryBackground
}
color={theme.palette.distributedStatusHeader.textPrimary}
> >
Uptime: {(monitor.totalUptime * 100).toFixed(2)}% Last updated{" "}
<LastUpdate
suffix={"seconds ago"}
lastUpdateTime={monitor.timeSinceLastCheck}
/>
</Typography> </Typography>
</Stack> </Stack>
<Typography
variant="body2"
color={theme.palette.distributedStatusHeader.textSecondary}
>
Last updated{" "}
<LastUpdate
suffix={"seconds ago"}
lastUpdateTime={monitor.timeSinceLastCheck}
/>
</Typography>
</Stack> </Stack>
<ShareComponent elementToCapture={elementToCapture} />
</Stack> </Stack>
<ChatBot sx={{ marginTop: theme.spacing(10) }} /> <ChatBot sx={{ marginTop: theme.spacing(10) }} />
</ColContainer> </ColContainer>
@@ -19,7 +19,7 @@ import StatusHeader from "../../DistributedUptime/Details/Components/StatusHeade
//Utils //Utils
import { useTheme } from "@mui/material/styles"; import { useTheme } from "@mui/material/styles";
import { useState } from "react"; import { useState, useRef } from "react";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import { useSubscribeToDetails } from "../../DistributedUptime/Details/Hooks/useSubscribeToDetails"; import { useSubscribeToDetails } from "../../DistributedUptime/Details/Hooks/useSubscribeToDetails";
import { useStatusPageFetchByUrl } from "./Hooks/useStatusPageFetchByUrl"; import { useStatusPageFetchByUrl } from "./Hooks/useStatusPageFetchByUrl";
@@ -31,6 +31,7 @@ const DistributedUptimeStatus = () => {
const location = useLocation(); const location = useLocation();
const isPublic = location.pathname.startsWith("/status/distributed/public"); const isPublic = location.pathname.startsWith("/status/distributed/public");
const elementToCapture = useRef(null);
// Local State // Local State
const [dateRange, setDateRange] = useState("day"); const [dateRange, setDateRange] = useState("day");
const [isDeleteOpen, setIsDeleteOpen] = useState(false); const [isDeleteOpen, setIsDeleteOpen] = useState(false);
@@ -135,9 +136,12 @@ const DistributedUptimeStatus = () => {
return ( return (
<Stack <Stack
ref={elementToCapture}
direction="column" direction="column"
gap={theme.spacing(10)} gap={theme.spacing(10)}
sx={sx} sx={{
...sx,
}}
> >
{!isPublic && <Breadcrumbs list={BREADCRUMBS} />} {!isPublic && <Breadcrumbs list={BREADCRUMBS} />}
<ControlsHeader <ControlsHeader
@@ -153,6 +157,7 @@ const DistributedUptimeStatus = () => {
<StatusHeader <StatusHeader
monitor={monitor} monitor={monitor}
connectionStatus={connectionStatus} connectionStatus={connectionStatus}
elementToCapture={elementToCapture}
/> />
<NextExpectedCheck <NextExpectedCheck