Add grouping for servers on top stats, live radar, and scoreboard

This commit is contained in:
RaidMax 2023-04-07 16:23:24 -05:00
parent c6c7ca6305
commit 129e70c82c
10 changed files with 77 additions and 29 deletions

View File

@ -31,7 +31,8 @@ namespace IW4MAdmin.Plugins.LiveRadar.Web.Controllers
{
Name = server.Hostname,
IPAddress = server.ListenAddress,
Port = server.ListenPort
Port = server.ListenPort,
Game = server.GameCode
});
ViewBag.Title = Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_RADAR_TITLE"];

View File

@ -16,7 +16,6 @@ using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using ILogger = Microsoft.Extensions.Logging.ILogger;
using Data.Abstractions;
using IW4MAdmin.Plugins.Stats.Config;
using Stats.Config;
namespace IW4MAdmin.Plugins.Web.StatsWeb.Controllers
@ -70,7 +69,8 @@ namespace IW4MAdmin.Plugins.Web.StatsWeb.Controllers
{
Name = selectedServer.Hostname,
IPAddress = selectedServer.ListenAddress,
Port = selectedServer.ListenPort
Port = selectedServer.ListenPort,
Game = selectedServer.GameCode
}));
}

View File

@ -61,15 +61,16 @@ namespace WebfrontCore.Controllers
public ActionResult Scoreboard(string serverId)
{
ViewBag.Title = Localization["WEBFRONT_TITLE_SCOREBOARD"];
ViewBag.SelectedServerId = string.IsNullOrEmpty(serverId) ? Manager.GetServers().FirstOrDefault()?.ToString() : serverId;
ViewBag.SelectedServerId = string.IsNullOrEmpty(serverId)
? Manager.GetServers().FirstOrDefault()?.ToString()
: serverId;
return View(ProjectScoreboard(Manager.GetServers(), null, true));
}
[HttpGet("[controller]/{id}/scoreboard")]
public ActionResult Scoreboard(string id, [FromQuery]string order = null, [FromQuery] bool down = true)
public ActionResult Scoreboard(string id, [FromQuery] string order = null, [FromQuery] bool down = true)
{
var server = Manager.GetServers().FirstOrDefault(srv => srv.ToString() == id);
if (server == null)
@ -78,19 +79,20 @@ namespace WebfrontCore.Controllers
}
ViewBag.SelectedServerId = id;
return View("_Scoreboard", ProjectScoreboard(new[] {server}, order, down).First());
return View("_Scoreboard", ProjectScoreboard(new[] { server }, order, down).First());
}
private static IEnumerable<ScoreboardInfo> ProjectScoreboard(IEnumerable<Server> servers, string order,
bool down)
{
return servers.Select((server, index) => new ScoreboardInfo
return servers.Select(server => new ScoreboardInfo
{
OrderByKey = order,
ShouldOrderDescending = down,
MapName = server.CurrentMap.ToString(),
ServerName = server.Hostname,
ServerId = server.ToString(),
GameCode = server.GameCode,
ClientInfo = server.GetClientsAsList().Select(client =>
new
{
@ -107,7 +109,9 @@ namespace WebfrontCore.Controllers
Deaths = clientData.stats?.MatchData?.Deaths,
ScorePerMinute = clientData.stats?.SessionSPM,
Kdr = clientData.stats?.MatchData?.Kdr,
ZScore = clientData.stats?.ZScore == null || clientData.stats.ZScore == 0 ? null : clientData.stats.ZScore,
ZScore = clientData.stats?.ZScore == null || clientData.stats.ZScore == 0
? null
: clientData.stats.ZScore,
Team = clientData.client.Team
})
.ToList()

View File

@ -1,4 +1,6 @@
using System.Collections.Generic;
using Data.Models;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using SharedLibraryCore.Database.Models;
namespace WebfrontCore.ViewModels
@ -7,6 +9,7 @@ namespace WebfrontCore.ViewModels
{
public string ServerName { get; set; }
public string ServerId { get; set; }
public Reference.Game GameCode { get; set; }
public string MapName { get; set; }
public string OrderByKey { get; set; }
public bool ShouldOrderDescending { get; set; }

View File

@ -7,6 +7,7 @@ public class SideContextMenuItem
public bool IsLink { get; set; }
public bool IsButton { get; set; }
public bool IsActive { get; set; }
public bool IsCollapse { get; set; }
public string Title { get; set; }
public string Reference { get; set; }
public string Icon { get; set; }

View File

@ -27,7 +27,9 @@
IsLink = true,
Reference = Url.Action("TopPlayers", "Stats", new { serverId = server.Endpoint }),
Title = server.Name.StripColors(),
IsActive = ViewBag.SelectedServerId == server.Endpoint
IsActive = ViewBag.SelectedServerId == server.Endpoint,
Meta = server.Game.ToString(),
IsCollapse = true
}).Prepend(new SideContextMenuItem
{
IsLink = true,

View File

@ -42,9 +42,11 @@
IsLink = true,
// ReSharper disable Mvc.ActionNotResolved
// ReSharper disable Mvc.ControllerNotResolved
Reference = Url.Action("Index", "Radar", new { serverId = server.Endpoint }),
Reference = Url.Action("Index", "Radar", new { serverId = (dynamic)server.Endpoint }),
Title = server.Name.StripColors(),
IsActive = ViewBag.SelectedServerId == server.Endpoint
IsActive = ViewBag.SelectedServerId == server.Endpoint ,
IsCollapse = true,
Meta = server.Game.ToString()
}).ToList()
};
}

View File

@ -22,7 +22,9 @@
IsLink = true,
Reference = Url.Action("Scoreboard", "Server", new { serverId = server.ServerId }),
Title = server.ServerName.StripColors(),
IsActive = ViewBag.SelectedServerId == server.ServerId
IsActive = ViewBag.SelectedServerId == server.ServerId,
IsCollapse = true,
Meta = server.GameCode.ToString()
}).ToList()
};
}

View File

@ -2,11 +2,18 @@
@{ Layout = null; }
<div class="d-none d-lg-flex col-3">
<div class="content mt-0">
<div class="on-this-page-nav pt-0">
<div class="on-this-page-nav pt-0" style="margin-left: 3rem;">
<div>
<div class="title">@Model.MenuTitle</div>
@foreach (var item in Model.Items)
@{
var groupedItems = Model.Items.Where(item => item.IsCollapse)
.GroupBy(item => item.Meta)
.ToList();
var index = 0;
}
@foreach (var item in Model.Items.Where(item => !item.IsCollapse))
{
<a href="@(item.IsLink ? item.Reference : "#")" class="@(item.IsLink ? "" : "profile-action")" data-action="@(item.IsLink ? "" : item.Reference)" data-action-id="@item.EntityId" data-action-meta="@item.Meta">
<div class="@(item.IsButton ? "btn btn-block" : "")" data-title="@item.Tooltip" data-placement="left" data-toggle="@(string.IsNullOrEmpty(item.Tooltip) ? "" : "tooltip")">
@ -15,6 +22,27 @@
</div>
</a>
}
@foreach (var group in groupedItems)
{
<details class="collapse-panel mt-10 mb-10" @(index == 0 ? "open" : "")>
<summary class="collapse-header">
@ViewBag.Localization[$"GAME_{group.Key}"]
</summary>
<div class="collapse-content" style="overflow: scroll; max-height: 30rem; max-width:350px;">
@foreach (var item in group)
{
<a href="@(item.IsLink ? item.Reference : "#")" style="border: 0; padding: 0;" class="@(item.IsLink ? "" : "profile-action")" data-action="@(item.IsLink ? "" : item.Reference)" data-action-id="@item.EntityId" data-action-meta="@item.Meta">
<div class="@(item.IsButton ? "btn btn-block" : "")" data-title="@item.Tooltip" data-placement="left" data-toggle="@(string.IsNullOrEmpty(item.Tooltip) ? "" : "tooltip")">
<i class="@(string.IsNullOrEmpty(item.Icon) ? "" : $"oi {item.Icon}") mr-5 font-size-12"></i>
<span class="@(item.IsActive ? "text-primary" : "") text-truncate">@item.Title</span>
</div>
</a>
}
</div>
</details>
index++;
}
</div>
</div>
</div>

View File

@ -26,6 +26,10 @@ $dp-cell-focus-background-color: rgba(255, 255, 255, 0.05);
--card-border-width: 0;
--dm-modal-overlay-bg-color: rgba(0, 0, 0, 0.8);
--collapse-header-padding-with-bg-image: 0.75rem 2.5rem 0.75rem 4.5rem;
--collapse-content-padding: 1rem 1rem 0 1rem;
--webkit-scrollbar-track-border-width: 0;
--dm-webkit-scrollbar-corner-border-color: transparent;
}
.server-history-row {
@ -353,17 +357,18 @@ table {
/* Sidenav */
.on-this-page-nav {
position: fixed;
margin-right: 2rem;
z-index: 20;
background-color: var(--lm-base-body-bg-color);
padding: 0.5rem;
border-radius: 0.4rem;
height: 90%;
overflow: scroll;
}
.dark-mode .on-this-page-nav {
background-color: #25282c;
}
.on-this-page-nav .title {
font-weight: 500;
font-size: 1.5rem;