/* An admin page (only available to admin users, of course) */
app.get('/admin/', auth_admin, (request, response) => {
- let active = 0;
- let idle = 0;
+ let active = [];
+ let idle = [];
for (let id in lmno.ids) {
if (lmno.ids[id].game.clients.length)
- active++;
- else
- idle++;
+ active.push(lmno.ids[id]);
+ else
+ idle.push(lmno.ids[id]);
}
- response.send(`<html><body>Active games: ${active}.<br>
-Idle games: ${idle}</body></html>`);
+ response.render('admin.html', { test: "foobar", games: { active: active, idle: idle}});
});
--- /dev/null
+{% extends "base.html" %}
+
+{% block page %}
+<h1>
+ LMNO Admin
+</h1>
+
+<h2>
+ Active games
+</h2>
+
+<ul>
+ {% for game in games.active %}
+ <li>
+ {{ game.id }} ({{ game.game.clients.length }}/{{ game.game._players.length }} active)
+ {% for player in game.game._players %}
+ {{ player.name }}
+ {% endfor %}
+ </li>
+ {% endfor %}
+</ul>
+
+<h2>
+ Idle games
+</h2>
+
+<ul>
+ {% for game in games.idle %}
+ <li>
+ {{ game.id }} ({{ game.game._players.length }} active)
+ {% for player in game.game._players %}
+ {{ player.name }}
+ {% endfor %}
+ </li>
+ {% endfor %}
+</ul>
+{% endblock %}