diff --git a/Client/src/Components/CustomizedTables/index.css b/Client/src/Components/CustomizedTables/index.css new file mode 100644 index 000000000..e69de29bb diff --git a/Client/src/Components/CustomizedTables/index.jsx b/Client/src/Components/CustomizedTables/index.jsx new file mode 100644 index 000000000..2630d5671 --- /dev/null +++ b/Client/src/Components/CustomizedTables/index.jsx @@ -0,0 +1,152 @@ +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 Typography from '@mui/material/Typography'; +import { StatusLabel } from "../../Components/Label/"; +import PropTypes from 'prop-types'; + +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, + }, +})); + +function createData(name, date, message) { + return { name, date, message }; +} + +const CustomizedTables = ({ monitor }) => { + const theme = useTheme(); + + const rows = (monitor && monitor.checks) ? monitor.checks.map(check => createData( + , + new Date(check.createdAt).toLocaleString(), + `HTTP ${check.statusCode} - ${check.status ? 'OK' : 'NOK'}` + )) : []; + + return ( + + + {[...Array(4)].map((_, index) => ( + + + Currently up for + + + 4h 30m 2s + + + ))} + + + + History + + + + + + + Status + Date & Time + Message + + + + {rows.map((row) => ( + + + {row.name} + + {row.date} + {row.message} + + ))} + +
+
+
+ ); +}; + +CustomizedTables.propTypes = { + monitor: PropTypes.shape({ + checks: PropTypes.arrayOf( + PropTypes.shape({ + status: PropTypes.bool.isRequired, + createdAt: PropTypes.string.isRequired, + statusCode: PropTypes.number.isRequired, + }) + ), + }), +}; + +CustomizedTables.defaultProps = { + monitor: { checks: [] }, +}; + +export default CustomizedTables; diff --git a/Client/src/Pages/Details/index.jsx b/Client/src/Pages/Details/index.jsx index 2630d5671..3cf527ac1 100644 --- a/Client/src/Pages/Details/index.jsx +++ b/Client/src/Pages/Details/index.jsx @@ -1,152 +1,50 @@ -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 Typography from '@mui/material/Typography'; -import { StatusLabel } from "../../Components/Label/"; -import PropTypes from 'prop-types'; +import CustomizedTables from '../../Components/CustomizedTables'; -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, - }, -})); - -function createData(name, date, message) { - return { name, date, message }; -} - -const CustomizedTables = ({ monitor }) => { - const theme = useTheme(); - - const rows = (monitor && monitor.checks) ? monitor.checks.map(check => createData( - , - new Date(check.createdAt).toLocaleString(), - `HTTP ${check.statusCode} - ${check.status ? 'OK' : 'NOK'}` - )) : []; +const DetailsPage = () => { + const monitorData = { + "_id": "66863aa2437936b46e225d1f", + "userId": "66863a8f437936b46e225d1a", + "name": "Google", + "description": "Google", + "status": false, + "type": "http", + "url": "https://www.google.com/404", + "isActive": true, + "interval": 60000, + "createdAt": "2024-07-04T06:01:06.527Z", + "updatedAt": "2024-07-04T06:02:00.250Z", + "__v": 0, + "checks": [ + { + "_id": "66863ad8437936b46e225d6d", + "monitorId": "66863aa2437936b46e225d1f", + "status": false, + "responseTime": 144, + "expiry": "2024-07-04T06:02:00.247Z", + "statusCode": 404, + "createdAt": "2024-07-04T06:02:00.248Z", + "updatedAt": "2024-07-04T06:02:00.248Z", + "__v": 0 + }, + { + "_id": "66863b14437936b46e225d79", + "monitorId": "66863aa2437936b46e225d1f", + "status": false, + "responseTime": 140, + "expiry": "2024-07-04T06:03:00.167Z", + "statusCode": 404, + "createdAt": "2024-07-04T06:03:00.168Z", + "updatedAt": "2024-07-04T06:03:00.168Z", + "__v": 0 + } + ] + }; return ( - - - {[...Array(4)].map((_, index) => ( - - - Currently up for - - - 4h 30m 2s - - - ))} - - - - History - - - - - - - Status - Date & Time - Message - - - - {rows.map((row) => ( - - - {row.name} - - {row.date} - {row.message} - - ))} - -
-
-
+
+ +
); }; -CustomizedTables.propTypes = { - monitor: PropTypes.shape({ - checks: PropTypes.arrayOf( - PropTypes.shape({ - status: PropTypes.bool.isRequired, - createdAt: PropTypes.string.isRequired, - statusCode: PropTypes.number.isRequired, - }) - ), - }), -}; - -CustomizedTables.defaultProps = { - monitor: { checks: [] }, -}; - -export default CustomizedTables; +export default DetailsPage;