ProjectLighthouse/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml
2022-09-18 15:48:56 -05:00

194 lines
No EOL
5.8 KiB
Text

@page "/user/{userId:int}"
@using System.Web
@using LBPUnion.ProjectLighthouse.Administration
@using LBPUnion.ProjectLighthouse.Extensions
@using LBPUnion.ProjectLighthouse.Localization.StringLists
@using LBPUnion.ProjectLighthouse.PlayerData
@using LBPUnion.ProjectLighthouse.Servers.Website.Extensions
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.UserPage
@{
Layout = "Layouts/BaseLayout";
Model.ShowTitleInPage = false;
Model.Title = Model.Translate(ProfileStrings.Title, Model.ProfileUser!.Username);
Model.Description = Model.ProfileUser!.Biography;
bool isMobile = Request.IsMobile();
string language = Model.GetLanguage();
string timeZone = Model.GetTimeZone();
}
@if (Model.ProfileUser.IsBanned)
{
<div class="ui inverted red segment">
<h2>User is currently banned!</h2>
@if (Model.User != null && Model.User.IsModerator)
{
<b>Reason:</b>
<span>"@Model.ProfileUser.BannedReason"</span>
<p>
<i>Note: Only you and other moderators may view the ban reason.</i>
</p>
}
else
{
<p>For shame...</p>
}
</div>
}
<div class="@(isMobile ? "" : "ui grid")">
<div class="eight wide column">
@await Html.PartialAsync("Partials/UserCardPartial", Model.ProfileUser, new ViewDataDictionary(ViewData)
{
{
"ShowLink", false
},
{
"IsMobile", Model.Request.IsMobile()
},
{
"Language", Model.GetLanguage()
},
{
"TimeZone", Model.GetTimeZone()
},
})
</div>
<div class="eight wide right aligned column">
<br>
@if (Model.ProfileUser != Model.User && Model.User != null)
{
if (!Model.IsProfileUserHearted)
{
<a class="ui pink button" href="/user/@Model.ProfileUser.UserId/heart">
<i class="heart icon"></i>
<span>Heart</span>
</a>
}
else
{
<a class="ui pink button" href="/user/@Model.ProfileUser.UserId/unheart">
<i class="heart broken icon"></i>
<span>Unheart</span>
</a>
}
}
@if (Model.ProfileUser == Model.User || (Model.User?.IsModerator ?? false))
{
<a class="ui blue button" href="/user/@Model.ProfileUser.UserId/settings">
<i class="cog icon"></i>
<span>Settings</span>
</a>
}
@if (Model.ProfileUser == Model.User)
{
<a href="/logout" class="ui red button">
<i class="user slash icon"></i>
@Model.Translate(BaseLayoutStrings.HeaderLogout)
</a>
}
</div>
@if (isMobile)
{
<br/>
}
<div class="eight wide column">
<div class="ui blue segment">
<h2>@Model.Translate(ProfileStrings.Biography)</h2>
@if (string.IsNullOrWhiteSpace(Model.ProfileUser.Biography))
{
<p>@Model.Translate(ProfileStrings.NoBiography, Model.ProfileUser.Username)</p>
}
else
{
<p style="overflow-wrap: anywhere;">@HttpUtility.HtmlDecode(Model.ProfileUser.Biography)</p>
}
</div>
</div>
@if (isMobile)
{
<br/>
}
<div class="eight wide column">
<div class="ui red segment">
<h2>@Model.Translate(GeneralStrings.RecentActivity)</h2>
<p>@Model.Translate(GeneralStrings.Soon)</p>
</div>
</div>
@if (isMobile)
{
<br/>
}
</div>
@if (Model.Photos != null && Model.Photos.Count != 0)
{
<div class="ui purple segment">
<h2>@Model.Translate(GeneralStrings.RecentPhotos)</h2>
<div class="ui center aligned grid">
@foreach (Photo photo in Model.Photos)
{
string width = isMobile ? "sixteen" : "eight";
<div class="@width wide column">
@await photo.ToHtml(Html, ViewData, language, timeZone)
</div>
}
</div>
</div>
@if (isMobile)
{
<br/>
}
}
@await Html.PartialAsync("Partials/CommentsPartial", ViewData.WithLang(language).WithTime(timeZone))
@if (Model.User != null && Model.User.IsModerator)
{
<div class="ui green segment">
<h2>Moderation Options</h2>
@if (!Model.ProfileUser.IsBanned)
{
<div>
<a class="ui red button" href="/moderation/newCase?type=@((int)CaseType.UserBan)&affectedId=@Model.ProfileUser.UserId">
<i class="ban icon"></i>
<span>Ban User</span>
</a>
</div>
<div class="ui fitted hidden divider"></div>
}
@if (Model.ProfileUser.CommentsEnabled)
{
<div>
<a class="ui yellow button" href="/moderation/newCase?type=@((int)CaseType.UserDisableComments)&affectedId=@Model.ProfileUser.UserId">
<i class="lock icon"></i>
<span>Disable Comments</span>
</a>
</div>
<div class="ui fitted hidden divider"></div>
}
<div>
<a class="ui red button" href="/moderation/user/@Model.ProfileUser.UserId/wipePlanets">
<i class="trash alternate icon"></i>
<span>Wipe user's earth decorations</span>
</a>
</div>
<div class="ui fitted hidden divider"></div>
@if (Model.User.IsAdmin)
{
@await Html.PartialAsync("Partials/AdminSetGrantedSlotsFormPartial", Model.ProfileUser)
}
</div>
@if (isMobile)
{
<br/>
}
}