mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-17 21:40:31 +00:00
c60fab04c1
Users are now able to fetch their user data : Whitelist, Operators, BannedIps, BannedPlayers.
125 lines
5.2 KiB
HTML
125 lines
5.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>API Interaction Form</title>
|
|
</head>
|
|
<body>
|
|
|
|
<h2>Generic Calls</h2>
|
|
<form id="genericForm">
|
|
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>
|
|
Framework: <label for="serverFramework"></label><input type="text" id="serverFramework"><br>
|
|
<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>
|
|
<button type="button" class="actionButton" data-action="FetchServers">Fetch Servers</button>
|
|
<button type="button" class="actionButton" data-action="FetchLogs">Fetch Logs</button>
|
|
<button type="button" class="actionButton" data-action="FetchPlayersStatus">Fetch Players Status</button>
|
|
|
|
</form>
|
|
|
|
<h2>Update Property</h2>
|
|
<form id="updatePropertyForm">
|
|
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>
|
|
<button type="button" class="actionButton" data-action="UpdateProperties">Update Property</button>
|
|
</form>
|
|
|
|
<h2>Send Command</h2>
|
|
<form id="sendCommandForm">
|
|
Command: <label for="command"></label><input type="text" id="command"><br>
|
|
<button type="button" class="actionButton" data-action="Command">Send command</button>
|
|
</form>
|
|
|
|
<h2>Set Subdomain</h2>
|
|
<form id="sendCommandForm">
|
|
Command: <label for="subdomain"></label><input type="text" id="subdomain"><br>
|
|
<button type="button" class="actionButton" data-action="SetSubdomain">Send command</button>
|
|
</form>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
const buttons = document.querySelectorAll('.actionButton');
|
|
|
|
buttons.forEach(button => {
|
|
button.addEventListener('click', async event => {
|
|
const action = button.dataset.action;
|
|
const token = "kPbH7QbrOzTrNcpqTnZGDJfSj3E3";
|
|
const framework = document.getElementById('serverFramework').value;
|
|
const subdomain = document.getElementById('subdomain').value;
|
|
const email = document.getElementById('accountEmail').value;
|
|
const port = document.getElementById('accountPort').value;
|
|
const name = document.getElementById('serverName').value;
|
|
const version = document.getElementById('serverVersion').value;
|
|
const prop = document.getElementById('update_property').value;
|
|
const value = document.getElementById('update_value').value;
|
|
const command = document.getElementById('command').value;
|
|
const props = [[prop, value], ["max-players", "666"]];
|
|
let data = {};
|
|
switch(action) {
|
|
case 'FetchServers':
|
|
data = {token};
|
|
break;
|
|
case 'FetchLogs':
|
|
data = {token, name};
|
|
break;
|
|
case 'FetchPlayersStatus':
|
|
data = {token, name};
|
|
break;
|
|
case 'AccountCreate':
|
|
data = {email, port, token};
|
|
break;
|
|
case 'AccountDelete':
|
|
data = {subdomain, port, token};
|
|
break;
|
|
case 'ServerCreate':
|
|
data = {port, name, version, token, framework};
|
|
break;
|
|
case 'ServerDelete':
|
|
data = {port, name, token};
|
|
break;
|
|
case 'ServerRun':
|
|
data = {port, name, token};
|
|
break;
|
|
case 'ServerStop':
|
|
data = {port, name, token};
|
|
break;
|
|
case 'UpdateProperties':
|
|
data = {port, name, props, value, token};
|
|
break;
|
|
case 'Command':
|
|
data = {port, name, command, token};
|
|
break;
|
|
case 'SetSubdomain':
|
|
data = {token, subdomain}
|
|
break;
|
|
}
|
|
sendRequest(action, data)
|
|
.then(response => response.text())
|
|
.then(data => alert(`Response: ${data}`))
|
|
.catch(error => console.error('Error:', error));
|
|
});
|
|
});
|
|
|
|
function sendRequest(endpoint, payload) {
|
|
return fetch(`http://localhost:3000/${endpoint}`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify(payload)
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|