diff --git a/resources/scripts/components/server/ServerDetailsBlock.tsx b/resources/scripts/components/server/ServerDetailsBlock.tsx
index 6df4a764c..a87dc3b01 100644
--- a/resources/scripts/components/server/ServerDetailsBlock.tsx
+++ b/resources/scripts/components/server/ServerDetailsBlock.tsx
@@ -7,14 +7,16 @@ import TitledGreyBox from '@/components/elements/TitledGreyBox';
import { ServerContext } from '@/state/server';
import CopyOnClick from '@/components/elements/CopyOnClick';
import { SocketEvent, SocketRequest } from '@/components/server/events';
+import UptimeDuration from '@/components/server/UptimeDuration';
interface Stats {
memory: number;
cpu: number;
disk: number;
+ uptime: number;
}
-function statusToColor (status: string|null, installing: boolean): TwStyle {
+function statusToColor (status: string | null, installing: boolean): TwStyle {
if (installing) {
status = '';
}
@@ -30,7 +32,7 @@ function statusToColor (status: string|null, installing: boolean): TwStyle {
}
const ServerDetailsBlock = () => {
- const [ stats, setStats ] = useState
diff --git a/resources/scripts/components/server/UptimeDuration.tsx b/resources/scripts/components/server/UptimeDuration.tsx new file mode 100644 index 000000000..1406450fa --- /dev/null +++ b/resources/scripts/components/server/UptimeDuration.tsx @@ -0,0 +1,14 @@ +import React from 'react'; + +export default ({ uptime }: { uptime: number }) => { + const hours = Math.floor(Math.floor(uptime) / 60 / 60); + const remainder = Math.floor(uptime - (hours * 60 * 60)); + const minutes = Math.floor(remainder / 60); + const seconds = remainder % 60; + + return ( + <> + {hours.toString().padStart(2, '0')}:{minutes.toString().padStart(2, '0')}:{seconds.toString().padStart(2, '0')} + > + ); +};