Fixed pagination styling
This commit is contained in:
1 parent
7e30be9085
commit
6d5cc931d0
2 files changed
+70
-52
No files matched your search
@@ -80,7 +80,7 @@ export const updatePageSpeed = createAsyncThunk(
|
|||||||
// notifications: monitor.notifications,
|
// notifications: monitor.notifications,
|
||||||
};
|
};
|
||||||
const res = await axiosInstance.put(
|
const res = await axiosInstance.put(
|
||||||
`/monitors/edit/${monitor._id}`,
|
`/monitors/${monitor._id}`,
|
||||||
updatedFields,
|
updatedFields,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -8,12 +8,17 @@ import {
|
|||||||
TableBody,
|
TableBody,
|
||||||
TableFooter,
|
TableFooter,
|
||||||
TablePagination,
|
TablePagination,
|
||||||
|
PaginationItem,
|
||||||
|
Pagination,
|
||||||
|
Paper,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import axiosInstance from "../../../../Utils/axiosConfig";
|
import axiosInstance from "../../../../Utils/axiosConfig";
|
||||||
import { StatusLabel } from "../../../../Components/Label";
|
import { StatusLabel } from "../../../../Components/Label";
|
||||||
|
import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded";
|
||||||
|
import ArrowForwardRoundedIcon from "@mui/icons-material/ArrowForwardRounded";
|
||||||
|
|
||||||
const PaginationTable = ({ monitorId, filter }) => {
|
const PaginationTable = ({ monitorId, filter }) => {
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
const { authToken } = useSelector((state) => state.auth);
|
||||||
@@ -53,63 +58,76 @@ const PaginationTable = ({ monitorId, filter }) => {
|
|||||||
const handlePageChange = (_, newPage) => {
|
const handlePageChange = (_, newPage) => {
|
||||||
setPaginationController({
|
setPaginationController({
|
||||||
...paginationController,
|
...paginationController,
|
||||||
page: newPage,
|
page: newPage - 1,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChangeRowsPerPage = (event) => {
|
let paginationComponent = <></>;
|
||||||
setPaginationController({
|
if (checksCount > paginationController.rowsPerPage) {
|
||||||
...paginationController,
|
paginationComponent = (
|
||||||
rowsPerPage: parseInt(event.target.value, 10),
|
<Pagination
|
||||||
page: 0,
|
count={Math.ceil(checksCount / paginationController.rowsPerPage)}
|
||||||
});
|
page={paginationController.page + 1}
|
||||||
};
|
onChange={handlePageChange}
|
||||||
|
shape="rounded"
|
||||||
|
renderItem={(item) => (
|
||||||
|
<PaginationItem
|
||||||
|
slots={{
|
||||||
|
previous: ArrowBackRoundedIcon,
|
||||||
|
next: ArrowForwardRoundedIcon,
|
||||||
|
}}
|
||||||
|
{...item}
|
||||||
|
sx={{
|
||||||
|
"&:focus": {
|
||||||
|
outline: "none",
|
||||||
|
},
|
||||||
|
"& .MuiTouchRipple-root": {
|
||||||
|
pointerEvents: "none",
|
||||||
|
display: "none",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableContainer>
|
<>
|
||||||
<Table>
|
<TableContainer component={Paper}>
|
||||||
<TableHead>
|
<Table>
|
||||||
<TableRow>
|
<TableHead>
|
||||||
<TableCell>Status</TableCell>
|
<TableRow>
|
||||||
<TableCell>Date & Time</TableCell>
|
<TableCell>Status</TableCell>
|
||||||
<TableCell>Message</TableCell>
|
<TableCell>Date & Time</TableCell>
|
||||||
</TableRow>
|
<TableCell>Message</TableCell>
|
||||||
</TableHead>
|
</TableRow>
|
||||||
<TableBody>
|
</TableHead>
|
||||||
{checks.map((check) => {
|
<TableBody>
|
||||||
const status = check.status === true ? "up" : "down";
|
{checks.map((check) => {
|
||||||
|
const status = check.status === true ? "up" : "down";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow key={check._id}>
|
<TableRow key={check._id}>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<StatusLabel
|
<StatusLabel
|
||||||
status={status}
|
status={status}
|
||||||
text={status}
|
text={status}
|
||||||
customStyles={{ textTransform: "capitalize" }}
|
customStyles={{ textTransform: "capitalize" }}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{new Date(check.createdAt).toLocaleString()}
|
{new Date(check.createdAt).toLocaleString()}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>{check.statusCode}</TableCell>
|
<TableCell>{check.statusCode}</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
<TableFooter>
|
</Table>
|
||||||
<TableRow>
|
</TableContainer>
|
||||||
<TablePagination
|
{paginationComponent}
|
||||||
rowsPerPageOptions={[5, 10, 25]}
|
</>
|
||||||
onPageChange={handlePageChange}
|
|
||||||
page={paginationController.page}
|
|
||||||
count={checksCount}
|
|
||||||
rowsPerPage={paginationController.rowsPerPage}
|
|
||||||
onRowsPerPageChange={handleChangeRowsPerPage}
|
|
||||||
/>
|
|
||||||
</TableRow>
|
|
||||||
</TableFooter>
|
|
||||||
</Table>
|
|
||||||
</TableContainer>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user