@@ -7,14 +7,16 @@ import TitledGreyBox from '@/components/elements/TitledGreyBox';
77import { ServerContext } from '@/state/server' ;
88import CopyOnClick from '@/components/elements/CopyOnClick' ;
99import { SocketEvent , SocketRequest } from '@/components/server/events' ;
10+ import UptimeDuration from '@/components/server/UptimeDuration' ;
1011
1112interface Stats {
1213 memory : number ;
1314 cpu : number ;
1415 disk : number ;
16+ uptime : number ;
1517}
1618
17- function statusToColor ( status : string | null , installing : boolean ) : TwStyle {
19+ function statusToColor ( status : string | null , installing : boolean ) : TwStyle {
1820 if ( installing ) {
1921 status = '' ;
2022 }
@@ -30,7 +32,7 @@ function statusToColor (status: string|null, installing: boolean): TwStyle {
3032}
3133
3234const ServerDetailsBlock = ( ) => {
33- const [ stats , setStats ] = useState < Stats > ( { memory : 0 , cpu : 0 , disk : 0 } ) ;
35+ const [ stats , setStats ] = useState < Stats > ( { memory : 0 , cpu : 0 , disk : 0 , uptime : 0 } ) ;
3436
3537 const status = ServerContext . useStoreState ( state => state . status . value ) ;
3638 const connected = ServerContext . useStoreState ( state => state . socket . connected ) ;
@@ -48,6 +50,7 @@ const ServerDetailsBlock = () => {
4850 memory : stats . memory_bytes ,
4951 cpu : stats . cpu_absolute ,
5052 disk : stats . disk_bytes ,
53+ uptime : stats . uptime || 0 ,
5154 } ) ;
5255 } ;
5356
@@ -69,7 +72,7 @@ const ServerDetailsBlock = () => {
6972 const isTransferring = ServerContext . useStoreState ( state => state . server . data ! . isTransferring ) ;
7073 const limits = ServerContext . useStoreState ( state => state . server . data ! . limits ) ;
7174 const primaryAllocation = ServerContext . useStoreState ( state => state . server . data ! . allocations . filter ( alloc => alloc . isDefault ) . map (
72- allocation => ( allocation . alias || allocation . ip ) + ':' + allocation . port
75+ allocation => ( allocation . alias || allocation . ip ) + ':' + allocation . port ,
7376 ) ) . toString ( ) ;
7477
7578 const diskLimit = limits . disk ? megabytesToHuman ( limits . disk ) : 'Unlimited' ;
@@ -88,6 +91,11 @@ const ServerDetailsBlock = () => {
8891 ] }
8992 />
9093 { ! status ? 'Connecting...' : ( isInstalling ? 'Installing' : ( isTransferring ) ? 'Transferring' : status ) }
94+ { stats . uptime > 0 &&
95+ < span css = { tw `ml-2` } >
96+ (< UptimeDuration uptime = { stats . uptime / 1000 } /> )
97+ </ span >
98+ }
9199 </ p >
92100 < CopyOnClick text = { primaryAllocation } >
93101 < p css = { tw `text-xs mt-2` } >
0 commit comments