2024-06-14 21:33:55 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<title>API Interaction Form</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<h2>Generic Calls</h2>
|
|
|
|
<form id="genericForm">
|
2024-07-01 13:42:28 +00:00
|
|
|
Email: <label for="accountEmail"></label><input type="text" id="accountEmail"><br>
|
|
|
|
Port: <label for="accountPort"></label><input type="number" id="accountPort"><br>
|
|
|
|
Name: <label for="serverName"></label><input type="text" id="serverName"><br>
|
|
|
|
Version: <label for="serverVersion"></label><input type="text" id="serverVersion"><br>
|
2024-08-15 10:07:45 +00:00
|
|
|
Framework: <label for="serverFramework"></label><input type="text" id="serverFramework"><br>
|
2024-06-14 21:33:55 +00:00
|
|
|
<button type="button" class="actionButton" data-action="AccountCreate">Create Account</button>
|
|
|
|
<button type="button" class="actionButton" data-action="AccountDelete">Delete Account</button>
|
|
|
|
<button type="button" class="actionButton" data-action="ServerCreate">Create Server</button>
|
|
|
|
<button type="button" class="actionButton" data-action="ServerDelete">Delete Server</button>
|
|
|
|
<button type="button" class="actionButton" data-action="ServerRun">Start Server</button>
|
|
|
|
<button type="button" class="actionButton" data-action="ServerStop">Stop Server</button>
|
2024-06-25 22:15:44 +00:00
|
|
|
<button type="button" class="actionButton" data-action="FetchServers">Fetch Servers</button>
|
2024-08-15 10:07:45 +00:00
|
|
|
<button type="button" class="actionButton" data-action="FetchLogs">Fetch Logs</button>
|
2024-08-24 11:23:23 +00:00
|
|
|
<button type="button" class="actionButton" data-action="FetchPlayersStatus">Fetch Players Status</button>
|
2024-08-15 10:07:45 +00:00
|
|
|
|
2024-06-14 21:33:55 +00:00
|
|
|
</form>
|
|
|
|
|
|
|
|
<h2>Update Property</h2>
|
|
|
|
<form id="updatePropertyForm">
|
2024-07-01 13:42:28 +00:00
|
|
|
Property: <label for="update_property"></label><input type="text" id="update_property"><br>
|
|
|
|
Value: <label for="update_value"></label><input type="text" id="update_value"><br>
|
2024-07-08 20:05:07 +00:00
|
|
|
<button type="button" class="actionButton" data-action="UpdateProperties">Update Property</button>
|
2024-06-14 21:33:55 +00:00
|
|
|
</form>
|
|
|
|
|
|
|
|
<h2>Send Command</h2>
|
|
|
|
<form id="sendCommandForm">
|
2024-07-01 13:42:28 +00:00
|
|
|
Command: <label for="command"></label><input type="text" id="command"><br>
|
2024-06-14 21:33:55 +00:00
|
|
|
<button type="button" class="actionButton" data-action="Command">Send command</button>
|
|
|
|
</form>
|
|
|
|
|
2024-06-25 22:15:44 +00:00
|
|
|
<h2>Set Subdomain</h2>
|
|
|
|
<form id="sendCommandForm">
|
2024-07-01 13:42:28 +00:00
|
|
|
Command: <label for="subdomain"></label><input type="text" id="subdomain"><br>
|
2024-06-25 22:15:44 +00:00
|
|
|
<button type="button" class="actionButton" data-action="SetSubdomain">Send command</button>
|
|
|
|
</form>
|
|
|
|
|
2024-06-14 21:33:55 +00:00
|
|
|
<script>
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
const buttons = document.querySelectorAll('.actionButton');
|
|
|
|
|
|
|
|
buttons.forEach(button => {
|
|
|
|
button.addEventListener('click', async event => {
|
|
|
|
const action = button.dataset.action;
|
2024-08-24 11:23:23 +00:00
|
|
|
const token = "kPbH7QbrOzTrNcpqTnZGDJfSj3E3";
|
2024-07-08 20:05:07 +00:00
|
|
|
const framework = document.getElementById('serverFramework').value;
|
2024-06-25 22:15:44 +00:00
|
|
|
const subdomain = document.getElementById('subdomain').value;
|
2024-06-14 21:33:55 +00:00
|
|
|
const email = document.getElementById('accountEmail').value;
|
|
|
|
const port = document.getElementById('accountPort').value;
|
|
|
|
const name = document.getElementById('serverName').value;
|
|
|
|
const version = document.getElementById('serverVersion').value;
|
2024-06-24 00:50:08 +00:00
|
|
|
const prop = document.getElementById('update_property').value;
|
2024-06-14 21:33:55 +00:00
|
|
|
const value = document.getElementById('update_value').value;
|
|
|
|
const command = document.getElementById('command').value;
|
2024-07-09 17:39:43 +00:00
|
|
|
const props = [[prop, value], ["max-players", "666"]];
|
2024-06-25 22:15:44 +00:00
|
|
|
let data = {};
|
2024-06-14 21:33:55 +00:00
|
|
|
switch(action) {
|
2024-06-25 22:15:44 +00:00
|
|
|
case 'FetchServers':
|
|
|
|
data = {token};
|
|
|
|
break;
|
2024-08-15 10:07:45 +00:00
|
|
|
case 'FetchLogs':
|
|
|
|
data = {token, name};
|
|
|
|
break;
|
2024-08-24 11:23:23 +00:00
|
|
|
case 'FetchPlayersStatus':
|
|
|
|
data = {token, name};
|
|
|
|
break;
|
2024-06-14 21:33:55 +00:00
|
|
|
case 'AccountCreate':
|
2024-06-25 22:15:44 +00:00
|
|
|
data = {email, port, token};
|
2024-06-14 21:33:55 +00:00
|
|
|
break;
|
|
|
|
case 'AccountDelete':
|
2024-06-25 22:15:44 +00:00
|
|
|
data = {subdomain, port, token};
|
2024-06-14 21:33:55 +00:00
|
|
|
break;
|
|
|
|
case 'ServerCreate':
|
2024-06-25 22:15:44 +00:00
|
|
|
data = {port, name, version, token, framework};
|
2024-06-14 21:33:55 +00:00
|
|
|
break;
|
|
|
|
case 'ServerDelete':
|
2024-06-25 22:15:44 +00:00
|
|
|
data = {port, name, token};
|
2024-06-14 21:33:55 +00:00
|
|
|
break;
|
|
|
|
case 'ServerRun':
|
2024-06-25 22:15:44 +00:00
|
|
|
data = {port, name, token};
|
2024-06-14 21:33:55 +00:00
|
|
|
break;
|
|
|
|
case 'ServerStop':
|
2024-06-25 22:15:44 +00:00
|
|
|
data = {port, name, token};
|
2024-06-14 21:33:55 +00:00
|
|
|
break;
|
2024-07-08 20:05:07 +00:00
|
|
|
case 'UpdateProperties':
|
|
|
|
data = {port, name, props, value, token};
|
2024-06-14 21:33:55 +00:00
|
|
|
break;
|
|
|
|
case 'Command':
|
2024-06-25 22:15:44 +00:00
|
|
|
data = {port, name, command, token};
|
|
|
|
break;
|
|
|
|
case 'SetSubdomain':
|
|
|
|
data = {token, subdomain}
|
2024-06-14 21:33:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
sendRequest(action, data)
|
|
|
|
.then(response => response.text())
|
|
|
|
.then(data => alert(`Response: ${data}`))
|
|
|
|
.catch(error => console.error('Error:', error));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
function sendRequest(endpoint, payload) {
|
2024-08-24 11:23:23 +00:00
|
|
|
return fetch(`http://localhost:3000/${endpoint}`, {
|
2024-06-14 21:33:55 +00:00
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify(payload)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|