From 7336287a9cd1ccd4805ad4549eda14bdd9842ba8 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 13 Aug 2024 12:36:19 -0700 Subject: [PATCH 1/7] implement 60 min history chart --- .../Charts/MonitorDetails60MinChart/index.jsx | 62 +++++++++++++++++++ Client/src/Pages/Monitors/Details/index.jsx | 10 ++- Server/db/mongo/modules/monitorModule.js | 12 +++- 3 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 Client/src/Components/Charts/MonitorDetails60MinChart/index.jsx diff --git a/Client/src/Components/Charts/MonitorDetails60MinChart/index.jsx b/Client/src/Components/Charts/MonitorDetails60MinChart/index.jsx new file mode 100644 index 000000000..2c181eaec --- /dev/null +++ b/Client/src/Components/Charts/MonitorDetails60MinChart/index.jsx @@ -0,0 +1,62 @@ +import { + BarChart, + Bar, + XAxis, + YAxis, + Cell, + ResponsiveContainer, + ReferenceLine, + Label, +} from "recharts"; + +import PropTypes from "prop-types"; + +const MonitorDetails60MinChart = ({ data }) => { + const labelStyle = { + fontSize: "8px", + fill: "black", + }; + return ( + + + + + + {data.map((check, index) => ( + + ))} + + + + + + + + + + ); +}; + +MonitorDetails60MinChart.propTypes = { + data: PropTypes.array.isRequired, +}; + +export default MonitorDetails60MinChart; diff --git a/Client/src/Pages/Monitors/Details/index.jsx b/Client/src/Pages/Monitors/Details/index.jsx index 5f3ddf9fc..a8b75e6cc 100644 --- a/Client/src/Pages/Monitors/Details/index.jsx +++ b/Client/src/Pages/Monitors/Details/index.jsx @@ -17,6 +17,7 @@ import { formatDurationRounded, } from "../../../Utils/timeUtils"; import "./index.css"; +import MonitorDetails60MinChart from "../../../Components/Charts/MonitorDetails60MinChart"; const StatBox = ({ title, value }) => { return ( @@ -178,10 +179,13 @@ const DetailsPage = () => { {monitor?.status ? : } + + {monitor.url?.replace(/^https?:\/\//, "") || "..."} + + + + - - {monitor.url?.replace(/^https?:\/\//, "") || "..."} - { * @returns {Array} Array of booleans representing up/down. */ const getStatusBarValues = (checks) => { - return checks.map((check) => { - return check.status; - }); + return checks + .map((check) => { + return { + status: check.status, + responseTime: check.responseTime, + value: 75, + }; + }) + .reverse(); }; /** * Get stats by monitor ID From 801f962af94c737cca9c7a5b2714e30a90146c95 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 13 Aug 2024 15:33:07 -0700 Subject: [PATCH 2/7] Add empty checks if there are less than 60 mins worth of cehcks --- Server/db/mongo/modules/monitorModule.js | 28 ++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Server/db/mongo/modules/monitorModule.js b/Server/db/mongo/modules/monitorModule.js index 44a1d6132..689521acd 100644 --- a/Server/db/mongo/modules/monitorModule.js +++ b/Server/db/mongo/modules/monitorModule.js @@ -126,16 +126,22 @@ const getIncidents = (checks) => { * @param {Array} checks Array of check objects. * @returns {Array} Array of booleans representing up/down. */ -const getStatusBarValues = (checks) => { - return checks - .map((check) => { - return { - status: check.status, - responseTime: check.responseTime, - value: 75, - }; - }) - .reverse(); +const getStatusBarValues = (monitor, checks) => { + const checksIn60Mins = Math.floor((60 * 60 * 1000) / monitor.interval); + const noBlankChecks = checksIn60Mins - checks.length; + + const statusBarValues = checks.map((check) => { + return { + status: check.status, + responseTime: check.responseTime, + value: 75, + }; + }); + + for (let i = 0; i < noBlankChecks; i++) { + statusBarValues.push({ status: false, responseTime: 0, value: 0 }); + } + return statusBarValues.reverse(); }; /** * Get stats by monitor ID @@ -211,7 +217,7 @@ const getMonitorStatsById = async (req) => { getAverageResponseTime24Hours(checks24Hours); monitorStats.uptime24Hours = getUptimePercentage(checks24Hours); monitorStats.uptime30Days = getUptimePercentage(checks30Days); - monitorStats.statusBar = getStatusBarValues(checks60Mins); + monitorStats.statusBar = getStatusBarValues(monitor, checks60Mins); } //Get checks for dateRange From ac5385746a5d67ebacfb61f404d3442210869bd0 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 13 Aug 2024 15:54:23 -0700 Subject: [PATCH 3/7] Justified URL, added placeholders --- .../Charts/MonitorDetails60MinChart/index.jsx | 17 ++++++++--------- Client/src/Pages/Monitors/Details/index.jsx | 7 ++++++- Client/src/index.css | 1 + Server/db/mongo/modules/monitorModule.js | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Client/src/Components/Charts/MonitorDetails60MinChart/index.jsx b/Client/src/Components/Charts/MonitorDetails60MinChart/index.jsx index 2c181eaec..719f711b7 100644 --- a/Client/src/Components/Charts/MonitorDetails60MinChart/index.jsx +++ b/Client/src/Components/Charts/MonitorDetails60MinChart/index.jsx @@ -16,8 +16,14 @@ const MonitorDetails60MinChart = ({ data }) => { fontSize: "8px", fill: "black", }; + + const color = { + true: "var(--env-var-color-23)", + false: "var(--env-var-color-24)", + undefined: "var(--env-var-color-33)", + }; return ( - + { {data.map((check, index) => ( - + ))} diff --git a/Client/src/Pages/Monitors/Details/index.jsx b/Client/src/Pages/Monitors/Details/index.jsx index a8b75e6cc..5a670a4fd 100644 --- a/Client/src/Pages/Monitors/Details/index.jsx +++ b/Client/src/Pages/Monitors/Details/index.jsx @@ -177,7 +177,12 @@ const DetailsPage = () => { }} /> - + {monitor?.status ? : } {monitor.url?.replace(/^https?:\/\//, "") || "..."} diff --git a/Client/src/index.css b/Client/src/index.css index 9e404d61c..58e26ed71 100644 --- a/Client/src/index.css +++ b/Client/src/index.css @@ -58,6 +58,7 @@ --env-var-color-30: #fcfcfd; --env-var-color-31: #1a1919; --env-var-color-32: #f5f5f5; + --env-var-color-33: rgba(83, 83, 83, 0.1); --env-var-radius-1: 4px; --env-var-radius-2: 8px; diff --git a/Server/db/mongo/modules/monitorModule.js b/Server/db/mongo/modules/monitorModule.js index 689521acd..65b20d471 100644 --- a/Server/db/mongo/modules/monitorModule.js +++ b/Server/db/mongo/modules/monitorModule.js @@ -139,7 +139,7 @@ const getStatusBarValues = (monitor, checks) => { }); for (let i = 0; i < noBlankChecks; i++) { - statusBarValues.push({ status: false, responseTime: 0, value: 0 }); + statusBarValues.push({ status: undefined, responseTime: 0, value: 75 }); } return statusBarValues.reverse(); }; From b72fbc459901978e97c9bf22344a8c035d5d9305 Mon Sep 17 00:00:00 2001 From: Daniel Cojocea Date: Wed, 14 Aug 2024 14:54:43 -0400 Subject: [PATCH 4/7] Implement styling to match Figma designs --- Client/src/Components/BasicTable/index.css | 2 +- .../Charts/MonitorDetails60MinChart/index.jsx | 63 ++++++++----------- Client/src/Pages/Monitors/Details/index.css | 2 +- Client/src/Pages/Monitors/Details/index.jsx | 48 +++++++------- 4 files changed, 54 insertions(+), 61 deletions(-) diff --git a/Client/src/Components/BasicTable/index.css b/Client/src/Components/BasicTable/index.css index fd1f75b53..14adc440c 100644 --- a/Client/src/Components/BasicTable/index.css +++ b/Client/src/Components/BasicTable/index.css @@ -72,7 +72,7 @@ } .MuiPaper-root + .MuiPagination-root { - margin-top: 35px; + margin-top: 24px; 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); diff --git a/Client/src/Components/Charts/MonitorDetails60MinChart/index.jsx b/Client/src/Components/Charts/MonitorDetails60MinChart/index.jsx index 719f711b7..ac7d1ee3b 100644 --- a/Client/src/Components/Charts/MonitorDetails60MinChart/index.jsx +++ b/Client/src/Components/Charts/MonitorDetails60MinChart/index.jsx @@ -1,13 +1,4 @@ -import { - BarChart, - Bar, - XAxis, - YAxis, - Cell, - ResponsiveContainer, - ReferenceLine, - Label, -} from "recharts"; +import { BarChart, Bar, Cell, ReferenceLine, Label } from "recharts"; import PropTypes from "prop-types"; @@ -23,34 +14,32 @@ const MonitorDetails60MinChart = ({ data }) => { undefined: "var(--env-var-color-33)", }; return ( - - + + {data.map((check, index) => ( + + ))} + + + + - - - - {data.map((check, index) => ( - - ))} - - - - - - - - - + + + + ); }; diff --git a/Client/src/Pages/Monitors/Details/index.css b/Client/src/Pages/Monitors/Details/index.css index 359a002bc..e2bd28d77 100644 --- a/Client/src/Pages/Monitors/Details/index.css +++ b/Client/src/Pages/Monitors/Details/index.css @@ -35,7 +35,7 @@ } .monitor-details .stat-box { - flex: 1; + flex: 1 20%; min-width: 100px; border: solid 1px; border-radius: var(--env-var-radius-1); diff --git a/Client/src/Pages/Monitors/Details/index.jsx b/Client/src/Pages/Monitors/Details/index.jsx index 5a670a4fd..3a20273b9 100644 --- a/Client/src/Pages/Monitors/Details/index.jsx +++ b/Client/src/Pages/Monitors/Details/index.jsx @@ -163,12 +163,12 @@ const DetailsPage = () => { <>