diff --git a/client/src/Hooks/checkHooks.js b/client/src/Hooks/checkHooks.js
index 98fb0cfd5..a7dae8b9a 100644
--- a/client/src/Hooks/checkHooks.js
+++ b/client/src/Hooks/checkHooks.js
@@ -122,4 +122,30 @@ const useFetchChecksByMonitor = ({
return [checks, checksCount, isLoading, networkError];
};
-export { useFetchChecksByMonitor, useFetchChecksTeam };
+const useFetchChecksSummaryByTeamId = () => {
+ const [summary, setSummary] = useState(undefined);
+ const [isLoading, setIsLoading] = useState(false);
+ const [networkError, setNetworkError] = useState(false);
+
+ useEffect(() => {
+ const fetchSummary = async () => {
+ try {
+ setIsLoading(true);
+
+ const res = await networkService.getChecksAndSummaryByTeamId();
+ setSummary(res.data.data);
+ } catch (error) {
+ setNetworkError(true);
+ createToast({ body: error.message });
+ } finally {
+ setIsLoading(false);
+ }
+ };
+
+ fetchSummary();
+ }, []);
+
+ return [summary, isLoading, networkError];
+};
+
+export { useFetchChecksByMonitor, useFetchChecksTeam, useFetchChecksSummaryByTeamId };
diff --git a/client/src/Pages/Incidents/Components/StatusBoxes/StatusBox.jsx b/client/src/Pages/Incidents/Components/StatusBoxes/StatusBox.jsx
index ef7457a9e..ac3d1660e 100644
--- a/client/src/Pages/Incidents/Components/StatusBoxes/StatusBox.jsx
+++ b/client/src/Pages/Incidents/Components/StatusBoxes/StatusBox.jsx
@@ -22,31 +22,31 @@ const StatusBox = ({ title, value, status }) => {
color = theme.palette.success.lowContrast;
icon = (
-
+
);
} else if (status === "down") {
color = theme.palette.error.lowContrast;
icon = (
-
+
);
} else if (status === "paused") {
color = theme.palette.warning.lowContrast;
icon = (
-
+
);
} else {
- color = theme.palette.accent.main;
- icon = (
-
-
-
- );
- }
+ color = theme.palette.accent.main;
+ icon = (
+
+
+
+ );
+ }
return (
{
+const StatusBoxes = ({ isLoading, summary }) => {
const theme = useTheme();
if (isLoading) return ;
return (
@@ -15,35 +15,30 @@ const StatusBoxes = ({ isLoading, statusCounts }) => {
>
+
+
-
-
);
};
StatusBoxes.propTypes = {
isLoading: PropTypes.bool,
- statusCounts: PropTypes.shape({
- total: PropTypes.number,
- resolved: PropTypes.number,
- cannotResolve: PropTypes.number,
- down: PropTypes.number,
- }),
+ summary: PropTypes.object,
};
-export default StatusBoxes;
\ No newline at end of file
+export default StatusBoxes;
diff --git a/client/src/Pages/Incidents/index.jsx b/client/src/Pages/Incidents/index.jsx
index 708b443a5..11946ae63 100644
--- a/client/src/Pages/Incidents/index.jsx
+++ b/client/src/Pages/Incidents/index.jsx
@@ -9,6 +9,7 @@ import StatusBoxes from "./Components/StatusBoxes";
//Utils
import { useTheme } from "@emotion/react";
import { useFetchMonitorsByTeamId } from "../../Hooks/monitorHooks";
+import { useFetchChecksSummaryByTeamId } from "../../Hooks/checkHooks";
import { useState, useEffect } from "react";
import NetworkError from "../../Components/GenericFallback/NetworkError";
import { useTranslation } from "react-i18next";
@@ -32,6 +33,8 @@ const Incidents = () => {
//Utils
const theme = useTheme();
const [monitors, , isLoading, networkError] = useFetchMonitorsByTeamId({});
+ const [summary, isLoadingSummary, networkErrorSummary] =
+ useFetchChecksSummaryByTeamId();
const { monitorId } = useParams();
useEffect(() => {
@@ -52,7 +55,7 @@ const Incidents = () => {
setMonitorLookup(monitorLookup);
}, [monitors]);
- if (networkError) {
+ if (networkError || networkErrorSummary) {
return (
@@ -64,7 +67,8 @@ const Incidents = () => {
} The response from the axios GET request.
+ */
+ getChecksAndSummaryByTeamId = async () => {
+ return this.axiosInstance.get(`/checks/team/summary`);
+ };
+
/**
* ************************************
* Update the status of a check
diff --git a/server/controllers/checkController.js b/server/controllers/checkController.js
index 8f9d0fbb5..e50d5b7fc 100755
--- a/server/controllers/checkController.js
+++ b/server/controllers/checkController.js
@@ -111,6 +111,19 @@ class CheckController {
}
};
+ getChecksSummaryByTeamId = async (req, res, next) => {
+ try {
+ const { teamId } = req.user;
+ const summary = await this.db.getChecksSummaryByTeamId({ teamId });
+ return res.success({
+ msg: this.stringService.checkGetSummary,
+ data: summary,
+ });
+ } catch (error) {
+ next(handleError(error, SERVICE_NAME, "getChecksSummaryByTeamId"));
+ }
+ };
+
ackCheck = async (req, res, next) => {
try {
await ackCheckBodyValidation.validateAsync(req.body);
diff --git a/server/db/mongo/modules/checkModule.js b/server/db/mongo/modules/checkModule.js
index 835f358fa..7c9682557 100755
--- a/server/db/mongo/modules/checkModule.js
+++ b/server/db/mongo/modules/checkModule.js
@@ -312,12 +312,14 @@ const ackAllChecks = async (monitorId, teamId, ack, path) => {
* @returns {Promise