From 09fb5595abe0b19f68aff7031874e1a667e8f68d Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Thu, 26 Sep 2024 10:42:03 +0800 Subject: [PATCH 1/2] Fix proptype errors, remove old alert reference --- Client/src/Pages/Monitors/Home/index.jsx | 2 +- Client/src/Pages/PageSpeed/Details/index.jsx | 2 +- Server/controllers/monitorController.js | 26 +++++++++++--------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Client/src/Pages/Monitors/Home/index.jsx b/Client/src/Pages/Monitors/Home/index.jsx index c2a532bb9..a03959076 100644 --- a/Client/src/Pages/Monitors/Home/index.jsx +++ b/Client/src/Pages/Monitors/Home/index.jsx @@ -134,7 +134,7 @@ const Monitors = ({ isAdmin }) => { { normalize: null, }); setMonitor(res?.data?.data ?? {}); - setAudits(res?.data?.data?.checks?.[0]?.audits ?? []); + setAudits(res?.data?.data?.checks?.[0]?.audits ?? {}); } catch (error) { logger.error(logger); navigate("/not-found", { replace: true }); diff --git a/Server/controllers/monitorController.js b/Server/controllers/monitorController.js index e534e0f60..a8b90c084 100644 --- a/Server/controllers/monitorController.js +++ b/Server/controllers/monitorController.js @@ -20,6 +20,7 @@ const SERVICE_NAME = "monitorController"; const { errorMessages, successMessages } = require("../utils/messages"); const jwt = require("jsonwebtoken"); const { getTokenFromHeaders } = require("../utils/utils"); +const logger = require("../utils/logger"); /** * Returns all monitors @@ -315,18 +316,21 @@ const deleteMonitor = async (req, res, next) => { try { const monitor = await req.db.deleteMonitor(req, res, next); // Delete associated checks,alerts,and notifications - await req.jobQueue.deleteJob(monitor); - await req.db.deleteChecks(monitor._id); - await req.db.deleteAlertByMonitorId(monitor._id); - await req.db.deletePageSpeedChecksByMonitorId(monitor._id); - await req.db.deleteNotificationsByMonitorId(monitor._id); + try { + await req.jobQueue.deleteJob(monitor); + await req.db.deleteChecks(monitor._id); + await req.db.deletePageSpeedChecksByMonitorId(monitor._id); + await req.db.deleteNotificationsByMonitorId(monitor._id); + } catch (error) { + logger.error( + `Error deleting associated records for monitor ${monitor._id} with name ${monitor.name}`, + { + service: SERVICE_NAME, + error: error.message, + } + ); + } - /** - * TODO - * We should remove all checks and alerts associated with this monitor - * when it is deleted so there is no orphaned data - * We also need to make sure to stop all running services for this monitor - */ return res .status(200) .json({ success: true, msg: successMessages.MONITOR_DELETE }); From 38ee162f619d7217452d95b1d2594210b2967836 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Thu, 26 Sep 2024 11:01:38 +0800 Subject: [PATCH 2/2] improve error handling in network service, fix username form errors --- Client/src/Components/Inputs/Field/index.jsx | 11 ++++++++++- .../Components/TabPanels/Account/PasswordPanel.jsx | 10 +++++++++- Server/controllers/monitorController.js | 1 + Server/service/networkService.js | 11 +++++++++-- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Client/src/Components/Inputs/Field/index.jsx b/Client/src/Components/Inputs/Field/index.jsx index e7326ec41..1843a411b 100644 --- a/Client/src/Components/Inputs/Field/index.jsx +++ b/Client/src/Components/Inputs/Field/index.jsx @@ -16,6 +16,7 @@ import "./index.css"; * @param {Object} props * @param {string} [props.type] - Type of input field (e.g., 'text', 'password'). * @param {string} props.id - ID of the input field. + * @param {string} props.name - Name of the input field. * @param {string} [props.label] - Label for the input field. * @param {boolean} [props.https] - Indicates if it should display http or https. * @param {boolean} [props.isRequired] - Indicates if the field is required, will display a red asterisk. @@ -27,6 +28,7 @@ import "./index.css"; * @param {function} props.onChange - Function called on input change. * @param {string} [props.error] - Error message to display for the input field. * @param {boolean} [props.disabled] - Indicates if the input field is disabled. + * @param {boolean} [props.hidden] - Indicates if the input field is hidden. * @param {React.Ref} [ref] - Ref forwarded to the underlying `TextField` component. Allows for direct interactions such as focusing. */ @@ -35,6 +37,7 @@ const Field = forwardRef( { type = "text", id, + name, label, https, isRequired, @@ -47,6 +50,7 @@ const Field = forwardRef( onInput, error, disabled, + hidden, }, ref ) => { @@ -107,6 +111,7 @@ const Field = forwardRef( )}