Add power controls
This commit is contained in:
parent
33f306d40b
commit
5df46b23d2
1 changed files with 33 additions and 3 deletions
|
@ -37,6 +37,10 @@ export default () => {
|
||||||
setCpu(stats.cpu_absolute);
|
setCpu(stats.cpu_absolute);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const sendPowerCommand = (command: 'start' | 'stop' | 'restart' | 'kill') => {
|
||||||
|
instance && instance.send('set state', command);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!connected || !instance) {
|
if (!connected || !instance) {
|
||||||
return;
|
return;
|
||||||
|
@ -91,9 +95,35 @@ export default () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<GreyBox className={'justify-center'}>
|
<GreyBox className={'justify-center'}>
|
||||||
<button className={'btn btn-secondary btn-xs mr-2'}>Start</button>
|
<button
|
||||||
<button className={'btn btn-secondary btn-xs mr-2'}>Restart</button>
|
className={'btn btn-secondary btn-xs mr-2'}
|
||||||
<button className={'btn btn-red btn-xs'}>Stop</button>
|
disabled={status !== 'offline'}
|
||||||
|
onClick={e => {
|
||||||
|
e.preventDefault();
|
||||||
|
sendPowerCommand('start');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Start
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className={'btn btn-secondary btn-xs mr-2'}
|
||||||
|
onClick={e => {
|
||||||
|
e.preventDefault();
|
||||||
|
sendPowerCommand('restart');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Restart
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className={'btn btn-red btn-xs'}
|
||||||
|
disabled={status === 'offline'}
|
||||||
|
onClick={e => {
|
||||||
|
e.preventDefault();
|
||||||
|
sendPowerCommand(status === 'stopping' ? 'kill' : 'stop');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Stop
|
||||||
|
</button>
|
||||||
</GreyBox>
|
</GreyBox>
|
||||||
</div>
|
</div>
|
||||||
<React.Suspense
|
<React.Suspense
|
||||||
|
|
Loading…
Add table
Reference in a new issue