added server state option

This commit is contained in:
ACoolName 2024-05-27 22:26:26 +03:00
parent cda0d0a159
commit 36659fea46
3 changed files with 26 additions and 13 deletions

View File

@ -442,16 +442,8 @@ export const SERVER_ACTIONS: ActionInfo[] = [
requestType: "post",
endpoint: "/servers/{server_id}/start",
permissions: Permission.Start,
response_action: "Ignore"
},
{
name: "Terminal",
args: {
},
requestType: "post",
endpoint: "/servers/{server_id}/attach",
permissions: Permission.RunCommand,
response_action: "Terminal"
response_action: "Ignore",
ServerState: "off",
},
{
name: "Stop",
@ -465,7 +457,18 @@ export const SERVER_ACTIONS: ActionInfo[] = [
requestType: "post",
endpoint: "/servers/{server_id}/stop",
permissions: Permission.Stop,
response_action: "Ignore"
response_action: "Ignore",
ServerState: "on",
},
{
name: "Terminal",
args: {
},
requestType: "post",
endpoint: "/servers/{server_id}/attach",
permissions: Permission.RunCommand,
response_action: "Terminal",
ServerState: "on",
},
{
name: "Delete Server",
@ -500,7 +503,8 @@ export const SERVER_ACTIONS: ActionInfo[] = [
requestType: "post",
endpoint: "/servers/{server_id}/run_command",
permissions: Permission.RunCommand,
response_action: "Ignore"
response_action: "Ignore",
ServerState: "on",
},
{
name: "Browse",

View File

@ -114,6 +114,7 @@ export interface ActionInfo {
args: {}
permissions?: number
response_action?: 'Ignore' | 'Browse' | 'Terminal'
ServerState?: 'on' | 'off'
}

View File

@ -56,7 +56,15 @@ function ServerItem(props: { server_info: ServerInfo }) {
<TableCell>{props.server_info.Domain}</TableCell>
<TableCell>{props.server_info.Ports.map((port, index, array) => { return <Chip label={`${port.Number}/${port.Protocol}`} /> })}</TableCell>
<TableCell>
<ActionGroup actions={actions} identifierSubstring="server_id" />
<ActionGroup actions={actions.filter((value, _, _)=>{
switch (value.ServerState){
case undefined:
return true
case "off":
return !props.server_info.On
case "on":
return props.server_info.On
}})} identifierSubstring="server_id" />
</TableCell>
</TableRow>
</actionIdentifierContext.Provider>