diff --git a/client/src/Hooks/monitorHooks.js b/client/src/Hooks/monitorHooks.js index 5072b5594..8df0faa3b 100644 --- a/client/src/Hooks/monitorHooks.js +++ b/client/src/Hooks/monitorHooks.js @@ -414,10 +414,10 @@ const useDeleteAllMonitors = () => { const UseDeleteMonitorStats = () => { const { t } = useTranslation(); const [isLoading, setIsLoading] = useState(false); - const deleteMonitorStats = async ({ teamId }) => { + const deleteMonitorStats = async () => { setIsLoading(true); try { - const res = await networkService.deleteChecksByTeamId({ teamId }); + await networkService.deleteChecksByTeamId(); createToast({ body: t("settingsStatsCleared") }); } catch (error) { createToast({ body: t("settingsFailedToClearStats") }); diff --git a/client/src/Pages/Infrastructure/Create/index.jsx b/client/src/Pages/Infrastructure/Create/index.jsx index fa63dd4dc..bcdf09785 100644 --- a/client/src/Pages/Infrastructure/Create/index.jsx +++ b/client/src/Pages/Infrastructure/Create/index.jsx @@ -186,8 +186,6 @@ const CreateInfrastructureMonitor = () => { ...(isCreate ? {} : { _id: monitorId }), ...rest, description: form.name, - teamId: user.teamId, - userId: user._id, type: "hardware", notifications: infrastructureMonitor.notifications, thresholds, diff --git a/client/src/Pages/Notifications/create/index.jsx b/client/src/Pages/Notifications/create/index.jsx index 19335c790..3c17c113c 100644 --- a/client/src/Pages/Notifications/create/index.jsx +++ b/client/src/Pages/Notifications/create/index.jsx @@ -48,8 +48,6 @@ const CreateNotifications = () => { // local state const [notification, setNotification] = useState({ - userId: user._id, - teamId: user.teamId, notificationName: "", address: "", type: NOTIFICATION_TYPES[0]._id, diff --git a/client/src/Pages/PageSpeed/Create/index.jsx b/client/src/Pages/PageSpeed/Create/index.jsx index a138fe0a2..5cc4a1a54 100644 --- a/client/src/Pages/PageSpeed/Create/index.jsx +++ b/client/src/Pages/PageSpeed/Create/index.jsx @@ -86,8 +86,6 @@ const CreatePageSpeed = () => { form = { ...form, description: form.name, - teamId: user.teamId, - userId: user._id, notifications: monitor.notifications, }; diff --git a/client/src/Pages/Settings/index.jsx b/client/src/Pages/Settings/index.jsx index d8bd79551..11e432e17 100644 --- a/client/src/Pages/Settings/index.jsx +++ b/client/src/Pages/Settings/index.jsx @@ -96,7 +96,7 @@ const Settings = () => { } if (name === "deleteStats") { - await deleteMonitorStats({ teamId: user.teamId }); + await deleteMonitorStats(); return; } diff --git a/client/src/Pages/Uptime/Create/index.jsx b/client/src/Pages/Uptime/Create/index.jsx index 184beffe5..c800e295c 100644 --- a/client/src/Pages/Uptime/Create/index.jsx +++ b/client/src/Pages/Uptime/Create/index.jsx @@ -142,8 +142,6 @@ const CreateMonitor = () => { form = { ...form, description: monitor.name || monitor.url, - teamId: user.teamId, - userId: user._id, notifications: monitor.notifications, }; diff --git a/server/controllers/monitorController.js b/server/controllers/monitorController.js index 4262b9818..228eabbb0 100755 --- a/server/controllers/monitorController.js +++ b/server/controllers/monitorController.js @@ -238,7 +238,12 @@ class MonitorController { } try { - const monitor = await this.db.createMonitor(req.body); + const { _id, teamId } = req.user; + const monitor = await this.db.createMonitor({ + body: req.body, + teamId, + userId: _id, + }); // Add monitor to job queue this.jobQueue.addJob(monitor._id, monitor); diff --git a/server/db/mongo/modules/monitorModule.js b/server/db/mongo/modules/monitorModule.js index 700625b73..6c03dcd4c 100755 --- a/server/db/mongo/modules/monitorModule.js +++ b/server/db/mongo/modules/monitorModule.js @@ -665,9 +665,9 @@ const getMonitorsWithChecksByTeamId = async ({ * @returns {Promise} * @throws {Error} */ -const createMonitor = async (body) => { +const createMonitor = async ({ body, teamId, userId }) => { try { - const monitor = new Monitor({ ...body }); + const monitor = new Monitor({ ...body, teamId, userId }); const saved = await monitor.save(); return saved; } catch (error) {