Merge pull request #296 from bluewave-labs/feat/monitors-pagination

Monitors pagination styling, resolves #295
This commit is contained in:
Alexander Holliday
2024-07-08 22:50:48 -07:00
committed by GitHub
5 changed files with 101 additions and 50 deletions

View File

@@ -55,7 +55,7 @@
border: solid 1px var(--env-var-color-16);
border-radius: var(--env-var-radius-1);
}
.monitors .MuiTableFooter-root .MuiTableCell-root {
.monitors .MuiTableBody-root .MuiTableRow-root:last-child .MuiTableCell-root {
border: none;
}
.monitors .MuiTableHead-root,
@@ -72,21 +72,64 @@
color: var(--env-var-color-2);
}
.monitors .MuiTableHead-root span {
position: relative;
display: inline-block;
height: 14px;
height: 17px;
width: 20px;
overflow: hidden;
margin-bottom: -3px;
margin-bottom: -2px;
margin-left: 2px;
}
.monitors .MuiTableHead-root span svg {
position: absolute;
width: 20px;
height: 20px;
bottom: 0;
}
.monitors .MuiTableBody-root .MuiTableCell-root {
color: var(--env-var-color-5);
padding: 6px var(--env-var-spacing-2);
}
.monitors .MuiPagination-root {
flex: 1;
margin-top: 35px;
border: solid 1px var(--env-var-color-16);
border-radius: var(--env-var-radius-1);
padding: var(--env-var-spacing-1-plus) var(--env-var-spacing-2);
}
.monitors .MuiPagination-root ul {
justify-content: center;
}
.monitors .MuiPagination-root ul li button {
font-size: var(--env-var-font-size-medium);
color: var(--env-var-color-5);
font-weight: 500;
}
.monitors .MuiPagination-root ul li:first-child {
margin-right: auto;
}
.monitors .MuiPagination-root ul li:last-child {
margin-left: auto;
}
.monitors .MuiPagination-root ul li:first-child button,
.monitors .MuiPagination-root ul li:last-child button {
border: solid 1px var(--env-var-color-16);
border-radius: var(--env-var-radius-1);
}
.monitors .MuiPagination-root ul li:first-child button {
padding: 0 var(--env-var-spacing-1) 0 var(--env-var-spacing-1-plus);
}
.monitors .MuiPagination-root ul li:last-child button {
padding: 0 var(--env-var-spacing-1-plus) 0 var(--env-var-spacing-1);
}
.monitors .MuiPagination-root ul li:first-child button::after,
.monitors .MuiPagination-root ul li:last-child button::before {
position: relative;
display: inline-block;
}
.monitors .MuiPagination-root ul li:first-child button::after {
content: "Previous";
margin-left: 15px;
}
.monitors .MuiPagination-root ul li:last-child button::before {
content: "Next";
margin-right: 15px;
}

View File

@@ -1,7 +1,6 @@
import "./index.css";
import { useState } from "react";
import PropTypes from "prop-types";
import OpenIt from "../../assets/Images/Icon-open-in-tab-gray.png";
import ResponseTimeChart from "../Charts/ResponseTimeChart";
import {
Table,
@@ -10,12 +9,14 @@ import {
TableContainer,
TableHead,
TableRow,
TableFooter,
TablePagination,
Paper,
Pagination,
PaginationItem,
} from "@mui/material";
import SouthRoundedIcon from "@mui/icons-material/SouthRounded";
import OpenInNewPage from "../../assets/icons/open-in-new-page.svg?react"
import ArrowDownwardRoundedIcon from "@mui/icons-material/ArrowDownwardRounded";
import OpenInNewPage from "../../assets/icons/open-in-new-page.svg?react";
import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded";
import ArrowForwardRoundedIcon from "@mui/icons-material/ArrowForwardRounded";
/**
* Host component.
@@ -94,17 +95,12 @@ const Status = ({ params }) => {
*/
const MonitorTable = ({ monitors = [] }) => {
const [page, setPage] = useState(0);
const [rowsPerPage, setRowsPerPage] = useState(5);
const rowsPerPage = 5;
const handleChangePage = (event, newPage) => {
setPage(newPage);
};
const handleChangeRowsPerPage = (event) => {
setRowsPerPage(parseInt(event.target.value, 10));
setPage(0);
};
const mappedRows = monitors
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
.map((monitor) => {
@@ -144,36 +140,46 @@ const MonitorTable = ({ monitors = [] }) => {
});
return (
<TableContainer component={Paper}>
<Table>
<TableHead>
<TableRow>
<TableCell>Host</TableCell>
<TableCell>
Status
<span>
<SouthRoundedIcon />
</span>
</TableCell>
<TableCell>Response Time</TableCell>
<TableCell>Actions</TableCell>
</TableRow>
</TableHead>
<TableBody>{mappedRows}</TableBody>
<TableFooter>
<TableRow>
<TablePagination
rowsPerPageOptions={[5, 10, 25]}
count={monitors.length}
rowsPerPage={rowsPerPage}
page={page}
onPageChange={handleChangePage}
onRowsPerPageChange={handleChangeRowsPerPage}
/>
</TableRow>
</TableFooter>
</Table>
</TableContainer>
<>
<TableContainer component={Paper}>
<Table>
<TableHead>
<TableRow>
<TableCell>Host</TableCell>
<TableCell>
Status
<span>
<ArrowDownwardRoundedIcon />
</span>
</TableCell>
<TableCell>Response Time</TableCell>
<TableCell>Actions</TableCell>
</TableRow>
</TableHead>
<TableBody>{mappedRows}</TableBody>
</Table>
</TableContainer>
<Pagination
count={Math.ceil(monitors?.length / rowsPerPage)}
page={page + 1}
onChange={(event, value) => handleChangePage(event, value - 1)}
shape="rounded"
renderItem={(item) => (
<PaginationItem
slots={{
previous: ArrowBackRoundedIcon,
next: ArrowForwardRoundedIcon,
}}
{...item}
sx={{
"&:focus": {
outline: "none",
},
}}
/>
)}
/>
</>
);
};

View File

@@ -1,11 +1,11 @@
import "./searchTextField.css";
import React from "react";
import Search from "../../../assets/Images/Icon-search-gray.png";
import SearchSvg from "../../../assets/icons/search.svg?react";
const SearchTextField = () => {
return (
<div className="search-field-holder">
<img className="search-field-icon" src={Search} alt="Search" />
<SearchSvg style={{ marginRight: "5px" }} />
<input className="search-field" type="text" placeholder="Search" />
</div>
);

View File

@@ -67,7 +67,6 @@ const Monitors = () => {
</div>
<div className="monitors-v-gaping" />
<MonitorTable monitors={monitorState.monitors} />
<div className="monitors-v-gaping" />
</div>
</div>
);

View File

@@ -0,0 +1,3 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13 13L10.6667 10.6667M12.3333 6.66667C12.3333 9.79628 9.79628 12.3333 6.66667 12.3333C3.53705 12.3333 1 9.79628 1 6.66667C1 3.53705 3.53705 1 6.66667 1C9.79628 1 12.3333 3.53705 12.3333 6.66667Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 394 B