From d318a578301dc51a31784bf592d8948355bbad3e Mon Sep 17 00:00:00 2001 From: RaidMax Date: Mon, 25 Feb 2019 19:36:10 -0600 Subject: [PATCH] start implementation for per server top stats issue #39 --- .gitignore | 2 +- Application/Application.csproj | 6 +-- Plugins/Stats/Controllers/StatsController.cs | 2 + Plugins/Stats/Dtos/TopStatsInfo.cs | 1 + Plugins/Web/StatsWeb/StatsWeb.csproj | 3 +- Plugins/Web/StatsWeb/Views/Stats/Index.cshtml | 51 ++++++++++++++++--- WebfrontCore/Startup.cs | 8 +++ .../Views/Client/Profile/Index.cshtml | 2 +- WebfrontCore/WebfrontCore.csproj | 2 +- WebfrontCore/wwwroot/css/bootstrap-custom.css | 19 +++++++ .../wwwroot/css/bootstrap-custom.scss | 23 +++++++++ 11 files changed, 106 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index dc5dc8c76..acbf2afb3 100644 --- a/.gitignore +++ b/.gitignore @@ -223,7 +223,7 @@ global.min.js bootstrap-custom.min.css **/Master/static **/Master/dev_env -/WebfrontCore/Views/Plugins/Stats +/WebfrontCore/Views/Plugins/* /WebfrontCore/wwwroot/**/dds /DiscordWebhook/env diff --git a/Application/Application.csproj b/Application/Application.csproj index 53334a694..d48d5f714 100644 --- a/Application/Application.csproj +++ b/Application/Application.csproj @@ -6,7 +6,7 @@ 2.2.2 false RaidMax.IW4MAdmin.Application - 2.2.5.5 + 2.2.5.6 RaidMax Forever None IW4MAdmin @@ -31,8 +31,8 @@ true true - 2.2.5.5 - 2.2.5.5 + 2.2.5.6 + 2.2.5.6 diff --git a/Plugins/Stats/Controllers/StatsController.cs b/Plugins/Stats/Controllers/StatsController.cs index 334ae80b9..eb37c8bcb 100644 --- a/Plugins/Stats/Controllers/StatsController.cs +++ b/Plugins/Stats/Controllers/StatsController.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using SharedLibraryCore; +using SharedLibraryCore.Dtos; using System; using System.Linq; using System.Threading.Tasks; @@ -16,6 +17,7 @@ namespace IW4MAdmin.Plugins.Stats.Web.Controllers { ViewBag.Title = Utilities.CurrentLocalization.LocalizationIndex.Set["WEBFRONT_STATS_INDEX_TITLE"]; ViewBag.Description = Utilities.CurrentLocalization.LocalizationIndex.Set["WEBFRONT_STATS_INDEX_DESC"]; + ViewBag.Servers = Manager.GetServers().Select(_server => new ServerInfo() { Name = _server.Hostname, ID = _server.GetHashCode() }); return View("Index", await Plugin.Manager.GetTopStats(0, 50)); } diff --git a/Plugins/Stats/Dtos/TopStatsInfo.cs b/Plugins/Stats/Dtos/TopStatsInfo.cs index 22fa8a8f0..f49e03f32 100644 --- a/Plugins/Stats/Dtos/TopStatsInfo.cs +++ b/Plugins/Stats/Dtos/TopStatsInfo.cs @@ -18,5 +18,6 @@ namespace IW4MAdmin.Plugins.Stats.Web.Dtos public int Deaths { get; set; } public int RatingChange { get; set; } public List PerformanceHistory { get; set; } + public List Servers { get; set; } } } diff --git a/Plugins/Web/StatsWeb/StatsWeb.csproj b/Plugins/Web/StatsWeb/StatsWeb.csproj index 85f71f306..51f178402 100644 --- a/Plugins/Web/StatsWeb/StatsWeb.csproj +++ b/Plugins/Web/StatsWeb/StatsWeb.csproj @@ -1,7 +1,8 @@  netcoreapp2.2 - true + false + true RazorSdk Debug;Release;Prerelease diff --git a/Plugins/Web/StatsWeb/Views/Stats/Index.cshtml b/Plugins/Web/StatsWeb/Views/Stats/Index.cshtml index 34a1e030d..2d82a5a92 100644 --- a/Plugins/Web/StatsWeb/Views/Stats/Index.cshtml +++ b/Plugins/Web/StatsWeb/Views/Stats/Index.cshtml @@ -1,14 +1,53 @@ @model List -

@ViewBag.Title

