From 284c2e97262b1a66fadd3078fa896006bc532b2e Mon Sep 17 00:00:00 2001 From: RaidMax Date: Thu, 21 Apr 2022 12:39:09 -0500 Subject: [PATCH] ui tweaks/improvements including recent players and ip info lookup --- SharedLibraryCore/Dtos/ClientInfo.cs | 1 + SharedLibraryCore/Dtos/ServerInfo.cs | 1 + SharedLibraryCore/Services/ClientService.cs | 31 +- WebfrontCore/Controllers/ActionController.cs | 21 +- .../Controllers/Client/ClientController.cs | 5 +- WebfrontCore/Views/Client/Find/Index.cshtml | 3 +- WebfrontCore/Views/Client/Message/Find.cshtml | 3 +- .../Views/Client/Privileged/Index.cshtml | 43 ++- .../Views/Client/Profile/Index.cshtml | 356 +++++++++--------- .../Client/Profile/Meta/_Information.cshtml | 19 +- .../Meta/_ReceivedPenaltyResponse.cshtml | 2 +- .../Views/Penalty/PenaltyInfoList.cshtml | 11 +- .../Components/Client/_RecentClients.cshtml | 51 +-- .../Views/Shared/Partials/_Reports.cshtml | 39 ++ WebfrontCore/Views/Shared/_Layout.cshtml | 96 ++--- WebfrontCore/Views/Shared/_LeftNavBar.cshtml | 14 +- WebfrontCore/WebfrontCore.csproj | 2 +- WebfrontCore/wwwroot/css/src/main.scss | 4 +- WebfrontCore/wwwroot/css/src/profile.scss | 9 +- WebfrontCore/wwwroot/js/action.js | 11 +- WebfrontCore/wwwroot/js/profile.js | 25 +- 21 files changed, 422 insertions(+), 325 deletions(-) create mode 100644 WebfrontCore/Views/Shared/Partials/_Reports.cshtml diff --git a/SharedLibraryCore/Dtos/ClientInfo.cs b/SharedLibraryCore/Dtos/ClientInfo.cs index 5e05fcd0d..b252899a3 100644 --- a/SharedLibraryCore/Dtos/ClientInfo.cs +++ b/SharedLibraryCore/Dtos/ClientInfo.cs @@ -10,5 +10,6 @@ namespace SharedLibraryCore.Dtos public int LinkId { get; set; } public EFClient.Permission Level { get; set; } public DateTime LastConnection { get; set; } + public bool IsMasked { get; set; } } } diff --git a/SharedLibraryCore/Dtos/ServerInfo.cs b/SharedLibraryCore/Dtos/ServerInfo.cs index 1c7397406..68febd140 100644 --- a/SharedLibraryCore/Dtos/ServerInfo.cs +++ b/SharedLibraryCore/Dtos/ServerInfo.cs @@ -15,6 +15,7 @@ namespace SharedLibraryCore.Dtos public int MaxClients { get; set; } public List ChatHistory { get; set; } public List Players { get; set; } + public List Reports { get; set; } public ClientHistoryInfo ClientHistory { get; set; } public long ID { get; set; } public bool Online { get; set; } diff --git a/SharedLibraryCore/Services/ClientService.cs b/SharedLibraryCore/Services/ClientService.cs index 6b5d98348..6e02ffc77 100644 --- a/SharedLibraryCore/Services/ClientService.cs +++ b/SharedLibraryCore/Services/ClientService.cs @@ -47,13 +47,15 @@ namespace SharedLibraryCore.Services private readonly ApplicationConfiguration _appConfig; private readonly IDatabaseContextFactory _contextFactory; private readonly ILogger _logger; + private readonly IGeoLocationService _geoLocationService; public ClientService(ILogger logger, IDatabaseContextFactory databaseContextFactory, - ApplicationConfiguration appConfig) + ApplicationConfiguration appConfig, IGeoLocationService geoLocationService) { _contextFactory = databaseContextFactory; _logger = logger; _appConfig = appConfig; + _geoLocationService = geoLocationService; } public async Task Create(EFClient entity) @@ -782,7 +784,8 @@ namespace SharedLibraryCore.Services Password = client.Password, PasswordSalt = client.PasswordSalt, NetworkId = client.NetworkId, - LastConnection = client.LastConnection + LastConnection = client.LastConnection, + Masked = client.Masked }; return await iqClients.ToListAsync(); @@ -901,18 +904,24 @@ namespace SharedLibraryCore.Services await using var context = _contextFactory.CreateContext(false); var iqClients = context.Clients - .Where(_client => _client.CurrentAlias.IPAddress != null) - .Where(_client => _client.FirstConnection >= startOfPeriod) - .OrderByDescending(_client => _client.FirstConnection) - .Select(_client => new PlayerInfo + .Where(client => client.CurrentAlias.IPAddress != null) + .Where(client => client.FirstConnection >= startOfPeriod) + .OrderByDescending(client => client.FirstConnection) + .Select(client => new PlayerInfo { - ClientId = _client.ClientId, - Name = _client.CurrentAlias.Name, - IPAddress = _client.CurrentAlias.IPAddress.ConvertIPtoString(), - LastConnection = _client.FirstConnection + ClientId = client.ClientId, + Name = client.CurrentAlias.Name, + IPAddress = client.CurrentAlias.IPAddress.ConvertIPtoString(), + LastConnection = client.FirstConnection }); - return await iqClients.ToListAsync(); + var clientList = await iqClients.ToListAsync(); + foreach (var client in clientList) + { + client.GeoLocationInfo = await _geoLocationService.Locate(client.IPAddress); + } + + return clientList; } #endregion diff --git a/WebfrontCore/Controllers/ActionController.cs b/WebfrontCore/Controllers/ActionController.cs index 1a79e2b5b..d3d8db325 100644 --- a/WebfrontCore/Controllers/ActionController.cs +++ b/WebfrontCore/Controllers/ActionController.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Mvc; using SharedLibraryCore; using SharedLibraryCore.Commands; using SharedLibraryCore.Configuration; +using SharedLibraryCore.Dtos; using SharedLibraryCore.Interfaces; using WebfrontCore.Permissions; using WebfrontCore.ViewModels; @@ -317,17 +318,21 @@ namespace WebfrontCore.Controllers public async Task RecentClientsForm() { var clients = await Manager.GetClientService().GetRecentClients(); - foreach (var client in clients) - { - client.IPAddress = - _appConfig.HasPermission(Client.Level, WebfrontEntity.ClientIPAddress, WebfrontPermission.Read) - ? client.IPAddress - : null; - } - return View("~/Views/Shared/Components/Client/_RecentClients.cshtml", clients); } + public IActionResult RecentReportsForm() + { + var serverInfo = Manager.GetServers().Select(server => + new ServerInfo + { + Name = server.Hostname, + Reports = server.Reports + }); + + return View("Partials/_Reports", serverInfo); + } + public IActionResult FlagForm() { var info = new ActionInfo diff --git a/WebfrontCore/Controllers/Client/ClientController.cs b/WebfrontCore/Controllers/Client/ClientController.cs index 710801b2d..43f5f4f5c 100644 --- a/WebfrontCore/Controllers/Client/ClientController.cs +++ b/WebfrontCore/Controllers/Client/ClientController.cs @@ -176,11 +176,12 @@ namespace WebfrontCore.Controllers adminsDict.Add(admin.Level, new List()); } - adminsDict[admin.Level].Add(new ClientInfo() + adminsDict[admin.Level].Add(new ClientInfo { Name = admin.Name, ClientId = admin.ClientId, - LastConnection = admin.LastConnection + LastConnection = admin.LastConnection, + IsMasked = admin.Masked }); } diff --git a/WebfrontCore/Views/Client/Find/Index.cshtml b/WebfrontCore/Views/Client/Find/Index.cshtml index c968c8bcd..37a916493 100644 --- a/WebfrontCore/Views/Client/Find/Index.cshtml +++ b/WebfrontCore/Views/Client/Find/Index.cshtml @@ -5,7 +5,8 @@
-

