From f42facdea005089d64e19aabda021e022d83dcde Mon Sep 17 00:00:00 2001 From: Daniel Cojocea Date: Mon, 8 Jul 2024 19:51:21 -0400 Subject: [PATCH] Changed pagination to reflect Figma design --- Client/src/Components/MonitorTable/index.css | 55 ++++++++++-- Client/src/Components/MonitorTable/index.jsx | 92 +++++++++++--------- 2 files changed, 98 insertions(+), 49 deletions(-) diff --git a/Client/src/Components/MonitorTable/index.css b/Client/src/Components/MonitorTable/index.css index f2d24252e..360526fc4 100644 --- a/Client/src/Components/MonitorTable/index.css +++ b/Client/src/Components/MonitorTable/index.css @@ -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; +} diff --git a/Client/src/Components/MonitorTable/index.jsx b/Client/src/Components/MonitorTable/index.jsx index db1d90630..bf24fe8b3 100644 --- a/Client/src/Components/MonitorTable/index.jsx +++ b/Client/src/Components/MonitorTable/index.jsx @@ -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. @@ -93,20 +94,15 @@ const Status = ({ params }) => { * @returns {React.Component} Returns a table with the monitor data. */ const MonitorTable = ({ monitors = [] }) => { - const [page, setPage] = useState(0); - const [rowsPerPage, setRowsPerPage] = useState(5); + const [page, setPage] = useState(1); + 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) + .slice((page - 1) * rowsPerPage, page * rowsPerPage) .map((monitor) => { const params = { url: monitor.url, @@ -144,36 +140,46 @@ const MonitorTable = ({ monitors = [] }) => { }); return ( - - - - - Host - - Status - - - - - Response Time - Actions - - - {mappedRows} - - - - - -
-
+ <> + + + + + Host + + Status + + + + + Response Time + Actions + + + {mappedRows} +
+
+ ( + + )} + /> + ); };