ProjectLighthouse/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml
Josh f6a7fe6283
User settings, level settings, language and timezone selection and more. (#471)
* Initial work for user settings page

* Finish user setting and slot setting pages

* Don't show slot upload date on home page and fix team pick redirection

* Fix upload image button alignment on mobile

* Fix image upload on iPhone

* Remove unused css and add selected button color

* Fix login email check and bump ChromeDriver to 105

* Remove duplicated code and allow users to leave fields empty

* Add unpublish button on level settings and move settings button position

* Don't show edit button on mini card

* Self review bug fixes and users can no longer use an in-use email
2022-09-17 14:02:46 -05:00

284 lines
No EOL
9.2 KiB
Text

@page "/slot/{id:int}"
@using System.Web
@using LBPUnion.ProjectLighthouse.Administration
@using LBPUnion.ProjectLighthouse.Configuration
@using LBPUnion.ProjectLighthouse.Extensions
@using LBPUnion.ProjectLighthouse.Files
@using LBPUnion.ProjectLighthouse.Helpers
@using LBPUnion.ProjectLighthouse.PlayerData
@using LBPUnion.ProjectLighthouse.PlayerData.Reviews
@using LBPUnion.ProjectLighthouse.Servers.Website.Extensions
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.SlotPage
@{
Layout = "Layouts/BaseLayout";
Model.ShowTitleInPage = false;
Model.Title = HttpUtility.HtmlDecode(Model.Slot?.Name ?? "");
Model.Description = HttpUtility.HtmlDecode(Model.Slot?.Description ?? "");
bool isMobile = this.Request.IsMobile();
string language = Model.GetLanguage();
string timeZone = Model.GetTimeZone();
}
@if (Model.Slot!.Hidden)
{
<div class="ui inverted red segment">
<h2>This level is currently hidden.</h2>
<p><b>Only you and moderators may view this level.</b></p>
<b>Reason:</b> <span>"@Model.Slot.HiddenReason"</span>
<p><b>For more information please contact a moderator.</b></p>
</div>
}
@await Html.PartialAsync("Partials/SlotCardPartial", Model.Slot, new ViewDataDictionary(ViewData)
{
{
"User", Model.User
},
{
"CallbackUrl", $"~/slot/{Model.Slot?.SlotId}"
},
{
"ShowLink", false
},
{
"IsMobile", Model.Request.IsMobile()
},
})
<br>
<div class="@(isMobile ? "" : "ui grid")">
<div class="eight wide column">
<div class="ui blue segment">
<h2>Description</h2>
<p style="overflow-wrap: anywhere">@HttpUtility.HtmlDecode(string.IsNullOrEmpty(Model.Slot?.Description) ? "This level has no description." : Model.Slot.Description)</p>
</div>
</div>
@if (isMobile)
{
<br/>
}
<div class="eight wide column">
<div class="ui red segment">
<h2>Tags</h2>
@{
string[] authorLabels;
if (Model.Slot?.GameVersion == GameVersion.LittleBigPlanet1)
{
authorLabels = Model.Slot?.LevelTags ?? Array.Empty<string>();
}
else
{
authorLabels = Model.Slot?.AuthorLabels.Split(",") ?? Array.Empty<string>();
// Split() returns an array with an empty character for some reason
if (authorLabels.Length == 1) authorLabels = Array.Empty<string>();
}
if (authorLabels.Length == 0)
{
<p>This level has no tags.</p>
}
else
{
foreach (string label in authorLabels.Where(label => !string.IsNullOrEmpty(label)))
{
<div class="ui blue label">@LabelHelper.TranslateTag(label)</div>
}
}
}
</div>
</div>
@if (isMobile)
{
<br/>
}
<div class="eight wide column">
@await Html.PartialAsync("Partials/CommentsPartial", ViewData.WithLang(language).WithTime(timeZone))
</div>
@if (isMobile)
{
<br/>
}
<div class="eight wide column">
<div class="ui purple segment">
<h2>Reviews</h2>
@if (Model.Reviews.Count == 0 && Model.ReviewsEnabled)
{
<p>There are no reviews.</p>
}
else if (!Model.ReviewsEnabled)
{
<b>
<i>Reviews are disabled on this level.</i>
</b>
}
else
{
int count = Model.Reviews.Count;
<p>There @(count == 1 ? "is" : "are") @count review@(count == 1 ? "" : "s").</p>
<div class="ui divider"></div>
}
@for(int i = 0; i < Model.Reviews.Count; i++)
{
Review review = Model.Reviews[i];
string faceHash = (review.Thumb switch {
-1 => review.Reviewer?.BooHash,
0 => review.Reviewer?.MehHash,
1 => review.Reviewer?.YayHash,
_ => throw new ArgumentOutOfRangeException(),
}) ?? "";
if (string.IsNullOrWhiteSpace(faceHash) || !FileHelper.ResourceExists(faceHash))
{
faceHash = ServerConfiguration.Instance.WebsiteConfiguration.MissingIconHash;
}
string faceAlt = review.Thumb switch {
-1 => "Boo!",
0 => "Meh.",
1 => "Yay!",
_ => throw new ArgumentOutOfRangeException(),
};
int size = isMobile ? 50 : 100;
<div class="card">
<div>
<img class="cardIcon slotCardIcon" src="@ServerConfiguration.Instance.ExternalUrl/gameAssets/@faceHash" alt="@faceAlt" title="@faceAlt" style="min-width: @(size)px; width: @(size)px; height: @(size)px">
</div>
<div class="cardStats">
<h3 style="margin-bottom: 5px;">@review.Reviewer?.Username</h3>
@if (review.Deleted)
{
if (review.DeletedBy == DeletedBy.LevelAuthor)
{
<p>
<i>This review has been deleted by the level author.</i>
</p>
}
else
{
<p>
<i>This review has been deleted by a moderator.</i>
</p>
}
}
else
{
@if (review.Labels.Length > 1)
{
@foreach (string reviewLabel in review.Labels)
{
<div class="ui blue label">@LabelHelper.TranslateTag(reviewLabel)</div>
}
}
@if (string.IsNullOrWhiteSpace(review.Text))
{
<p>
<i>This review contains no text.</i>
</p>
}
else
{
{
<p>@HttpUtility.HtmlDecode(review.Text)</p>
}
}
}
</div>
</div>
@if (i != Model.Reviews.Count - 1)
{
<div class="ui divider"></div>
}
}
</div>
@if (isMobile)
{
<br/>
}
</div>
</div>
@if (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">
@await photo.ToHtml(Html, ViewData, language, timeZone)
</div>
}
</div>
</div>
@if (isMobile)
{
<br/>
}
}
@if (Model.User != null && Model.User.IsModerator)
{
<div class="ui green segment">
<h2>Moderation Options</h2>
@if (Model.Slot?.TeamPick ?? false)
{
<a href="/moderation/slot/@Model.Slot.SlotId/removeTeamPick">
<div class="ui pink button">
<i class="star icon"></i>
<span>Remove Team Pick</span>
</div>
</a>
}
else
{
<a href="/moderation/slot/@Model.Slot?.SlotId/teamPick">
<div class="ui pink button">
<i class="star icon"></i>
<span>Team Pick</span>
</div>
</a>
}
<a href="/moderation/slot/@Model.Slot?.SlotId/delete">
<div class="ui red button">
<i class="trash icon"></i>
<span>Delete</span>
</div>
</a>
@if (!Model.Slot!.Hidden)
{
<a href="/moderation/newCase?type=@((int)CaseType.LevelHide)&affectedId=@Model.Slot?.SlotId">
<div class="ui yellow button">
<i class="lock icon"></i>
<span>Hide</span>
</div>
</a>
}
@if (Model.Slot!.CommentsEnabled)
{
<a class="ui yellow button" href="/moderation/newCase?type=@((int)CaseType.LevelDisableComments)&affectedId=@Model.Slot?.SlotId">
<i class="lock icon"></i>
<span>Disable Comments</span>
</a>
}
</div>
@if (isMobile)
{
<br/>
}
}