Added monitor range displayed

This commit is contained in:
Daniel Cojocea committed 2024-08-19 19:07:07 -04:00
1 parent e22f7276d4
commit e15152a618
1 file changed
+46 -33
+46 -33
View File
@@ -10,6 +10,8 @@ import {
TableBody, TableBody,
TablePagination, TablePagination,
Box, Box,
Typography,
Stack,
} from "@mui/material"; } from "@mui/material";
import LeftArrowDouble from "../../assets/icons/left-arrow-double.svg?react"; import LeftArrowDouble from "../../assets/icons/left-arrow-double.svg?react";
import RightArrowDouble from "../../assets/icons/right-arrow-double.svg?react"; import RightArrowDouble from "../../assets/icons/right-arrow-double.svg?react";
@@ -158,6 +160,12 @@ const BasicTable = ({ data, paginated, reversed, rows = 5 }) => {
return <div>No data</div>; return <div>No data</div>;
} }
const getRange = () => {
let start = page * rowsPerPage + 1;
let end = Math.min(page * rowsPerPage + rowsPerPage, data.rows.length);
return `${start} - ${end}`;
};
return ( return (
<> <>
<TableContainer component={Paper}> <TableContainer component={Paper}>
@@ -188,41 +196,46 @@ const BasicTable = ({ data, paginated, reversed, rows = 5 }) => {
</TableBody> </TableBody>
</Table> </Table>
</TableContainer> </TableContainer>
<TablePagination <Stack direction="row" alignItems="center" justifyContent="space-between">
component="div" <Typography sx={{ opacity: 0.7 }}>
count={data.rows.length} Showing {getRange()} of {data.rows.length} monitor(s)
page={page} </Typography>
onPageChange={handleChangePage} <TablePagination
rowsPerPage={rowsPerPage} component="div"
rowsPerPageOptions={[5, 10, 15, 25]} count={data.rows.length}
onRowsPerPageChange={handleChangeRowsPerPage} page={page}
ActionsComponent={TablePaginationActions} onPageChange={handleChangePage}
labelRowsPerPage="Rows per page" rowsPerPage={rowsPerPage}
labelDisplayedRows={({ page, count }) => rowsPerPageOptions={[5, 10, 15, 25]}
`Page ${page + 1} of ${Math.max(0, Math.ceil(count / rowsPerPage))}` onRowsPerPageChange={handleChangeRowsPerPage}
} ActionsComponent={TablePaginationActions}
slotProps={{ labelRowsPerPage="Rows per page"
select: { labelDisplayedRows={({ page, count }) =>
MenuProps: { `Page ${page + 1} of ${Math.max(0, Math.ceil(count / rowsPerPage))}`
PaperProps: { }
className: "pagination-dropdown", slotProps={{
select: {
MenuProps: {
PaperProps: {
className: "pagination-dropdown",
},
transformOrigin: { vertical: "bottom", horizontal: "left" },
anchorOrigin: { vertical: "top", horizontal: "left" },
sx: { mt: "-4px" },
},
inputProps: { id: "pagination-dropdown" },
IconComponent: SelectorVertical,
sx: {
ml: "8px",
mr: "25px",
minWidth: "50px",
textAlign: "left",
"&.Mui-focused > div": { backgroundColor: "white" },
}, },
transformOrigin: { vertical: "bottom", horizontal: "left" },
anchorOrigin: { vertical: "top", horizontal: "left" },
sx: { mt: "-4px" },
}, },
inputProps: { id: "pagination-dropdown" }, }}
IconComponent: SelectorVertical, />
sx: { </Stack>
ml: "8px",
mr: "25px",
minWidth: "50px",
textAlign: "left",
"&.Mui-focused > div": { backgroundColor: "white" },
},
},
}}
/>
</> </>
); );
}; };