Add players online count to landing page

This commit is contained in:
jvyden 2021-11-21 18:53:34 -05:00
commit e12fa2ea66
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
3 changed files with 17 additions and 5 deletions

View file

@ -10,3 +10,16 @@
{
<p>You are currently logged in as <b>@Model.User.Username</b>.</p>
}
@if (Model.PlayersOnline == 1)
{
<p>There is 1 user currently online.</p>
}
else if (Model.PlayersOnline == 0)
{
<p>There are no users online. Why not hop on?</p>
}
else
{
<p>There are currently @Model.PlayersOnline users online.</p>
}

View file

@ -1,8 +1,8 @@
#nullable enable
using System.Threading.Tasks;
using JetBrains.Annotations;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types;
using Microsoft.AspNetCore.Mvc;
namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth
@ -12,13 +12,12 @@ namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth
public LandingPage(Database database) : base(database)
{}
public new User? User { get; set; }
public int PlayersOnline;
[UsedImplicitly]
public async Task<IActionResult> OnGet()
{
User = await this.Database.UserFromWebRequest(this.Request);
this.PlayersOnline = await StatisticsHelper.RecentMatches();
return this.Page();
}
}

View file

@ -51,7 +51,7 @@
<div class="ui black attached inverted segment">
<div class="ui container">
<p>Page generated by @GitVersionHelper.FullVersion</p>
<p>Page generated by @GitVersionHelper.FullVersion.</p>
@if (GitVersionHelper.IsDirty)
{
<p>This page was generated using a modified version of Project Lighthouse. Please make sure you are properly disclosing the source code to any users who may be using this instance.</p>