feat: incident skeleton adjustement
This commit is contained in:
1 parent
a20db6df51
commit
4bf3ce6781
5 files changed
+457
-376
No files matched your search
@@ -0,0 +1,32 @@
|
|||||||
|
import { useTheme } from "@emotion/react";
|
||||||
|
import PlaceholderLight from "../../../../assets/Images/data_placeholder.svg?react";
|
||||||
|
import PlaceholderDark from "../../../../assets/Images/data_placeholder_dark.svg?react";
|
||||||
|
import { Box, Typography } from "@mui/material";
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
|
const Empty = ({ styles, mode }) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
return (
|
||||||
|
<Box sx={{ ...styles }}>
|
||||||
|
<Box
|
||||||
|
textAlign="center"
|
||||||
|
pb={theme.spacing(20)}
|
||||||
|
>
|
||||||
|
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
||||||
|
</Box>
|
||||||
|
<Typography
|
||||||
|
textAlign="center"
|
||||||
|
color={theme.palette.text.secondary}
|
||||||
|
>
|
||||||
|
No incidents recorded yet.
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Empty.propTypes = {
|
||||||
|
styles: PropTypes.object,
|
||||||
|
mode: PropTypes.string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export { Empty };
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { Skeleton /* , Stack */ } from "@mui/material";
|
||||||
|
const IncidentSkeleton = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Skeleton
|
||||||
|
animation={"wave"}
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={300}
|
||||||
|
/>
|
||||||
|
<Skeleton
|
||||||
|
animation={"wave"}
|
||||||
|
variant="rounded"
|
||||||
|
width="100%"
|
||||||
|
height={100}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { IncidentSkeleton };
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import {
|
import {
|
||||||
TableContainer,
|
TableContainer,
|
||||||
Table,
|
Table,
|
||||||
TableHead,
|
TableHead,
|
||||||
TableRow,
|
TableRow,
|
||||||
TableCell,
|
TableCell,
|
||||||
TableBody,
|
TableBody,
|
||||||
Pagination,
|
Pagination,
|
||||||
PaginationItem,
|
PaginationItem,
|
||||||
Paper,
|
Paper,
|
||||||
Typography,
|
Typography,
|
||||||
Box,
|
Box,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
|
||||||
import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded";
|
import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded";
|
||||||
@@ -24,185 +24,197 @@ import { useTheme } from "@emotion/react";
|
|||||||
import { formatDateWithTz } from "../../../Utils/timeUtils";
|
import { formatDateWithTz } from "../../../Utils/timeUtils";
|
||||||
import PlaceholderLight from "../../../assets/Images/data_placeholder.svg?react";
|
import PlaceholderLight from "../../../assets/Images/data_placeholder.svg?react";
|
||||||
import PlaceholderDark from "../../../assets/Images/data_placeholder_dark.svg?react";
|
import PlaceholderDark from "../../../assets/Images/data_placeholder_dark.svg?react";
|
||||||
|
import { Empty } from "./Empty/Empty";
|
||||||
|
import { IncidentSkeleton } from "./Skeleton/Skeleton";
|
||||||
|
|
||||||
const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
|
||||||
const uiTimezone = useSelector((state) => state.ui.timezone);
|
const uiTimezone = useSelector((state) => state.ui.timezone);
|
||||||
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { authToken, user } = useSelector((state) => state.auth);
|
const { authToken, user } = useSelector((state) => state.auth);
|
||||||
const mode = useSelector((state) => state.ui.mode);
|
const mode = useSelector((state) => state.ui.mode);
|
||||||
const [checks, setChecks] = useState([]);
|
const [checks, setChecks] = useState([]);
|
||||||
const [checksCount, setChecksCount] = useState(0);
|
const [checksCount, setChecksCount] = useState(0);
|
||||||
const [paginationController, setPaginationController] = useState({
|
const [paginationController, setPaginationController] = useState({
|
||||||
page: 0,
|
page: 0,
|
||||||
rowsPerPage: 14,
|
rowsPerPage: 14,
|
||||||
});
|
});
|
||||||
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setPaginationController((prevPaginationController) => ({
|
setPaginationController((prevPaginationController) => ({
|
||||||
...prevPaginationController,
|
...prevPaginationController,
|
||||||
page: 0,
|
page: 0,
|
||||||
}));
|
}));
|
||||||
}, [filter, selectedMonitor]);
|
}, [filter, selectedMonitor]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchPage = async () => {
|
const fetchPage = async () => {
|
||||||
if (!monitors || Object.keys(monitors).length === 0) {
|
if (!monitors || Object.keys(monitors).length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let res;
|
setIsLoading(true);
|
||||||
if (selectedMonitor === "0") {
|
let res;
|
||||||
res = await networkService.getChecksByTeam({
|
if (selectedMonitor === "0") {
|
||||||
authToken: authToken,
|
res = await networkService.getChecksByTeam({
|
||||||
teamId: user.teamId,
|
authToken: authToken,
|
||||||
sortOrder: "desc",
|
teamId: user.teamId,
|
||||||
limit: null,
|
sortOrder: "desc",
|
||||||
dateRange: null,
|
limit: null,
|
||||||
filter: filter,
|
dateRange: null,
|
||||||
page: paginationController.page,
|
filter: filter,
|
||||||
rowsPerPage: paginationController.rowsPerPage,
|
page: paginationController.page,
|
||||||
});
|
rowsPerPage: paginationController.rowsPerPage,
|
||||||
} else {
|
});
|
||||||
res = await networkService.getChecksByMonitor({
|
} else {
|
||||||
authToken: authToken,
|
res = await networkService.getChecksByMonitor({
|
||||||
monitorId: selectedMonitor,
|
authToken: authToken,
|
||||||
sortOrder: "desc",
|
monitorId: selectedMonitor,
|
||||||
limit: null,
|
sortOrder: "desc",
|
||||||
dateRange: null,
|
limit: null,
|
||||||
sitler: filter,
|
dateRange: null,
|
||||||
page: paginationController.page,
|
sitler: filter,
|
||||||
rowsPerPage: paginationController.rowsPerPage,
|
page: paginationController.page,
|
||||||
});
|
rowsPerPage: paginationController.rowsPerPage,
|
||||||
}
|
});
|
||||||
setChecks(res.data.data.checks);
|
}
|
||||||
setChecksCount(res.data.data.checksCount);
|
setChecks(res.data.data.checks);
|
||||||
} catch (error) {
|
setChecksCount(res.data.data.checksCount);
|
||||||
logger.error(error);
|
} catch (error) {
|
||||||
}
|
logger.error(error);
|
||||||
};
|
} finally {
|
||||||
fetchPage();
|
setIsLoading(false);
|
||||||
}, [
|
}
|
||||||
authToken,
|
};
|
||||||
user,
|
fetchPage();
|
||||||
monitors,
|
}, [
|
||||||
selectedMonitor,
|
authToken,
|
||||||
filter,
|
user,
|
||||||
paginationController.page,
|
monitors,
|
||||||
paginationController.rowsPerPage,
|
selectedMonitor,
|
||||||
]);
|
filter,
|
||||||
|
paginationController.page,
|
||||||
|
paginationController.rowsPerPage,
|
||||||
|
]);
|
||||||
|
|
||||||
const handlePageChange = (_, newPage) => {
|
const handlePageChange = (_, newPage) => {
|
||||||
setPaginationController({
|
setPaginationController({
|
||||||
...paginationController,
|
...paginationController,
|
||||||
page: newPage - 1, // 0-indexed
|
page: newPage - 1, // 0-indexed
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
let paginationComponent = <></>;
|
let paginationComponent = <></>;
|
||||||
if (checksCount > paginationController.rowsPerPage) {
|
if (checksCount > paginationController.rowsPerPage) {
|
||||||
paginationComponent = (
|
paginationComponent = (
|
||||||
<Pagination
|
<Pagination
|
||||||
count={Math.ceil(checksCount / paginationController.rowsPerPage)}
|
count={Math.ceil(checksCount / paginationController.rowsPerPage)}
|
||||||
page={paginationController.page + 1} //0-indexed
|
page={paginationController.page + 1} //0-indexed
|
||||||
onChange={handlePageChange}
|
onChange={handlePageChange}
|
||||||
shape="rounded"
|
shape="rounded"
|
||||||
renderItem={(item) => (
|
renderItem={(item) => (
|
||||||
<PaginationItem
|
<PaginationItem
|
||||||
slots={{
|
slots={{
|
||||||
previous: ArrowBackRoundedIcon,
|
previous: ArrowBackRoundedIcon,
|
||||||
next: ArrowForwardRoundedIcon,
|
next: ArrowForwardRoundedIcon,
|
||||||
}}
|
}}
|
||||||
{...item}
|
{...item}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
sx={{ mt: "auto" }}
|
sx={{ mt: "auto" }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let sharedStyles = {
|
let sharedStyles = {
|
||||||
border: 1,
|
border: 1,
|
||||||
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,
|
||||||
p: theme.spacing(30),
|
p: theme.spacing(30),
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
const hasChecks = checks?.length === 0;
|
||||||
<>
|
const noIncidentsRecordedYet = hasChecks && selectedMonitor === "0";
|
||||||
{checks?.length === 0 && selectedMonitor === "0" ? (
|
const noIncidentsForThatMonitor = hasChecks && selectedMonitor !== "0";
|
||||||
<Box sx={{ ...sharedStyles }}>
|
|
||||||
<Box textAlign="center" pb={theme.spacing(20)}>
|
|
||||||
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
|
||||||
</Box>
|
|
||||||
<Typography textAlign="center" color={theme.palette.text.secondary}>
|
|
||||||
No incidents recorded yet.
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
) : checks?.length === 0 ? (
|
|
||||||
<Box sx={{ ...sharedStyles }}>
|
|
||||||
<Box textAlign="center" pb={theme.spacing(20)}>
|
|
||||||
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
|
||||||
</Box>
|
|
||||||
<Typography textAlign="center" color={theme.palette.text.secondary}>
|
|
||||||
The monitor you have selected has no recorded incidents yet.
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<TableContainer component={Paper}>
|
|
||||||
<Table>
|
|
||||||
<TableHead>
|
|
||||||
<TableRow>
|
|
||||||
<TableCell>Monitor Name</TableCell>
|
|
||||||
<TableCell>Status</TableCell>
|
|
||||||
<TableCell>Date & Time</TableCell>
|
|
||||||
<TableCell>Status Code</TableCell>
|
|
||||||
<TableCell>Message</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
</TableHead>
|
|
||||||
<TableBody>
|
|
||||||
{checks.map((check) => {
|
|
||||||
const status = check.status === true ? "up" : "down";
|
|
||||||
const formattedDate = formatDateWithTz(
|
|
||||||
check.createdAt,
|
|
||||||
"YYYY-MM-DD HH:mm:ss A",
|
|
||||||
uiTimezone
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow key={check._id}>
|
<>
|
||||||
<TableCell>{monitors[check.monitorId]?.name}</TableCell>
|
{isLoading ? (
|
||||||
<TableCell>
|
<IncidentSkeleton />
|
||||||
<StatusLabel
|
) : noIncidentsRecordedYet ? (
|
||||||
status={status}
|
<Empty
|
||||||
text={status}
|
mode={mode}
|
||||||
customStyles={{ textTransform: "capitalize" }}
|
styles={sharedStyles}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
) : noIncidentsForThatMonitor ? (
|
||||||
<TableCell>{formattedDate}</TableCell>
|
<Box sx={{ ...sharedStyles }}>
|
||||||
<TableCell>
|
<Box
|
||||||
{check.statusCode ? check.statusCode : "N/A"}
|
textAlign="center"
|
||||||
</TableCell>
|
pb={theme.spacing(20)}
|
||||||
<TableCell>{check.message}</TableCell>
|
>
|
||||||
</TableRow>
|
{mode === "light" ? <PlaceholderLight /> : <PlaceholderDark />}
|
||||||
);
|
</Box>
|
||||||
})}
|
<Typography
|
||||||
</TableBody>
|
textAlign="center"
|
||||||
</Table>
|
color={theme.palette.text.secondary}
|
||||||
</TableContainer>
|
>
|
||||||
{paginationComponent}
|
The monitor you have selected has no recorded incidents yet.
|
||||||
</>
|
</Typography>
|
||||||
)}
|
</Box>
|
||||||
</>
|
) : (
|
||||||
);
|
<>
|
||||||
|
<TableContainer component={Paper}>
|
||||||
|
<Table>
|
||||||
|
<TableHead>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell>Monitor Name</TableCell>
|
||||||
|
<TableCell>Status</TableCell>
|
||||||
|
<TableCell>Date & Time</TableCell>
|
||||||
|
<TableCell>Status Code</TableCell>
|
||||||
|
<TableCell>Message</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableHead>
|
||||||
|
<TableBody>
|
||||||
|
{checks.map((check) => {
|
||||||
|
const status = check.status === true ? "up" : "down";
|
||||||
|
const formattedDate = formatDateWithTz(
|
||||||
|
check.createdAt,
|
||||||
|
"YYYY-MM-DD HH:mm:ss A",
|
||||||
|
uiTimezone
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TableRow key={check._id}>
|
||||||
|
<TableCell>{monitors[check.monitorId]?.name}</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<StatusLabel
|
||||||
|
status={status}
|
||||||
|
text={status}
|
||||||
|
customStyles={{ textTransform: "capitalize" }}
|
||||||
|
/>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>{formattedDate}</TableCell>
|
||||||
|
<TableCell>{check.statusCode ? check.statusCode : "N/A"}</TableCell>
|
||||||
|
<TableCell>{check.message}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</TableContainer>
|
||||||
|
{paginationComponent}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
IncidentTable.propTypes = {
|
IncidentTable.propTypes = {
|
||||||
monitors: PropTypes.object.isRequired,
|
monitors: PropTypes.object.isRequired,
|
||||||
selectedMonitor: PropTypes.string.isRequired,
|
selectedMonitor: PropTypes.string.isRequired,
|
||||||
filter: PropTypes.string.isRequired,
|
filter: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default IncidentTable;
|
export default IncidentTable;
|
||||||
@@ -11,119 +11,133 @@ import SkeletonLayout from "./skeleton";
|
|||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
const Incidents = () => {
|
const Incidents = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const authState = useSelector((state) => state.auth);
|
const authState = useSelector((state) => state.auth);
|
||||||
const { monitorId } = useParams();
|
const { monitorId } = useParams();
|
||||||
|
|
||||||
const [monitors, setMonitors] = useState({});
|
const [monitors, setMonitors] = useState({});
|
||||||
const [selectedMonitor, setSelectedMonitor] = useState("0");
|
const [selectedMonitor, setSelectedMonitor] = useState("0");
|
||||||
const [loading, setLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
// TODO do something with these filters
|
// TODO do something with these filters
|
||||||
const [filter, setFilter] = useState("all");
|
const [filter, setFilter] = useState("all");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchMonitors = async () => {
|
const fetchMonitors = async () => {
|
||||||
setLoading(true);
|
try {
|
||||||
const res = await networkService.getMonitorsByTeamId({
|
setIsLoading(true);
|
||||||
authToken: authState.authToken,
|
const res = await networkService.getMonitorsByTeamId({
|
||||||
teamId: authState.user.teamId,
|
authToken: authState.authToken,
|
||||||
limit: -1,
|
teamId: authState.user.teamId,
|
||||||
types: null,
|
limit: -1,
|
||||||
status: null,
|
types: null,
|
||||||
checkOrder: null,
|
status: null,
|
||||||
normalize: null,
|
checkOrder: null,
|
||||||
page: null,
|
normalize: null,
|
||||||
rowsPerPage: null,
|
page: null,
|
||||||
filter: null,
|
rowsPerPage: null,
|
||||||
field: null,
|
filter: null,
|
||||||
order: null,
|
field: null,
|
||||||
});
|
order: null,
|
||||||
// Reduce to a lookup object for 0(1) lookup
|
});
|
||||||
if (res?.data?.data?.monitors?.length > 0) {
|
// Reduce to a lookup object for 0(1) lookup
|
||||||
const monitorLookup = res.data.data.monitors.reduce((acc, monitor) => {
|
if (res?.data?.data?.monitors?.length > 0) {
|
||||||
acc[monitor._id] = monitor;
|
const monitorLookup = res.data.data.monitors.reduce((acc, monitor) => {
|
||||||
return acc;
|
acc[monitor._id] = monitor;
|
||||||
}, {});
|
return acc;
|
||||||
setMonitors(monitorLookup);
|
}, {});
|
||||||
monitorId !== undefined && setSelectedMonitor(monitorId);
|
setMonitors(monitorLookup);
|
||||||
}
|
monitorId !== undefined && setSelectedMonitor(monitorId);
|
||||||
setLoading(false);
|
}
|
||||||
};
|
} catch (error) {
|
||||||
|
console.info(error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fetchMonitors();
|
||||||
|
}, [authState]);
|
||||||
|
|
||||||
fetchMonitors();
|
useEffect(() => {}, [monitors]);
|
||||||
}, [authState]);
|
|
||||||
|
|
||||||
useEffect(() => {}, []);
|
const handleSelect = (event) => {
|
||||||
|
setSelectedMonitor(event.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
const handleSelect = (event) => {
|
const isActuallyLoading = isLoading && Object.keys(monitors)?.length === 0;
|
||||||
setSelectedMonitor(event.target.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className="incidents" pt={theme.spacing(6)} gap={theme.spacing(12)}>
|
<Stack
|
||||||
{loading ? (
|
className="incidents"
|
||||||
<SkeletonLayout />
|
pt={theme.spacing(6)}
|
||||||
) : (
|
gap={theme.spacing(12)}
|
||||||
<>
|
>
|
||||||
<Stack direction="row" alignItems="center" gap={theme.spacing(6)}>
|
{isActuallyLoading ? (
|
||||||
<Typography
|
<SkeletonLayout />
|
||||||
display="inline-block"
|
) : (
|
||||||
component="h1"
|
<>
|
||||||
color={theme.palette.text.secondary}
|
<Stack
|
||||||
>
|
direction="row"
|
||||||
Incidents for
|
alignItems="center"
|
||||||
</Typography>
|
gap={theme.spacing(6)}
|
||||||
<Select
|
>
|
||||||
id="incidents-select-monitor"
|
<Typography
|
||||||
placeholder="All servers"
|
display="inline-block"
|
||||||
value={selectedMonitor}
|
component="h1"
|
||||||
onChange={handleSelect}
|
color={theme.palette.text.secondary}
|
||||||
items={Object.values(monitors)}
|
>
|
||||||
sx={{
|
Incidents for
|
||||||
backgroundColor: theme.palette.background.main,
|
</Typography>
|
||||||
}}
|
<Select
|
||||||
/>
|
id="incidents-select-monitor"
|
||||||
<ButtonGroup
|
placeholder="All servers"
|
||||||
sx={{
|
value={selectedMonitor}
|
||||||
ml: "auto",
|
onChange={handleSelect}
|
||||||
"& .MuiButtonBase-root, & .MuiButtonBase-root:hover": {
|
items={Object.values(monitors)}
|
||||||
borderColor: theme.palette.border.light,
|
sx={{
|
||||||
},
|
backgroundColor: theme.palette.background.main,
|
||||||
}}
|
}}
|
||||||
>
|
/>
|
||||||
<Button
|
<ButtonGroup
|
||||||
variant="group"
|
sx={{
|
||||||
filled={(filter === "all").toString()}
|
ml: "auto",
|
||||||
onClick={() => setFilter("all")}
|
"& .MuiButtonBase-root, & .MuiButtonBase-root:hover": {
|
||||||
>
|
borderColor: theme.palette.border.light,
|
||||||
All
|
},
|
||||||
</Button>
|
}}
|
||||||
<Button
|
>
|
||||||
variant="group"
|
<Button
|
||||||
filled={(filter === "down").toString()}
|
variant="group"
|
||||||
onClick={() => setFilter("down")}
|
filled={(filter === "all").toString()}
|
||||||
>
|
onClick={() => setFilter("all")}
|
||||||
Down
|
>
|
||||||
</Button>
|
All
|
||||||
<Button
|
</Button>
|
||||||
variant="group"
|
<Button
|
||||||
filled={(filter === "resolve").toString()}
|
variant="group"
|
||||||
onClick={() => setFilter("resolve")}
|
filled={(filter === "down").toString()}
|
||||||
>
|
onClick={() => setFilter("down")}
|
||||||
Cannot Resolve
|
>
|
||||||
</Button>
|
Down
|
||||||
</ButtonGroup>
|
</Button>
|
||||||
</Stack>
|
<Button
|
||||||
<IncidentTable
|
variant="group"
|
||||||
monitors={monitors}
|
filled={(filter === "resolve").toString()}
|
||||||
selectedMonitor={selectedMonitor}
|
onClick={() => setFilter("resolve")}
|
||||||
filter={filter}
|
>
|
||||||
/>
|
Cannot Resolve
|
||||||
</>
|
</Button>
|
||||||
)}
|
</ButtonGroup>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
<IncidentTable
|
||||||
|
monitors={monitors}
|
||||||
|
selectedMonitor={selectedMonitor}
|
||||||
|
filter={filter}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Incidents;
|
export default Incidents;
|
||||||
@@ -10,103 +10,105 @@ import Breadcrumbs from "../../Components/Breadcrumbs";
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
const Maintenance = ({ isAdmin }) => {
|
const Maintenance = ({ isAdmin }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
const { authToken } = useSelector((state) => state.auth);
|
||||||
const { rowsPerPage } = useSelector((state) => state.ui.maintenance);
|
const { rowsPerPage } = useSelector((state) => state.ui.maintenance);
|
||||||
|
|
||||||
const [maintenanceWindows, setMaintenanceWindows] = useState([]);
|
const [maintenanceWindows, setMaintenanceWindows] = useState([]);
|
||||||
const [maintenanceWindowCount, setMaintenanceWindowCount] = useState(0);
|
const [maintenanceWindowCount, setMaintenanceWindowCount] = useState(0);
|
||||||
const [page, setPage] = useState(0);
|
const [page, setPage] = useState(0);
|
||||||
const [sort, setSort] = useState({});
|
const [sort, setSort] = useState({});
|
||||||
const [updateTrigger, setUpdateTrigger] = useState(false);
|
const [updateTrigger, setUpdateTrigger] = useState(false);
|
||||||
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
const handleActionMenuDelete = () => {
|
const handleActionMenuDelete = () => {
|
||||||
setUpdateTrigger((prev) => !prev);
|
setUpdateTrigger((prev) => !prev);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchMaintenanceWindows = async () => {
|
const fetchMaintenanceWindows = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await networkService.getMaintenanceWindowsByTeamId({
|
setIsLoading(true);
|
||||||
authToken: authToken,
|
const response = await networkService.getMaintenanceWindowsByTeamId({
|
||||||
page: page,
|
authToken: authToken,
|
||||||
rowsPerPage: rowsPerPage,
|
page: page,
|
||||||
});
|
rowsPerPage: rowsPerPage,
|
||||||
const { maintenanceWindows, maintenanceWindowCount } =
|
});
|
||||||
response.data.data;
|
const { maintenanceWindows, maintenanceWindowCount } = response.data.data;
|
||||||
setMaintenanceWindows(maintenanceWindows);
|
setMaintenanceWindows(maintenanceWindows);
|
||||||
setMaintenanceWindowCount(maintenanceWindowCount);
|
setMaintenanceWindowCount(maintenanceWindowCount);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
} finally {
|
||||||
};
|
setIsLoading(false);
|
||||||
fetchMaintenanceWindows();
|
}
|
||||||
}, [authToken, page, rowsPerPage, updateTrigger]);
|
};
|
||||||
|
fetchMaintenanceWindows();
|
||||||
|
}, [authToken, page, rowsPerPage, updateTrigger]);
|
||||||
|
|
||||||
return (
|
const isActuallyLoading = isLoading && maintenanceWindows?.length === 0;
|
||||||
<Box
|
return (
|
||||||
className="maintenance"
|
<Box
|
||||||
sx={{
|
className="maintenance"
|
||||||
':has(> [class*="fallback__"])': {
|
sx={{
|
||||||
position: "relative",
|
':has(> [class*="fallback__"])': {
|
||||||
border: 1,
|
position: "relative",
|
||||||
borderColor: theme.palette.border.light,
|
border: 1,
|
||||||
borderRadius: theme.shape.borderRadius,
|
borderColor: theme.palette.border.light,
|
||||||
borderStyle: "dashed",
|
borderRadius: theme.shape.borderRadius,
|
||||||
backgroundColor: theme.palette.background.main,
|
borderStyle: "dashed",
|
||||||
overflow: "hidden",
|
backgroundColor: theme.palette.background.main,
|
||||||
},
|
overflow: "hidden",
|
||||||
}}
|
},
|
||||||
>
|
}}
|
||||||
{maintenanceWindows.length > 0 && (
|
>
|
||||||
<Stack gap={theme.spacing(8)}>
|
{maintenanceWindows.length > 0 && (
|
||||||
<Stack
|
<Stack gap={theme.spacing(8)}>
|
||||||
direction="row"
|
<Stack
|
||||||
justifyContent="space-between"
|
direction="row"
|
||||||
alignItems="center"
|
justifyContent="space-between"
|
||||||
mt={theme.spacing(5)}
|
alignItems="center"
|
||||||
>
|
mt={theme.spacing(5)}
|
||||||
<Breadcrumbs
|
>
|
||||||
list={[{ name: "maintenance", path: "/maintenance" }]}
|
<Breadcrumbs list={[{ name: "maintenance", path: "/maintenance" }]} />
|
||||||
/>
|
<Button
|
||||||
<Button
|
variant="contained"
|
||||||
variant="contained"
|
color="primary"
|
||||||
color="primary"
|
onClick={() => {
|
||||||
onClick={() => {
|
navigate("/maintenance/create");
|
||||||
navigate("/maintenance/create");
|
}}
|
||||||
}}
|
sx={{ fontWeight: 500 }}
|
||||||
sx={{ fontWeight: 500 }}
|
>
|
||||||
>
|
Create maintenance window
|
||||||
Create maintenance window
|
</Button>
|
||||||
</Button>
|
</Stack>
|
||||||
</Stack>
|
<MaintenanceTable
|
||||||
<MaintenanceTable
|
page={page}
|
||||||
page={page}
|
setPage={setPage}
|
||||||
setPage={setPage}
|
rowsPerPage={rowsPerPage}
|
||||||
rowsPerPage={rowsPerPage}
|
sort={sort}
|
||||||
sort={sort}
|
setSort={setSort}
|
||||||
setSort={setSort}
|
maintenanceWindows={maintenanceWindows}
|
||||||
maintenanceWindows={maintenanceWindows}
|
maintenanceWindowCount={maintenanceWindowCount}
|
||||||
maintenanceWindowCount={maintenanceWindowCount}
|
updateCallback={handleActionMenuDelete}
|
||||||
updateCallback={handleActionMenuDelete}
|
/>
|
||||||
/>
|
</Stack>
|
||||||
</Stack>
|
)}
|
||||||
)}
|
{maintenanceWindows.length === 0 && (
|
||||||
{maintenanceWindows.length === 0 && (
|
<Fallback
|
||||||
<Fallback
|
title="maintenance window"
|
||||||
title="maintenance window"
|
checks={[
|
||||||
checks={[
|
"Mark your maintenance periods",
|
||||||
"Mark your maintenance periods",
|
"Eliminate any misunderstandings",
|
||||||
"Eliminate any misunderstandings",
|
"Stop sending alerts in maintenance windows",
|
||||||
"Stop sending alerts in maintenance windows",
|
]}
|
||||||
]}
|
link="/maintenance/create"
|
||||||
link="/maintenance/create"
|
isAdmin={true}
|
||||||
isAdmin={true}
|
/>
|
||||||
/>
|
)}
|
||||||
)}
|
</Box>
|
||||||
</Box>
|
);
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Maintenance;
|
export default Maintenance;
|
||||||
Reference in new issue
Block a user