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 { useTranslation } from "react-i18next";
const useFetchMonitorsWithSummary = ({ teamId, types, monitorUpdateTrigger }) => {
const useFetchMonitorsWithSummary = ({ types, monitorUpdateTrigger }) => {
const [isLoading, setIsLoading] = useState(false);
const [monitors, setMonitors] = useState(undefined);
const [monitorsSummary, setMonitorsSummary] = useState(undefined);
@@ -17,7 +17,6 @@ const useFetchMonitorsWithSummary = ({ teamId, types, monitorUpdateTrigger }) =>
try {
setIsLoading(true);
const res = await networkService.getMonitorsWithSummaryByTeamId({
teamId,
types,
});
const { monitors, summary } = res?.data?.data ?? {};
@@ -34,12 +33,11 @@ const useFetchMonitorsWithSummary = ({ teamId, types, monitorUpdateTrigger }) =>
}
};
fetchMonitors();
}, [teamId, types, monitorUpdateTrigger]);
}, [types, monitorUpdateTrigger]);
return [monitors, monitorsSummary, isLoading, networkError];
};
const useFetchMonitorsWithChecks = ({
teamId,
types,
limit,
page,
@@ -61,7 +59,6 @@ const useFetchMonitorsWithChecks = ({
try {
setIsLoading(true);
const res = await networkService.getMonitorsWithChecksByTeamId({
teamId,
limit,
types,
page,
@@ -95,7 +92,6 @@ const useFetchMonitorsWithChecks = ({
order,
page,
rowsPerPage,
teamId,
theme,
types,
monitorUpdateTrigger,
@@ -104,7 +100,6 @@ const useFetchMonitorsWithChecks = ({
};
const useFetchMonitorsByTeamId = ({
teamId,
types,
limit,
page,
@@ -127,7 +122,6 @@ const useFetchMonitorsByTeamId = ({
try {
setIsLoading(true);
const res = await networkService.getMonitorsByTeamId({
teamId,
limit,
types,
page,
@@ -154,7 +148,6 @@ const useFetchMonitorsByTeamId = ({
};
fetchMonitors();
}, [
teamId,
types,
limit,
page,
@@ -135,7 +135,6 @@ const CreateMaintenance = () => {
setIsLoading(true);
try {
const response = await networkService.getMonitorsByTeamId({
teamId: user.teamId,
limit: null,
types: ["http", "ping", "pagespeed", "port"],
});
@@ -13,7 +13,6 @@ const useMonitorsFetch = () => {
const fetchMonitors = async () => {
try {
const response = await networkService.getMonitorsByTeamId({
teamId: user.teamId,
limit: null, // donot return any checks for the monitors
types: ["http", "ping", "port"], // status page is available for uptime, ping, and port monitors
});
@@ -64,7 +64,6 @@ CreateMonitorButton.propTypes = {
const UptimeMonitors = () => {
// Redux state
const { user } = useSelector((state) => state.auth);
const rowsPerPage = useSelector((state) => state.ui.monitors.rowsPerPage);
// Local state
@@ -106,11 +105,8 @@ const UptimeMonitors = () => {
setMonitorUpdateTrigger((prev) => !prev);
}, []);
const teamId = user.teamId;
const [monitors, monitorsSummary, monitorsWithSummaryIsLoading, networkError] =
useFetchMonitorsWithSummary({
teamId,
types: TYPES,
monitorUpdateTrigger,
});
@@ -140,7 +136,6 @@ const UptimeMonitors = () => {
monitorsWithChecksIsLoading,
monitorsWithChecksNetworkError,
] = useFetchMonitorsWithChecks({
teamId,
types: effectiveTypes,
limit: 25,
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
@@ -184,7 +154,7 @@ class NetworkService {
*/
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();
if (limit) params.append("limit", limit);
@@ -199,7 +169,7 @@ class NetworkService {
if (field) params.append("field", field);
if (order) params.append("order", order);
return this.axiosInstance.get(`/monitors/team/${teamId}?${params.toString()}`, {
return this.axiosInstance.get(`/monitors/team?${params.toString()}`, {
headers: {
"Content-Type": "application/json",
},
@@ -949,7 +919,7 @@ class NetworkService {
// Fetch monitors with summary by TeamID
// ************************************
async getMonitorsWithSummaryByTeamId(config) {
const { teamId, types } = config;
const { types } = config;
const params = new URLSearchParams();
if (types) {
@@ -958,21 +928,18 @@ class NetworkService {
});
}
return this.axiosInstance.get(
`/monitors/summary/team/${teamId}?${params.toString()}`,
{
headers: {
"Content-Type": "application/json",
},
}
);
return this.axiosInstance.get(`/monitors/summary/team?${params.toString()}`, {
headers: {
"Content-Type": "application/json",
},
});
}
// ************************************
// Fetch monitors with checks by TeamID
// ************************************
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();
if (limit) params.append("limit", limit);
@@ -987,14 +954,11 @@ class NetworkService {
if (field) params.append("field", field);
if (order) params.append("order", order);
return this.axiosInstance.get(
`/monitors/team/${teamId}/with-checks?${params.toString()}`,
{
headers: {
"Content-Type": "application/json",
},
}
);
return this.axiosInstance.get(`/monitors/team/with-checks?${params.toString()}`, {
headers: {
"Content-Type": "application/json",
},
});
}
// ************************************