From 7a5efd99ca4ccf35fdfb7abf9d8bcdb45ee8e371 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Mon, 1 Jul 2024 17:12:33 +0100 Subject: [PATCH] chore: Update ProbeStatusElement component to use connectionStatus field This commit updates the ProbeStatusElement component to use the new connectionStatus field from the Probe model. The component previously relied on the lastAlive field to determine the probe's connection status, but now it directly checks the connectionStatus field. This change ensures that the component accurately reflects the probe's current connection status, improving the reliability of the application. --- App/FeatureSet/Workers/Index.ts | 4 ++++ Dashboard/src/Components/Probe/ProbeStatus.tsx | 9 ++------- Dashboard/src/Pages/Monitor/View/Probes.tsx | 4 ++-- Dashboard/src/Pages/Settings/Probes.tsx | 4 ++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/App/FeatureSet/Workers/Index.ts b/App/FeatureSet/Workers/Index.ts index 59dc719323..361d3dd249 100644 --- a/App/FeatureSet/Workers/Index.ts +++ b/App/FeatureSet/Workers/Index.ts @@ -61,6 +61,10 @@ import QueueWorker from "CommonServer/Infrastructure/QueueWorker"; import FeatureSet from "CommonServer/Types/FeatureSet"; import logger from "CommonServer/Utils/Logger"; +// Probes +import "./Jobs/Probe/SendOwnerAddedNotification"; +import "./Jobs/Probe/UpdateConnectionStatus"; + const WorkersFeatureSet: FeatureSet = { init: async (): Promise => { try { diff --git a/Dashboard/src/Components/Probe/ProbeStatus.tsx b/Dashboard/src/Components/Probe/ProbeStatus.tsx index 7b04c48889..0774fde1ca 100644 --- a/Dashboard/src/Components/Probe/ProbeStatus.tsx +++ b/Dashboard/src/Components/Probe/ProbeStatus.tsx @@ -1,8 +1,7 @@ import { Green, Red } from "Common/Types/BrandColors"; -import OneUptimeDate from "Common/Types/Date"; import { JSONObject } from "Common/Types/JSON"; import Statusbubble from "CommonUI/src/Components/StatusBubble/StatusBubble"; -import Probe from "Model/Models/Probe"; +import Probe, { ProbeConnectionStatus } from "Model/Models/Probe"; import React, { FunctionComponent, ReactElement } from "react"; export interface ComponentProps { @@ -14,11 +13,7 @@ const ProbeStatusElement: FunctionComponent = ( ): ReactElement => { if ( props.probe && - props.probe["lastAlive"] && - OneUptimeDate.getNumberOfMinutesBetweenDates( - OneUptimeDate.fromString(props.probe["lastAlive"] as string), - OneUptimeDate.getCurrentDate(), - ) < 5 + props.probe["connectionStatus"] === ProbeConnectionStatus.Connected ) { return ( diff --git a/Dashboard/src/Pages/Monitor/View/Probes.tsx b/Dashboard/src/Pages/Monitor/View/Probes.tsx index 6cb37b81cf..ca1f222077 100644 --- a/Dashboard/src/Pages/Monitor/View/Probes.tsx +++ b/Dashboard/src/Pages/Monitor/View/Probes.tsx @@ -1,5 +1,5 @@ import DisabledWarning from "../../../Components/Monitor/DisabledWarning"; -import ProbeStatusElement from "../../../Components/Probe/ProbeConnectionStatus"; +import ProbeStatusElement from "../../../Components/Probe/ProbeStatus"; import DashboardNavigation from "../../../Utils/Navigation"; import ProbeUtil from "../../../Utils/Probe"; import PageComponentProps from "../../PageComponentProps"; @@ -228,7 +228,7 @@ const MonitorProbes: FunctionComponent< { field: { probe: { - lastAlive: true, + connectionStatus: true, }, }, title: "Probe Status", diff --git a/Dashboard/src/Pages/Settings/Probes.tsx b/Dashboard/src/Pages/Settings/Probes.tsx index 4f13ce4ec2..94fbacb382 100644 --- a/Dashboard/src/Pages/Settings/Probes.tsx +++ b/Dashboard/src/Pages/Settings/Probes.tsx @@ -1,4 +1,4 @@ -import ProbeStatusElement from "../../Components/Probe/ProbeConnectionStatus"; +import ProbeStatusElement from "../../Components/Probe/ProbeStatus"; import DashboardNavigation from "../../Utils/Navigation"; import PageComponentProps from "../PageComponentProps"; import Route from "Common/Types/API/Route"; @@ -90,7 +90,7 @@ const ProbePage: FunctionComponent = (): ReactElement => { }, { field: { - lastAlive: true, + connectionStatus: true, }, title: "Probe Status", type: FieldType.Text,