Add user page

This commit is contained in:
jvyden 2021-11-22 21:07:30 -05:00
commit 3d9cb328e0
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
4 changed files with 81 additions and 5 deletions

View file

@ -47,6 +47,7 @@
<div class="ui container">
<br>
@RenderBody()
<div style="height: 150px; width: 1px;"></div> @* solves quirk with footer *@
</div>
</body>
<footer class="lighthouse-footer">

View file

@ -19,7 +19,7 @@
<i>
Taken by
<b>
<a href="/users/@photo.Creator!.UserId">@photo.Creator.Username</a>
<a href="/user/@photo.Creator!.UserId">@photo.Creator.Username</a>
</b>
</i>
</p>
@ -29,7 +29,7 @@
</p>
@foreach (PhotoSubject subject in photo.Subjects)
{
<a href="/users/@subject.UserId">@subject.User.Username</a>
<a href="/user/@subject.UserId">@subject.User.Username</a>
}
</div>
}
@ -38,6 +38,4 @@
{
<a href="/photos/@(Model.PageNumber - 1)">Previous Page</a>
}
<a href="/photos/@(Model.PageNumber + 1)">Next Page</a>
<div style="height: 100px; width: 1px;"></div> @* solves quirk with footer *@
<a href="/photos/@(Model.PageNumber + 1)">Next Page</a>

View file

@ -0,0 +1,47 @@
@page "/user/{userId:int}"
@using LBPUnion.ProjectLighthouse.Types
@using LBPUnion.ProjectLighthouse.Types.Settings
@model LBPUnion.ProjectLighthouse.Pages.UserPage
@{
Layout = "Layouts/BaseLayout";
}
<h1>@Model.ProfileUser!.Username's user page</h1>
<div>
<i class="pink heart icon" title="Hearts"></i> @Model.ProfileUser.Hearts
<i class="blue comment icon" title="Comments"></i> @Model.ProfileUser.Comments
<i class="green upload icon" title="Uploaded Levels"></i>@Model.ProfileUser.UsedSlots / @ServerStatics.EntitledSlots
<i class="purple camera icon" title="Uploaded Photos"></i>@Model.ProfileUser.PhotosByMe
</div>
<div class="ui blue segment">
<h2>Biography</h2>
<p>@Model.ProfileUser.Biography</p>
</div>
@if (Model.Photos != null && Model.Photos.Count != 0)
{
<div class="ui purple segment">
<h2>Most recent photos</h2>
<div class="ui center aligned grid">
@foreach (Photo photo in Model.Photos)
{
<div class="eight wide column">
<img src="/gameAssets/@photo.LargeHash" style="width: 100%; height: auto; border-radius: .28571429rem;">
<br>
<p>
<b>Photo contains @photo.Subjects.Count @(photo.Subjects.Count == 1 ? "person" : "people"):</b>
</p>
@foreach (PhotoSubject subject in photo.Subjects)
{
<a href="/user/@subject.UserId">@subject.User.Username</a>
}
</div>
}
</div>
</div>
}

View file

@ -0,0 +1,30 @@
#nullable enable
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Pages
{
public class UserPage : BaseLayout
{
public UserPage(Database database) : base(database)
{}
public User? ProfileUser;
public List<Photo>? Photos;
public async Task<IActionResult> OnGet([FromRoute] int userId)
{
this.ProfileUser = await this.Database.Users.FirstOrDefaultAsync(u => u.UserId == userId);
if (this.ProfileUser == null) return this.NotFound();
this.Photos = await this.Database.Photos.OrderByDescending(p => p.Timestamp).Where(p => p.CreatorId == userId).Take(5).ToListAsync();
return this.Page();
}
}
}