remove authToken reading and passing in UI component and hooks
This commit is contained in:
1 parent
6a1e5532e4
commit
f2ae99768a
41 files changed
+76
-135
No files matched your search
@@ -25,8 +25,6 @@ const ActionsMenu = ({
|
|||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const authState = useSelector((state) => state.auth);
|
|
||||||
const authToken = authState.authToken;
|
|
||||||
const { isLoading } = useSelector((state) => state.uptimeMonitors);
|
const { isLoading } = useSelector((state) => state.uptimeMonitors);
|
||||||
|
|
||||||
const handleRemove = async (event) => {
|
const handleRemove = async (event) => {
|
||||||
@@ -34,7 +32,7 @@ const ActionsMenu = ({
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
let monitor = { _id: actions.id };
|
let monitor = { _id: actions.id };
|
||||||
const action = await dispatch(
|
const action = await dispatch(
|
||||||
deleteUptimeMonitor({ authToken: authState.authToken, monitor })
|
deleteUptimeMonitor({ monitor })
|
||||||
);
|
);
|
||||||
if (action.meta.requestStatus === "fulfilled") {
|
if (action.meta.requestStatus === "fulfilled") {
|
||||||
setIsOpen(false); // close modal
|
setIsOpen(false); // close modal
|
||||||
@@ -49,7 +47,7 @@ const ActionsMenu = ({
|
|||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const action = await dispatch(
|
const action = await dispatch(
|
||||||
pauseUptimeMonitor({ authToken, monitorId: monitor._id })
|
pauseUptimeMonitor({ monitorId: monitor._id })
|
||||||
);
|
);
|
||||||
if (pauseUptimeMonitor.fulfilled.match(action)) {
|
if (pauseUptimeMonitor.fulfilled.match(action)) {
|
||||||
const state = action?.payload?.data.isActive === false ? "paused" : "resumed";
|
const state = action?.payload?.data.isActive === false ? "paused" : "resumed";
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const PasswordPanel = () => {
|
|||||||
const SPACING_GAP = theme.spacing(12);
|
const SPACING_GAP = theme.spacing(12);
|
||||||
|
|
||||||
//redux state
|
//redux state
|
||||||
const { authToken, isLoading } = useSelector((state) => state.auth);
|
const { isLoading } = useSelector((state) => state.auth);
|
||||||
|
|
||||||
const idToName = {
|
const idToName = {
|
||||||
"edit-current-password": "password",
|
"edit-current-password": "password",
|
||||||
@@ -89,7 +89,7 @@ const PasswordPanel = () => {
|
|||||||
});
|
});
|
||||||
setErrors(newErrors);
|
setErrors(newErrors);
|
||||||
} else {
|
} else {
|
||||||
const action = await dispatch(update({ authToken, localData }));
|
const action = await dispatch(update({ localData }));
|
||||||
if (action.payload.success) {
|
if (action.payload.success) {
|
||||||
createToast({
|
createToast({
|
||||||
body: "Your password was changed successfully.",
|
body: "Your password was changed successfully.",
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const ProfilePanel = () => {
|
|||||||
const SPACING_GAP = theme.spacing(12);
|
const SPACING_GAP = theme.spacing(12);
|
||||||
|
|
||||||
//redux state
|
//redux state
|
||||||
const { user, authToken, isLoading } = useSelector((state) => state.auth);
|
const { user, isLoading } = useSelector((state) => state.auth);
|
||||||
|
|
||||||
const idToName = {
|
const idToName = {
|
||||||
"edit-first-name": "firstName",
|
"edit-first-name": "firstName",
|
||||||
@@ -164,7 +164,7 @@ const ProfilePanel = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const action = await dispatch(update({ authToken, localData }));
|
const action = await dispatch(update({ localData }));
|
||||||
if (action.payload.success) {
|
if (action.payload.success) {
|
||||||
createToast({
|
createToast({
|
||||||
body: "Your profile data was changed successfully.",
|
body: "Your profile data was changed successfully.",
|
||||||
@@ -187,7 +187,7 @@ const ProfilePanel = () => {
|
|||||||
|
|
||||||
// Initiates the account deletion process
|
// Initiates the account deletion process
|
||||||
const handleDeleteAccount = async () => {
|
const handleDeleteAccount = async () => {
|
||||||
const action = await dispatch(deleteUser(authToken));
|
const action = await dispatch(deleteUser());
|
||||||
if (action.payload.success) {
|
if (action.payload.success) {
|
||||||
dispatch(clearAuthState());
|
dispatch(clearAuthState());
|
||||||
dispatch(clearUptimeMonitorState());
|
dispatch(clearUptimeMonitorState());
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ const TeamPanel = () => {
|
|||||||
|
|
||||||
const SPACING_GAP = theme.spacing(12);
|
const SPACING_GAP = theme.spacing(12);
|
||||||
|
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
|
||||||
const [toInvite, setToInvite] = useState({
|
const [toInvite, setToInvite] = useState({
|
||||||
email: "",
|
email: "",
|
||||||
role: ["0"],
|
role: ["0"],
|
||||||
@@ -63,9 +62,7 @@ const TeamPanel = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchTeam = async () => {
|
const fetchTeam = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await networkService.getAllUsers({
|
const response = await networkService.getAllUsers();
|
||||||
authToken: authToken,
|
|
||||||
});
|
|
||||||
setMembers(response.data.data);
|
setMembers(response.data.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
createToast({
|
createToast({
|
||||||
@@ -75,7 +72,7 @@ const TeamPanel = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchTeam();
|
fetchTeam();
|
||||||
}, [authToken]);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const ROLE_MAP = {
|
const ROLE_MAP = {
|
||||||
@@ -150,7 +147,6 @@ const TeamPanel = () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await networkService.requestInvitationToken({
|
await networkService.requestInvitationToken({
|
||||||
authToken: authToken,
|
|
||||||
email: toInvite.email,
|
email: toInvite.email,
|
||||||
role: toInvite.role,
|
role: toInvite.role,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,17 +4,15 @@ import { useSelector } from "react-redux";
|
|||||||
import { createToast } from "../../../../Utils/toastUtils";
|
import { createToast } from "../../../../Utils/toastUtils";
|
||||||
|
|
||||||
const useCreateDistributedUptimeMonitor = ({ isCreate, monitorId }) => {
|
const useCreateDistributedUptimeMonitor = ({ isCreate, monitorId }) => {
|
||||||
const { authToken, user } = useSelector((state) => state.auth);
|
|
||||||
|
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [networkError, setNetworkError] = useState(false);
|
const [networkError, setNetworkError] = useState(false);
|
||||||
const createDistributedUptimeMonitor = async ({ form }) => {
|
const createDistributedUptimeMonitor = async ({ form }) => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
if (isCreate) {
|
if (isCreate) {
|
||||||
await networkService.createMonitor({ authToken, monitor: form });
|
await networkService.createMonitor({ monitor: form });
|
||||||
} else {
|
} else {
|
||||||
await networkService.updateMonitor({ authToken, monitor: form, monitorId });
|
await networkService.updateMonitor({ monitor: form, monitorId });
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useEffect, useState } from "react";
|
|||||||
import { networkService } from "../../../../main";
|
import { networkService } from "../../../../main";
|
||||||
import { createToast } from "../../../../Utils/toastUtils";
|
import { createToast } from "../../../../Utils/toastUtils";
|
||||||
|
|
||||||
export const useMonitorFetch = ({ authToken, monitorId, isCreate }) => {
|
export const useMonitorFetch = ({ monitorId, isCreate }) => {
|
||||||
const [networkError, setNetworkError] = useState(false);
|
const [networkError, setNetworkError] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [monitor, setMonitor] = useState(undefined);
|
const [monitor, setMonitor] = useState(undefined);
|
||||||
@@ -12,7 +12,6 @@ export const useMonitorFetch = ({ authToken, monitorId, isCreate }) => {
|
|||||||
try {
|
try {
|
||||||
if (isCreate) return;
|
if (isCreate) return;
|
||||||
const res = await networkService.getUptimeDetailsById({
|
const res = await networkService.getUptimeDetailsById({
|
||||||
authToken: authToken,
|
|
||||||
monitorId: monitorId,
|
monitorId: monitorId,
|
||||||
normalize: true,
|
normalize: true,
|
||||||
});
|
});
|
||||||
@@ -25,7 +24,7 @@ export const useMonitorFetch = ({ authToken, monitorId, isCreate }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchMonitors();
|
fetchMonitors();
|
||||||
}, [authToken, monitorId, isCreate]);
|
}, [monitorId, isCreate]);
|
||||||
return [monitor, isLoading, networkError];
|
return [monitor, isLoading, networkError];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ const CreateDistributedUptime = () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Redux state
|
// Redux state
|
||||||
const { user, authToken } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
|
|
||||||
// Local state
|
// Local state
|
||||||
const [https, setHttps] = useState(true);
|
const [https, setHttps] = useState(true);
|
||||||
@@ -68,7 +68,6 @@ const CreateDistributedUptime = () => {
|
|||||||
useCreateDistributedUptimeMonitor({ isCreate, monitorId });
|
useCreateDistributedUptimeMonitor({ isCreate, monitorId });
|
||||||
|
|
||||||
const [monitor, monitorIsLoading, monitorNetworkError] = useMonitorFetch({
|
const [monitor, monitorIsLoading, monitorNetworkError] = useMonitorFetch({
|
||||||
authToken,
|
|
||||||
monitorId,
|
monitorId,
|
||||||
isCreate,
|
isCreate,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,11 +5,10 @@ import { createToast } from "../../../../Utils/toastUtils";
|
|||||||
|
|
||||||
const useDeleteMonitor = ({ monitorId }) => {
|
const useDeleteMonitor = ({ monitorId }) => {
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
|
||||||
const deleteMonitor = async () => {
|
const deleteMonitor = async () => {
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
await networkService.deleteMonitorById({ authToken, monitorId });
|
await networkService.deleteMonitorById({ monitorId });
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
createToast({
|
createToast({
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ const useSubscribeToDetails = ({ monitorId, isPublic, isPublished, dateRange })
|
|||||||
const [monitor, setMonitor] = useState(undefined);
|
const [monitor, setMonitor] = useState(undefined);
|
||||||
const [lastUpdateTrigger, setLastUpdateTrigger] = useState(0);
|
const [lastUpdateTrigger, setLastUpdateTrigger] = useState(0);
|
||||||
const [devices, setDevices] = useState(Array.from({ length: 5 }, getRandomDevice));
|
const [devices, setDevices] = useState(Array.from({ length: 5 }, getRandomDevice));
|
||||||
const authToken = useSelector((state) => state.auth.token);
|
|
||||||
|
|
||||||
const prevDateRangeRef = useRef(dateRange);
|
const prevDateRangeRef = useRef(dateRange);
|
||||||
|
|
||||||
@@ -68,7 +67,6 @@ const useSubscribeToDetails = ({ monitorId, isPublic, isPublished, dateRange })
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const cleanup = networkService.subscribeToDistributedUptimeDetails({
|
const cleanup = networkService.subscribeToDistributedUptimeDetails({
|
||||||
authToken,
|
|
||||||
monitorId,
|
monitorId,
|
||||||
dateRange: dateRange,
|
dateRange: dateRange,
|
||||||
normalize: true,
|
normalize: true,
|
||||||
@@ -105,7 +103,6 @@ const useSubscribeToDetails = ({ monitorId, isPublic, isPublished, dateRange })
|
|||||||
setNetworkError(true);
|
setNetworkError(true);
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
authToken,
|
|
||||||
dateRange,
|
dateRange,
|
||||||
monitorId,
|
monitorId,
|
||||||
retryCount,
|
retryCount,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { createToast } from "../../../../Utils/toastUtils";
|
|||||||
|
|
||||||
const useSubscribeToMonitors = () => {
|
const useSubscribeToMonitors = () => {
|
||||||
// Redux
|
// Redux
|
||||||
const { authToken, user } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
|
|
||||||
// Local state
|
// Local state
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
@@ -22,7 +22,6 @@ const useSubscribeToMonitors = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
try {
|
try {
|
||||||
const cleanup = networkService.subscribeToDistributedUptimeMonitors({
|
const cleanup = networkService.subscribeToDistributedUptimeMonitors({
|
||||||
authToken: authToken,
|
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
limit: 25,
|
limit: 25,
|
||||||
types: ["distributed_http"],
|
types: ["distributed_http"],
|
||||||
@@ -57,7 +56,7 @@ const useSubscribeToMonitors = () => {
|
|||||||
});
|
});
|
||||||
setNetworkError(true);
|
setNetworkError(true);
|
||||||
}
|
}
|
||||||
}, [authToken, user, getMonitorWithPercentage, theme]);
|
}, [user, getMonitorWithPercentage, theme]);
|
||||||
return [isLoading, networkError, monitors, monitorsSummary, filteredMonitors];
|
return [isLoading, networkError, monitors, monitorsSummary, filteredMonitors];
|
||||||
};
|
};
|
||||||
export { useSubscribeToMonitors };
|
export { useSubscribeToMonitors };
|
||||||
@@ -9,12 +9,10 @@ const useStatusPageFetchByUrl = ({ url }) => {
|
|||||||
const [statusPage, setStatusPage] = useState(undefined);
|
const [statusPage, setStatusPage] = useState(undefined);
|
||||||
const [monitorId, setMonitorId] = useState(undefined);
|
const [monitorId, setMonitorId] = useState(undefined);
|
||||||
const [isPublished, setIsPublished] = useState(false);
|
const [isPublished, setIsPublished] = useState(false);
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchStatusPageByUrl = async () => {
|
const fetchStatusPageByUrl = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await networkService.getStatusPageByUrl({
|
const response = await networkService.getStatusPageByUrl({
|
||||||
authToken,
|
|
||||||
url,
|
url,
|
||||||
type: "distributed",
|
type: "distributed",
|
||||||
});
|
});
|
||||||
@@ -33,7 +31,7 @@ const useStatusPageFetchByUrl = ({ url }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchStatusPageByUrl();
|
fetchStatusPageByUrl();
|
||||||
}, [authToken, url]);
|
}, [url]);
|
||||||
|
|
||||||
return [isLoading, networkError, statusPage, monitorId, isPublished];
|
return [isLoading, networkError, statusPage, monitorId, isPublished];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { createToast } from "../../../Utils/toastUtils";
|
|||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
const useChecksFetch = ({ selectedMonitor, filter, dateRange, page, rowsPerPage }) => {
|
const useChecksFetch = ({ selectedMonitor, filter, dateRange, page, rowsPerPage }) => {
|
||||||
//Redux
|
//Redux
|
||||||
const { authToken, user } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
|
|
||||||
//Local
|
//Local
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
@@ -20,7 +20,6 @@ const useChecksFetch = ({ selectedMonitor, filter, dateRange, page, rowsPerPage
|
|||||||
|
|
||||||
if (selectedMonitor === "0") {
|
if (selectedMonitor === "0") {
|
||||||
res = await networkService.getChecksByTeam({
|
res = await networkService.getChecksByTeam({
|
||||||
authToken: authToken,
|
|
||||||
status: false,
|
status: false,
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
sortOrder: "desc",
|
sortOrder: "desc",
|
||||||
@@ -32,7 +31,6 @@ const useChecksFetch = ({ selectedMonitor, filter, dateRange, page, rowsPerPage
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
res = await networkService.getChecksByMonitor({
|
res = await networkService.getChecksByMonitor({
|
||||||
authToken: authToken,
|
|
||||||
status: false,
|
status: false,
|
||||||
monitorId: selectedMonitor,
|
monitorId: selectedMonitor,
|
||||||
sortOrder: "desc",
|
sortOrder: "desc",
|
||||||
@@ -53,7 +51,7 @@ const useChecksFetch = ({ selectedMonitor, filter, dateRange, page, rowsPerPage
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchChecks();
|
fetchChecks();
|
||||||
}, [authToken, user, dateRange, page, rowsPerPage, filter, selectedMonitor]);
|
}, [user, dateRange, page, rowsPerPage, filter, selectedMonitor]);
|
||||||
return { isLoading, networkError, checks, checksCount };
|
return { isLoading, networkError, checks, checksCount };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { networkService } from "../../../main";
|
import { networkService } from "../../../main";
|
||||||
import { createToast } from "../../../Utils/toastUtils";
|
import { createToast } from "../../../Utils/toastUtils";
|
||||||
const useMonitorsFetch = ({ authToken, teamId }) => {
|
const useMonitorsFetch = ({ teamId }) => {
|
||||||
//Local state
|
//Local state
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [networkError, setNetworkError] = useState(false);
|
const [networkError, setNetworkError] = useState(false);
|
||||||
@@ -13,7 +13,6 @@ const useMonitorsFetch = ({ authToken, teamId }) => {
|
|||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const res = await networkService.getMonitorsByTeamId({
|
const res = await networkService.getMonitorsByTeamId({
|
||||||
authToken,
|
|
||||||
teamId,
|
teamId,
|
||||||
limit: null,
|
limit: null,
|
||||||
types: null,
|
types: null,
|
||||||
@@ -44,7 +43,7 @@ const useMonitorsFetch = ({ authToken, teamId }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchMonitors();
|
fetchMonitors();
|
||||||
}, [authToken, teamId]);
|
}, [teamId]);
|
||||||
return { isLoading, monitors, networkError };
|
return { isLoading, monitors, networkError };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const BREADCRUMBS = [{ name: `Incidents`, path: "/incidents" }];
|
|||||||
|
|
||||||
const Incidents = () => {
|
const Incidents = () => {
|
||||||
// Redux state
|
// Redux state
|
||||||
const { authToken, user } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
|
|
||||||
// Local state
|
// Local state
|
||||||
const [selectedMonitor, setSelectedMonitor] = useState("0");
|
const [selectedMonitor, setSelectedMonitor] = useState("0");
|
||||||
@@ -26,7 +26,6 @@ const Incidents = () => {
|
|||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
const { monitors, isLoading, networkError } = useMonitorsFetch({
|
const { monitors, isLoading, networkError } = useMonitorsFetch({
|
||||||
authToken,
|
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ const getAlertError = (errors) => {
|
|||||||
|
|
||||||
const CreateInfrastructureMonitor = () => {
|
const CreateInfrastructureMonitor = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { user, authToken } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
const monitorState = useSelector((state) => state.infrastructureMonitor);
|
const monitorState = useSelector((state) => state.infrastructureMonitor);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -148,7 +148,7 @@ const CreateInfrastructureMonitor = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const action = await dispatch(
|
const action = await dispatch(
|
||||||
createInfrastructureMonitor({ authToken, monitor: form })
|
createInfrastructureMonitor({ monitor: form })
|
||||||
);
|
);
|
||||||
if (action.meta.requestStatus === "fulfilled") {
|
if (action.meta.requestStatus === "fulfilled") {
|
||||||
createToast({ body: "Infrastructure monitor created successfully!" });
|
createToast({ body: "Infrastructure monitor created successfully!" });
|
||||||
|
|||||||
@@ -7,13 +7,10 @@ const useHardwareMonitorsFetch = ({ monitorId, dateRange }) => {
|
|||||||
const [networkError, setNetworkError] = useState(false);
|
const [networkError, setNetworkError] = useState(false);
|
||||||
const [monitor, setMonitor] = useState(undefined);
|
const [monitor, setMonitor] = useState(undefined);
|
||||||
|
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await networkService.getHardwareDetailsByMonitorId({
|
const response = await networkService.getHardwareDetailsByMonitorId({
|
||||||
authToken: authToken,
|
|
||||||
monitorId: monitorId,
|
monitorId: monitorId,
|
||||||
dateRange: dateRange,
|
dateRange: dateRange,
|
||||||
});
|
});
|
||||||
@@ -26,7 +23,7 @@ const useHardwareMonitorsFetch = ({ monitorId, dateRange }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchData();
|
fetchData();
|
||||||
}, [monitorId, dateRange, authToken]);
|
}, [monitorId, dateRange]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isLoading,
|
isLoading,
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ const InfrastructureMenu = ({ monitor, isAdmin, updateCallback }) => {
|
|||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const authState = useSelector((state) => state.auth);
|
|
||||||
const authToken = authState.authToken;
|
|
||||||
const { isLoading } = useSelector((state) => state.uptimeMonitors);
|
const { isLoading } = useSelector((state) => state.uptimeMonitors);
|
||||||
|
|
||||||
const openMenu = (e) => {
|
const openMenu = (e) => {
|
||||||
@@ -61,7 +59,6 @@ const InfrastructureMenu = ({ monitor, isAdmin, updateCallback }) => {
|
|||||||
const handleRemove = async () => {
|
const handleRemove = async () => {
|
||||||
try {
|
try {
|
||||||
await networkService.deleteMonitorById({
|
await networkService.deleteMonitorById({
|
||||||
authToken,
|
|
||||||
monitorId: monitor.id,
|
monitorId: monitor.id,
|
||||||
});
|
});
|
||||||
createToast({ body: "Monitor deleted successfully." });
|
createToast({ body: "Monitor deleted successfully." });
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { createToast } from "../../../../Utils/toastUtils";
|
|||||||
|
|
||||||
const useMonitorFetch = ({ page, rowsPerPage, updateTrigger }) => {
|
const useMonitorFetch = ({ page, rowsPerPage, updateTrigger }) => {
|
||||||
// Redux state
|
// Redux state
|
||||||
const { authToken, user } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
|
|
||||||
// Local state
|
// Local state
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
@@ -17,7 +17,6 @@ const useMonitorFetch = ({ page, rowsPerPage, updateTrigger }) => {
|
|||||||
const fetchMonitors = async () => {
|
const fetchMonitors = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await networkService.getMonitorsByTeamId({
|
const response = await networkService.getMonitorsByTeamId({
|
||||||
authToken,
|
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
limit: 1,
|
limit: 1,
|
||||||
types: ["hardware"],
|
types: ["hardware"],
|
||||||
@@ -37,7 +36,7 @@ const useMonitorFetch = ({ page, rowsPerPage, updateTrigger }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchMonitors();
|
fetchMonitors();
|
||||||
}, [page, rowsPerPage, authToken, user.teamId, updateTrigger]);
|
}, [page, rowsPerPage, user.teamId, updateTrigger]);
|
||||||
|
|
||||||
return { monitors, summary, isLoading, networkError };
|
return { monitors, summary, isLoading, networkError };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ const CreateMaintenance = () => {
|
|||||||
const { maintenanceWindowId } = useParams();
|
const { maintenanceWindowId } = useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { user, authToken } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
const [monitors, setMonitors] = useState([]);
|
const [monitors, setMonitors] = useState([]);
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
@@ -133,7 +133,6 @@ const CreateMaintenance = () => {
|
|||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const response = await networkService.getMonitorsByTeamId({
|
const response = await networkService.getMonitorsByTeamId({
|
||||||
authToken: authToken,
|
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
limit: null,
|
limit: null,
|
||||||
types: ["http", "ping", "pagespeed"],
|
types: ["http", "ping", "pagespeed"],
|
||||||
@@ -146,7 +145,6 @@ const CreateMaintenance = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const res = await networkService.getMaintenanceWindowById({
|
const res = await networkService.getMaintenanceWindowById({
|
||||||
authToken: authToken,
|
|
||||||
maintenanceWindowId: maintenanceWindowId,
|
maintenanceWindowId: maintenanceWindowId,
|
||||||
});
|
});
|
||||||
const maintenanceWindow = res.data.data;
|
const maintenanceWindow = res.data.data;
|
||||||
@@ -174,7 +172,7 @@ const CreateMaintenance = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchMonitors();
|
fetchMonitors();
|
||||||
}, [authToken, user]);
|
}, [user]);
|
||||||
|
|
||||||
const handleSearch = (value) => {
|
const handleSearch = (value) => {
|
||||||
setSearch(value);
|
setSearch(value);
|
||||||
@@ -239,7 +237,7 @@ const CreateMaintenance = () => {
|
|||||||
submit.expiry = end;
|
submit.expiry = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
const requestConfig = { authToken: authToken, maintenanceWindow: submit };
|
const requestConfig = { maintenanceWindow: submit };
|
||||||
|
|
||||||
if (maintenanceWindowId !== undefined) {
|
if (maintenanceWindowId !== undefined) {
|
||||||
requestConfig.maintenanceWindowId = maintenanceWindowId;
|
requestConfig.maintenanceWindowId = maintenanceWindowId;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import Dialog from "../../../../Components/Dialog";
|
|||||||
|
|
||||||
const ActionsMenu = ({ /* isAdmin, */ maintenanceWindow, updateCallback }) => {
|
const ActionsMenu = ({ /* isAdmin, */ maintenanceWindow, updateCallback }) => {
|
||||||
maintenanceWindow;
|
maintenanceWindow;
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
@@ -26,7 +25,6 @@ const ActionsMenu = ({ /* isAdmin, */ maintenanceWindow, updateCallback }) => {
|
|||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
await networkService.deleteMaintenanceWindow({
|
await networkService.deleteMaintenanceWindow({
|
||||||
authToken,
|
|
||||||
maintenanceWindowId: maintenanceWindow._id,
|
maintenanceWindowId: maintenanceWindow._id,
|
||||||
});
|
});
|
||||||
updateCallback();
|
updateCallback();
|
||||||
@@ -47,7 +45,6 @@ const ActionsMenu = ({ /* isAdmin, */ maintenanceWindow, updateCallback }) => {
|
|||||||
active: !maintenanceWindow.active,
|
active: !maintenanceWindow.active,
|
||||||
};
|
};
|
||||||
await networkService.editMaintenanceWindow({
|
await networkService.editMaintenanceWindow({
|
||||||
authToken,
|
|
||||||
maintenanceWindowId: maintenanceWindow._id,
|
maintenanceWindowId: maintenanceWindow._id,
|
||||||
maintenanceWindow: data,
|
maintenanceWindow: data,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import { useIsAdmin } from "../../Hooks/useIsAdmin";
|
|||||||
const Maintenance = () => {
|
const Maintenance = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
|
||||||
const { rowsPerPage } = useSelector((state) => state.ui.maintenance);
|
const { rowsPerPage } = useSelector((state) => state.ui.maintenance);
|
||||||
const isAdmin = useIsAdmin();
|
const isAdmin = useIsAdmin();
|
||||||
const [maintenanceWindows, setMaintenanceWindows] = useState([]);
|
const [maintenanceWindows, setMaintenanceWindows] = useState([]);
|
||||||
@@ -30,7 +29,6 @@ const Maintenance = () => {
|
|||||||
const fetchMaintenanceWindows = async () => {
|
const fetchMaintenanceWindows = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await networkService.getMaintenanceWindowsByTeamId({
|
const response = await networkService.getMaintenanceWindowsByTeamId({
|
||||||
authToken: authToken,
|
|
||||||
page: page,
|
page: page,
|
||||||
rowsPerPage: rowsPerPage,
|
rowsPerPage: rowsPerPage,
|
||||||
});
|
});
|
||||||
@@ -42,7 +40,7 @@ const Maintenance = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchMaintenanceWindows();
|
fetchMaintenanceWindows();
|
||||||
}, [authToken, page, rowsPerPage, updateTrigger]);
|
}, [page, rowsPerPage, updateTrigger]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const PageSpeedConfigure = () => {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const MS_PER_MINUTE = 60000;
|
const MS_PER_MINUTE = 60000;
|
||||||
const { user, authToken } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
const { isLoading } = useSelector((state) => state.pageSpeedMonitors);
|
const { isLoading } = useSelector((state) => state.pageSpeedMonitors);
|
||||||
const { monitorId } = useParams();
|
const { monitorId } = useParams();
|
||||||
const [monitor, setMonitor] = useState({});
|
const [monitor, setMonitor] = useState({});
|
||||||
@@ -59,7 +59,7 @@ const PageSpeedConfigure = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchMonitor = async () => {
|
const fetchMonitor = async () => {
|
||||||
try {
|
try {
|
||||||
const action = await dispatch(getPagespeedMonitorById({ authToken, monitorId }));
|
const action = await dispatch(getPagespeedMonitorById({ monitorId }));
|
||||||
|
|
||||||
if (getPagespeedMonitorById.fulfilled.match(action)) {
|
if (getPagespeedMonitorById.fulfilled.match(action)) {
|
||||||
const monitor = action.payload.data;
|
const monitor = action.payload.data;
|
||||||
@@ -73,7 +73,7 @@ const PageSpeedConfigure = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchMonitor();
|
fetchMonitor();
|
||||||
}, [dispatch, authToken, monitorId, navigate]);
|
}, [dispatch, monitorId, navigate]);
|
||||||
|
|
||||||
const handleChange = (event, name) => {
|
const handleChange = (event, name) => {
|
||||||
let { value, id } = event.target;
|
let { value, id } = event.target;
|
||||||
@@ -130,7 +130,7 @@ const PageSpeedConfigure = () => {
|
|||||||
|
|
||||||
const handlePause = async () => {
|
const handlePause = async () => {
|
||||||
try {
|
try {
|
||||||
const action = await dispatch(pausePageSpeed({ authToken, monitorId }));
|
const action = await dispatch(pausePageSpeed({ monitorId }));
|
||||||
if (pausePageSpeed.fulfilled.match(action)) {
|
if (pausePageSpeed.fulfilled.match(action)) {
|
||||||
const monitor = action.payload.data;
|
const monitor = action.payload.data;
|
||||||
setMonitor(monitor);
|
setMonitor(monitor);
|
||||||
@@ -147,10 +147,10 @@ const PageSpeedConfigure = () => {
|
|||||||
|
|
||||||
const handleSave = async (event) => {
|
const handleSave = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const action = await dispatch(updatePageSpeed({ authToken, monitor: monitor }));
|
const action = await dispatch(updatePageSpeed({ monitor: monitor }));
|
||||||
if (action.meta.requestStatus === "fulfilled") {
|
if (action.meta.requestStatus === "fulfilled") {
|
||||||
createToast({ body: "Monitor updated successfully!" });
|
createToast({ body: "Monitor updated successfully!" });
|
||||||
dispatch(getPageSpeedByTeamId(authToken));
|
dispatch(getPageSpeedByTeamId());
|
||||||
} else {
|
} else {
|
||||||
createToast({ body: "Failed to update monitor." });
|
createToast({ body: "Failed to update monitor." });
|
||||||
}
|
}
|
||||||
@@ -160,7 +160,7 @@ const PageSpeedConfigure = () => {
|
|||||||
const handleRemove = async (event) => {
|
const handleRemove = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
setButtonLoading(true);
|
setButtonLoading(true);
|
||||||
const action = await dispatch(deletePageSpeed({ authToken, monitor }));
|
const action = await dispatch(deletePageSpeed({ monitor }));
|
||||||
if (action.meta.requestStatus === "fulfilled") {
|
if (action.meta.requestStatus === "fulfilled") {
|
||||||
navigate("/pagespeed");
|
navigate("/pagespeed");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ const CreatePageSpeed = () => {
|
|||||||
|
|
||||||
const [https, setHttps] = useState(true);
|
const [https, setHttps] = useState(true);
|
||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
const { user, authToken } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
const { isLoading } = useSelector((state) => state.pageSpeedMonitors);
|
const { isLoading } = useSelector((state) => state.pageSpeedMonitors);
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
@@ -87,7 +87,7 @@ const CreatePageSpeed = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const checkEndpointAction = await dispatch(
|
const checkEndpointAction = await dispatch(
|
||||||
checkEndpointResolution({ authToken, monitorURL: form.url })
|
checkEndpointResolution({ monitorURL: form.url })
|
||||||
);
|
);
|
||||||
|
|
||||||
if (checkEndpointAction.meta.requestStatus === "rejected") {
|
if (checkEndpointAction.meta.requestStatus === "rejected") {
|
||||||
@@ -106,7 +106,7 @@ const CreatePageSpeed = () => {
|
|||||||
notifications: monitor.notifications,
|
notifications: monitor.notifications,
|
||||||
};
|
};
|
||||||
|
|
||||||
const action = await dispatch(createPageSpeed({ authToken, monitor: form }));
|
const action = await dispatch(createPageSpeed({ monitor: form }));
|
||||||
if (action.meta.requestStatus === "fulfilled") {
|
if (action.meta.requestStatus === "fulfilled") {
|
||||||
createToast({ body: "Monitor created successfully!" });
|
createToast({ body: "Monitor created successfully!" });
|
||||||
navigate("/pagespeed");
|
navigate("/pagespeed");
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useEffect, useState } from "react";
|
|||||||
import { networkService } from "../../../../main";
|
import { networkService } from "../../../../main";
|
||||||
import { createToast } from "../../../../Utils/toastUtils";
|
import { createToast } from "../../../../Utils/toastUtils";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
const useMonitorFetch = ({ authToken, monitorId }) => {
|
const useMonitorFetch = ({ monitorId }) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [monitor, setMonitor] = useState(undefined);
|
const [monitor, setMonitor] = useState(undefined);
|
||||||
@@ -13,7 +13,6 @@ const useMonitorFetch = ({ authToken, monitorId }) => {
|
|||||||
const fetchMonitor = async () => {
|
const fetchMonitor = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await networkService.getStatsByMonitorId({
|
const res = await networkService.getStatsByMonitorId({
|
||||||
authToken: authToken,
|
|
||||||
monitorId: monitorId,
|
monitorId: monitorId,
|
||||||
sortOrder: "desc",
|
sortOrder: "desc",
|
||||||
limit: 50,
|
limit: 50,
|
||||||
@@ -32,7 +31,7 @@ const useMonitorFetch = ({ authToken, monitorId }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchMonitor();
|
fetchMonitor();
|
||||||
}, [authToken, monitorId, navigate]);
|
}, [monitorId, navigate]);
|
||||||
|
|
||||||
return { monitor, audits, isLoading };
|
return { monitor, audits, isLoading };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,10 +25,8 @@ const PageSpeedDetails = () => {
|
|||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isAdmin = useIsAdmin();
|
const isAdmin = useIsAdmin();
|
||||||
const { monitorId } = useParams();
|
const { monitorId } = useParams();
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
|
||||||
|
|
||||||
const { monitor, audits, isLoading, networkError } = useMonitorFetch({
|
const { monitor, audits, isLoading, networkError } = useMonitorFetch({
|
||||||
authToken,
|
|
||||||
monitorId,
|
monitorId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useEffect, useState } from "react";
|
|||||||
import { networkService } from "../../../../main";
|
import { networkService } from "../../../../main";
|
||||||
import { createToast } from "../../../../Utils/toastUtils";
|
import { createToast } from "../../../../Utils/toastUtils";
|
||||||
|
|
||||||
const useMonitorsFetch = ({ authToken, teamId }) => {
|
const useMonitorsFetch = ({ teamId }) => {
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [monitors, setMonitors] = useState([]);
|
const [monitors, setMonitors] = useState([]);
|
||||||
const [summary, setSummary] = useState({});
|
const [summary, setSummary] = useState({});
|
||||||
@@ -13,7 +13,6 @@ const useMonitorsFetch = ({ authToken, teamId }) => {
|
|||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const res = await networkService.getMonitorsByTeamId({
|
const res = await networkService.getMonitorsByTeamId({
|
||||||
authToken: authToken,
|
|
||||||
teamId: teamId,
|
teamId: teamId,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
types: ["pagespeed"],
|
types: ["pagespeed"],
|
||||||
@@ -38,7 +37,7 @@ const useMonitorsFetch = ({ authToken, teamId }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchMonitors();
|
fetchMonitors();
|
||||||
}, [authToken, teamId]);
|
}, [teamId]);
|
||||||
return { isLoading, monitors, summary, networkError };
|
return { isLoading, monitors, summary, networkError };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,9 @@ const BREADCRUMBS = [{ name: `pagespeed`, path: "/pagespeed" }];
|
|||||||
const PageSpeed = () => {
|
const PageSpeed = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isAdmin = useIsAdmin();
|
const isAdmin = useIsAdmin();
|
||||||
const { user, authToken } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
|
|
||||||
const { isLoading, monitors, summary, networkError } = useMonitorsFetch({
|
const { isLoading, monitors, summary, networkError } = useMonitorsFetch({
|
||||||
authToken: authToken,
|
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ const SECONDS_PER_DAY = 86400;
|
|||||||
const Settings = () => {
|
const Settings = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isAdmin = useIsAdmin();
|
const isAdmin = useIsAdmin();
|
||||||
const { user, authToken } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
const { checkTTL } = user;
|
const { checkTTL } = user;
|
||||||
const { isLoading } = useSelector((state) => state.uptimeMonitors);
|
const { isLoading } = useSelector((state) => state.uptimeMonitors);
|
||||||
const { isLoading: authIsLoading } = useSelector((state) => state.auth);
|
const { isLoading: authIsLoading } = useSelector((state) => state.auth);
|
||||||
@@ -115,11 +115,10 @@ const Settings = () => {
|
|||||||
try {
|
try {
|
||||||
setChecksIsLoading(true);
|
setChecksIsLoading(true);
|
||||||
await networkService.updateChecksTTL({
|
await networkService.updateChecksTTL({
|
||||||
authToken: authToken,
|
|
||||||
ttl: form.ttl,
|
ttl: form.ttl,
|
||||||
});
|
});
|
||||||
const updatedUser = { ...user, checkTTL: form.ttl };
|
const updatedUser = { ...user, checkTTL: form.ttl };
|
||||||
const action = await dispatch(update({ authToken, localData: updatedUser }));
|
const action = await dispatch(update({ localData: updatedUser }));
|
||||||
|
|
||||||
if (action.payload.success) {
|
if (action.payload.success) {
|
||||||
createToast({
|
createToast({
|
||||||
@@ -149,7 +148,7 @@ const Settings = () => {
|
|||||||
const handleClearStats = async () => {
|
const handleClearStats = async () => {
|
||||||
try {
|
try {
|
||||||
const action = await dispatch(
|
const action = await dispatch(
|
||||||
deleteMonitorChecksByTeamId({ teamId: user.teamId, authToken })
|
deleteMonitorChecksByTeamId({ teamId: user.teamId })
|
||||||
);
|
);
|
||||||
|
|
||||||
if (deleteMonitorChecksByTeamId.fulfilled.match(action)) {
|
if (deleteMonitorChecksByTeamId.fulfilled.match(action)) {
|
||||||
@@ -167,7 +166,7 @@ const Settings = () => {
|
|||||||
|
|
||||||
const handleInsertDemoMonitors = async () => {
|
const handleInsertDemoMonitors = async () => {
|
||||||
try {
|
try {
|
||||||
const action = await dispatch(addDemoMonitors({ authToken }));
|
const action = await dispatch(addDemoMonitors());
|
||||||
if (addDemoMonitors.fulfilled.match(action)) {
|
if (addDemoMonitors.fulfilled.match(action)) {
|
||||||
createToast({ body: "Successfully added demo monitors" });
|
createToast({ body: "Successfully added demo monitors" });
|
||||||
} else {
|
} else {
|
||||||
@@ -181,7 +180,7 @@ const Settings = () => {
|
|||||||
|
|
||||||
const handleDeleteAllMonitors = async () => {
|
const handleDeleteAllMonitors = async () => {
|
||||||
try {
|
try {
|
||||||
const action = await dispatch(deleteAllMonitors({ authToken }));
|
const action = await dispatch(deleteAllMonitors());
|
||||||
if (deleteAllMonitors.fulfilled.match(action)) {
|
if (deleteAllMonitors.fulfilled.match(action)) {
|
||||||
createToast({ body: "Successfully deleted all monitors" });
|
createToast({ body: "Successfully deleted all monitors" });
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import { useSelector } from "react-redux";
|
|||||||
import { createToast } from "../../../../Utils/toastUtils";
|
import { createToast } from "../../../../Utils/toastUtils";
|
||||||
|
|
||||||
const useCreateStatusPage = (isCreate, url) => {
|
const useCreateStatusPage = (isCreate, url) => {
|
||||||
const { authToken, user } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
|
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [networkError, setNetworkError] = useState(false);
|
const [networkError, setNetworkError] = useState(false);
|
||||||
const createStatusPage = async ({ form }) => {
|
const createStatusPage = async ({ form }) => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
await networkService.createStatusPage({ authToken, user, form, isCreate, url });
|
await networkService.createStatusPage({ user, form, isCreate, url });
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setNetworkError(true);
|
setNetworkError(true);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useSelector } from "react-redux";
|
|||||||
import { createToast } from "../../../../Utils/toastUtils";
|
import { createToast } from "../../../../Utils/toastUtils";
|
||||||
|
|
||||||
const useMonitorsFetch = () => {
|
const useMonitorsFetch = () => {
|
||||||
const { user, authToken } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
|
|
||||||
const [monitors, setMonitors] = useState(undefined);
|
const [monitors, setMonitors] = useState(undefined);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
@@ -13,7 +13,6 @@ const useMonitorsFetch = () => {
|
|||||||
const fetchMonitors = async () => {
|
const fetchMonitors = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await networkService.getMonitorsByTeamId({
|
const response = await networkService.getMonitorsByTeamId({
|
||||||
authToken: authToken,
|
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
limit: null, // donot return any checks for the monitors
|
limit: null, // donot return any checks for the monitors
|
||||||
types: ["http"], // status page is available only for the uptime type
|
types: ["http"], // status page is available only for the uptime type
|
||||||
@@ -27,7 +26,7 @@ const useMonitorsFetch = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchMonitors();
|
fetchMonitors();
|
||||||
}, [authToken, user]);
|
}, [user]);
|
||||||
|
|
||||||
return [monitors, isLoading, networkError];
|
return [monitors, isLoading, networkError];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,11 +5,10 @@ import { createToast } from "../../../../Utils/toastUtils";
|
|||||||
|
|
||||||
const useStatusPageDelete = (fetchStatusPage, url) => {
|
const useStatusPageDelete = (fetchStatusPage, url) => {
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
|
||||||
const deleteStatusPage = async () => {
|
const deleteStatusPage = async () => {
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
await networkService.deleteStatusPage({ authToken, url });
|
await networkService.deleteStatusPage({ url });
|
||||||
fetchStatusPage?.();
|
fetchStatusPage?.();
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -10,13 +10,11 @@ const useStatusPageFetch = (isCreate = false, url) => {
|
|||||||
const [networkError, setNetworkError] = useState(false);
|
const [networkError, setNetworkError] = useState(false);
|
||||||
const [statusPage, setStatusPage] = useState(undefined);
|
const [statusPage, setStatusPage] = useState(undefined);
|
||||||
const [monitors, setMonitors] = useState(undefined);
|
const [monitors, setMonitors] = useState(undefined);
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { getMonitorWithPercentage } = useMonitorUtils();
|
const { getMonitorWithPercentage } = useMonitorUtils();
|
||||||
const fetchStatusPage = useCallback(async () => {
|
const fetchStatusPage = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
const response = await networkService.getStatusPageByUrl({
|
const response = await networkService.getStatusPageByUrl({
|
||||||
authToken,
|
|
||||||
url,
|
url,
|
||||||
type: "uptime",
|
type: "uptime",
|
||||||
});
|
});
|
||||||
@@ -40,7 +38,7 @@ const useStatusPageFetch = (isCreate = false, url) => {
|
|||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
}, [authToken, theme, getMonitorWithPercentage, url]);
|
}, [theme, getMonitorWithPercentage, url]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isCreate === true) {
|
if (isCreate === true) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useSelector } from "react-redux";
|
|||||||
import { createToast } from "../../../../Utils/toastUtils";
|
import { createToast } from "../../../../Utils/toastUtils";
|
||||||
|
|
||||||
const useStatusPagesFetch = () => {
|
const useStatusPagesFetch = () => {
|
||||||
const { authToken, user } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
|
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [networkError, setNetworkError] = useState(false);
|
const [networkError, setNetworkError] = useState(false);
|
||||||
@@ -14,7 +14,6 @@ const useStatusPagesFetch = () => {
|
|||||||
const fetchStatusPages = async () => {
|
const fetchStatusPages = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await networkService.getStatusPagesByTeamId({
|
const res = await networkService.getStatusPagesByTeamId({
|
||||||
authToken,
|
|
||||||
teamId: user.teamId,
|
teamId: user.teamId,
|
||||||
});
|
});
|
||||||
setStatusPages(res?.data?.data);
|
setStatusPages(res?.data?.data);
|
||||||
@@ -28,7 +27,7 @@ const useStatusPagesFetch = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchStatusPages();
|
fetchStatusPages();
|
||||||
}, [authToken, user]);
|
}, [user]);
|
||||||
return [isLoading, networkError, statusPages];
|
return [isLoading, networkError, statusPages];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ const Configure = () => {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { user, authToken } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
const { isLoading } = useSelector((state) => state.uptimeMonitors);
|
const { isLoading } = useSelector((state) => state.uptimeMonitors);
|
||||||
const [monitor, setMonitor] = useState({});
|
const [monitor, setMonitor] = useState({});
|
||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
@@ -76,7 +76,7 @@ const Configure = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchMonitor = async () => {
|
const fetchMonitor = async () => {
|
||||||
try {
|
try {
|
||||||
const action = await dispatch(getUptimeMonitorById({ authToken, monitorId }));
|
const action = await dispatch(getUptimeMonitorById({ monitorId }));
|
||||||
|
|
||||||
if (getUptimeMonitorById.fulfilled.match(action)) {
|
if (getUptimeMonitorById.fulfilled.match(action)) {
|
||||||
const monitor = action.payload.data;
|
const monitor = action.payload.data;
|
||||||
@@ -90,7 +90,7 @@ const Configure = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchMonitor();
|
fetchMonitor();
|
||||||
}, [monitorId, authToken, navigate]);
|
}, [monitorId, navigate]);
|
||||||
|
|
||||||
const handleChange = (event, name) => {
|
const handleChange = (event, name) => {
|
||||||
let { value, id } = event.target;
|
let { value, id } = event.target;
|
||||||
@@ -147,7 +147,7 @@ const Configure = () => {
|
|||||||
|
|
||||||
const handlePause = async () => {
|
const handlePause = async () => {
|
||||||
try {
|
try {
|
||||||
const action = await dispatch(pauseUptimeMonitor({ authToken, monitorId }));
|
const action = await dispatch(pauseUptimeMonitor({ monitorId }));
|
||||||
if (pauseUptimeMonitor.fulfilled.match(action)) {
|
if (pauseUptimeMonitor.fulfilled.match(action)) {
|
||||||
const monitor = action.payload.data;
|
const monitor = action.payload.data;
|
||||||
setMonitor(monitor);
|
setMonitor(monitor);
|
||||||
@@ -164,7 +164,7 @@ const Configure = () => {
|
|||||||
|
|
||||||
const handleSubmit = async (event) => {
|
const handleSubmit = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const action = await dispatch(updateUptimeMonitor({ authToken, monitor: monitor }));
|
const action = await dispatch(updateUptimeMonitor({ monitor: monitor }));
|
||||||
if (action.meta.requestStatus === "fulfilled") {
|
if (action.meta.requestStatus === "fulfilled") {
|
||||||
createToast({ body: "Monitor updated successfully!" });
|
createToast({ body: "Monitor updated successfully!" });
|
||||||
} else {
|
} else {
|
||||||
@@ -175,7 +175,7 @@ const Configure = () => {
|
|||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const handleRemove = async (event) => {
|
const handleRemove = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const action = await dispatch(deleteUptimeMonitor({ authToken, monitor }));
|
const action = await dispatch(deleteUptimeMonitor({ monitor }));
|
||||||
if (action.meta.requestStatus === "fulfilled") {
|
if (action.meta.requestStatus === "fulfilled") {
|
||||||
navigate("/uptime");
|
navigate("/uptime");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ const CreateMonitor = () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const { user, authToken } = useSelector((state) => state.auth);
|
const { user } = useSelector((state) => state.auth);
|
||||||
const { isLoading } = useSelector((state) => state.uptimeMonitors);
|
const { isLoading } = useSelector((state) => state.uptimeMonitors);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -126,7 +126,7 @@ const CreateMonitor = () => {
|
|||||||
|
|
||||||
if (monitor.type === "http") {
|
if (monitor.type === "http") {
|
||||||
// const checkEndpointAction = await dispatch(
|
// const checkEndpointAction = await dispatch(
|
||||||
// checkEndpointResolution({ authToken, monitorURL: form.url })
|
// checkEndpointResolution({ monitorURL: form.url })
|
||||||
// );
|
// );
|
||||||
// if (checkEndpointAction.meta.requestStatus === "rejected") {
|
// if (checkEndpointAction.meta.requestStatus === "rejected") {
|
||||||
// createToast({
|
// createToast({
|
||||||
@@ -144,7 +144,7 @@ const CreateMonitor = () => {
|
|||||||
userId: user._id,
|
userId: user._id,
|
||||||
notifications: monitor.notifications,
|
notifications: monitor.notifications,
|
||||||
};
|
};
|
||||||
const action = await dispatch(createUptimeMonitor({ authToken, monitor: form }));
|
const action = await dispatch(createUptimeMonitor({ monitor: form }));
|
||||||
if (action.meta.requestStatus === "fulfilled") {
|
if (action.meta.requestStatus === "fulfilled") {
|
||||||
createToast({ body: "Monitor created successfully!" });
|
createToast({ body: "Monitor created successfully!" });
|
||||||
navigate("/uptime");
|
navigate("/uptime");
|
||||||
@@ -205,7 +205,7 @@ const CreateMonitor = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchMonitor = async () => {
|
const fetchMonitor = async () => {
|
||||||
if (monitorId) {
|
if (monitorId) {
|
||||||
const action = await dispatch(getUptimeMonitorById({ authToken, monitorId }));
|
const action = await dispatch(getUptimeMonitorById({ monitorId }));
|
||||||
|
|
||||||
if (action.payload.success) {
|
if (action.payload.success) {
|
||||||
const data = action.payload.data;
|
const data = action.payload.data;
|
||||||
@@ -228,7 +228,7 @@ const CreateMonitor = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchMonitor();
|
fetchMonitor();
|
||||||
}, [monitorId, authToken, dispatch, navigate]);
|
}, [monitorId, dispatch, navigate]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box className="create-monitor">
|
<Box className="create-monitor">
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { formatDateWithTz } from "../../../../Utils/timeUtils";
|
|||||||
|
|
||||||
const useCertificateFetch = ({
|
const useCertificateFetch = ({
|
||||||
monitor,
|
monitor,
|
||||||
authToken,
|
|
||||||
monitorId,
|
monitorId,
|
||||||
certificateDateFormat,
|
certificateDateFormat,
|
||||||
uiTimezone,
|
uiTimezone,
|
||||||
@@ -22,7 +21,6 @@ const useCertificateFetch = ({
|
|||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const res = await networkService.getCertificateExpiry({
|
const res = await networkService.getCertificateExpiry({
|
||||||
authToken: authToken,
|
|
||||||
monitorId: monitorId,
|
monitorId: monitorId,
|
||||||
});
|
});
|
||||||
if (res?.data?.data?.certificateDate) {
|
if (res?.data?.data?.certificateDate) {
|
||||||
@@ -39,7 +37,7 @@ const useCertificateFetch = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchCertificate();
|
fetchCertificate();
|
||||||
}, [authToken, monitorId, certificateDateFormat, uiTimezone, monitor]);
|
}, [monitorId, certificateDateFormat, uiTimezone, monitor]);
|
||||||
return [certificateExpiry, isLoading];
|
return [certificateExpiry, isLoading];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { useEffect } from "react";
|
|||||||
import { networkService } from "../../../../main";
|
import { networkService } from "../../../../main";
|
||||||
import { createToast } from "../../../../Utils/toastUtils";
|
import { createToast } from "../../../../Utils/toastUtils";
|
||||||
export const useChecksFetch = ({
|
export const useChecksFetch = ({
|
||||||
authToken,
|
|
||||||
monitorId,
|
monitorId,
|
||||||
dateRange,
|
dateRange,
|
||||||
page,
|
page,
|
||||||
@@ -19,7 +18,6 @@ export const useChecksFetch = ({
|
|||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const res = await networkService.getChecksByMonitor({
|
const res = await networkService.getChecksByMonitor({
|
||||||
authToken: authToken,
|
|
||||||
monitorId: monitorId,
|
monitorId: monitorId,
|
||||||
sortOrder: "desc",
|
sortOrder: "desc",
|
||||||
limit: null,
|
limit: null,
|
||||||
@@ -38,7 +36,7 @@ export const useChecksFetch = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchChecks();
|
fetchChecks();
|
||||||
}, [authToken, monitorId, dateRange, page, rowsPerPage]);
|
}, [monitorId, dateRange, page, rowsPerPage]);
|
||||||
|
|
||||||
return [checks, checksCount, isLoading, networkError];
|
return [checks, checksCount, isLoading, networkError];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { networkService } from "../../../../main";
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { createToast } from "../../../../Utils/toastUtils";
|
import { createToast } from "../../../../Utils/toastUtils";
|
||||||
|
|
||||||
export const useMonitorFetch = ({ authToken, monitorId, dateRange }) => {
|
export const useMonitorFetch = ({ monitorId, dateRange }) => {
|
||||||
const [networkError, setNetworkError] = useState(false);
|
const [networkError, setNetworkError] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [monitor, setMonitor] = useState(undefined);
|
const [monitor, setMonitor] = useState(undefined);
|
||||||
@@ -13,7 +13,6 @@ export const useMonitorFetch = ({ authToken, monitorId, dateRange }) => {
|
|||||||
const fetchMonitors = async () => {
|
const fetchMonitors = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await networkService.getUptimeDetailsById({
|
const res = await networkService.getUptimeDetailsById({
|
||||||
authToken: authToken,
|
|
||||||
monitorId: monitorId,
|
monitorId: monitorId,
|
||||||
dateRange: dateRange,
|
dateRange: dateRange,
|
||||||
normalize: true,
|
normalize: true,
|
||||||
@@ -27,7 +26,7 @@ export const useMonitorFetch = ({ authToken, monitorId, dateRange }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchMonitors();
|
fetchMonitors();
|
||||||
}, [authToken, dateRange, monitorId, navigate]);
|
}, [dateRange, monitorId, navigate]);
|
||||||
return [monitor, isLoading, networkError];
|
return [monitor, isLoading, networkError];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ const certificateDateFormat = "MMM D, YYYY h A";
|
|||||||
|
|
||||||
const UptimeDetails = () => {
|
const UptimeDetails = () => {
|
||||||
// Redux state
|
// Redux state
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
|
||||||
const uiTimezone = useSelector((state) => state.ui.timezone);
|
const uiTimezone = useSelector((state) => state.ui.timezone);
|
||||||
|
|
||||||
// Local state
|
// Local state
|
||||||
@@ -48,21 +47,18 @@ const UptimeDetails = () => {
|
|||||||
const isAdmin = useIsAdmin();
|
const isAdmin = useIsAdmin();
|
||||||
|
|
||||||
const [monitor, monitorIsLoading, monitorNetworkError] = useMonitorFetch({
|
const [monitor, monitorIsLoading, monitorNetworkError] = useMonitorFetch({
|
||||||
authToken,
|
|
||||||
monitorId,
|
monitorId,
|
||||||
dateRange,
|
dateRange,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [certificateExpiry, certificateIsLoading] = useCertificateFetch({
|
const [certificateExpiry, certificateIsLoading] = useCertificateFetch({
|
||||||
monitor,
|
monitor,
|
||||||
authToken,
|
|
||||||
monitorId,
|
monitorId,
|
||||||
certificateDateFormat,
|
certificateDateFormat,
|
||||||
uiTimezone,
|
uiTimezone,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [checks, checksCount, checksAreLoading, checksNetworkError] = useChecksFetch({
|
const [checks, checksCount, checksAreLoading, checksNetworkError] = useChecksFetch({
|
||||||
authToken,
|
|
||||||
monitorId,
|
monitorId,
|
||||||
dateRange,
|
dateRange,
|
||||||
page,
|
page,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { useTheme } from "@emotion/react";
|
|||||||
import { useMonitorUtils } from "../../../../Hooks/useMonitorUtils";
|
import { useMonitorUtils } from "../../../../Hooks/useMonitorUtils";
|
||||||
|
|
||||||
export const useMonitorFetch = ({
|
export const useMonitorFetch = ({
|
||||||
authToken,
|
|
||||||
teamId,
|
teamId,
|
||||||
limit,
|
limit,
|
||||||
page,
|
page,
|
||||||
@@ -28,7 +27,6 @@ export const useMonitorFetch = ({
|
|||||||
try {
|
try {
|
||||||
setMonitorsAreLoading(true);
|
setMonitorsAreLoading(true);
|
||||||
const res = await networkService.getMonitorsByTeamId({
|
const res = await networkService.getMonitorsByTeamId({
|
||||||
authToken,
|
|
||||||
teamId,
|
teamId,
|
||||||
limit,
|
limit,
|
||||||
types: ["http", "ping", "docker", "port"],
|
types: ["http", "ping", "docker", "port"],
|
||||||
@@ -56,7 +54,6 @@ export const useMonitorFetch = ({
|
|||||||
};
|
};
|
||||||
fetchMonitors();
|
fetchMonitors();
|
||||||
}, [
|
}, [
|
||||||
authToken,
|
|
||||||
teamId,
|
teamId,
|
||||||
limit,
|
limit,
|
||||||
field,
|
field,
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ CreateMonitorButton.propTypes = {
|
|||||||
|
|
||||||
const UptimeMonitors = () => {
|
const UptimeMonitors = () => {
|
||||||
// Redux state
|
// Redux state
|
||||||
const { authToken, user } = useSelector((state) => state.auth);
|
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
|
||||||
@@ -96,7 +96,6 @@ const UptimeMonitors = () => {
|
|||||||
monitorsSummary,
|
monitorsSummary,
|
||||||
networkError,
|
networkError,
|
||||||
} = useMonitorsFetch({
|
} = useMonitorsFetch({
|
||||||
authToken,
|
|
||||||
teamId,
|
teamId,
|
||||||
limit: 25,
|
limit: 25,
|
||||||
page: page,
|
page: page,
|
||||||
|
|||||||
Reference in new issue
Block a user