mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-18 05:50:31 +00:00
[V2+] api_sender.html
Signed-off-by: Charles Le Maux <charles.le-maux@epitech.eu>
This commit is contained in:
parent
cac649c013
commit
7704818f6f
@ -18,6 +18,7 @@
|
|||||||
<button type="button" class="actionButton" data-action="ServerDelete">Delete 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="ServerRun">Start Server</button>
|
||||||
<button type="button" class="actionButton" data-action="ServerStop">Stop Server</button>
|
<button type="button" class="actionButton" data-action="ServerStop">Stop Server</button>
|
||||||
|
<button type="button" class="actionButton" data-action="FetchServers">Fetch Servers</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<h2>Update Property</h2>
|
<h2>Update Property</h2>
|
||||||
@ -33,6 +34,12 @@
|
|||||||
<button type="button" class="actionButton" data-action="Command">Send command</button>
|
<button type="button" class="actionButton" data-action="Command">Send command</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<h2>Set Subdomain</h2>
|
||||||
|
<form id="sendCommandForm">
|
||||||
|
Command: <input type="text" id="subdomain"><br>
|
||||||
|
<button type="button" class="actionButton" data-action="SetSubdomain">Send command</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const forms = document.querySelectorAll('form');
|
const forms = document.querySelectorAll('form');
|
||||||
@ -42,6 +49,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
button.addEventListener('click', async event => {
|
button.addEventListener('click', async event => {
|
||||||
const form = event.target.closest('form');
|
const form = event.target.closest('form');
|
||||||
const action = button.dataset.action;
|
const action = button.dataset.action;
|
||||||
|
const token = "gqZN3eCHF3V2er3Py3rlgk8u2t83";
|
||||||
|
const framework = "paper"
|
||||||
|
const subdomain = document.getElementById('subdomain').value;
|
||||||
const email = document.getElementById('accountEmail').value;
|
const email = document.getElementById('accountEmail').value;
|
||||||
const port = document.getElementById('accountPort').value;
|
const port = document.getElementById('accountPort').value;
|
||||||
const name = document.getElementById('serverName').value;
|
const name = document.getElementById('serverName').value;
|
||||||
@ -49,31 +59,37 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
const prop = document.getElementById('update_property').value;
|
const prop = document.getElementById('update_property').value;
|
||||||
const value = document.getElementById('update_value').value;
|
const value = document.getElementById('update_value').value;
|
||||||
const command = document.getElementById('command').value;
|
const command = document.getElementById('command').value;
|
||||||
var data = {}
|
let data = {};
|
||||||
switch(action) {
|
switch(action) {
|
||||||
|
case 'FetchServers':
|
||||||
|
data = {token};
|
||||||
|
break;
|
||||||
case 'AccountCreate':
|
case 'AccountCreate':
|
||||||
data = {email, port}
|
data = {email, port, token};
|
||||||
break;
|
break;
|
||||||
case 'AccountDelete':
|
case 'AccountDelete':
|
||||||
data = {email, port}
|
data = {subdomain, port, token};
|
||||||
break;
|
break;
|
||||||
case 'ServerCreate':
|
case 'ServerCreate':
|
||||||
data = {port, name, version}
|
data = {port, name, version, token, framework};
|
||||||
break;
|
break;
|
||||||
case 'ServerDelete':
|
case 'ServerDelete':
|
||||||
data = {port, name}
|
data = {port, name, token};
|
||||||
break;
|
break;
|
||||||
case 'ServerRun':
|
case 'ServerRun':
|
||||||
data = {port, name}
|
data = {port, name, token};
|
||||||
break;
|
break;
|
||||||
case 'ServerStop':
|
case 'ServerStop':
|
||||||
data = {port, name}
|
data = {port, name, token};
|
||||||
break;
|
break;
|
||||||
case 'UpdateProperty':
|
case 'UpdateProperty':
|
||||||
data = {port, name, prop, value}
|
data = {port, name, prop, value, token};
|
||||||
break;
|
break;
|
||||||
case 'Command':
|
case 'Command':
|
||||||
data = {port, name, command}
|
data = {port, name, command, token};
|
||||||
|
break;
|
||||||
|
case 'SetSubdomain':
|
||||||
|
data = {token, subdomain}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sendRequest(action, data)
|
sendRequest(action, data)
|
||||||
@ -84,7 +100,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function sendRequest(endpoint, payload) {
|
function sendRequest(endpoint, payload) {
|
||||||
return fetch(`http://localhost:3005/${endpoint}`, {
|
return fetch(`http://localhost:3000/${endpoint}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
Loading…
Reference in New Issue
Block a user