File tree Expand file tree Collapse file tree 1 file changed +33
-3
lines changed
resources/scripts/components/server Expand file tree Collapse file tree 1 file changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ export default () => {
3737 setCpu ( stats . cpu_absolute ) ;
3838 } ;
3939
40+ const sendPowerCommand = ( command : 'start' | 'stop' | 'restart' | 'kill' ) => {
41+ instance && instance . send ( 'set state' , command ) ;
42+ } ;
43+
4044 useEffect ( ( ) => {
4145 if ( ! connected || ! instance ) {
4246 return ;
@@ -91,9 +95,35 @@ export default () => {
9195 </ div >
9296 </ div >
9397 < GreyBox className = { 'justify-center' } >
94- < button className = { 'btn btn-secondary btn-xs mr-2' } > Start</ button >
95- < button className = { 'btn btn-secondary btn-xs mr-2' } > Restart</ button >
96- < button className = { 'btn btn-red btn-xs' } > Stop</ button >
98+ < button
99+ className = { 'btn btn-secondary btn-xs mr-2' }
100+ disabled = { status !== 'offline' }
101+ onClick = { e => {
102+ e . preventDefault ( ) ;
103+ sendPowerCommand ( 'start' ) ;
104+ } }
105+ >
106+ Start
107+ </ button >
108+ < button
109+ className = { 'btn btn-secondary btn-xs mr-2' }
110+ onClick = { e => {
111+ e . preventDefault ( ) ;
112+ sendPowerCommand ( 'restart' ) ;
113+ } }
114+ >
115+ Restart
116+ </ button >
117+ < button
118+ className = { 'btn btn-red btn-xs' }
119+ disabled = { status === 'offline' }
120+ onClick = { e => {
121+ e . preventDefault ( ) ;
122+ sendPowerCommand ( status === 'stopping' ? 'kill' : 'stop' ) ;
123+ } }
124+ >
125+ Stop
126+ </ button >
97127 </ GreyBox >
98128 </ div >
99129 < React . Suspense
You can’t perform that action at this time.
0 commit comments