Added monitor actions menu dropdown and styling
This commit is contained in:
1 parent
5be6d1653e
commit
d9c5b8eab7
4 files changed
+85
-30
No files matched your search
@@ -31,3 +31,23 @@
|
||||
margin-left: 10px;
|
||||
line-height: 0.8;
|
||||
}
|
||||
|
||||
body:has(.monitors) .actions-menu .MuiPaper-root {
|
||||
box-shadow: var(--env-var-shadow-1);
|
||||
border: solid 1px var(--env-var-color-6);
|
||||
border-radius: var(--env-var-radius-1);
|
||||
gap: 1px;
|
||||
}
|
||||
body:has(.monitors) .actions-menu .MuiList-root {
|
||||
padding: 6px 8px;
|
||||
min-width: 100px;
|
||||
}
|
||||
body:has(.monitors) .actions-menu li.MuiButtonBase-root {
|
||||
font-size: var(--env-var-font-size-medium);
|
||||
color: var(--env-var-color-5);
|
||||
padding: 5px 8px;
|
||||
border-radius: var(--env-var-radius-1);
|
||||
}
|
||||
body:has(.monitors) .actions-menu li.MuiButtonBase-root:last-of-type {
|
||||
color: var(--env-var-color-26);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import "./index.css";
|
||||
import { useEffect } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { getUptimeMonitorsByUserId } from "../../Features/UptimeMonitors/uptimeMonitorsSlice";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
@@ -8,10 +8,18 @@ import ServerStatus from "../../Components/Charts/Servers/ServerStatus";
|
||||
import { useTheme } from "@emotion/react";
|
||||
import ArrowDownwardRoundedIcon from "@mui/icons-material/ArrowDownwardRounded";
|
||||
import OpenInNewPage from "../../assets/icons/open-in-new-page.svg?react";
|
||||
import Settings from "../../assets/icons/settings-bold.svg?react";
|
||||
import BasicTable from "../../Components/BasicTable";
|
||||
import { StatusLabel } from "../../Components/Label";
|
||||
import ResponseTimeChart from "../../Components/Charts/ResponseTimeChart";
|
||||
import { Box, Stack, Typography } from "@mui/material";
|
||||
import {
|
||||
Box,
|
||||
IconButton,
|
||||
Menu,
|
||||
MenuItem,
|
||||
Stack,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
|
||||
/**
|
||||
* Host component.
|
||||
@@ -27,18 +35,13 @@ import { Box, Stack, Typography } from "@mui/material";
|
||||
*/
|
||||
const Host = ({ params }) => {
|
||||
return (
|
||||
<div className="host-row">
|
||||
<Stack direction="row" alignItems="center" className="host">
|
||||
<a href={params.url} target="_blank" rel="noreferrer">
|
||||
<OpenInNewPage />
|
||||
</a>
|
||||
<div className="host-name">{params.title}</div>
|
||||
<div
|
||||
className="host-percentage"
|
||||
style={{ color: params.percentageColor }}
|
||||
>
|
||||
{params.precentage}%
|
||||
</div>
|
||||
</div>
|
||||
<Box>{params.title}</Box>
|
||||
<Box sx={{ color: params.percentageColor }}>{params.precentage}%</Box>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -49,6 +52,8 @@ const Monitors = () => {
|
||||
const authState = useSelector((state) => state.auth);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const [anchorEl, setAnchorEl] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(getUptimeMonitorsByUserId(authState.authToken));
|
||||
}, []);
|
||||
@@ -65,12 +70,12 @@ const Monitors = () => {
|
||||
{
|
||||
id: 2,
|
||||
name: (
|
||||
<>
|
||||
<Box width="max-content">
|
||||
Status
|
||||
<span>
|
||||
<ArrowDownwardRoundedIcon />
|
||||
</span>
|
||||
</>
|
||||
</Box>
|
||||
),
|
||||
},
|
||||
{ id: 3, name: "Response Time" },
|
||||
@@ -97,7 +102,8 @@ const Monitors = () => {
|
||||
|
||||
return {
|
||||
id: monitor._id,
|
||||
handleClick: () => navigate(`/monitors/${monitor._id}`),
|
||||
// disabled for now
|
||||
// handleClick: () => navigate(`/monitors/${monitor._id}`),
|
||||
data: [
|
||||
{ id: idx, data: <Host params={params} /> },
|
||||
{
|
||||
@@ -117,7 +123,24 @@ const Monitors = () => {
|
||||
<span style={{ textTransform: "uppercase" }}>{monitor.type}</span>
|
||||
),
|
||||
},
|
||||
{ id: idx + 4, data: "TODO" },
|
||||
{
|
||||
id: idx + 4,
|
||||
data: (
|
||||
<>
|
||||
<IconButton
|
||||
aria-label="monitor actions"
|
||||
onClick={(event) => setAnchorEl(event.currentTarget)}
|
||||
sx={{
|
||||
"&:focus": {
|
||||
outline: "none",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Settings />
|
||||
</IconButton>
|
||||
</>
|
||||
),
|
||||
},
|
||||
],
|
||||
};
|
||||
});
|
||||
@@ -163,6 +186,19 @@ const Monitors = () => {
|
||||
</Stack>
|
||||
<BasicTable data={data} paginated={true} />
|
||||
</Stack>
|
||||
<Menu
|
||||
className="actions-menu"
|
||||
anchorEl={anchorEl}
|
||||
open={Boolean(anchorEl)}
|
||||
onClose={() => setAnchorEl(null)}
|
||||
>
|
||||
<MenuItem>Open site</MenuItem>
|
||||
<MenuItem>Details</MenuItem>
|
||||
{/* TODO - pass monitor id to Incidents page */}
|
||||
<MenuItem disabled>Incidents</MenuItem>
|
||||
<MenuItem>Configure</MenuItem>
|
||||
<MenuItem>Remove</MenuItem>
|
||||
</Menu>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user