From a5662e96ccb0722927f3d1c22bbd8feca7cab787 Mon Sep 17 00:00:00 2001 From: noreplydev Date: Mon, 4 Nov 2024 16:49:45 +0100 Subject: [PATCH] Fix last view value of agent card component --- .../src/bundles/agents/agents/agentsPage.tsx | 23 +++++++++++-------- .../bundles/agents/bifrost/bifrostUtils.ts | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/protolib/src/bundles/agents/agents/agentsPage.tsx b/packages/protolib/src/bundles/agents/agents/agentsPage.tsx index 68c15b426..81f45570a 100644 --- a/packages/protolib/src/bundles/agents/agents/agentsPage.tsx +++ b/packages/protolib/src/bundles/agents/agents/agentsPage.tsx @@ -87,6 +87,19 @@ const AgentCard = ({ data, extraMenuActions }) => { online: false, last_view: null }) + + useEffect(() => { + const setNewStatus = async () => { + const statusResult = await getAgentStatus(data.name) + setStatus(statusResult.status) + } + + setNewStatus() + const interval = setInterval(setNewStatus, 5000) + + return () => clearInterval(interval) + }, []) + const getAgentStatus = async (agentName) => { const response = await API.get(`${sourceUrl}/${agentName}/status`) if (!response.data) return { @@ -110,16 +123,6 @@ const AgentCard = ({ data, extraMenuActions }) => { return `${hours}:${minutes} ${day}/${month}/${year}`; } - - useEffect(() => { - const interval = setInterval(async () => { - const statusResult = await getAgentStatus(data.name) - setStatus(statusResult.status) - }, 5000) - - return () => clearInterval(interval) - }, []) - return { diff --git a/packages/protolib/src/bundles/agents/bifrost/bifrostUtils.ts b/packages/protolib/src/bundles/agents/bifrost/bifrostUtils.ts index 035e121a5..e7f75c0e3 100644 --- a/packages/protolib/src/bundles/agents/bifrost/bifrostUtils.ts +++ b/packages/protolib/src/bundles/agents/bifrost/bifrostUtils.ts @@ -1,3 +1,3 @@ -export const heartbeatTimeout = 15_000 // 30 seconds +export const heartbeatTimeout = 30_000 // 30 seconds export const defActionEndpoint = (agentName: string, subsystemName: string, actionName: string) => `agents/${agentName}/subsystem/${subsystemName}/action/${actionName}` export const defMonitorEndpoint = (agentName: string, subsystemName: string, monitorName: string) => `agents/${agentName}/subsystem/${subsystemName}/monitor/${monitorName}` \ No newline at end of file