Merge pull request #433 from bluewave-labs/feat/incidents-styling

Incidents page styling
This commit is contained in:
Alexander Holliday authored and GitHub committed 2024-07-23 15:20:49 -07:00
commit 53fcfa11a8
7 files changed
+85 -27

No files matched your search

@@ -77,7 +77,6 @@
} }
.MuiPaper-root + .MuiPagination-root { .MuiPaper-root + .MuiPagination-root {
flex: 1;
margin-top: 35px; margin-top: 35px;
border: solid 1px var(--env-var-color-16); border: solid 1px var(--env-var-color-16);
border-radius: var(--env-var-radius-1); border-radius: var(--env-var-radius-1);
+3 -2
View File
@@ -33,6 +33,7 @@ import ArrowForwardRoundedIcon from "@mui/icons-material/ArrowForwardRounded";
* @param {function} props.data.rows.data.handleClick - Function to call when the row is clicked. * @param {function} props.data.rows.data.handleClick - Function to call when the row is clicked.
* @param {boolean} [props.paginated=false] - Flag to enable pagination. * @param {boolean} [props.paginated=false] - Flag to enable pagination.
* @param {boolean} [props.reversed=false] - Flag to enable reverse order. * @param {boolean} [props.reversed=false] - Flag to enable reverse order.
* @param {number} props.rowsPerPage- Number of rows per page (table).
* *
* @example * @example
* const data = { * const data = {
@@ -67,11 +68,10 @@ import ArrowForwardRoundedIcon from "@mui/icons-material/ArrowForwardRounded";
* <BasicTable data={data} rows={rows} paginated={true} /> * <BasicTable data={data} rows={rows} paginated={true} />
*/ */
const BasicTable = ({ data, paginated, reversed }) => { const BasicTable = ({ data, paginated, reversed, rowsPerPage = 5 }) => {
// Add headers to props validation // Add headers to props validation
const [page, setPage] = useState(0); const [page, setPage] = useState(0);
const rowsPerPage = 5;
const handleChangePage = (event, newPage) => { const handleChangePage = (event, newPage) => {
setPage(newPage); setPage(newPage);
@@ -158,6 +158,7 @@ BasicTable.propTypes = {
data: PropTypes.object.isRequired, data: PropTypes.object.isRequired,
paginated: PropTypes.bool, paginated: PropTypes.bool,
reversed: PropTypes.bool, reversed: PropTypes.bool,
rowPerPage: PropTypes.number,
}; };
export default BasicTable; export default BasicTable;
@@ -282,19 +282,28 @@ const TeamPanel = () => {
level="secondary" level="secondary"
label="All" label="All"
onClick={() => setFilter("all")} onClick={() => setFilter("all")}
sx={{ backgroundColor: filter === "all" && "#f4f4f4" }} sx={{
backgroundColor:
filter === "all" && theme.palette.otherColors.fillGray,
}}
/> />
<Button <Button
level="secondary" level="secondary"
label="Administrator" label="Administrator"
onClick={() => setFilter("admin")} onClick={() => setFilter("admin")}
sx={{ backgroundColor: filter === "admin" && "#f4f4f4" }} sx={{
backgroundColor:
filter === "admin" && theme.palette.otherColors.fillGray,
}}
/> />
<Button <Button
level="secondary" level="secondary"
label="Member" label="Member"
onClick={() => setFilter("user")} onClick={() => setFilter("user")}
sx={{ backgroundColor: filter === "user" && "#f4f4f4" }} sx={{
backgroundColor:
filter === "user" && theme.palette.otherColors.fillGray,
}}
/> />
</ButtonGroup> </ButtonGroup>
</Stack> </Stack>
+17
View File
@@ -0,0 +1,17 @@
.incidents h1.MuiTypography-root {
color: var(--env-var-color-5);
}
.incidents h1.MuiTypography-root {
font-size: var(--env-var-font-size-large);
font-weight: 600;
}
.incidents button.MuiButtonBase-root {
font-size: var(--env-var-font-size-medium);
height: 34px;
border-color: var(--env-var-color-16);
}
/* remove later */
.incidents .MuiSelect-select {
padding: 0 10px;
}
+51 -20
View File
@@ -1,13 +1,23 @@
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { Select, MenuItem, Typography, ButtonGroup } from "@mui/material"; import {
Select,
MenuItem,
Typography,
ButtonGroup,
Stack,
} from "@mui/material";
import Button from "../../Components/Button"; import Button from "../../Components/Button";
import axiosInstance from "../../Utils/axiosConfig"; import axiosInstance from "../../Utils/axiosConfig";
import BasicTable from "../../Components/BasicTable"; import BasicTable from "../../Components/BasicTable";
import { StatusLabel } from "../../Components/Label"; import { StatusLabel } from "../../Components/Label";
import { useTheme } from "@emotion/react";
import "./index.css";
const Incidents = () => { const Incidents = () => {
const theme = useTheme();
const authState = useSelector((state) => state.auth); const authState = useSelector((state) => state.auth);
const [monitors, setMonitors] = useState({}); const [monitors, setMonitors] = useState({});
const [selectedMonitor, setSelectedMonitor] = useState("0"); const [selectedMonitor, setSelectedMonitor] = useState("0");
@@ -65,6 +75,11 @@ const Incidents = () => {
.sort((a, b) => { .sort((a, b) => {
return new Date(b.createdAt) - new Date(a.createdAt); return new Date(b.createdAt) - new Date(a.createdAt);
}) })
.filter((incident) => {
if (filter === "all") return true;
else if (filter === "resolve") return incident.statusCode === 5000;
else if (filter === "down") return incident.status === false;
})
.map((incident, idx) => { .map((incident, idx) => {
const params = { const params = {
status: "Down", status: "Down",
@@ -94,41 +109,57 @@ const Incidents = () => {
data.rows = incidents; data.rows = incidents;
return ( return (
<div> <Stack
<div style={{ display: "flex", justifyContent: "space-between" }}> className="incidents"
<div style={{ display: "flex" }}> gap={theme.gap.large}
<Typography>Incident history for: </Typography> style={{
<Select value={selectedMonitor} onChange={handleSelect}> padding: `${theme.content.pY} ${theme.content.pX}`,
<MenuItem value={"0"}>All servers</MenuItem> }}
{Object.values(monitors).map((monitor) => { >
return ( <Stack direction="row" alignItems="center" gap={theme.gap.medium}>
<MenuItem key={monitor._id} value={monitor._id}> <Typography component="h1">Incident history for: </Typography>
{monitor.name} <Select value={selectedMonitor} onChange={handleSelect}>
</MenuItem> <MenuItem value={"0"}>All servers</MenuItem>
); {Object.values(monitors).map((monitor) => {
})} return (
</Select> <MenuItem key={monitor._id} value={monitor._id}>
</div> {monitor.name}
<ButtonGroup> </MenuItem>
);
})}
</Select>
<ButtonGroup sx={{ ml: "auto" }}>
<Button <Button
level="secondary" level="secondary"
label="All" label="All"
onClick={() => setFilter("all")} onClick={() => setFilter("all")}
sx={{
backgroundColor:
filter === "all" && theme.palette.otherColors.fillGray,
}}
/> />
<Button <Button
level="secondary" level="secondary"
label="Down" label="Down"
onClick={() => setFilter("down")} onClick={() => setFilter("down")}
sx={{
backgroundColor:
filter === "down" && theme.palette.otherColors.fillGray,
}}
/> />
<Button <Button
level="secondary" level="secondary"
label="Cannot Resolve" label="Cannot Resolve"
onClick={() => setFilter("resolve")} onClick={() => setFilter("resolve")}
sx={{
backgroundColor:
filter === "resolve" && theme.palette.otherColors.fillGray,
}}
/> />
</ButtonGroup> </ButtonGroup>
</div> </Stack>
<BasicTable data={data} paginated={true} /> <BasicTable data={data} paginated={true} rowsPerPage={12}/>
</div> </Stack>
); );
}; };
+2
View File
@@ -26,6 +26,7 @@ const otherColorsWhite = "#fff";
const otherColorsGraishWhiteLight = "#f2f2f2"; const otherColorsGraishWhiteLight = "#f2f2f2";
const otherColorsStrongBlue = "#f2f2f2"; const otherColorsStrongBlue = "#f2f2f2";
const otherColorsSlateGray = "#667085"; const otherColorsSlateGray = "#667085";
const otherColorsFillGray = "#f4f4f4";
//box shadow //box shadow
const shadow = const shadow =
@@ -74,6 +75,7 @@ const theme = createTheme({
graishWhiteLight: otherColorsGraishWhiteLight, graishWhiteLight: otherColorsGraishWhiteLight,
strongBlue: otherColorsStrongBlue, strongBlue: otherColorsStrongBlue,
slateGray: otherColorsSlateGray, slateGray: otherColorsSlateGray,
fillGray: otherColorsFillGray,
}, },
}, },
font: { font: {
-1
View File
@@ -1,6 +1,5 @@
:root { :root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400; font-weight: 400;
/* color-scheme: light dark; /* color-scheme: light dark;