draft: devWeb - Add informations of connected users

This commit is contained in:
kmitresse
2024-04-27 16:03:15 +02:00
parent e2aaefe3a4
commit af0ac4dedd
3 changed files with 46 additions and 11 deletions
@@ -6,9 +6,18 @@ public class SimpleUser {
private final int id; private final int id;
private final String username; private final String username;
private final int nbPlayedGames;
private final int nbWin;
private final double rigthClickPercentRate;
private final double rapidClickPercentRate;
public SimpleUser(User user) { public SimpleUser(User user) {
this.id = user.getId().intValue(); this.id = user.getId().intValue();
this.username = user.getUsername(); this.username = user.getUsername();
this.nbPlayedGames = user.getNbPlayedGame();
this.nbWin = user.getNbWin();
this.rigthClickPercentRate = user.getRightClickPercentRate();
this.rapidClickPercentRate = user.getRapidClickPercentRate();
} }
public int getId() { public int getId() {
@@ -18,4 +27,20 @@ public class SimpleUser {
public String getUsername() { public String getUsername() {
return username; return username;
} }
public int getNbPlayedGames() {
return nbPlayedGames;
}
public int getNbWin() {
return nbWin;
}
public double getRigthClickPercentRate() {
return rigthClickPercentRate;
}
public double getRapidClickPercentRate() {
return rapidClickPercentRate;
}
} }
@@ -10,12 +10,12 @@
<component:card title="Menu principal"> <component:card title="Menu principal">
<ul> <ul>
<li><a href="${pageContext.request.contextPath}/new">Nouvelle partie</a></li> <li><a href="${pageContext.request.contextPath}/new">Nouvelle partie</a></li>
<li><a href="${pageContext.request.contextPath}/join">Rejoindre une partie</a></li> <%-- <li><a href="${pageContext.request.contextPath}/join">Rejoindre une partie</a></li>--%>
</ul> </ul>
</component:card> </component:card>
</div> </div>
<div class="column"> <div class="column">
<component:card> <component:card title="Utilisateurs connectés">
<component:connected-user-list/> <component:connected-user-list/>
</component:card> </component:card>
</div> </div>
@@ -8,7 +8,9 @@
<table id="connected-user-list" class="table is-fullwidth"> <table id="connected-user-list" class="table is-fullwidth">
<thead> <thead>
<tr> <tr>
<th>Utilisateur</th> <th>Nom d'utilisateur</th>
<th>Nombre de parties jouées</th>
<th>Nombre de victoires</th>
</tr> </tr>
</thead> </thead>
<tbody></tbody> <tbody></tbody>
@@ -27,12 +29,20 @@
// Add the users to the table // Add the users to the table
users.forEach(user => { users.forEach(user => {
const tr = document.createElement('tr'); const tr = document.createElement('tr');
const td = document.createElement('td'); const tdUsername = document.createElement('td');
tdUsername.dataset.id = user.id;
tdUsername.textContent = user.username;
const tdNbGames = document.createElement('td');
tdNbGames.dataset.id = user.id;
tdNbGames.textContent = user.nbPlayedGames;
const tdNbWin = document.createElement('td');
tdNbWin.dataset.id = user.id;
tdNbWin.textContent = user.nbWin;
td.dataset.id = user.id;
td.textContent = user.username;
tr.appendChild(td); tr.appendChild(tdUsername);
tr.appendChild(tdNbGames);
tr.appendChild(tdNbWin);
table.appendChild(tr); table.appendChild(tr);
}); });
} }