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

@ -9,4 +9,17 @@
@if (Model.User != null) @if (Model.User != null)
{ {
<p>You are currently logged in as <b>@Model.User.Username</b>.</p> <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 #nullable enable
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations; using JetBrains.Annotations;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Pages.Layouts; using LBPUnion.ProjectLighthouse.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth
@ -12,13 +12,12 @@ namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth
public LandingPage(Database database) : base(database) public LandingPage(Database database) : base(database)
{} {}
public new User? User { get; set; } public int PlayersOnline;
[UsedImplicitly] [UsedImplicitly]
public async Task<IActionResult> OnGet() public async Task<IActionResult> OnGet()
{ {
User = await this.Database.UserFromWebRequest(this.Request); this.PlayersOnline = await StatisticsHelper.RecentMatches();
return this.Page(); return this.Page();
} }
} }

View file

@ -51,7 +51,7 @@
<div class="ui black attached inverted segment"> <div class="ui black attached inverted segment">
<div class="ui container"> <div class="ui container">
<p>Page generated by @GitVersionHelper.FullVersion</p> <p>Page generated by @GitVersionHelper.FullVersion.</p>
@if (GitVersionHelper.IsDirty) @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> <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>