Improve API response and add a static website at root

This commit is contained in:
Ac_K 2020-08-16 19:57:30 +02:00
commit 7afd8032a8
3 changed files with 184 additions and 0 deletions

94
index.html Normal file
View file

@ -0,0 +1,94 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
<title>Ryujinx Ldn</title>
</head>
<body>
<div class="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 navbar shadow">
<h5 class="my-0 mr-md-auto font-weight-normal"><img class="mb-2" src="https://ryujinx.org/public/logo.png" alt="" width="30" height="30"> Ryujinx Ldn</h5>
<nav class="my-2 my-md-0 mr-md-3">
<u>State :</u> <i class="online-dot fas fa-circle"></i> Online
</nav>
</div>
<div class="intro-header px-3 py-3 pt-md-5 pb-md-4 mx-auto text-center">
<h1 class="display-4">Status</h1>
<p class="lead">Multiplayer statistics for Ryujinx local wireless game connection.</p>
</div>
<div class="container">
<div class="row">
<div class="col-sm-5">
<div class="card shadow">
<div class="card-header">
<h4 class="my-0 font-weight-normal"><i class="fas fa-users"></i> Who is online ?</h4>
</div>
<div class="card-body">
<div class="container main-stats"></div>
</div>
</div>
</div>
<div class="col-sm-7">
<div class="card shadow">
<div class="card-header">
<h4 class="my-0 font-weight-normal"><i class="fas fa-network-wired"></i> Hosted Games</h4>
</div>
<div class="card-body public-games">
<table class="table">
<thead>
<tr>
<th>Game</th>
<th>Players</th>
<th>State</th>
</tr>
</thead>
<tbody class="games-table">
</tbody>
</table>
</div>
</div>
</div>
</div>
<footer class="pt-4 my-md-5 pt-md-5 border-top">
<div class="row">
<div class="col-12 col-md">
<img class="mb-2" src="https://ryujinx.org/public/logo.png" alt="" width="48" height="48">
<small class="d-block mb-3 text-muted">&copy; 20XX</small>
</div>
<div class="col-6 col-md">
<h5>Project</h5>
<ul class="list-unstyled text-small">
<li><a class="text-muted" href="https://ryujinx.org/" target="_blank">Website</a></li>
<li><a class="text-muted" href="https://blog.ryujinx.org/" target="_blank">Blog</a></li>
<li><a class="text-muted" href="https://ryujinx.org/contribute" target="_blank">Contribute</a></li>
</ul>
</div>
<div class="col-6 col-md">
<h5>Resources</h5>
<ul class="list-unstyled text-small">
<li><a class="text-muted" href="https://ryujinx.org/download" target="_blank">Download</a></li>
<li><a class="text-muted" href="https://github.com/Ryujinx/Ryujinx-Games-List/issues" target="_blank">Compatibily</a></li>
<li><a class="text-muted" href="https://github.com/Ryujinx/Ryujinx/wiki/Ryujinx-Setup-&-Configuration-Guide" target="_blank">Setup & Configuration Guide</a></li>
</ul>
</div>
<div class="col-6 col-md">
<h5>Social</h5>
<ul class="list-unstyled text-small">
<li><a class="text-muted" href="https://patreon.com/Ryujinx" target="_blank">Patreon</a></li>
<li><a class="text-muted" href="https://github.com/Ryujinx/Ryujinx" target="_blank">GitHub</a></li>
<li><a class="text-muted" href="https://twitter.com/RyujinxEmu" target="_blank">Twitter</a></li>
<li><a class="text-muted" href="https://discord.gg/VkQYXAZ" target="_blank">Discord</a></li>
</ul>
</div>
</div>
</footer>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/js/all.min.js" integrity="sha256-KzZiKy0DWYsnwMF+X1DvQngQ2/FxF7MF3Ff72XcpuPs=" crossorigin="anonymous"></script>
<script src="main.js"></script>
</body>
</html>

20
main.js Normal file
View file

@ -0,0 +1,20 @@
$(document).ready(function() {
$.getJSON("/api", function(data) {
$(".main-stats").append('<div class="row"><div class="col-1"><i class="fas fa-user"></i></div><div class="col-6">Public Players</div><div class="col-4 text-right">' + data.public_players_count + '</div></div>');
$(".main-stats").append('<div class="row"><div class="col-1"><i class="fas fa-user-secret"></i></div><div class="col-6">Private Players</div><div class="col-4 text-right">' + data.private_players_count + '</div></div>');
$(".main-stats").append('<div class="row"><div class="col-1"><i class="fas fa-users"></i></div><div class="col-6">Total Players</div><div class="col-4 text-right">' + data.total_players_count + '</div></div>');
$(".main-stats").append('<div class="row row-space"></div>');
$(".main-stats").append('<div class="row"><div class="col-1"><i class="fas fa-gamepad"></i></div><div class="col-6">Public Games</div><div class="col-4 text-right">' + data.public_games_count + '</div></div>');
$(".main-stats").append('<div class="row"><div class="col-1"><i class="fas fa-lock"></i></div><div class="col-6">Private Games</div><div class="col-4 text-right">' + data.private_games_count + '</div></div>');
$(".main-stats").append('<div class="row"><div class="col-1"><i class="fas fa-layer-group"></i></div><div class="col-6">Total Games</div><div class="col-4 text-right">' + data.total_games_count + '</div></div>');
$(".main-stats").append('<div class="row row-space"></div>');
$(".main-stats").append('<div class="row"><div class="col-1"><i class="fas fa-people-arrows"></i></div><div class="col-6">In Connection</div><div class="col-4 text-right">' + data.in_progress_count + '</div></div>');
$(".main-stats").append('<div class="row"><div class="col-1"><i class="fas fa-server"></i></div><div class="col-6">On Proxy Server</div><div class="col-4 text-right">' + data.master_proxy_count + '</div></div>');
});
$.getJSON("/api/public_games", function(data) {
$.each(data, function() {
$(".games-table").append('<tr><th><i class="fas fa-gamepad"></i> ' + this.game_name + '<br /><span class="titleid">(' + this.title_id + ')</span></th><td>' + this.player_count + '/' + this.max_player_count + ' <i class="fas fa-users"></i><br />' + this.players.join(', ') + '</td><td><i class="fas fa-network-wired"></i> ' + this.mode + ' (' + this.status + ')</td></tr>');
});
});
});

70
style.css Normal file
View file

@ -0,0 +1,70 @@
html {
font-size: 14px;
}
body {
background-color: #303036 !important;
color: #FFFFFF;
}
.navbar {
background-color: #303036;
}
table {
color: #FFFFFF !important;
}
.public-games {
height: 300px;
overflow-y: scroll;
}
.display-4, .font-weight-normal {
font-weight: 500 !important;
}
.container {
max-width: 1280px;
}
.intro-header {
max-width: 700px;
}
.card {
border: none !important;
}
.card-header {
background-color: #47474e !important;
}
.card-body {
background-color: #515159;
}
.row-space { height: 15px; }
.main-stats .col-4 {
padding-right: 0;
}
.main-stats .row {
margin-right: -30px;
}
.titleid {
font-size: 12px;
font-weight: normal;
}
.online-dot {
color: #4bd6d1;
}
@media (min-width: 768px) {
html {
font-size: 16px;
}
}