Add page for showing individual slots

This commit is contained in:
jvyden 2021-11-30 19:03:29 -05:00
commit 896795b9a2
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
5 changed files with 86 additions and 4 deletions

View file

@ -9,12 +9,11 @@ namespace LBPUnion.ProjectLighthouse.Pages.Layouts
{
public readonly Database Database;
private User? user;
public string Title = string.Empty;
public bool ShowTitleInPage = true;
private User? user;
public new User? User {
get {
if (this.user != null) return this.user;

View file

@ -21,10 +21,22 @@
}
string callbackUrl = (string)ViewData["CallbackUrl"];
bool showLink = (bool?)ViewData["ShowLink"] ?? false;
}
<div class="ui grid">
<div class="eight wide column">
<h2 style="margin-bottom: 2px;">@slotName</h2>
@if (showLink)
{
<h2 style="margin-bottom: 2px;">
<a href="~/slot/@Model.SlotId">@slotName</a>
</h2>
}
else
{
<h1 style="margin-bottom: 2px;">
@slotName
</h1>
}
<div class="statsUnderTitle" style="margin-bottom: 10px;">
<i class="pink heart icon" title="Hearts"></i> <span>@Model.Hearts</span>
<i class="blue play icon" title="Plays"></i> <span>@Model.Plays</span>

View file

@ -0,0 +1,40 @@
@page "/slot/{id:int}"
@model LBPUnion.ProjectLighthouse.Pages.SlotPage
@{
Layout = "Layouts/BaseLayout";
Model.Title = Model.Slot.Name;
Model.ShowTitleInPage = false;
}
@await Html.PartialAsync("Partials/SlotCardPartial", Model.Slot, new ViewDataDictionary(ViewData)
{
{
"User", Model.User
},
{
"CallbackUrl", $"~/slot/{Model.Slot.SlotId}"
},
{
"ShowLink", false
},
})
<div class="ui grid">
<div class="eight wide column">
<div class="ui blue segment">
<h2>Description</h2>
<p>@Model.Slot.Description</p>
</div>
</div>
<div class="eight wide column">
<div class="ui red segment">
<h2>Tags</h2>
@foreach (string label in Model.Slot.AuthorLabels.Split(","))
{
<div class="ui blue label">@label.Replace("LABEL_", "")</div>
}
</div>
</div>
</div>

View file

@ -0,0 +1,28 @@
#nullable enable
using System.Threading.Tasks;
using JetBrains.Annotations;
using LBPUnion.ProjectLighthouse.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Levels;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Pages
{
public class SlotPage : BaseLayout
{
public SlotPage([NotNull] Database database) : base(database)
{}
public Slot Slot;
public async Task<IActionResult> OnGet([FromRoute] int id)
{
Slot? slot = await this.Database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
if (slot == null) return this.NotFound();
this.Slot = slot;
return this.Page();
}
}
}

View file

@ -20,6 +20,9 @@
{
"CallbackUrl", $"~/slots/{Model.PageNumber}"
},
{
"ShowLink", true
},
})
</div>
}