IW4M-Admin/WebfrontCore/Views/Server/_Scoreboard.cshtml

57 lines
3.7 KiB
Plaintext
Raw Normal View History

2022-01-24 10:56:48 -05:00
@using WebfrontCore.ViewModels
2022-01-24 12:26:56 -05:00
@using System.Globalization
2022-01-24 10:56:48 -05:00
@model WebfrontCore.ViewModels.ScoreboardInfo
2022-01-22 13:49:12 -05:00
@{
Layout = null;
2022-01-24 10:56:48 -05:00
object OrderByFunc(ClientScoreboardInfo item)
{
var property = typeof(ClientScoreboardInfo).GetProperties().FirstOrDefault(prop =>
prop.CanRead && prop.Name.Equals(Model.OrderByKey, StringComparison.InvariantCultureIgnoreCase));
return property != null ? property.GetValue(item) : item.Score;
}
string GetColumnSortDisplay(string propertyName)
{
2022-01-24 12:05:07 -05:00
if (propertyName == (Model.OrderByKey ?? nameof(ClientScoreboardInfo.Score)))
2022-01-24 10:56:48 -05:00
{
2022-01-24 12:05:07 -05:00
return Model.ShouldOrderDescending ? "<span class=\"ml-2\">▼</span>" : "<span class=\"ml-2\">▲</span>";
2022-01-24 10:56:48 -05:00
}
return null;
}
2022-01-22 13:49:12 -05:00
}
<table class="table thead-light bg-dark mb-0 table-responsive-md table-sort"
2022-01-24 12:05:07 -05:00
data-sort-column="@(Model.OrderByKey ?? nameof(ClientScoreboardInfo.Score))"
2022-01-24 10:56:48 -05:00
data-sort-down="@Model.ShouldOrderDescending.ToString().ToLower()">
2022-01-22 13:49:12 -05:00
<tr class="bg-dark border-bottom">
2022-01-24 10:56:48 -05:00
<th class="table-sort-column" data-column-name="@nameof(ClientScoreboardInfo.ClientName)">@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_PLAYER"]@Html.Raw(GetColumnSortDisplay(nameof(ClientScoreboardInfo.ClientName)))</th>
<th class="table-sort-column" data-column-name="@nameof(ClientScoreboardInfo.Score)">@ViewBag.Localization["WEBFRONT_ADV_STATS_SCORE"]@Html.Raw(GetColumnSortDisplay(nameof(ClientScoreboardInfo.Score)))</th>
<th class="table-sort-column" data-column-name="@nameof(ClientScoreboardInfo.Kills)">@ViewBag.Localization["WEBFRONT_ADV_STATS_KILLS"]@Html.Raw(GetColumnSortDisplay(nameof(ClientScoreboardInfo.Kills)))</th>
<th class="table-sort-column" data-column-name="@nameof(ClientScoreboardInfo.Deaths)">@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_DEATHS"]@Html.Raw(GetColumnSortDisplay(nameof(ClientScoreboardInfo.Deaths)))</th>
<th class="table-sort-column" data-column-name="@nameof(ClientScoreboardInfo.Kdr)">@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_RATIO"]@Html.Raw(GetColumnSortDisplay(nameof(ClientScoreboardInfo.Kdr)))</th>
<th class="table-sort-column" data-column-name="@nameof(ClientScoreboardInfo.ScorePerMinute)">@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_SPM"]@Html.Raw(GetColumnSortDisplay(nameof(ClientScoreboardInfo.ScorePerMinute)))</th>
<th class="table-sort-column" data-column-name="@nameof(ClientScoreboardInfo.ZScore)">@ViewBag.Localization["WEBFRONT_ADV_STATS_ZSCORE"]@Html.Raw(GetColumnSortDisplay(nameof(ClientScoreboardInfo.ZScore)))</th>
<th class="text-right table-sort-column" data-column-name="@nameof(ClientScoreboardInfo.Ping)">@ViewBag.Localization["WEBFRONT_SCOREBOARD_TABLE_PING"]@Html.Raw(GetColumnSortDisplay(nameof(ClientScoreboardInfo.Ping)))</th>
2022-01-22 13:49:12 -05:00
</tr>
2022-01-24 10:56:48 -05:00
@foreach (var client in Model.ShouldOrderDescending ? Model.ClientInfo.OrderByDescending(OrderByFunc) : Model.ClientInfo.OrderBy(OrderByFunc))
2022-01-22 13:49:12 -05:00
{
<tr class="team-@client.Team.ToString().ToLower()-bg">
2022-01-22 13:49:12 -05:00
<td>
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@client.ClientId">
<color-code value="@client.ClientName"></color-code>
</a>
</td>
<td>@client.Score</td>
<td>@(client.Kills ?? 0)</td>
<td>@(client.Deaths ?? 0)</td>
<td>@Math.Round(client.Kdr ?? 0, 2)</td>
<td>@Math.Round(client.ScorePerMinute ?? 0)</td>
2022-03-25 14:39:51 -04:00
<td>@(client.ZScore is null or 0 ? "--" : Math.Round(client.ZScore.Value, 2).ToString(CultureInfo.CurrentCulture))</td>
2022-01-22 13:49:12 -05:00
<td class="text-right">@client.Ping</td>
</tr>
}
</table>