This repository has been archived by the owner on Mar 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a command page, two commands have been added as of now:
- DestroyWildDinos - SaveWorld There is the possibility for expansion in the future. Though, additional commands may require an input box for args. Closes #86
- Loading branch information
Jordan Dalby
committed
Nov 16, 2023
1 parent
75514ee
commit c7bfaa4
Showing
4 changed files
with
94 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { | ||
Button, | ||
Divider, | ||
Typography, | ||
Card, | ||
TabPanel | ||
} from "@mui/joy"; | ||
import {server} from "../../../wailsjs/go/models"; | ||
import React from "react"; | ||
import { | ||
IssueRCONCommand | ||
} from "../../../wailsjs/go/server/ServerController"; | ||
import {useAlert} from "../../components/AlertProvider"; | ||
|
||
type Props = { | ||
setServ: React.Dispatch<React.SetStateAction<server.Server>> | ||
serv: server.Server; | ||
serverStatus: boolean; | ||
} | ||
|
||
export function CommandsCard({ setServ, serv, serverStatus }: Props) { | ||
|
||
const {addAlert} = useAlert() | ||
|
||
function onCommandButtonPressed(command: string) { | ||
addAlert("Running command '" + command + "'", "neutral") | ||
IssueRCONCommand(serv.id, command).then(() => addAlert("RCON command ran successfully", "success")).catch((err) => addAlert("error running command: " + err, "danger")); | ||
} | ||
|
||
return ( | ||
<Card variant="soft" className={''}> | ||
<Typography level="title-md"> | ||
Commands | ||
</Typography> | ||
<Divider className={'mx-2'}/> | ||
|
||
<div className={'space-x-4 w-full flex'}> | ||
<div className={'inline-block'}> | ||
<Button color={'neutral'} variant="solid" disabled={!serverStatus} onClick={()=>onCommandButtonPressed("destroywilddinos")}>Dino Wipe</Button> | ||
</div> | ||
<div className={'inline-block'}> | ||
<Button color={'neutral'} variant="solid" disabled={!serverStatus} onClick={()=>onCommandButtonPressed("saveworld")}>Save World</Button> | ||
</div> | ||
</div> | ||
</Card> | ||
); | ||
} | ||
|
||
export function Commands({setServ, serv, serverStatus }: Props) { | ||
return ( | ||
<TabPanel value={4} className={'space-y-8'}> | ||
<CommandsCard setServ={setServ} serv={serv} serverStatus={serverStatus}/> | ||
</TabPanel> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters