From 7336287a9cd1ccd4805ad4549eda14bdd9842ba8 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 13 Aug 2024 12:36:19 -0700 Subject: [PATCH 01/12] 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 02/12] 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 03/12] 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 809e6ee58fe40f9b2247893fa96fdf67db4944f8 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Wed, 14 Aug 2024 10:20:35 -0700 Subject: [PATCH 04/12] Refactored notifications from Check model to NetworkService --- Server/db/mongo/modules/monitorModule.js | 63 +----------------------- Server/index.js | 4 +- Server/models/Check.js | 57 --------------------- Server/service/jobQueue.js | 6 +-- Server/service/networkService.js | 58 +++++++++++++++++++--- 5 files changed, 59 insertions(+), 129 deletions(-) diff --git a/Server/db/mongo/modules/monitorModule.js b/Server/db/mongo/modules/monitorModule.js index 1d53db978..491106a17 100644 --- a/Server/db/mongo/modules/monitorModule.js +++ b/Server/db/mongo/modules/monitorModule.js @@ -263,69 +263,10 @@ const getMonitorStatsById = async (req) => { * @returns {Promise} * @throws {Error} */ -const getMonitorById = async (req, res) => { +const getMonitorById = async (monitorId) => { try { - const { monitorId } = req.params; - let { status, limit, sortOrder, filter, numToDisplay, normalize } = - req.query; - - const filterLookup = { - day: new Date(new Date().setDate(new Date().getDate() - 1)), - week: new Date(new Date().setDate(new Date().getDate() - 7)), - month: new Date(new Date().setMonth(new Date().getMonth() - 1)), - }; - - // This effectively removes limit, returning all checks - if (limit === undefined) limit = 0; - - // Default sort order is newest -> oldest - if (sortOrder === "asc") { - sortOrder = 1; - } else if (sortOrder === "desc") { - sortOrder = -1; - } else sortOrder = -1; - const monitor = await Monitor.findById(monitorId); - - const checksQuery = { monitorId: monitor._id }; - - if (status !== undefined) { - checksQuery.status = status; - } - - // Filter checks by "day", "week", or "month" - if (filter !== undefined) { - checksQuery.createdAt = { $gte: filterLookup[filter] }; - } - - // Determine model type - let model = - monitor.type === "http" || monitor.type === "ping" - ? Check - : PageSpeedCheck; - - let checks = await model - .find(checksQuery) - .sort({ - createdAt: sortOrder, - }) - .limit(limit); - - // If more than numToDisplay checks, pick every nth check - if (numToDisplay !== undefined && checks && checks.length > numToDisplay) { - const n = Math.ceil(checks.length / numToDisplay); - checks = checks.filter( - (_, index) => index % n === 0 || index === checks.length - 1 - ); - } - - // Normalize checks if requested - if (normalize !== undefined) { - checks = NormalizeData(checks, 1, 100); - } - const notifications = await Notification.find({ monitorId: monitor._id }); - const monitorWithChecks = { ...monitor.toObject(), checks, notifications }; - return monitorWithChecks; + return monitor; } catch (error) { throw error; } diff --git a/Server/index.js b/Server/index.js index 1eb5d886b..110057987 100644 --- a/Server/index.js +++ b/Server/index.js @@ -16,6 +16,7 @@ const maintenanceWindowRouter = require("./routes/maintenanceWindowRoute"); const { connectDbAndRunServer } = require("./configs/db"); const queueRouter = require("./routes/queueRoute"); const JobQueue = require("./service/jobQueue"); +const NetworkService = require("./service/networkService"); const EmailService = require("./service/emailService"); const PageSpeedService = require("./service/pageSpeedService"); @@ -114,8 +115,9 @@ const startApp = async () => { // Create services await connectDbAndRunServer(app, db); - const jobQueue = await JobQueue.createJobQueue(db); const emailService = new EmailService(); + const networkService = new NetworkService(db, emailService); + const jobQueue = await JobQueue.createJobQueue(db, networkService); const pageSpeedService = new PageSpeedService(); const cleanup = async () => { diff --git a/Server/models/Check.js b/Server/models/Check.js index a9ac7f288..55bb2d988 100644 --- a/Server/models/Check.js +++ b/Server/models/Check.js @@ -69,61 +69,4 @@ const CheckSchema = mongoose.Schema( } ); -/** - * Pre-save middleware to handle status change notifications. - * - * This middleware checks if the status of the monitor associated - * with the check has changed and sends notifications if necessary. - */ -CheckSchema.pre("save", async function (next) { - try { - const monitor = await mongoose.model("Monitor").findById(this.monitorId); - - if (monitor) { - const notifications = await Notification.find({ - monitorId: this.monitorId, - }); - - // Check if there are any notifications - - // Only send email if monitor status has changed - if (monitor.status !== this.status) { - const emailService = new EmailService(); - - let template = ""; - let status = ""; - if (monitor.status === true && this.status === false) { - template = "serverIsDownTemplate"; - status = "down"; - } - - if (monitor.status === false && this.status === true) { - // Notify users that the monitor is up - template = "serverIsUpTemplate"; - status = "up"; - } - - for (const notification of notifications) { - if (notification.type === "email") { - await emailService.buildAndSendEmail( - template, - { monitorName: monitor.name, monitorUrl: monitor.url }, - notification.address, - `Monitor ${monitor.name} is ${status}` - ); - } - } - - // Update monitor status - monitor.status = this.status; - await monitor.save(); - } - } - } catch (error) { - console.log(error); - } finally { - next(); - } -}); - module.exports = mongoose.model("Check", CheckSchema); diff --git a/Server/service/jobQueue.js b/Server/service/jobQueue.js index 12c151abd..4c7a02192 100644 --- a/Server/service/jobQueue.js +++ b/Server/service/jobQueue.js @@ -16,7 +16,7 @@ class JobQueue { * @constructor * @throws {Error} */ - constructor() { + constructor(networkService) { this.queue = new Queue(QUEUE_NAME, { connection, }); @@ -32,11 +32,11 @@ class JobQueue { * @returns {Promise} - Returns a new JobQueue * */ - static async createJobQueue(db) { + static async createJobQueue(db, networkService) { const queue = new JobQueue(); try { queue.db = db; - queue.networkService = new NetworkService(db); + queue.networkService = networkService; const monitors = await db.getAllMonitors(); for (const monitor of monitors) { await queue.addJob(monitor.id, monitor); diff --git a/Server/service/networkService.js b/Server/service/networkService.js index dc8994945..375380f2e 100644 --- a/Server/service/networkService.js +++ b/Server/service/networkService.js @@ -3,8 +3,9 @@ const ping = require("ping"); const logger = require("../utils/logger"); class NetworkService { - constructor(db) { + constructor(db, emailService) { this.db = db; + this.emailService = emailService; this.TYPE_PING = "ping"; this.TYPE_HTTP = "http"; this.TYPE_PAGESPEED = "pagespeed"; @@ -12,6 +13,33 @@ class NetworkService { this.NETWORK_ERROR = 5000; } + async handleNotification(job, isAlive) { + const { _id } = job.data; + const monitor = await this.db.getMonitorById(_id); + + // If monitor status changes, update monitor status and send notification + if (monitor.status !== isAlive) { + monitor.status = !monitor.status; + await monitor.save(); + + let template = + isAlive === true ? "serverIsUpTemplate" : "serverIsDownTemplate"; + let status = isAlive === true ? "up" : "down"; + + const notifications = await this.db.getNotificationsByMonitorId(_id); + for (const notification of notifications) { + if (notification.type === "email") { + await this.emailService.buildAndSendEmail( + template, + { monitorName: monitor.name, monitorUrl: monitor.url }, + notification.address, + `Monitor ${monitor.name} is ${status}` + ); + } + } + } + } + /** * Measures the response time of an asynchronous operation. * @param {Function} operation - An asynchronous operation to measure. @@ -42,10 +70,12 @@ class NetworkService { return response; }; + let isAlive; + try { const { responseTime, response } = await this.measureResponseTime(operation); - const isAlive = response.alive; + isAlive = response.alive; const checkData = { monitorId: job.data._id, @@ -54,12 +84,15 @@ class NetworkService { }; return await this.logAndStoreCheck(checkData, this.db.createCheck); } catch (error) { + isAlive = false; const checkData = { monitorId: job.data._id, - status: false, + status: isAlive, responseTime: error.responseTime, }; return await this.logAndStoreCheck(checkData, this.db.createCheck); + } finally { + this.handleNotification(job, isAlive); } } @@ -75,13 +108,15 @@ class NetworkService { return response; }; + let isAlive; + // attempt connection try { const { responseTime, response } = await this.measureResponseTime(operation); // check if response is in the 200 range, if so, service is up - const isAlive = response.status >= 200 && response.status < 300; + isAlive = response.status >= 200 && response.status < 300; //Create a check with relevant data const checkData = { @@ -92,9 +127,10 @@ class NetworkService { }; return await this.logAndStoreCheck(checkData, this.db.createCheck); } catch (error) { + isAlive = false; const checkData = { monitorId: job.data._id, - status: false, + status: isAlive, responseTime: error.responseTime, }; // The server returned a response @@ -104,6 +140,8 @@ class NetworkService { checkData.statusCode = this.NETWORK_ERROR; } return await this.logAndStoreCheck(checkData, this.db.createCheck); + } finally { + this.handleNotification(job, isAlive); } } @@ -122,6 +160,8 @@ class NetworkService { * @throws {Error} Throws an error if there is an issue with fetching or processing the PageSpeed insights. */ async handlePagespeed(job) { + let isAlive; + try { const url = job.data.url; const response = await axios.get( @@ -145,9 +185,10 @@ class NetworkService { // Total Blocking Time 30% // Cumulative Layout Shift 25% + isAlive = true; const checkData = { monitorId: job.data._id, - status: true, + status: isAlive, accessibility: (categories.accessibility?.score || 0) * 100, bestPractices: (categories["best-practices"]?.score || 0) * 100, seo: (categories.seo?.score || 0) * 100, @@ -163,15 +204,18 @@ class NetworkService { this.logAndStoreCheck(checkData, this.db.createPageSpeedCheck); } catch (error) { + isAlive = false; const checkData = { monitorId: job.data._id, - status: false, + status: isAlive, accessibility: 0, bestPractices: 0, seo: 0, performance: 0, }; this.logAndStoreCheck(checkData, this.db.createPageSpeedCheck); + } finally { + this.handleNotification(job, isAlive); } } From a5e65ccba263e8f546dba9e74556fe0ab13661b7 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Wed, 14 Aug 2024 10:56:39 -0700 Subject: [PATCH 05/12] Fixed mutation of data --- Client/src/Pages/PageSpeed/Details/index.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/src/Pages/PageSpeed/Details/index.jsx b/Client/src/Pages/PageSpeed/Details/index.jsx index ed8c942af..006f2acf3 100644 --- a/Client/src/Pages/PageSpeed/Details/index.jsx +++ b/Client/src/Pages/PageSpeed/Details/index.jsx @@ -299,7 +299,7 @@ const PageSpeedDetails = () => { const [expand, setExpand] = useState(false); let loading = Object.keys(monitor).length === 0; - + const data = monitor?.checks ? [...monitor.checks].reverse() : []; return ( {loading ? ( @@ -406,7 +406,7 @@ const PageSpeedDetails = () => { Score history - + Performance report From 091f5e64f7b837d367fe1a6947048f1ae8a9a3d3 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Wed, 14 Aug 2024 11:51:27 -0700 Subject: [PATCH 06/12] Bump axios and recharts --- Client/package-lock.json | 24 +++++++++--------------- Client/package.json | 4 ++-- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Client/package-lock.json b/Client/package-lock.json index 2a7b9b7e1..44e276f63 100644 --- a/Client/package-lock.json +++ b/Client/package-lock.json @@ -18,7 +18,7 @@ "@mui/x-data-grid": "7.3.2", "@mui/x-date-pickers": "7.3.2", "@reduxjs/toolkit": "2.2.5", - "axios": "1.7.2", + "axios": "1.7.4", "chart.js": "^4.4.3", "dayjs": "1.11.11", "joi": "17.13.1", @@ -29,7 +29,7 @@ "react-router": "^6.23.0", "react-router-dom": "^6.23.1", "react-toastify": "^10.0.5", - "recharts": "2.12.7", + "recharts": "2.13.0-alpha.4", "redux-persist": "6.0.0", "vite-plugin-svgr": "^4.2.0" }, @@ -2655,9 +2655,9 @@ } }, "node_modules/axios": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", - "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz", + "integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==", "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", @@ -5509,15 +5509,15 @@ } }, "node_modules/recharts": { - "version": "2.12.7", - "resolved": "https://registry.npmjs.org/recharts/-/recharts-2.12.7.tgz", - "integrity": "sha512-hlLJMhPQfv4/3NBSAyq3gzGg4h2v69RJh6KU7b3pXYNNAELs9kEoXOjbkxdXpALqKBoVmVptGfLpxdaVYqjmXQ==", + "version": "2.13.0-alpha.4", + "resolved": "https://registry.npmjs.org/recharts/-/recharts-2.13.0-alpha.4.tgz", + "integrity": "sha512-K9naL6F7pEcDYJE6yFQASSCQecSLPP0JagnvQ9hPtA/aHgsxsnIOjouLP5yrFZehxzfCkV5TEORr7/uNtSr7Qw==", "license": "MIT", "dependencies": { "clsx": "^2.0.0", "eventemitter3": "^4.0.1", "lodash": "^4.17.21", - "react-is": "^16.10.2", + "react-is": "^18.3.1", "react-smooth": "^4.0.0", "recharts-scale": "^0.4.4", "tiny-invariant": "^1.3.1", @@ -5540,12 +5540,6 @@ "decimal.js-light": "^2.4.1" } }, - "node_modules/recharts/node_modules/react-is": { - "version": "16.13.1", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", - "license": "MIT" - }, "node_modules/redux": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz", diff --git a/Client/package.json b/Client/package.json index f711bff9a..769e1f4a6 100644 --- a/Client/package.json +++ b/Client/package.json @@ -20,7 +20,7 @@ "@mui/x-data-grid": "7.3.2", "@mui/x-date-pickers": "7.3.2", "@reduxjs/toolkit": "2.2.5", - "axios": "1.7.2", + "axios": "1.7.4", "chart.js": "^4.4.3", "dayjs": "1.11.11", "joi": "17.13.1", @@ -31,7 +31,7 @@ "react-router": "^6.23.0", "react-router-dom": "^6.23.1", "react-toastify": "^10.0.5", - "recharts": "2.12.7", + "recharts": "2.13.0-alpha.4", "redux-persist": "6.0.0", "vite-plugin-svgr": "^4.2.0" }, From 7e92193ecf245f6d9e856a8a193a50bebfa8b723 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Wed, 14 Aug 2024 11:54:16 -0700 Subject: [PATCH 07/12] Removed erorr squash in Monitor Details chart --- .../Components/Charts/MonitorDetailsAreaChart/index.jsx | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Client/src/Components/Charts/MonitorDetailsAreaChart/index.jsx b/Client/src/Components/Charts/MonitorDetailsAreaChart/index.jsx index 91657f542..c37e467f6 100644 --- a/Client/src/Components/Charts/MonitorDetailsAreaChart/index.jsx +++ b/Client/src/Components/Charts/MonitorDetailsAreaChart/index.jsx @@ -28,15 +28,6 @@ const CustomToolTip = ({ active, payload, label }) => { }; const MonitorDetailsAreaChart = ({ checks }) => { - // SQUASH ERROR, NOT PERMANENT SOLUTION - const error = console.error; - console.error = (...args) => { - if (/defaultProps/.test(args[0])) return; - error(...args); - }; - - // END SQUASH ERROR, NOT PERMANENT SOLUTION - const formatDate = (timestamp) => { const date = new Date(timestamp); return date.toLocaleTimeString("en-US", { From b72fbc459901978e97c9bf22344a8c035d5d9305 Mon Sep 17 00:00:00 2001 From: Daniel Cojocea Date: Wed, 14 Aug 2024 14:54:43 -0400 Subject: [PATCH 08/12] 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 = () => { <>