adding virtual console ajax to actually send the command

This commit is contained in:
Phillip Tarrant 2020-09-21 22:01:16 -04:00
parent e4cc400d20
commit 7657b77785
3 changed files with 23 additions and 1 deletions

View File

@ -74,4 +74,25 @@ class AjaxHandler(BaseHandler):
logger.warning("Skipping Log Line due to error: {}".format(e))
pass
def post(self, page):
user_data = json.loads(self.get_secure_cookie("user_data"))
error = bleach.clean(self.get_argument('error', "WTF Error!"))
page_data = {
'user_data': user_data,
'error': error
}
if page == "send_command":
command = bleach.clean(self.get_body_argument('command', default=None, strip=True))
server_id = bleach.clean(self.get_argument('id'))
if server_id is None:
logger.warning("Server ID not found in send_command ajax call")
srv_obj = controller.get_server_obj(server_id)
if command:
if srv_obj.check_running():
srv_obj.send_command(command)

View File

@ -1,5 +1,5 @@
{
"last_refreshed": "09/17/2020, 18:43:17",
"last_refreshed": "09/21/2020, 21:59:31",
"servers": {
"nukkitx": [
"1.14"

View File

@ -75,6 +75,7 @@
<div class="input-group">
<input type="text" class="form-control" id="server_command" name="server_command" placeholder="Enter your server command" autofocus="">
<span class="input-group-btn ml-5">
<input type="hidden" value="" id="last_command"/>
<button id="submit" class="btn btn-sm btn-info" type="button">Send Command</button>
</span>
</div>