@ViewBag.ResultCount result(s) for @ViewBag.SearchTerm

+

Search Results

+
@ViewBag.SearchTerm returned @ViewBag.ResultCount matche(s)
diff --git a/WebfrontCore/Views/Client/Message/Find.cshtml b/WebfrontCore/Views/Client/Message/Find.cshtml index 64fcf098f..46d0b381a 100644 --- a/WebfrontCore/Views/Client/Message/Find.cshtml +++ b/WebfrontCore/Views/Client/Message/Find.cshtml @@ -9,7 +9,8 @@ else { -

@Html.Raw(Utilities.FormatExt(ViewBag.Localization["WEBFRONT_STATS_MESSAGES_FOUND"], $"{Model.TotalResultCount.ToString("N0")}"))

+

Search Results

+
@Html.Raw(Utilities.FormatExt(ViewBag.Localization["WEBFRONT_STATS_MESSAGES_FOUND"], $"{Model.TotalResultCount.ToString("N0")}"))
diff --git a/WebfrontCore/Views/Client/Privileged/Index.cshtml b/WebfrontCore/Views/Client/Privileged/Index.cshtml index e1eb61cad..b493c5495 100644 --- a/WebfrontCore/Views/Client/Privileged/Index.cshtml +++ b/WebfrontCore/Views/Client/Privileged/Index.cshtml @@ -1,7 +1,8 @@ -@model Dictionary> +@model Dictionary>

@ViewBag.Title

+ @foreach (var key in Model.Keys) {
@@ -12,20 +13,34 @@ - @foreach (var client in Model[key].OrderByDescending(client => client.LastConnection)) - { - - - - - } + + @foreach (var client in Model[key].OrderByDescending(client => client.LastConnection)) + { + if (!ViewBag.Authorized && client.IsMasked) + { + continue; + } + + + + + } +
- - - - - @client.LastConnection.HumanizeForCurrentCulture() -
+ @if (client.IsMasked) + { + + + + } + + + + + + @client.LastConnection.HumanizeForCurrentCulture() +
} +
diff --git a/WebfrontCore/Views/Client/Profile/Index.cshtml b/WebfrontCore/Views/Client/Profile/Index.cshtml index 5d5403e1c..76bdfdf9f 100644 --- a/WebfrontCore/Views/Client/Profile/Index.cshtml +++ b/WebfrontCore/Views/Client/Profile/Index.cshtml @@ -33,205 +33,217 @@
- @if (Model.ActivePenalty != null) - { - -