Merge pull request #523 from bluewave-labs/feat/incidents-placeholder
Added placeholder if no incidents are found, resolves #520
This commit is contained in:
2 files changed
+94
-47
No files matched your search
@@ -1,12 +1,16 @@
|
|||||||
.incidents h1.MuiTypography-root {
|
.incidents h1.MuiTypography-root,
|
||||||
|
.incidents p.MuiTypography-root {
|
||||||
color: var(--env-var-color-5);
|
color: var(--env-var-color-5);
|
||||||
}
|
}
|
||||||
.incidents h1.MuiTypography-root {
|
.incidents h1.MuiTypography-root {
|
||||||
font-size: var(--env-var-font-size-large);
|
font-size: var(--env-var-font-size-large);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.incidents button.MuiButtonBase-root {
|
.incidents button.MuiButtonBase-root,
|
||||||
|
.incidents p.MuiTypography-root {
|
||||||
font-size: var(--env-var-font-size-medium);
|
font-size: var(--env-var-font-size-medium);
|
||||||
|
}
|
||||||
|
.incidents button.MuiButtonBase-root {
|
||||||
height: 34px;
|
height: 34px;
|
||||||
border-color: var(--env-var-color-16);
|
border-color: var(--env-var-color-16);
|
||||||
}
|
}
|
||||||
@@ -14,4 +18,4 @@
|
|||||||
/* remove later */
|
/* remove later */
|
||||||
.incidents .MuiSelect-select {
|
.incidents .MuiSelect-select {
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,20 @@
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { Typography, ButtonGroup, Stack } from "@mui/material";
|
import { Typography, ButtonGroup, Stack, Box } from "@mui/material";
|
||||||
|
import WestRoundedIcon from "@mui/icons-material/WestRounded";
|
||||||
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 { useTheme } from "@emotion/react";
|
||||||
|
import { useNavigate } from "react-router";
|
||||||
|
import Select from "../../Components/Inputs/Select";
|
||||||
|
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import Select from "../../Components/Inputs/Select";
|
|
||||||
|
|
||||||
const Incidents = () => {
|
const Incidents = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const navigate = useNavigate();
|
||||||
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");
|
||||||
@@ -58,13 +60,19 @@ const Incidents = () => {
|
|||||||
setSelectedMonitor(event.target.value);
|
setSelectedMonitor(event.target.value);
|
||||||
};
|
};
|
||||||
let incidents = [];
|
let incidents = [];
|
||||||
|
let hasAnyIncidents = false;
|
||||||
|
let hasSpecificIncidents = false;
|
||||||
if (selectedMonitor === "0") {
|
if (selectedMonitor === "0") {
|
||||||
Object.values(monitors).forEach((monitor) => {
|
Object.values(monitors).forEach((monitor) => {
|
||||||
incidents = incidents.concat(monitor.checks);
|
incidents = incidents.concat(monitor.checks);
|
||||||
});
|
});
|
||||||
|
if (incidents.length !== 0) hasAnyIncidents = true;
|
||||||
|
hasSpecificIncidents = hasAnyIncidents;
|
||||||
} else {
|
} else {
|
||||||
const monitor = monitors[selectedMonitor];
|
const monitor = monitors[selectedMonitor];
|
||||||
incidents = monitor.checks;
|
incidents = monitor.checks;
|
||||||
|
if (incidents.length !== 0) hasSpecificIncidents = true;
|
||||||
|
hasAnyIncidents = true;
|
||||||
}
|
}
|
||||||
incidents = incidents
|
incidents = incidents
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
@@ -92,48 +100,83 @@ const Incidents = () => {
|
|||||||
data.rows = incidents;
|
data.rows = incidents;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="incidents" gap={theme.gap.large}>
|
<>
|
||||||
<Stack direction="row" alignItems="center" gap={theme.gap.medium}>
|
<Stack className="incidents" gap={theme.gap.large}>
|
||||||
<Typography component="h1">Incident history for: </Typography>
|
{hasAnyIncidents ? (
|
||||||
<Select
|
<>
|
||||||
id="incidents-select-monitor"
|
<Stack direction="row" alignItems="center" gap={theme.gap.medium}>
|
||||||
placeholder="All servers"
|
<Typography component="h1">Incident history for: </Typography>
|
||||||
value={selectedMonitor}
|
<Select
|
||||||
onChange={handleSelect}
|
id="incidents-select-monitor"
|
||||||
items={Object.values(monitors)}
|
placeholder="All servers"
|
||||||
/>
|
value={selectedMonitor}
|
||||||
<ButtonGroup sx={{ ml: "auto" }}>
|
onChange={handleSelect}
|
||||||
<Button
|
items={Object.values(monitors)}
|
||||||
level="secondary"
|
/>
|
||||||
label="All"
|
{hasAnyIncidents && hasSpecificIncidents && (
|
||||||
onClick={() => setFilter("all")}
|
<ButtonGroup sx={{ ml: "auto" }}>
|
||||||
sx={{
|
<Button
|
||||||
backgroundColor:
|
level="secondary"
|
||||||
filter === "all" && theme.palette.otherColors.fillGray,
|
label="All"
|
||||||
}}
|
onClick={() => setFilter("all")}
|
||||||
/>
|
sx={{
|
||||||
<Button
|
backgroundColor:
|
||||||
level="secondary"
|
filter === "all" && theme.palette.otherColors.fillGray,
|
||||||
label="Down"
|
}}
|
||||||
onClick={() => setFilter("down")}
|
/>
|
||||||
sx={{
|
<Button
|
||||||
backgroundColor:
|
level="secondary"
|
||||||
filter === "down" && theme.palette.otherColors.fillGray,
|
label="Down"
|
||||||
}}
|
onClick={() => setFilter("down")}
|
||||||
/>
|
sx={{
|
||||||
<Button
|
backgroundColor:
|
||||||
level="secondary"
|
filter === "down" && theme.palette.otherColors.fillGray,
|
||||||
label="Cannot Resolve"
|
}}
|
||||||
onClick={() => setFilter("resolve")}
|
/>
|
||||||
sx={{
|
<Button
|
||||||
backgroundColor:
|
level="secondary"
|
||||||
filter === "resolve" && theme.palette.otherColors.fillGray,
|
label="Cannot Resolve"
|
||||||
}}
|
onClick={() => setFilter("resolve")}
|
||||||
/>
|
sx={{
|
||||||
</ButtonGroup>
|
backgroundColor:
|
||||||
|
filter === "resolve" &&
|
||||||
|
theme.palette.otherColors.fillGray,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</ButtonGroup>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
{hasAnyIncidents && hasSpecificIncidents ? (
|
||||||
|
<BasicTable data={data} paginated={true} rowsPerPage={12} />
|
||||||
|
) : (
|
||||||
|
<Typography alignSelf="center" mt={theme.gap.xxl}>
|
||||||
|
The monitor you have selected, has no recorded incidents yet.
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<Stack alignItems="center" mt={theme.gap.xxl} gap={theme.gap.small}>
|
||||||
|
<Typography>No incidents, yet.</Typography>
|
||||||
|
<Button
|
||||||
|
level="tertiary"
|
||||||
|
label="Back"
|
||||||
|
animate="slideLeft"
|
||||||
|
img={<WestRoundedIcon />}
|
||||||
|
onClick={() => navigate(-1)}
|
||||||
|
sx={{
|
||||||
|
backgroundColor: theme.palette.otherColors.fillGray,
|
||||||
|
mb: theme.gap.medium,
|
||||||
|
px: theme.gap.ml,
|
||||||
|
"& svg.MuiSvgIcon-root": {
|
||||||
|
mr: theme.gap.small,
|
||||||
|
fill: theme.palette.otherColors.slateGray,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
<BasicTable data={data} paginated={true} rowsPerPage={12} />
|
</>
|
||||||
</Stack>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user