mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-09-25 18:59:07 +00:00
Add page for showing individual slots
This commit is contained in:
parent
6dacfc3645
commit
896795b9a2
5 changed files with 86 additions and 4 deletions
|
@ -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;
|
||||
|
|
|
@ -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>
|
||||
|
|
40
ProjectLighthouse/Pages/SlotPage.cshtml
Normal file
40
ProjectLighthouse/Pages/SlotPage.cshtml
Normal 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>
|
28
ProjectLighthouse/Pages/SlotPage.cshtml.cs
Normal file
28
ProjectLighthouse/Pages/SlotPage.cshtml.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,6 +20,9 @@
|
|||
{
|
||||
"CallbackUrl", $"~/slots/{Model.PageNumber}"
|
||||
},
|
||||
{
|
||||
"ShowLink", true
|
||||
},
|
||||
})
|
||||
</div>
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue