From 6ec08b405bcbba71f60e852c71380178d7be7cec Mon Sep 17 00:00:00 2001
From: RachelElysia <71795832+RachelElysia@users.noreply.github.com>
Date: Mon, 25 Jul 2022 09:37:12 -0400
Subject: [PATCH] Manage Host UI: Convert uptime column to last restarted
(#6812)
---
.../issue-6521-convert-uptime-to-last-restarted | 1 +
.../hosts/ManageHostsPage/HostTableConfig.tsx | 14 +++++++++-----
frontend/utilities/helpers.ts | 11 -----------
3 files changed, 10 insertions(+), 16 deletions(-)
create mode 100644 changes/issue-6521-convert-uptime-to-last-restarted
diff --git a/changes/issue-6521-convert-uptime-to-last-restarted b/changes/issue-6521-convert-uptime-to-last-restarted
new file mode 100644
index 0000000000..6218a64a5d
--- /dev/null
+++ b/changes/issue-6521-convert-uptime-to-last-restarted
@@ -0,0 +1 @@
+* Convert uptime column to last restarted on the Manage hosts page
\ No newline at end of file
diff --git a/frontend/pages/hosts/ManageHostsPage/HostTableConfig.tsx b/frontend/pages/hosts/ManageHostsPage/HostTableConfig.tsx
index 12aec6a180..e408abf2d4 100644
--- a/frontend/pages/hosts/ManageHostsPage/HostTableConfig.tsx
+++ b/frontend/pages/hosts/ManageHostsPage/HostTableConfig.tsx
@@ -15,7 +15,7 @@ import StatusCell from "components/TableContainer/DataTable/StatusCell/StatusCel
import TextCell from "components/TableContainer/DataTable/TextCell/TextCell";
import {
humanHostMemory,
- humanHostUptime,
+ humanHostLastRestart,
humanHostLastSeen,
humanHostDetailUpdated,
hostTeamName,
@@ -324,7 +324,7 @@ const allHostTableHeaders: IDataColumn[] = [
Cell: (cellProps: ICellProps) => ,
},
{
- title: "Uptime",
+ title: "Last restarted",
Header: (cellProps: IHeaderProps) => (
),
accessor: "uptime",
- Cell: (cellProps: ICellProps) => (
-
- ),
+ Cell: (cellProps: ICellProps) => {
+ const { uptime, detail_updated_at } = cellProps.row.original;
+
+ return (
+
+ );
+ },
},
{
title: "CPU",
diff --git a/frontend/utilities/helpers.ts b/frontend/utilities/helpers.ts
index 75563e660e..487969f025 100644
--- a/frontend/utilities/helpers.ts
+++ b/frontend/utilities/helpers.ts
@@ -580,16 +580,6 @@ export const inMilliseconds = (nanoseconds: number): number => {
return nanoseconds / NANOSECONDS_PER_MILLISECOND;
};
-export const humanHostUptime = (uptimeInNanoseconds: number): string => {
- const uptimeMilliseconds = inMilliseconds(uptimeInNanoseconds);
- const restartDate = new Date();
- restartDate.setMilliseconds(
- restartDate.getMilliseconds() - uptimeMilliseconds
- );
-
- return formatDistanceToNow(new Date(restartDate), { addSuffix: true });
-};
-
export const humanHostLastRestart = (
detailUpdatedAt: string,
uptime: number
@@ -817,7 +807,6 @@ export default {
generateRole,
generateTeam,
greyCell,
- humanHostUptime,
humanHostLastSeen,
humanHostEnrolled,
humanHostMemory,