Added animations back, added pagination
This commit is contained in:
1 parent
6a7a919789
commit
0555157200
2 files changed
+64
-36
No files matched your search
@@ -54,7 +54,7 @@ const ResponseTimeChart = ({ checks = [] }) => {
|
|||||||
<div className="chart-container">
|
<div className="chart-container">
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<BarChart width={150} height={40} data={normalizedChecks}>
|
<BarChart width={150} height={40} data={normalizedChecks}>
|
||||||
<Bar maxBarSize={10} dataKey="responseTime" isAnimationActive={false}>
|
<Bar maxBarSize={10} dataKey="responseTime">
|
||||||
{normalizedChecks.map((check, index) => (
|
{normalizedChecks.map((check, index) => (
|
||||||
<Cell
|
<Cell
|
||||||
key={`cell-${index}`}
|
key={`cell-${index}`}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
import { useState } from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { DataGrid } from "@mui/x-data-grid";
|
|
||||||
import OpenIt from "../../assets/Images/Icon-open-in-tab-gray.png";
|
import OpenIt from "../../assets/Images/Icon-open-in-tab-gray.png";
|
||||||
import ResponseTimeChart from "../Charts/ResponseTimeChart";
|
import ResponseTimeChart from "../Charts/ResponseTimeChart";
|
||||||
import {
|
import {
|
||||||
@@ -10,6 +10,8 @@ import {
|
|||||||
TableContainer,
|
TableContainer,
|
||||||
TableHead,
|
TableHead,
|
||||||
TableRow,
|
TableRow,
|
||||||
|
TableFooter,
|
||||||
|
TablePagination,
|
||||||
Paper,
|
Paper,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
|
||||||
@@ -84,41 +86,55 @@ const Status = ({ params }) => {
|
|||||||
* @returns {React.Component} Returns a table with the monitor data.
|
* @returns {React.Component} Returns a table with the monitor data.
|
||||||
*/
|
*/
|
||||||
const MonitorTable = ({ monitors = [] }) => {
|
const MonitorTable = ({ monitors = [] }) => {
|
||||||
const mappedRows = monitors.map((monitor) => {
|
const [page, setPage] = useState(0);
|
||||||
const params = {
|
const [rowsPerPage, setRowsPerPage] = useState(5);
|
||||||
url: monitor.url,
|
|
||||||
title: monitor.name,
|
|
||||||
precentage: 100,
|
|
||||||
percentageColor:
|
|
||||||
monitor.status === true
|
|
||||||
? "var(--env-var-color-17)"
|
|
||||||
: "var(--env-var-color-19)",
|
|
||||||
status: monitor.status === true ? "up" : "down",
|
|
||||||
backgroundColor:
|
|
||||||
monitor.status === true
|
|
||||||
? "var(--env-var-color-20)"
|
|
||||||
: "var(--env-var-color-21)",
|
|
||||||
statusDotColor:
|
|
||||||
monitor.status === true
|
|
||||||
? "var(--env-var-color-17)"
|
|
||||||
: "var(--env-var-color-19)",
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
const handleChangePage = (event, newPage) => {
|
||||||
<TableRow key={monitor._id}>
|
setPage(newPage);
|
||||||
<TableCell>
|
};
|
||||||
<Host params={params} />
|
|
||||||
</TableCell>
|
const handleChangeRowsPerPage = (event) => {
|
||||||
<TableCell>
|
setRowsPerPage(parseInt(event.target.value, 10));
|
||||||
<Status params={params} />
|
setPage(0);
|
||||||
</TableCell>
|
};
|
||||||
<TableCell>
|
|
||||||
<ResponseTimeChart checks={monitor.checks} />
|
const mappedRows = monitors
|
||||||
</TableCell>
|
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
||||||
<TableCell>TODO Add Actions</TableCell>
|
.map((monitor) => {
|
||||||
</TableRow>
|
const params = {
|
||||||
);
|
url: monitor.url,
|
||||||
});
|
title: monitor.name,
|
||||||
|
precentage: 100,
|
||||||
|
percentageColor:
|
||||||
|
monitor.status === true
|
||||||
|
? "var(--env-var-color-17)"
|
||||||
|
: "var(--env-var-color-19)",
|
||||||
|
status: monitor.status === true ? "up" : "down",
|
||||||
|
backgroundColor:
|
||||||
|
monitor.status === true
|
||||||
|
? "var(--env-var-color-20)"
|
||||||
|
: "var(--env-var-color-21)",
|
||||||
|
statusDotColor:
|
||||||
|
monitor.status === true
|
||||||
|
? "var(--env-var-color-17)"
|
||||||
|
: "var(--env-var-color-19)",
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TableRow key={monitor._id}>
|
||||||
|
<TableCell>
|
||||||
|
<Host params={params} />
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Status params={params} />
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<ResponseTimeChart checks={monitor.checks} />
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>TODO Add Actions</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableContainer component={Paper}>
|
<TableContainer component={Paper}>
|
||||||
@@ -132,6 +148,18 @@ const MonitorTable = ({ monitors = [] }) => {
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>{mappedRows}</TableBody>
|
<TableBody>{mappedRows}</TableBody>
|
||||||
|
<TableFooter>
|
||||||
|
<TableRow>
|
||||||
|
<TablePagination
|
||||||
|
rowsPerPageOptions={[5, 10, 25]}
|
||||||
|
count={monitors.length}
|
||||||
|
rowsPerPage={rowsPerPage}
|
||||||
|
page={page}
|
||||||
|
onPageChange={handleChangePage}
|
||||||
|
onRowsPerPageChange={handleChangeRowsPerPage}
|
||||||
|
/>
|
||||||
|
</TableRow>
|
||||||
|
</TableFooter>
|
||||||
</Table>
|
</Table>
|
||||||
</TableContainer>
|
</TableContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user