-
- @await Html.PartialAsync("_List", Model) + + +
+
+ @{ + if (Model.Count > 0) + { + await Html.PartialAsync("_List", Model); + } + else + { +
@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex.Set["PLUGINS_STATS_TEXT_NOQUALIFY"]
+ } + } +
+ + @foreach (var server in ViewBag.Servers) + { +
+ @{ + if (Model.Count > 0) + { + await Html.PartialAsync("_List", Model); + } + else + { +
@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex.Set["PLUGINS_STATS_TEXT_NOQUALIFY"]
+ } + } +
+ }
@section scripts { - - + @* + *@ - + @**@ } diff --git a/WebfrontCore/Startup.cs b/WebfrontCore/Startup.cs index 0e663c4cd..150b57c8b 100644 --- a/WebfrontCore/Startup.cs +++ b/WebfrontCore/Startup.cs @@ -47,6 +47,14 @@ namespace WebfrontCore } }); +#if DEBUG + mvcBuilder = mvcBuilder.AddRazorOptions(options => options.AllowRecompilingViewsOnFileChange = true); + services.Configure(_options => + { + _options.ViewLocationFormats.Add(@"/Views/Plugins/{1}/{0}" + RazorViewEngine.ViewExtension); + }); +#endif + foreach (var asm in Program.Manager.GetPluginAssemblies()) { mvcBuilder.AddApplicationPart(asm); diff --git a/WebfrontCore/Views/Client/Profile/Index.cshtml b/WebfrontCore/Views/Client/Profile/Index.cshtml index 5e84faf98..8de2d58a1 100644 --- a/WebfrontCore/Views/Client/Profile/Index.cshtml +++ b/WebfrontCore/Views/Client/Profile/Index.cshtml @@ -82,7 +82,7 @@ }
-
@Model.Level @(isTempBanned ? $"&emdash; {loc["WEBFRONT_PROFILE_TEMPBAN"]}" : "")
+
@Model.Level @(isTempBanned ? $"({loc["WEBFRONT_PROFILE_TEMPBAN"]})" : "")
@loc["WEBFRONT_PROFILE_PLAYER"] @Model.TimePlayed @loc["GLOBAL_TIME_HOURS"] diff --git a/WebfrontCore/WebfrontCore.csproj b/WebfrontCore/WebfrontCore.csproj index 79f2d3693..94693f988 100644 --- a/WebfrontCore/WebfrontCore.csproj +++ b/WebfrontCore/WebfrontCore.csproj @@ -3,7 +3,7 @@ netcoreapp2.2 2.2.2 - true + false true true 2.6 diff --git a/WebfrontCore/wwwroot/css/bootstrap-custom.css b/WebfrontCore/wwwroot/css/bootstrap-custom.css index c7a3f49b3..ea0af9ad6 100644 --- a/WebfrontCore/wwwroot/css/bootstrap-custom.css +++ b/WebfrontCore/wwwroot/css/bootstrap-custom.css @@ -6416,3 +6416,22 @@ form *, select { position: fixed; bottom: 1em; right: 1em; } + +.nav-tabs, .nav-tabs .nav-link.active { + border-color: #007ACC; + background-color: rgba(0, 0, 0, 0.2); + color: #fff !important; } + +.nav-tabs .nav-link:hover { + border-color: #007ACC; + background-color: rgba(0, 0, 0, 0.2); + border-width: 2px; } + +.nav-tabs .nav-link { + border-radius: 0; + padding: 1rem; + color: #6c757d; + border-width: 2px; } + +.nav-tabs .nav-link.active { + border-bottom-color: transparent; } diff --git a/WebfrontCore/wwwroot/css/bootstrap-custom.scss b/WebfrontCore/wwwroot/css/bootstrap-custom.scss index 7bd509ff3..9e6eadea6 100644 --- a/WebfrontCore/wwwroot/css/bootstrap-custom.scss +++ b/WebfrontCore/wwwroot/css/bootstrap-custom.scss @@ -219,3 +219,26 @@ form *, select { bottom: 1em; right: 1em; } + +.nav-tabs, .nav-tabs .nav-link.active { + border-color: $blue; + background-color: rgba(0, 0, 0, 0.2); + color: $white !important; +} + +.nav-tabs .nav-link:hover { + border-color: $blue; + background-color: rgba(0, 0, 0, 0.2); + border-width: 2px; +} + +.nav-tabs .nav-link { + border-radius: 0; + padding: 1rem; + color: #6c757d; + border-width: 2px; +} + +.nav-tabs .nav-link.active { + border-bottom-color: transparent; +}