4 files changed
+8
-7
No files matched your search
@@ -46,7 +46,7 @@ const ActionsMenu = ({
|
|||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const action = await dispatch(pauseUptimeMonitor({ monitorId: monitor._id }));
|
const action = await dispatch(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 ? "resumed" : "paused";
|
||||||
createToast({ body: `Monitor ${state} successfully.` });
|
createToast({ body: `Monitor ${state} successfully.` });
|
||||||
pauseCallback();
|
pauseCallback();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export const useFetchMonitorsWithChecks = ({
|
|||||||
filter,
|
filter,
|
||||||
field,
|
field,
|
||||||
order,
|
order,
|
||||||
|
monitorUpdateTrigger,
|
||||||
}) => {
|
}) => {
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [count, setCount] = useState(undefined);
|
const [count, setCount] = useState(undefined);
|
||||||
@@ -63,6 +64,7 @@ export const useFetchMonitorsWithChecks = ({
|
|||||||
teamId,
|
teamId,
|
||||||
theme,
|
theme,
|
||||||
types,
|
types,
|
||||||
|
monitorUpdateTrigger,
|
||||||
]);
|
]);
|
||||||
return [monitors, count, isLoading, networkError];
|
return [monitors, count, isLoading, networkError];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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 useFetchMonitorsWithSummary = ({ teamId, types }) => {
|
export const useFetchMonitorsWithSummary = ({ teamId, 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);
|
||||||
@@ -30,7 +30,7 @@ export const useFetchMonitorsWithSummary = ({ teamId, types }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchMonitors();
|
fetchMonitors();
|
||||||
}, [teamId, types]);
|
}, [teamId, types, monitorUpdateTrigger]);
|
||||||
return [monitors, monitorsSummary, isLoading, networkError];
|
return [monitors, monitorsSummary, isLoading, networkError];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,14 +24,12 @@ import { useState, useCallback } from "react";
|
|||||||
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import useMonitorsFetch from "./Hooks/useMonitorsFetch";
|
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import { setRowsPerPage } from "../../../Features/UI/uiSlice";
|
import { setRowsPerPage } from "../../../Features/UI/uiSlice";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import useFetchMonitorsWithSummary from "../../../Hooks/useFetchMonitorsWithSummary";
|
import useFetchMonitorsWithSummary from "../../../Hooks/useFetchMonitorsWithSummary";
|
||||||
import useFetchMonitorsWithChecks from "../../../Hooks/useFetchMonitorsWithChecks";
|
import useFetchMonitorsWithChecks from "../../../Hooks/useFetchMonitorsWithChecks";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
const BREADCRUMBS = [{ name: `Uptime`, path: "/uptime" }];
|
const BREADCRUMBS = [{ name: `Uptime`, path: "/uptime" }];
|
||||||
const TYPES = ["http", "ping", "docker", "port"];
|
const TYPES = ["http", "ping", "docker", "port"];
|
||||||
const CreateMonitorButton = ({ shouldRender }) => {
|
const CreateMonitorButton = ({ shouldRender }) => {
|
||||||
@@ -103,6 +101,7 @@ const UptimeMonitors = () => {
|
|||||||
useFetchMonitorsWithSummary({
|
useFetchMonitorsWithSummary({
|
||||||
teamId,
|
teamId,
|
||||||
types: TYPES,
|
types: TYPES,
|
||||||
|
monitorUpdateTrigger,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [
|
const [
|
||||||
@@ -119,11 +118,10 @@ const UptimeMonitors = () => {
|
|||||||
filter: search,
|
filter: search,
|
||||||
field: sort?.field,
|
field: sort?.field,
|
||||||
order: sort?.order,
|
order: sort?.order,
|
||||||
triggerUpdate,
|
monitorUpdateTrigger,
|
||||||
});
|
});
|
||||||
|
|
||||||
const isLoading = monitorsWithSummaryIsLoading || monitorsWithChecksIsLoading;
|
const isLoading = monitorsWithSummaryIsLoading || monitorsWithChecksIsLoading;
|
||||||
|
|
||||||
if (networkError) {
|
if (networkError) {
|
||||||
return (
|
return (
|
||||||
<GenericFallback>
|
<GenericFallback>
|
||||||
@@ -194,6 +192,7 @@ const UptimeMonitors = () => {
|
|||||||
sort={sort}
|
sort={sort}
|
||||||
setSort={setSort}
|
setSort={setSort}
|
||||||
monitorsAreLoading={monitorsWithChecksIsLoading}
|
monitorsAreLoading={monitorsWithChecksIsLoading}
|
||||||
|
triggerUpdate={triggerUpdate}
|
||||||
/>
|
/>
|
||||||
<Pagination
|
<Pagination
|
||||||
itemCount={monitorsWithChecksCount}
|
itemCount={monitorsWithChecksCount}
|
||||||
|
|||||||
Reference in new issue
Block a user