Remove team and user id

This commit is contained in:
Alex Holliday committed 2025-06-13 12:16:52 +08:00
1 parent c32cde6189
commit 5e23a2b79c
8 files changed
+11 -14

No files matched your search

+2 -2
View File
@@ -414,10 +414,10 @@ const useDeleteAllMonitors = () => {
const UseDeleteMonitorStats = () => { const UseDeleteMonitorStats = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const deleteMonitorStats = async ({ teamId }) => { const deleteMonitorStats = async () => {
setIsLoading(true); setIsLoading(true);
try { try {
const res = await networkService.deleteChecksByTeamId({ teamId }); await networkService.deleteChecksByTeamId();
createToast({ body: t("settingsStatsCleared") }); createToast({ body: t("settingsStatsCleared") });
} catch (error) { } catch (error) {
createToast({ body: t("settingsFailedToClearStats") }); createToast({ body: t("settingsFailedToClearStats") });
@@ -186,8 +186,6 @@ const CreateInfrastructureMonitor = () => {
...(isCreate ? {} : { _id: monitorId }), ...(isCreate ? {} : { _id: monitorId }),
...rest, ...rest,
description: form.name, description: form.name,
teamId: user.teamId,
userId: user._id,
type: "hardware", type: "hardware",
notifications: infrastructureMonitor.notifications, notifications: infrastructureMonitor.notifications,
thresholds, thresholds,
@@ -48,8 +48,6 @@ const CreateNotifications = () => {
// local state // local state
const [notification, setNotification] = useState({ const [notification, setNotification] = useState({
userId: user._id,
teamId: user.teamId,
notificationName: "", notificationName: "",
address: "", address: "",
type: NOTIFICATION_TYPES[0]._id, type: NOTIFICATION_TYPES[0]._id,
@@ -86,8 +86,6 @@ const CreatePageSpeed = () => {
form = { form = {
...form, ...form,
description: form.name, description: form.name,
teamId: user.teamId,
userId: user._id,
notifications: monitor.notifications, notifications: monitor.notifications,
}; };
+1 -1
View File
@@ -96,7 +96,7 @@ const Settings = () => {
} }
if (name === "deleteStats") { if (name === "deleteStats") {
await deleteMonitorStats({ teamId: user.teamId }); await deleteMonitorStats();
return; return;
} }
-2
View File
@@ -142,8 +142,6 @@ const CreateMonitor = () => {
form = { form = {
...form, ...form,
description: monitor.name || monitor.url, description: monitor.name || monitor.url,
teamId: user.teamId,
userId: user._id,
notifications: monitor.notifications, notifications: monitor.notifications,
}; };
+6 -1
View File
@@ -238,7 +238,12 @@ class MonitorController {
} }
try { 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 // Add monitor to job queue
this.jobQueue.addJob(monitor._id, monitor); this.jobQueue.addJob(monitor._id, monitor);
+2 -2
View File
@@ -665,9 +665,9 @@ const getMonitorsWithChecksByTeamId = async ({
* @returns {Promise<Monitor>} * @returns {Promise<Monitor>}
* @throws {Error} * @throws {Error}
*/ */
const createMonitor = async (body) => { const createMonitor = async ({ body, teamId, userId }) => {
try { try {
const monitor = new Monitor({ ...body }); const monitor = new Monitor({ ...body, teamId, userId });
const saved = await monitor.save(); const saved = await monitor.save();
return saved; return saved;
} catch (error) { } catch (error) {