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.
* Update README.md (#31) * added workflows * Update pull_request.yml (#38) * Update pull_request.yml * Update pull_request.yml * Add steamcmdpath config variable (#41) * added steamCMDPath config var for install * enhanced return val check steamCMD can return non null return value without failing * added better server state control * added support for spaces in server path wouldn't install to correct path because i had spaces in my username e.g.: C://Users/jens van de wiel the above would result in a error * initial version * added event when server exits outside of app * added confirmation modal for force stop * Update Server.tsx * Update README.md (#44) * Update README.md (#45) * Added button to open server files next to profile name (#47) * Revert "Added button to open server files next to profile name (#47)" This reverts commit a85bc58. * Revert "Update README.md (#45)" This reverts commit 0888303. * Revert "Update README.md (#44)" This reverts commit 6aa9a01. * Revert "added better server state control" This reverts commit 7b65ab8. * Revert "Add steamcmdpath config variable (#41)" This reverts commit 4ef591f. * Revert "Update pull_request.yml (#38)" This reverts commit 604eaba. * Revert "added workflows" This reverts commit 8ba0994. * Revert "Update README.md (#31)" This reverts commit ba504bf. * added parsing for servermap * re-ordered server tabs * added onServerStart event * tab refactoring * added basic console layout * inherit serverstatus from parent * added basic terminal * added rcon console * refactored to do it the react way ;) * cleaned code * refacored it more into the react way * use one definition type * fix spacing --------- Co-authored-by: pepijn <[email protected]> Co-authored-by: Ivan Oonincx <[email protected]>
- Loading branch information
1 parent
f9066fa
commit 05535e7
Showing
11 changed files
with
163 additions
and
20 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,9 @@ | ||
import {TabPanel} from "@mui/joy"; | ||
|
||
export function Administration() { | ||
return ( | ||
<TabPanel value={2} className={''}> | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { Button, Input, TabPanel } from "@mui/joy"; | ||
import React, { useEffect, useRef, useState } from "react"; | ||
import { server } from "../../../wailsjs/go/models"; | ||
import { SendRconCommand } from "../../../wailsjs/go/helpers/HelpersController"; | ||
|
||
type Message = { | ||
text: string; | ||
sender: string; | ||
}; | ||
|
||
type Props = { | ||
setServ: React.Dispatch<React.SetStateAction<server.Server>>; | ||
serv: server.Server; | ||
serverStatus: boolean; | ||
}; | ||
|
||
export function Console({ setServ, serv, serverStatus }: Props) { | ||
const [input, setInput] = useState(""); | ||
const [messages, setMessages] = useState<Message[]>([]); | ||
|
||
const terminalRef = useRef<HTMLDivElement>(null); | ||
|
||
const writeToConsole = (text: string, sender: string = "user") => { | ||
const newMessage: Message = { text, sender }; | ||
setMessages((prevMessages) => [...prevMessages, newMessage]); | ||
}; | ||
|
||
const doRconCommand = (text: string) => { | ||
SendRconCommand(text, serv.ipAddress, serv.rconPort, serv.adminPassword) | ||
.then((resp) => writeToConsole(resp, "server")) | ||
.catch((err) => writeToConsole("error sending command: " + err, "server")); | ||
}; | ||
|
||
useEffect(() => { | ||
if (terminalRef.current) { | ||
terminalRef.current.scrollTop = terminalRef.current.scrollHeight; | ||
} | ||
}, [messages]); | ||
|
||
if (serverStatus) { | ||
return ( | ||
<TabPanel value={0}> | ||
<div | ||
id={"terminal"} | ||
ref={terminalRef} | ||
className={"overflow-y-scroll font-jetbrains bg-black w-[100%] h-[50vh] p-4 rounded "} | ||
> | ||
{messages.map((message, index) => ( | ||
<div key={index}> | ||
{message.sender === "server" ? ( | ||
<span>{message.text}<br /></span> | ||
) : ( | ||
<span> | ||
<span style={{ color: "blue" }}>[{message.sender}]</span>{" "} | ||
<span style={{ color: "green" }}>$</span> {message.text}<br /> | ||
</span> | ||
)} | ||
</div> | ||
))} | ||
</div> | ||
<Input | ||
className={"my-2 font-jetbrains"} | ||
value={input} | ||
onChange={(e) => setInput(e.target.value)} | ||
startDecorator={<span className={"text-green-400"}>$</span>} | ||
endDecorator={ | ||
<Button | ||
color={"neutral"} | ||
onClick={(e) => { | ||
writeToConsole(input); | ||
setInput(""); | ||
doRconCommand(input); | ||
}} | ||
className={"m-1"} | ||
> | ||
Send | ||
</Button> | ||
} | ||
onKeyPress={(e) => { | ||
if (e.key === "Enter") { | ||
writeToConsole(input, "user"); | ||
doRconCommand(input); | ||
setInput(""); | ||
} | ||
}} | ||
></Input> | ||
</TabPanel> | ||
); | ||
} else { | ||
return ( | ||
<TabPanel value={0}> | ||
<div className={"h-16 flex w-full"}> | ||
<p className={"text-lg font-bold ml-8"}>Server is not running</p> | ||
</div> | ||
</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 was deleted.
Oops, something went wrong.
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
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,22 @@ | ||
package helpers | ||
|
||
import ( | ||
"fmt" | ||
"github.com/gorcon/rcon" | ||
"strconv" | ||
) | ||
|
||
func (c *HelpersController) SendRconCommand(command string, ip string, port int, password string) (string, error) { | ||
conn, err := rcon.Dial(ip+":"+strconv.Itoa(port), password) | ||
if err != nil { | ||
return "", fmt.Errorf("failed connectting to rcon server: %v", err) | ||
} | ||
defer conn.Close() | ||
|
||
response, err := conn.Execute(command) | ||
if err != nil { | ||
return "", fmt.Errorf("failed executing rcon command: %v", err) | ||
} | ||
|
||
return response, nil | ||
} |
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