From c15b5e790e220e1cb773a1513a7b6de4f5005f6e Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 26 Oct 2023 15:41:21 -0600 Subject: [PATCH] uptime in seconds --- .../ui/src/app/services/api/api.types.ts | 2 +- .../ui/src/app/services/time-service.ts | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/frontend/projects/ui/src/app/services/api/api.types.ts b/frontend/projects/ui/src/app/services/api/api.types.ts index 099d20594..860bc6003 100644 --- a/frontend/projects/ui/src/app/services/api/api.types.ts +++ b/frontend/projects/ui/src/app/services/api/api.types.ts @@ -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 diff --git a/frontend/projects/ui/src/app/services/time-service.ts b/frontend/projects/ui/src/app/services/time-service.ts index 23001fae2..26d1a216b 100644 --- a/frontend/projects/ui/src/app/services/time-service.ts +++ b/frontend/projects/ui/src/app/services/time-service.ts @@ -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({ @@ -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 } }), )