diff --git a/Plugins/LiveRadar/Controllers/RadarController.cs b/Plugins/LiveRadar/Controllers/RadarController.cs index 505322816..397277a2d 100644 --- a/Plugins/LiveRadar/Controllers/RadarController.cs +++ b/Plugins/LiveRadar/Controllers/RadarController.cs @@ -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"]; diff --git a/WebfrontCore/Controllers/Client/Legacy/StatsController.cs b/WebfrontCore/Controllers/Client/Legacy/StatsController.cs index 803f11888..4e6339109 100644 --- a/WebfrontCore/Controllers/Client/Legacy/StatsController.cs +++ b/WebfrontCore/Controllers/Client/Legacy/StatsController.cs @@ -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 })); } diff --git a/WebfrontCore/Controllers/ServerController.cs b/WebfrontCore/Controllers/ServerController.cs index 7477ef770..41ea1af3d 100644 --- a/WebfrontCore/Controllers/ServerController.cs +++ b/WebfrontCore/Controllers/ServerController.cs @@ -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 ProjectScoreboard(IEnumerable 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() diff --git a/WebfrontCore/ViewModels/ScoreboardInfo.cs b/WebfrontCore/ViewModels/ScoreboardInfo.cs index 59a2f4bd2..f58280ab8 100644 --- a/WebfrontCore/ViewModels/ScoreboardInfo.cs +++ b/WebfrontCore/ViewModels/ScoreboardInfo.cs @@ -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; } diff --git a/WebfrontCore/ViewModels/SideContextMenuItem.cs b/WebfrontCore/ViewModels/SideContextMenuItem.cs index 14823dcd6..76176a6f7 100644 --- a/WebfrontCore/ViewModels/SideContextMenuItem.cs +++ b/WebfrontCore/ViewModels/SideContextMenuItem.cs @@ -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; } diff --git a/WebfrontCore/Views/Client/Statistics/Index.cshtml b/WebfrontCore/Views/Client/Statistics/Index.cshtml index e4fef9549..cbf76fbd9 100644 --- a/WebfrontCore/Views/Client/Statistics/Index.cshtml +++ b/WebfrontCore/Views/Client/Statistics/Index.cshtml @@ -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, diff --git a/WebfrontCore/Views/Plugins/LiveRadar/Radar/Index.cshtml b/WebfrontCore/Views/Plugins/LiveRadar/Radar/Index.cshtml index 159d4ffba..76e3a887c 100644 --- a/WebfrontCore/Views/Plugins/LiveRadar/Radar/Index.cshtml +++ b/WebfrontCore/Views/Plugins/LiveRadar/Radar/Index.cshtml @@ -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() }; } diff --git a/WebfrontCore/Views/Server/Scoreboard.cshtml b/WebfrontCore/Views/Server/Scoreboard.cshtml index 07d7a5e99..6e287532f 100644 --- a/WebfrontCore/Views/Server/Scoreboard.cshtml +++ b/WebfrontCore/Views/Server/Scoreboard.cshtml @@ -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() }; } diff --git a/WebfrontCore/Views/Shared/_SideContextMenu.cshtml b/WebfrontCore/Views/Shared/_SideContextMenu.cshtml index caa80faa4..a7c23ba3e 100644 --- a/WebfrontCore/Views/Shared/_SideContextMenu.cshtml +++ b/WebfrontCore/Views/Shared/_SideContextMenu.cshtml @@ -2,21 +2,49 @@ @{ Layout = null; }
-
-
-
@Model.MenuTitle
+
+
+
@Model.MenuTitle
- @foreach (var item in Model.Items) - { - -
- - @item.Title -
-
- } + @{ + 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)) + { + +
+ + @item.Title +
+
+ } + + @foreach (var group in groupedItems) + { +
+ + @ViewBag.Localization[$"GAME_{group.Key}"] + +
+ @foreach (var item in group) + { + +
+ + @item.Title +
+
+ } +
+
+ index++; + } +
-