mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Manage Host UI: Convert uptime column to last restarted (#6812)
This commit is contained in:
parent
345b0a0cd2
commit
6ec08b405b
3 changed files with 10 additions and 16 deletions
1
changes/issue-6521-convert-uptime-to-last-restarted
Normal file
1
changes/issue-6521-convert-uptime-to-last-restarted
Normal file
|
|
@ -0,0 +1 @@
|
|||
* Convert uptime column to last restarted on the Manage hosts page
|
||||
|
|
@ -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) => <TextCell value={cellProps.cell.value} />,
|
||||
},
|
||||
{
|
||||
title: "Uptime",
|
||||
title: "Last restarted",
|
||||
Header: (cellProps: IHeaderProps) => (
|
||||
<HeaderCell
|
||||
value={cellProps.column.title}
|
||||
|
|
@ -332,9 +332,13 @@ const allHostTableHeaders: IDataColumn[] = [
|
|||
/>
|
||||
),
|
||||
accessor: "uptime",
|
||||
Cell: (cellProps: ICellProps) => (
|
||||
<TextCell value={cellProps.cell.value} formatter={humanHostUptime} />
|
||||
),
|
||||
Cell: (cellProps: ICellProps) => {
|
||||
const { uptime, detail_updated_at } = cellProps.row.original;
|
||||
|
||||
return (
|
||||
<TextCell value={humanHostLastRestart(detail_updated_at, uptime)} />
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "CPU",
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue