implement admin "privacy" for issue #185

This commit is contained in:
RaidMax 2021-01-09 12:37:20 -06:00
parent 843c01061d
commit 28373b9325
6 changed files with 60 additions and 13 deletions

View File

@ -134,6 +134,7 @@ namespace SharedLibraryCore
ViewBag.Localization = Utilities.CurrentLocalization.LocalizationIndex;
ViewBag.CustomBranding = Manager.GetApplicationSettings().Configuration().WebfrontCustomBranding ?? "IW4MAdmin";
ViewBag.EnableColorCodes = Manager.GetApplicationSettings().Configuration().EnableColorCodes;
ViewBag.EnablePrivilegedUserPrivacy = Manager.GetApplicationSettings().Configuration().EnablePrivilegedUserPrivacy;
base.OnActionExecuting(context);
}

View File

@ -135,6 +135,8 @@ namespace SharedLibraryCore.Configuration
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_PRESET_BAN_REASONS")]
public Dictionary<string, string> PresetPenaltyReasons { get; set; } = new Dictionary<string, string>
{{"afk", "Away from keyboard"}, {"ci", "Connection interrupted. Reconnect"}};
[LocalizedDisplayName(("WEBFRONT_CONFIGURATION_ENABLE_PRIVILEGED_USER_PRIVACY"))]
public bool EnablePrivilegedUserPrivacy { get; set; }
[UIHint("ServerConfiguration")]
public ServerConfiguration[] Servers { get; set; }

View File

@ -20,7 +20,14 @@
<color-code value="@client.Name" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
</div>
@if (!ViewBag.Authorized && ViewBag.EnablePrivilegedUserPrivacy)
{
<div class="col-4 level-color-0">@loc["GLOBAL_PERMISSION_USER"]</div>
}
else
{
<div class="col-4 level-color-@client.LevelInt">@client.Level</div>
}
<div class="col-3 text-right">@client.LastConnectionText</div>
</div>
}
@ -41,7 +48,14 @@
<color-code value="@client.Name" allow="@ViewBag.EnableColorCodes"></color-code>
</a>
</div>
@if (!ViewBag.Authorized && ViewBag.EnablePrivilegedUserPrivacy)
{
<div class="p-2 level-color-0">@loc["GLOBAL_PERMISSION_USER"]</div>
}
else
{
<div class="p-2 level-color-@client.LevelInt">@client.Level</div>
}
<div class="p-2 text-white-50">@client.LastConnectionText</div>
</div>
}

View File

@ -16,7 +16,7 @@
<div id="profile_wrapper" class="pb-3 row d-flex flex-column flex-lg-row">
<!-- Initial/Avatar Column -->
<div id="profile_avatar" class="d-block d-lg-inline-flex flex-column mr-auto ml-auto mr-lg-0 ml-lg-0 justify-content-center text-center level-bgcolor-@Model.LevelInt @(isTempBanned ? "penalties-bgcolor-tempban" : "")" style="background-image:url('@string.Format("https://gravatar.com/avatar/{0}?size=168&default=blank&rating=pg", gravatarUrl)')">
<div id="profile_avatar" class="d-block d-lg-inline-flex flex-column mr-auto ml-auto mr-lg-0 ml-lg-0 justify-content-center text-center level-bgcolor-@(!ViewBag.Authorized && ViewBag.EnablePrivilegedUserPrivacy ? "0" : Model.LevelInt.ToString()) @(isTempBanned ? "penalties-bgcolor-tempban" : "")" style="background-image:url('@string.Format("https://gravatar.com/avatar/{0}?size=168&default=blank&rating=pg", gravatarUrl)')">
@if (string.IsNullOrEmpty(gravatarUrl))
{
<span class="profile-shortcode">@shortCode</span>
@ -72,12 +72,22 @@
}
</div>
}
else
{
if (!ViewBag.Authorized && ViewBag.EnablePrivilegedUserPrivacy)
{
<div id="profile_level" class="font-weight-bold h4 mb-0 level-color-0">
@ViewBag.Localization["GLOBAL_PERMISSION_USER"]
</div>
}
else
{
<div id="profile_level" class="font-weight-bold h4 mb-0 level-color-@Model.LevelInt">
@Model.Level
</div>
}
}
</div>
@if (ViewBag.Authorized)
{
@ -142,11 +152,14 @@
</div>
</div>
<div class="row d-md-flex pt-2">
@if ((!ViewBag.Authorized && !ViewBag.EnablePrivilegedUserPrivacy) || ViewBag.Authorized)
{
<div class="row d-md-flex pt-2">
<div id="profile_events" class="text-muted text-left pl-4 pr-4 pl-md-0 pr-md-0">
@await Component.InvokeAsync("ProfileMetaList", new { clientId = Model.ClientId, count = 30, offset = 0, startAt = DateTime.UtcNow, metaType = Model.MetaFilterType })
@await Component.InvokeAsync("ProfileMetaList", new {clientId = Model.ClientId, count = 30, offset = 0, startAt = DateTime.UtcNow, metaType = Model.MetaFilterType})
</div>
</div>
</div>
}
<div class="row">
<div class="oi oi-chevron-bottom text-center mt-2 btn btn-primary btn-block loader-load-more" title="Load more meta" data-action="unban" aria-hidden="true"></div>

View File

@ -31,7 +31,12 @@
<tr class="d-table-row d-lg-none bg-dark">
<th scope="row" class="bg-primary">@loc["WEBFRONT_PENALTY_TEMPLATE_ADMIN"]</th>
<td>
@Html.ActionLink(SharedLibraryCore.Utilities.StripColors(Model.PunisherName), "ProfileAsync", "Client", new { id = Model.PunisherId }, new { @class = "level-color-" + (int)Model.PunisherLevel })
@Html.ActionLink(SharedLibraryCore.Utilities.StripColors(Model.PunisherName), "ProfileAsync",
"Client",
new { id = Model.PunisherId },
new { @class = !ViewBag.Authorized && ViewBag.EnablePrivilegedUserPrivacy
? "level-color-0"
: "level-color-" + (int)Model.PunisherLevel })
</td>
</tr>
@ -64,7 +69,12 @@
<color-code value="@($"{Model.Offense}{(ViewBag.Authorized ? Model.AdditionalPenaltyInformation : "")}")" allow="@ViewBag.EnableColorCodes"></color-code>
</td>
<td>
@Html.ActionLink(SharedLibraryCore.Utilities.StripColors(Model.PunisherName), "ProfileAsync", "Client", new { id = Model.PunisherId }, new { @class = "level-color-" + (int)Model.PunisherLevel })
@Html.ActionLink(SharedLibraryCore.Utilities.StripColors(Model.PunisherName), "ProfileAsync",
"Client",
new { id = Model.PunisherId },
new { @class = !ViewBag.Authorized && ViewBag.EnablePrivilegedUserPrivacy
? "level-color-0"
: "level-color-" + (int)Model.PunisherLevel })
</td>
<td class="text-right text-light">
@{

View File

@ -35,7 +35,14 @@
<ul class="navbar-nav mr-auto">
<li class="nav-item text-center text-lg-left">@Html.ActionLink(loc["WEBFRONT_NAV_HOME"], "Index", "Home", new { area = "" }, new { @class = "nav-link" })</li>
<li class="nav-item text-center text-lg-left">@Html.ActionLink(loc["WEBFRONT_NAV_PENALTIES"], "List", "Penalty", new { area = "" }, new { @class = "nav-link" })</li>
<li class="nav-item text-center text-lg-left">@Html.ActionLink(loc["WEBFRONT_NAV_PRIVILEGED"], "PrivilegedAsync", "Client", new { area = "" }, new { @class = "nav-link" })</li>
@if (ViewBag.Authorized)
{
<li class="nav-item text-center text-lg-left">@Html.ActionLink(loc["WEBFRONT_NAV_PRIVILEGED"], "PrivilegedAsync", "Client", new {area = ""}, new {@class = "nav-link"})</li>
}
else if (!ViewBag.Authorized && !ViewBag.EnablePrivilegedUserPrivacy)
{
<li class="nav-item text-center text-lg-left">@Html.ActionLink(loc["WEBFRONT_NAV_PRIVILEGED"], "PrivilegedAsync", "Client", new {area = ""}, new {@class = "nav-link"})</li>
}
<li class="nav-item text-center text-lg-left">@Html.ActionLink(loc["WEBFRONT_NAV_HELP"], "Help", "Home", new { area = "" }, new { @class = "nav-link" })</li>
@foreach (var _page in ViewBag.Pages)
{