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.
This commit is contained in:
Simon Larsen 2024-07-01 17:12:33 +01:00
parent 1e595be586
commit 7a5efd99ca
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
4 changed files with 10 additions and 11 deletions

View File

@ -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<void> => {
try {

View File

@ -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<ComponentProps> = (
): 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 (
<Statusbubble text={"Connected"} color={Green} shouldAnimate={true} />

View File

@ -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",

View File

@ -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<PageComponentProps> = (): ReactElement => {
},
{
field: {
lastAlive: true,
connectionStatus: true,
},
title: "Probe Status",
type: FieldType.Text,