diff --git a/Plugins/Stats/Extensions.cs b/Plugins/Stats/Extensions.cs index 67ee16b1c..993a750d0 100644 --- a/Plugins/Stats/Extensions.cs +++ b/Plugins/Stats/Extensions.cs @@ -13,7 +13,6 @@ namespace IW4MAdmin.Plugins.Stats { private const int ZScoreRange = 3; private const int RankIconDivisions = 24; - private const int MaxMessages = 100; public class LogParams { @@ -127,70 +126,5 @@ namespace IW4MAdmin.Plugins.Stats return 0; } - - /// - /// todo: lets abstract this out to a generic buildable query - /// this is just a dirty PoC - /// - /// - /// - public static ChatSearchQuery ParseSearchInfo(this string query, int count, int offset) - { - string[] filters = query.Split('|'); - var searchRequest = new ChatSearchQuery - { - Filter = query, - Count = count, - Offset = offset - }; - - // sanity checks - searchRequest.Count = Math.Min(searchRequest.Count, MaxMessages); - searchRequest.Count = Math.Max(searchRequest.Count, 0); - searchRequest.Offset = Math.Max(searchRequest.Offset, 0); - - if (filters.Length > 1) - { - if (filters[0].ToLower() != "chat") - { - throw new ArgumentException("Query is not compatible with chat"); - } - - foreach (string filter in filters.Skip(1)) - { - string[] args = filter.Split(' '); - - if (args.Length > 1) - { - string recombinedArgs = string.Join(' ', args.Skip(1)); - switch (args[0].ToLower()) - { - case "before": - searchRequest.SentBefore = DateTime.Parse(recombinedArgs); - break; - case "after": - searchRequest.SentAfter = DateTime.Parse(recombinedArgs); - break; - case "server": - searchRequest.ServerId = args[1]; - break; - case "client": - searchRequest.ClientId = int.Parse(args[1]); - break; - case "contains": - searchRequest.MessageContains = string.Join(' ', args.Skip(1)); - break; - case "sort": - searchRequest.Direction = Enum.Parse(args[1], ignoreCase: true); - break; - } - } - } - - return searchRequest; - } - - throw new ArgumentException("No filters specified for chat search"); - } } } diff --git a/SharedLibraryCore/Utilities.cs b/SharedLibraryCore/Utilities.cs index dde7d502d..6995f2705 100644 --- a/SharedLibraryCore/Utilities.cs +++ b/SharedLibraryCore/Utilities.cs @@ -50,8 +50,8 @@ namespace SharedLibraryCore public static char[] DirectorySeparatorChars = { '\\', '/' }; public static char CommandPrefix { get; set; } = '!'; - public static string ToStandardFormat(this DateTime? time) => time?.ToString("yyyy-MM-dd H:mm:ss UTC"); - public static string ToStandardFormat(this DateTime time) => time.ToString("yyyy-MM-dd H:mm:ss UTC"); + public static string ToStandardFormat(this DateTime? time) => time?.ToString("yyyy-MM-dd HH:mm:ss UTC"); + public static string ToStandardFormat(this DateTime time) => time.ToString("yyyy-MM-dd HH:mm:ss UTC"); public static EFClient IW4MAdminClient(Server server = null) { diff --git a/WebfrontCore/Controllers/Client/Legacy/StatsController.cs b/WebfrontCore/Controllers/Client/Legacy/StatsController.cs index 13528d2ed..24fa04942 100644 --- a/WebfrontCore/Controllers/Client/Legacy/StatsController.cs +++ b/WebfrontCore/Controllers/Client/Legacy/StatsController.cs @@ -137,29 +137,9 @@ namespace IW4MAdmin.Plugins.Web.StatsWeb.Controllers } [HttpGet("Message/FindNext")] - public async Task FindNextMessages([FromQuery] string query, [FromQuery] int count, - [FromQuery] int offset) + public async Task FindNextMessages(ChatResourceRequest query) { - ChatSearchQuery searchRequest; - - try - { - searchRequest = query.ParseSearchInfo(count, offset); - } - - catch (ArgumentException e) - { - _logger.LogWarning(e, "Could not parse chat message search query {query}", query); - throw; - } - - catch (FormatException e) - { - _logger.LogWarning(e, "Could not parse chat message search query filter format {query}", query); - throw; - } - - var result = await _chatResourceQueryHelper.QueryResource(searchRequest); + var result = await _chatResourceQueryHelper.QueryResource(query); return PartialView("~/Views/Client/Message/_Item.cshtml", result.Results); } diff --git a/WebfrontCore/Views/Client/Message/Find.cshtml b/WebfrontCore/Views/Client/Message/Find.cshtml index aa5515c57..74036c9b3 100644 --- a/WebfrontCore/Views/Client/Message/Find.cshtml +++ b/WebfrontCore/Views/Client/Message/Find.cshtml @@ -26,14 +26,14 @@ else -
+
@section scripts { } diff --git a/WebfrontCore/Views/Shared/Partials/Search/_ChatSearch.cshtml b/WebfrontCore/Views/Shared/Partials/Search/_ChatSearch.cshtml index 45546b272..255ba816a 100644 --- a/WebfrontCore/Views/Shared/Partials/Search/_ChatSearch.cshtml +++ b/WebfrontCore/Views/Shared/Partials/Search/_ChatSearch.cshtml @@ -44,7 +44,7 @@ @foreach (var server in manager!.GetServers()) { } @@ -62,6 +62,7 @@ value="@afterDate.ToString("s", CultureInfo.InvariantCulture)"/>
@@ -78,6 +79,7 @@ value="@beforeDate.ToString("s", CultureInfo.InvariantCulture)"/> diff --git a/WebfrontCore/wwwroot/js/search.js b/WebfrontCore/wwwroot/js/search.js index 370142551..c2e6c30be 100644 --- a/WebfrontCore/wwwroot/js/search.js +++ b/WebfrontCore/wwwroot/js/search.js @@ -1,28 +1,4 @@ $(document).ready(function () { - $('.form-inline').submit(function (e) { - const id = $(e.currentTarget).find('input'); - if ($(id).val().length < 3) { - e.preventDefault(); - $(id) - .addClass('input-text-danger') - .delay(25) - .queue(function () { - $(this).addClass('input-border-transition').dequeue(); - }) - .delay(1000) - .queue(function () { - $(this).removeClass('input-text-danger').dequeue(); - }) - .delay(500) - .queue(function () { - $(this).removeClass('input-border-transition').dequeue(); - }); - } else if ($(id).val().startsWith("chat|")) { - e.preventDefault(); - window.location = "/Message/Find?query=" + $(id).val(); - } - }); - $('.date-picker-input').each((index, selector) => { new Datepicker(selector, { buttonClass: 'btn', @@ -33,7 +9,6 @@ }); }); - const clientSearchWrapper = $('*[id^="clientSearchWrapper"]'); const chatSearchWrapper = $('*[id^="chatSearchWrapper"]'); const searchTypeSelector = $('#searchTypeSelectorParent select');