Skip to content

Commit

Permalink
feat: renterd hostd node profile uptime
Browse files Browse the repository at this point in the history
feat: hostd node profile uptime
  • Loading branch information
alexfreska committed Feb 16, 2024
1 parent ea9c20d commit c98f194
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-ducks-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The node profile details now include uptime.
5 changes: 5 additions & 0 deletions .changeset/wicked-sloths-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'hostd': minor
---

The node profile details now include uptime. Closes https://github.com/SiaFoundation/hostd/issues/92
16 changes: 16 additions & 0 deletions apps/hostd/components/Profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { useSyncStatus } from '../../hooks/useSyncStatus'
import { useDialog } from '../../contexts/dialog'
import { useSiascanUrl } from '../../hooks/useSiascanUrl'
import { humanTime } from '@siafoundation/units'

export function Profile() {
const { openDialog } = useDialog()
Expand All @@ -38,6 +39,11 @@ export function Profile() {
const versionUrl = version?.match(/^v\d+\.\d+\.\d+/)
? `https://github.com/SiaFoundation/hostd/releases/${version}`
: `https://github.com/SiaFoundation/hostd/tree/${version}`

const uptime = state.data
? new Date().getTime() - new Date(state.data?.startTime).getTime()
: 0

return (
<DaemonProfile
name="hostd"
Expand Down Expand Up @@ -93,6 +99,16 @@ export function Profile() {
/>
</div>
</div>
{state.data && (
<div className="flex gap-4 justify-between items-center">
<Label size="14" color="subtle" noWrap className="w-[100px]">
Uptime
</Label>
<div className="flex-1 flex justify-end overflow-hidden -mr-0.5 pr-0.5">
<Text size="14">{humanTime(uptime, { format: 'long' })}</Text>
</div>
</div>
)}
<div className="flex gap-2 justify-between items-center">
<Label size="14" color="subtle" noWrap className="w-[100px]">
Network
Expand Down
15 changes: 15 additions & 0 deletions apps/renterd/components/Profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
useWallet,
} from '@siafoundation/react-renterd'
import { useDialog } from '../../contexts/dialog'
import { humanTime } from '@siafoundation/units'

export function Profile() {
const { openDialog } = useDialog()
Expand Down Expand Up @@ -40,6 +41,10 @@ export function Profile() {
? `https://github.com/SiaFoundation/renterd/releases/${version}`
: `https://github.com/SiaFoundation/renterd/tree/${version}`

const uptime = state.data
? new Date().getTime() - new Date(state.data?.startTime).getTime()
: 0

return (
<DaemonProfile
name="renterd"
Expand All @@ -65,6 +70,16 @@ export function Profile() {
/>
</div>
</div>
{state.data && (
<div className="flex gap-4 justify-between items-center">
<Label size="14" color="subtle" noWrap className="w-[100px]">
Uptime
</Label>
<div className="flex-1 flex justify-end overflow-hidden -mr-0.5 pr-0.5">
<Text size="14">{humanTime(uptime, { format: 'long' })}</Text>
</div>
</div>
)}
<div className="flex gap-4 justify-between items-center">
<Label size="14" color="subtle" noWrap className="w-[100px]">
Network
Expand Down

0 comments on commit c98f194

Please sign in to comment.