Skip to content

Commit

Permalink
uptime in seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
MattDHill committed Oct 26, 2023
1 parent a584645 commit c15b5e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion frontend/projects/ui/src/app/services/api/api.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export module RR {
export type GetSystemTimeReq = {} // server.time
export type GetSystemTimeRes = {
now: string
uptime: number
uptime: number // seconds
}

export type GetServerLogsReq = ServerLogsReq // server.logs & server.kernel-logs
Expand Down
18 changes: 8 additions & 10 deletions frontend/projects/ui/src/app/services/time-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ export class TimeService {
return interval(1000).pipe(
map(index => {
const incremented = index + 1
const msToAdd = 1000 * incremented
return {
now: current + msToAdd,
uptime: uptime + msToAdd,
now: current + 1000 * incremented,
uptime: uptime + incremented,
}
}),
startWith({
Expand All @@ -42,13 +41,12 @@ export class TimeService {

readonly uptime$ = this.time$.pipe(
map(({ uptime }) => {
const days = Math.floor(uptime / (24 * 60 * 60 * 1000))
const daysms = uptime % (24 * 60 * 60 * 1000)
const hours = Math.floor(daysms / (60 * 60 * 1000))
const hoursms = uptime % (60 * 60 * 1000)
const minutes = Math.floor(hoursms / (60 * 1000))
const minutesms = uptime % (60 * 1000)
const seconds = Math.floor(minutesms / 1000)
const days = Math.floor(uptime / (24 * 60 * 60))
const daysSec = uptime % (24 * 60 * 60)
const hours = Math.floor(daysSec / (60 * 60))
const hoursSec = uptime % (60 * 60)
const minutes = Math.floor(hoursSec / 60)
const seconds = uptime % 60
return { days, hours, minutes, seconds }
}),
)
Expand Down

0 comments on commit c15b5e7

Please sign in to comment.