Merge pull request #1913 from Sir3lit/patch2

Add Disk display to console view
This commit is contained in:
Dane Everitt 2020-04-12 10:11:53 -07:00 committed by GitHub
commit d6ac0c3202
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import { faCircle } from '@fortawesome/free-solid-svg-icons/faCircle';
import classNames from 'classnames'; import classNames from 'classnames';
import { faMemory } from '@fortawesome/free-solid-svg-icons/faMemory'; import { faMemory } from '@fortawesome/free-solid-svg-icons/faMemory';
import { faMicrochip } from '@fortawesome/free-solid-svg-icons/faMicrochip'; import { faMicrochip } from '@fortawesome/free-solid-svg-icons/faMicrochip';
import { faHdd } from '@fortawesome/free-solid-svg-icons/faHdd';
import { bytesToHuman } from '@/helpers'; import { bytesToHuman } from '@/helpers';
import SuspenseSpinner from '@/components/elements/SuspenseSpinner'; import SuspenseSpinner from '@/components/elements/SuspenseSpinner';
import TitledGreyBox from '@/components/elements/TitledGreyBox'; import TitledGreyBox from '@/components/elements/TitledGreyBox';
@ -42,6 +43,7 @@ const StopOrKillButton = ({ onPress }: { onPress: (action: PowerAction) => void
export default () => { export default () => {
const [ memory, setMemory ] = useState(0); const [ memory, setMemory ] = useState(0);
const [ cpu, setCpu ] = useState(0); const [ cpu, setCpu ] = useState(0);
const [ disk, setDisk ] = useState(0);
const server = ServerContext.useStoreState(state => state.server.data!); const server = ServerContext.useStoreState(state => state.server.data!);
const status = ServerContext.useStoreState(state => state.status.value); const status = ServerContext.useStoreState(state => state.status.value);
@ -58,6 +60,7 @@ export default () => {
setMemory(stats.memory_bytes); setMemory(stats.memory_bytes);
setCpu(stats.cpu_absolute); setCpu(stats.cpu_absolute);
setDisk(stats.disk_bytes);
}; };
const sendPowerCommand = (command: PowerAction) => { const sendPowerCommand = (command: PowerAction) => {
@ -92,6 +95,14 @@ export default () => {
/> />
 {status}  {status}
</p> </p>
<p className={'text-xs mt-2'}>
<FontAwesomeIcon
icon={faMicrochip}
fixedWidth={true}
className={'mr-1'}
/>
&nbsp;{cpu.toFixed(2)} %
</p>
<p className={'text-xs mt-2'}> <p className={'text-xs mt-2'}>
<FontAwesomeIcon <FontAwesomeIcon
icon={faMemory} icon={faMemory}
@ -103,11 +114,12 @@ export default () => {
</p> </p>
<p className={'text-xs mt-2'}> <p className={'text-xs mt-2'}>
<FontAwesomeIcon <FontAwesomeIcon
icon={faMicrochip} icon={faHdd}
fixedWidth={true} fixedWidth={true}
className={'mr-1'} className={'mr-1'}
/> />
&nbsp;{cpu.toFixed(2)} % &nbsp;{bytesToHuman(disk)}
<span className={'text-neutral-500'}>/ {server.limits.disk} MB</span>
</p> </p>
</TitledGreyBox> </TitledGreyBox>
<Can action={[ 'control.start', 'control.stop', 'control.restart' ]} matchAny={true}> <Can action={[ 'control.start', 'control.stop', 'control.restart' ]} matchAny={true}>