Correct internal error when guild is not set on rank page

This commit is contained in:
Sebastien 2019-01-02 00:26:00 +01:00
parent 4e9728cbd3
commit c1cc670906
2 changed files with 134 additions and 125 deletions

View File

@ -157,9 +157,14 @@ public class GeneralWebView {
model.addAttribute("redirect_url", System.getenv("OAUTH_URL")); model.addAttribute("redirect_url", System.getenv("OAUTH_URL"));
try { try {
UserEntity userEntity = userUtils.getUserWithApiToken(userRepository, token); UserEntity userEntity = userUtils.getUserWithApiToken(userRepository, token);
addGuildAndRedirect(model, cookieGuildId); GuildStatsPack stack;
if(!cookieGuildId.equals("")){
stack = UserStatsUtils.getINSTANCE().getStatPack(userEntity, cookieGuildId);
addGuildAndRedirect(model, cookieGuildId);
GuildStatsPack stack = UserStatsUtils.getINSTANCE().getStatPack(userEntity, cookieGuildId); }
else
stack = null;
model.addAttribute("stack", stack); model.addAttribute("stack", stack);
return CheckPage.getPageIfReady("rank"); return CheckPage.getPageIfReady("rank");

View File

@ -46,148 +46,152 @@
<main> <main>
<!--/*@thymesVar id="stack" type="net.Broken.Tools.UserManager.Stats.GuildStatsPack"*/--> <!--/*@thymesVar id="stack" type="net.Broken.Tools.UserManager.Stats.GuildStatsPack"*/-->
<div class="row"> <th:block th:if="${stack != null}">
<div class="card-panel col l6 offset-l3 m10 offset-m1 s10 offset-s1 grey darken-4 white-text"> <div class="row">
<div class="row" style="margin-bottom: 0"> <div class="card-panel col l6 offset-l3 m10 offset-m1 s10 offset-s1 grey darken-4 white-text">
<div class="col s12 center" style="margin-top: 10px"> <div class="row" style="margin-bottom: 0">
<img class="circle" th:src="${stack.selfStats.avatarUrl}" <div class="col s12 center" style="margin-top: 10px">
style="border-color: green; border-style: solid;"/> <img class="circle" th:src="${stack.selfStats.avatarUrl}"
style="border-color: green; border-style: solid;"/>
</div>
<div class="col s12 center">
<h4 style="font-weight: bold; margin: 0;" th:text="${stack.selfStats.userName}"></h4>
</div>
</div> </div>
<div class="col s12 center"> <div class="row" style="margin-bottom: 0">
<h4 style="font-weight: bold; margin: 0;" th:text="${stack.selfStats.userName}"></h4> <div class="col m6 s12 center">
</div> <table class="centered">
</div> <thead>
<div class="row" style="margin-bottom: 0"> <tr>
<div class="col m6 s12 center"> <th>Rank</th>
<table class="centered"> </tr>
<thead> </thead>
<tr> <tbody>
<th>Rank</th> <tr>
</tr> <td>
</thead> <h4 style="font-weight: bold; margin: 0"><span th:text="${stack.rank}"
<tbody> th:remove="tag"></span> <span
<tr> th:text="${' / ' + stack.ranking.size()}">/ 50</span></h4>
<td> </td>
<h4 style="font-weight: bold; margin: 0"><span th:text="${stack.rank}" </tr>
th:remove="tag"></span> <span </tbody>
th:text="${' / ' + stack.ranking.size()}">/ 50</span></h4> </table>
</td>
</tr>
</tbody>
</table>
</div>
<div class="col m6 s12 center">
<table class="centered">
<thead>
<tr>
<th>Experience</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<h4 style="font-weight: bold; margin: 0"><span th:text="${stack.selfStats.total}"
th:remove="tag"></span>
<span>Xp</span>
</h4>
</td>
</tr>
</tbody>
</table>
</div>
</div> </div>
<div class="col m6 s12 center">
<table class="centered">
<thead>
<tr>
<th>Experience</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<h4 style="font-weight: bold; margin: 0"><span th:text="${stack.selfStats.total}"
th:remove="tag"></span> <span>Xp</span>
</h4>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row"> <div class="row">
<div class="col m6 s12 center"> <div class="col m6 s12 center">
<table class="centered"> <table class="centered">
<thead> <thead>
<tr> <tr>
<th>Vocal Time</th> <th>Vocal Time</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td> <td>
<h4 style="font-weight: bold; margin: 0"> <h4 style="font-weight: bold; margin: 0">
<span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stack.selfStats.voiceTime).get(0)}" <span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stack.selfStats.voiceTime).get(0)}"
th:remove="tag"></span> <span>H</span> th:remove="tag"></span> <span>H</span>
<span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stack.selfStats.voiceTime).get(1)}" <span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stack.selfStats.voiceTime).get(1)}"
th:remove="tag"></span> <span>M</span> th:remove="tag"></span> <span>M</span>
<span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stack.selfStats.voiceTime).get(2)}" <span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stack.selfStats.voiceTime).get(2)}"
th:remove="tag"></span> <span>S</span> th:remove="tag"></span> <span>S</span>
</h4> </h4>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="col m6 s12 center"> <div class="col m6 s12 center">
<table class="centered"> <table class="centered">
<thead> <thead>
<tr> <tr>
<th>Message count</th> <th>Message count</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td> <td>
<h4 style="font-weight: bold; margin: 0"><span th:text="${stack.selfStats.messageCount}" <h4 style="font-weight: bold; margin: 0"><span
th:remove="tag"></span> <span>msg</span> th:text="${stack.selfStats.messageCount}"
</h4> th:remove="tag"></span> <span>msg</span>
</td> </h4>
</tr> </td>
</tbody> </tr>
</table> </tbody>
</table>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="row"> <div class="row">
<div class="col l6 offset-l3 m10 offset-m1 hide-on-small-and-down card-panel grey darken-4 white-text"> <div class="col l6 offset-l3 m10 offset-m1 hide-on-small-and-down card-panel grey darken-4 white-text">
<h3 class="center"><b>Ranking</b></h3> <h3 class="center"><b>Ranking</b></h3>
<table class="centered"> <table class="centered">
<thead> <thead>
<tr>
<th>Rank</th>
<th></th>
<th>Name</th>
<th>Vocal Time</th>
<th>Message Count</th>
<th>Total XP</th>
</tr>
</thead>
<tbody>
<th:block th:each="stat : ${stack.ranking}">
<tr> <tr>
<td th:text="${stat.rank}"></td> <th>Rank</th>
<td><img th:src="${stat.avatarUrl}" class="circle" style="max-height: 50px"/> </td> <th></th>
<td th:text="${stat.userName}"></td> <th>Name</th>
<td> <span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stat.voiceTime).get(0)}" <th>Vocal Time</th>
th:remove="tag"></span> <span>H</span> <th>Message Count</th>
<span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stat.voiceTime).get(1)}" <th>Total XP</th>
th:remove="tag"></span> <span>M</span>
<span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stat.voiceTime).get(2)}"
th:remove="tag"></span> <span>S</span></td>
<td th:text="${stat.messageCount}"></td>
<td th:text="${stat.total}"></td>
</tr> </tr>
</th:block> </thead>
<tbody>
<th:block th:each="stat : ${stack.ranking}">
<tr>
<td th:text="${stat.rank}"></td>
<td><img th:src="${stat.avatarUrl}" class="circle" style="max-height: 50px"/></td>
<td th:text="${stat.userName}"></td>
<td> <span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stat.voiceTime).get(0)}"
th:remove="tag"></span> <span>H</span>
<span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stat.voiceTime).get(1)}"
th:remove="tag"></span> <span>M</span>
<span th:text="${T(net.Broken.Tools.TimeConvertor).sToTime(stat.voiceTime).get(2)}"
th:remove="tag"></span> <span>S</span></td>
<td th:text="${stat.messageCount}"></td>
<td th:text="${stat.total}"></td>
</tr>
</th:block>
</tbody>
</table>
</div>
</tbody>
</table>
</div> </div>
</th:block>
</div>
</main> </main>