11import React , { lazy , useEffect , useState } from 'react' ;
2- import { Helmet } from 'react-helmet' ;
32import { ServerContext } from '@/state/server' ;
43import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
54import { faCircle , faHdd , faMemory , faMicrochip , faServer } from '@fortawesome/free-solid-svg-icons' ;
65import { bytesToHuman , megabytesToHuman } from '@/helpers' ;
76import SuspenseSpinner from '@/components/elements/SuspenseSpinner' ;
87import TitledGreyBox from '@/components/elements/TitledGreyBox' ;
98import Can from '@/components/elements/Can' ;
10- import PageContentBlock from '@/components/elements/PageContentBlock' ;
119import ContentContainer from '@/components/elements/ContentContainer' ;
1210import tw from 'twin.macro' ;
1311import Button from '@/components/elements/Button' ;
1412import StopOrKillButton from '@/components/server/StopOrKillButton' ;
13+ import ServerContentBlock from '@/components/elements/ServerContentBlock' ;
1514
1615export type PowerAction = 'start' | 'stop' | 'restart' | 'kill' ;
1716
@@ -23,10 +22,13 @@ export default () => {
2322 const [ cpu , setCpu ] = useState ( 0 ) ;
2423 const [ disk , setDisk ] = useState ( 0 ) ;
2524
26- const server = ServerContext . useStoreState ( state => state . server . data ! ) ;
25+ const name = ServerContext . useStoreState ( state => state . server . data ! . name ) ;
26+ const limits = ServerContext . useStoreState ( state => state . server . data ! . limits ) ;
27+ const isInstalling = ServerContext . useStoreState ( state => state . server . data ! . isInstalling ) ;
2728 const status = ServerContext . useStoreState ( state => state . status . value ) ;
2829
29- const { connected, instance } = ServerContext . useStoreState ( state => state . socket ) ;
30+ const connected = ServerContext . useStoreState ( state => state . socket . connected ) ;
31+ const instance = ServerContext . useStoreState ( state => state . socket . instance ) ;
3032
3133 const statsListener = ( data : string ) => {
3234 let stats : any = { } ;
@@ -57,16 +59,13 @@ export default () => {
5759 } ;
5860 } , [ instance , connected ] ) ;
5961
60- const disklimit = server . limits . disk ? megabytesToHuman ( server . limits . disk ) : 'Unlimited' ;
61- const memorylimit = server . limits . memory ? megabytesToHuman ( server . limits . memory ) : 'Unlimited' ;
62+ const disklimit = limits . disk ? megabytesToHuman ( limits . disk ) : 'Unlimited' ;
63+ const memorylimit = limits . memory ? megabytesToHuman ( limits . memory ) : 'Unlimited' ;
6264
6365 return (
64- < PageContentBlock css = { tw `flex` } >
65- < Helmet >
66- < title > { server . name } | Console </ title >
67- </ Helmet >
66+ < ServerContentBlock title = { 'Console' } css = { tw `flex` } >
6867 < div css = { tw `w-1/4` } >
69- < TitledGreyBox title = { server . name } icon = { faServer } >
68+ < TitledGreyBox title = { name } icon = { faServer } >
7069 < p css = { tw `text-xs uppercase` } >
7170 < FontAwesomeIcon
7271 icon = { faCircle }
@@ -90,7 +89,7 @@ export default () => {
9089 < span css = { tw `text-neutral-500` } > / { disklimit } </ span >
9190 </ p >
9291 </ TitledGreyBox >
93- { ! server . isInstalling ?
92+ { ! isInstalling ?
9493 < Can action = { [ 'control.start' , 'control.stop' , 'control.restart' ] } matchAny >
9594 < div css = { tw `shadow-md bg-neutral-700 rounded p-3 flex text-xs mt-4 justify-center` } >
9695 < Can action = { 'control.start' } >
@@ -143,6 +142,6 @@ export default () => {
143142 < ChunkedStatGraphs />
144143 </ SuspenseSpinner >
145144 </ div >
146- </ PageContentBlock >
145+ </ ServerContentBlock >
147146 ) ;
148147} ;
0 commit comments