From 10de2caa2eac3cae69ae0d44bd52f0dca7b8b034 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 16 Jul 2024 15:00:30 -0700 Subject: [PATCH] Remove old tables --- Client/src/Components/StatusTable/index.css | 0 Client/src/Components/StatusTable/index.jsx | 114 ---------------- Client/src/Pages/Incidents/index.jsx | 142 +++++++++++++++----- 3 files changed, 110 insertions(+), 146 deletions(-) delete mode 100644 Client/src/Components/StatusTable/index.css delete mode 100644 Client/src/Components/StatusTable/index.jsx diff --git a/Client/src/Components/StatusTable/index.css b/Client/src/Components/StatusTable/index.css deleted file mode 100644 index e69de29bb..000000000 diff --git a/Client/src/Components/StatusTable/index.jsx b/Client/src/Components/StatusTable/index.jsx deleted file mode 100644 index 9546d5742..000000000 --- a/Client/src/Components/StatusTable/index.jsx +++ /dev/null @@ -1,114 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { styled, useTheme } from '@mui/material/styles'; -import Table from '@mui/material/Table'; -import TableBody from '@mui/material/TableBody'; -import TableCell, { tableCellClasses } from '@mui/material/TableCell'; -import TableContainer from '@mui/material/TableContainer'; -import TableHead from '@mui/material/TableHead'; -import TableRow from '@mui/material/TableRow'; -import Paper from '@mui/material/Paper'; -import Box from '@mui/material/Box'; -import Pagination from '../../Components/Pagination'; - -const StyledTableCell = styled(TableCell)(({ theme }) => ({ - [`&.${tableCellClasses.head}`]: { - backgroundColor: theme.palette.action.hover, - color: theme.palette.common.black, - }, - [`&.${tableCellClasses.body}`]: { - fontSize: 14, - }, -})); - -const StyledTableRow = styled(TableRow)(({ theme }) => ({ - '&:nth-of-type(odd)': { - backgroundColor: theme.palette.action.hover, - }, - '&:nth-of-type(even)': { - backgroundColor: theme.palette.common.white, - }, - '&:last-child td, &:last-child th': { - border: 0, - }, -})); - -const itemsPerPage = 5; // Number of items per page - -export default function StatusTable({ data, columns }) { - const theme = useTheme(); - const [currentPage, setCurrentPage] = React.useState(1); - - const onPageChange = (page) => { - setCurrentPage(page); - }; - - // Calculate total pages based on data length and items per page - const totalPages = Math.ceil(data.length / itemsPerPage); - - // Slice data based on current page and items per page - const paginatedData = data.slice((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage); - - return ( - - - - - - {columns.map((column, index) => ( - - {column.header} - - ))} - - - - {paginatedData.map((row, rowIndex) => ( - - {columns.map((column, colIndex) => ( - - {column.id === 'name' ? ( -
- {row.name} -
- ) : ( - row[column.id] - )} -
- ))} -
- ))} -
-
-
- {totalPages > 1 && ( - - )} -
- ); -} - -StatusTable.propTypes = { - data: PropTypes.arrayOf(PropTypes.object).isRequired, - columns: PropTypes.arrayOf( - PropTypes.shape({ - id: PropTypes.string.isRequired, - header: PropTypes.node.isRequired, - align: PropTypes.oneOf(['left', 'right', 'center']), - }) - ).isRequired, -}; diff --git a/Client/src/Pages/Incidents/index.jsx b/Client/src/Pages/Incidents/index.jsx index 4bb75a53d..da9851d11 100644 --- a/Client/src/Pages/Incidents/index.jsx +++ b/Client/src/Pages/Incidents/index.jsx @@ -1,22 +1,21 @@ -import * as React from 'react'; -import TextField from '@mui/material/TextField'; -import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete'; -import { useTheme } from '@mui/material/styles'; -import Box from '@mui/material/Box'; -import Typography from '@mui/material/Typography'; -import TuneIcon from '@mui/icons-material/Tune'; -import StatusTable from '../../Components/StatusTable'; +import * as React from "react"; +import TextField from "@mui/material/TextField"; +import Autocomplete, { createFilterOptions } from "@mui/material/Autocomplete"; +import { useTheme } from "@mui/material/styles"; +import Box from "@mui/material/Box"; +import Typography from "@mui/material/Typography"; +import TuneIcon from "@mui/icons-material/Tune"; import { StatusLabel } from "../../Components/Label/"; const filterOptions = createFilterOptions({ - matchFrom: 'start', + matchFrom: "start", stringify: (option) => option.title, }); const titles = [ - { title: 'Down' }, - { title: 'Cannot resolve' }, - { title: 'Clear / show all' }, + { title: "Down" }, + { title: "Cannot resolve" }, + { title: "Clear / show all" }, ]; /** @@ -32,11 +31,11 @@ function Filter() { filterOptions={filterOptions} sx={{ width: 170, - '& .MuiAutocomplete-inputRoot': { - height: '50px', + "& .MuiAutocomplete-inputRoot": { + height: "50px", }, - '& .MuiAutocomplete-listbox': { - maxHeight: '200px', + "& .MuiAutocomplete-listbox": { + maxHeight: "200px", }, }} disableClearable @@ -46,7 +45,9 @@ function Filter() { size="small" label={ - + Filter by status } @@ -58,17 +59,82 @@ function Filter() { } const sampleData = [ - { name: , date: '2024-03-14 21:41:09', message: 'HTTP 350 - NOK' }, - { name: , date: '2024-03-14 21:41:09', message: 'timeout of 48000ms exceeded' }, - { name: , date: '2024-03-14 21:41:09', message: 'timeout of 48000ms exceeded' }, - { name: , date: '2024-03-14 21:41:09', message: 'timeout of 48000ms exceeded' }, - { name: , date: '2024-03-14 21:41:09', message: 'HTTP 350 - NOK' }, + { + name: ( + + ), + date: "2024-03-14 21:41:09", + message: "HTTP 350 - NOK", + }, + { + name: ( + + ), + date: "2024-03-14 21:41:09", + message: "timeout of 48000ms exceeded", + }, + { + name: ( + + ), + date: "2024-03-14 21:41:09", + message: "timeout of 48000ms exceeded", + }, + { + name: ( + + ), + date: "2024-03-14 21:41:09", + message: "timeout of 48000ms exceeded", + }, + { + name: ( + + ), + date: "2024-03-14 21:41:09", + message: "HTTP 350 - NOK", + }, ]; const columns = [ - { id: 'name', header: 'Status' }, - { id: 'date', header: 'Date & Time' }, - { id: 'message', header: 'Message' }, + { id: "name", header: "Status" }, + { id: "date", header: "Date & Time" }, + { id: "message", header: "Message" }, ]; /** @@ -82,21 +148,33 @@ export default function CustomizedTables() { - - + + Incident History - + {/* TODO Replace with BasicTable */} + {/* */} ); }