remove teamId from uptime monitor requests

This commit is contained in:
Alex Holliday committed 2025-06-13 10:38:52 +08:00
1 parent 134e547736
commit d9c2f31f4e
5 files changed
+16 -66

No files matched your search

+2 -9
View File
@@ -6,7 +6,7 @@ import { useMonitorUtils } from "./useMonitorUtils";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
const useFetchMonitorsWithSummary = ({ teamId, types, monitorUpdateTrigger }) => { const useFetchMonitorsWithSummary = ({ types, monitorUpdateTrigger }) => {
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const [monitors, setMonitors] = useState(undefined); const [monitors, setMonitors] = useState(undefined);
const [monitorsSummary, setMonitorsSummary] = useState(undefined); const [monitorsSummary, setMonitorsSummary] = useState(undefined);
@@ -17,7 +17,6 @@ const useFetchMonitorsWithSummary = ({ teamId, types, monitorUpdateTrigger }) =>
try { try {
setIsLoading(true); setIsLoading(true);
const res = await networkService.getMonitorsWithSummaryByTeamId({ const res = await networkService.getMonitorsWithSummaryByTeamId({
teamId,
types, types,
}); });
const { monitors, summary } = res?.data?.data ?? {}; const { monitors, summary } = res?.data?.data ?? {};
@@ -34,12 +33,11 @@ const useFetchMonitorsWithSummary = ({ teamId, types, monitorUpdateTrigger }) =>
} }
}; };
fetchMonitors(); fetchMonitors();
}, [teamId, types, monitorUpdateTrigger]); }, [types, monitorUpdateTrigger]);
return [monitors, monitorsSummary, isLoading, networkError]; return [monitors, monitorsSummary, isLoading, networkError];
}; };
const useFetchMonitorsWithChecks = ({ const useFetchMonitorsWithChecks = ({
teamId,
types, types,
limit, limit,
page, page,
@@ -61,7 +59,6 @@ const useFetchMonitorsWithChecks = ({
try { try {
setIsLoading(true); setIsLoading(true);
const res = await networkService.getMonitorsWithChecksByTeamId({ const res = await networkService.getMonitorsWithChecksByTeamId({
teamId,
limit, limit,
types, types,
page, page,
@@ -95,7 +92,6 @@ const useFetchMonitorsWithChecks = ({
order, order,
page, page,
rowsPerPage, rowsPerPage,
teamId,
theme, theme,
types, types,
monitorUpdateTrigger, monitorUpdateTrigger,
@@ -104,7 +100,6 @@ const useFetchMonitorsWithChecks = ({
}; };
const useFetchMonitorsByTeamId = ({ const useFetchMonitorsByTeamId = ({
teamId,
types, types,
limit, limit,
page, page,
@@ -127,7 +122,6 @@ const useFetchMonitorsByTeamId = ({
try { try {
setIsLoading(true); setIsLoading(true);
const res = await networkService.getMonitorsByTeamId({ const res = await networkService.getMonitorsByTeamId({
teamId,
limit, limit,
types, types,
page, page,
@@ -154,7 +148,6 @@ const useFetchMonitorsByTeamId = ({
}; };
fetchMonitors(); fetchMonitors();
}, [ }, [
teamId,
types, types,
limit, limit,
page, page,
@@ -135,7 +135,6 @@ const CreateMaintenance = () => {
setIsLoading(true); setIsLoading(true);
try { try {
const response = await networkService.getMonitorsByTeamId({ const response = await networkService.getMonitorsByTeamId({
teamId: user.teamId,
limit: null, limit: null,
types: ["http", "ping", "pagespeed", "port"], types: ["http", "ping", "pagespeed", "port"],
}); });
@@ -13,7 +13,6 @@ const useMonitorsFetch = () => {
const fetchMonitors = async () => { const fetchMonitors = async () => {
try { try {
const response = await networkService.getMonitorsByTeamId({ const response = await networkService.getMonitorsByTeamId({
teamId: user.teamId,
limit: null, // donot return any checks for the monitors limit: null, // donot return any checks for the monitors
types: ["http", "ping", "port"], // status page is available for uptime, ping, and port monitors types: ["http", "ping", "port"], // status page is available for uptime, ping, and port monitors
}); });
@@ -64,7 +64,6 @@ CreateMonitorButton.propTypes = {
const UptimeMonitors = () => { const UptimeMonitors = () => {
// Redux state // Redux state
const { user } = useSelector((state) => state.auth);
const rowsPerPage = useSelector((state) => state.ui.monitors.rowsPerPage); const rowsPerPage = useSelector((state) => state.ui.monitors.rowsPerPage);
// Local state // Local state
@@ -106,11 +105,8 @@ const UptimeMonitors = () => {
setMonitorUpdateTrigger((prev) => !prev); setMonitorUpdateTrigger((prev) => !prev);
}, []); }, []);
const teamId = user.teamId;
const [monitors, monitorsSummary, monitorsWithSummaryIsLoading, networkError] = const [monitors, monitorsSummary, monitorsWithSummaryIsLoading, networkError] =
useFetchMonitorsWithSummary({ useFetchMonitorsWithSummary({
teamId,
types: TYPES, types: TYPES,
monitorUpdateTrigger, monitorUpdateTrigger,
}); });
@@ -140,7 +136,6 @@ const UptimeMonitors = () => {
monitorsWithChecksIsLoading, monitorsWithChecksIsLoading,
monitorsWithChecksNetworkError, monitorsWithChecksNetworkError,
] = useFetchMonitorsWithChecks({ ] = useFetchMonitorsWithChecks({
teamId,
types: effectiveTypes, types: effectiveTypes,
limit: 25, limit: 25,
page: page, page: page,
+14 -50
View File
@@ -135,36 +135,6 @@ class NetworkService {
}); });
} }
/**
*
* ************************************
* Gets monitors and summary of stats by TeamID
* ************************************
*
* @async
* @param {Object} config - The configuration object.
* @param {string} config.teamId - Team ID
* @param {Array<string>} config.types - Array of monitor types
* @returns {Promise<AxiosResponse>} The response from the axios POST request.
*/
async getMonitorsSummaryByTeamId(config) {
const params = new URLSearchParams();
if (config.types) {
config.types.forEach((type) => {
params.append("type", type);
});
}
return this.axiosInstance.get(
`/monitors/team/summary/${config.teamId}?${params.toString()}`,
{
headers: {
"Content-Type": "application/json",
},
}
);
}
/** /**
* ************************************ * ************************************
* Get all uptime monitors for a Team * Get all uptime monitors for a Team
@@ -184,7 +154,7 @@ class NetworkService {
*/ */
async getMonitorsByTeamId(config) { async getMonitorsByTeamId(config) {
const { teamId, limit, types, page, rowsPerPage, filter, field, order } = config; const { limit, types, page, rowsPerPage, filter, field, order } = config;
const params = new URLSearchParams(); const params = new URLSearchParams();
if (limit) params.append("limit", limit); if (limit) params.append("limit", limit);
@@ -199,7 +169,7 @@ class NetworkService {
if (field) params.append("field", field); if (field) params.append("field", field);
if (order) params.append("order", order); if (order) params.append("order", order);
return this.axiosInstance.get(`/monitors/team/${teamId}?${params.toString()}`, { return this.axiosInstance.get(`/monitors/team?${params.toString()}`, {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
@@ -949,7 +919,7 @@ class NetworkService {
// Fetch monitors with summary by TeamID // Fetch monitors with summary by TeamID
// ************************************ // ************************************
async getMonitorsWithSummaryByTeamId(config) { async getMonitorsWithSummaryByTeamId(config) {
const { teamId, types } = config; const { types } = config;
const params = new URLSearchParams(); const params = new URLSearchParams();
if (types) { if (types) {
@@ -958,21 +928,18 @@ class NetworkService {
}); });
} }
return this.axiosInstance.get( return this.axiosInstance.get(`/monitors/summary/team?${params.toString()}`, {
`/monitors/summary/team/${teamId}?${params.toString()}`, headers: {
{ "Content-Type": "application/json",
headers: { },
"Content-Type": "application/json", });
},
}
);
} }
// ************************************ // ************************************
// Fetch monitors with checks by TeamID // Fetch monitors with checks by TeamID
// ************************************ // ************************************
async getMonitorsWithChecksByTeamId(config) { async getMonitorsWithChecksByTeamId(config) {
const { teamId, limit, types, page, rowsPerPage, filter, field, order } = config; const { limit, types, page, rowsPerPage, filter, field, order } = config;
const params = new URLSearchParams(); const params = new URLSearchParams();
if (limit) params.append("limit", limit); if (limit) params.append("limit", limit);
@@ -987,14 +954,11 @@ class NetworkService {
if (field) params.append("field", field); if (field) params.append("field", field);
if (order) params.append("order", order); if (order) params.append("order", order);
return this.axiosInstance.get( return this.axiosInstance.get(`/monitors/team/with-checks?${params.toString()}`, {
`/monitors/team/${teamId}/with-checks?${params.toString()}`, headers: {
{ "Content-Type": "application/json",
headers: { },
"Content-Type": "application/json", });
},
}
);
} }
// ************************************ // ************************************