Skip to content

Commit

Permalink
Show last agent connection date-time to the agents page
Browse files Browse the repository at this point in the history
  • Loading branch information
noreplydev committed Oct 31, 2024
1 parent 8f96c42 commit 264ffb7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/protolib/src/bundles/agents/agents/agentsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ const AgentCard = ({ data, extraMenuActions }) => {
return response.data
}

function formatTimestamp(timestamp) {
if (timestamp === null) return "never connected"
const date = new Date(timestamp);

const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0');

const day = date.getDate().toString().padStart(2, '0');
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const year = date.getFullYear();

return `${hours}:${minutes} ${day}/${month}/${year}`;
}


useEffect(() => {
const interval = setInterval(async () => {
const statusResult = await getAgentStatus(data.name)
Expand All @@ -114,6 +129,7 @@ const AgentCard = ({ data, extraMenuActions }) => {
<XStack paddingInline={20} gap="$3">
<YStack h="$1" w="$1" bg={status.online ? "$color9" : "$color4"} borderRadius="100%" />
<Paragraph size={20}>{status.online ? 'online' : 'offline'}</Paragraph>
<Paragraph size={20} color={"$gray10"}>{formatTimestamp(status.last_view)}</Paragraph>
</XStack>
<YStack f={1}>
{
Expand Down

0 comments on commit 264ffb7

Please sign in to comment.