diff --git a/Application/Misc/ScriptPlugin.cs b/Application/Misc/ScriptPlugin.cs index b9b91503f..c596ee809 100644 --- a/Application/Misc/ScriptPlugin.cs +++ b/Application/Misc/ScriptPlugin.cs @@ -1,4 +1,5 @@ using Jint; +using Microsoft.CSharp.RuntimeBinder; using SharedLibraryCore; using SharedLibraryCore.Database.Models; using SharedLibraryCore.Interfaces; @@ -100,19 +101,20 @@ namespace IW4MAdmin.Application.Misc Name = pluginObject.name; Version = (float)pluginObject.version; + await OnLoadAsync(manager); + try { if (pluginObject.isParser) { - await OnLoadAsync(manager); IEventParser eventParser = (IEventParser)_scriptEngine.GetValue("eventParser").ToObject(); IRConParser rconParser = (IRConParser)_scriptEngine.GetValue("rconParser").ToObject(); manager.AdditionalEventParsers.Add(eventParser); manager.AdditionalRConParsers.Add(rconParser); } } - catch { } + catch (RuntimeBinderException) { } if (!firstRun) { diff --git a/SharedLibraryCore/Services/PenaltyService.cs b/SharedLibraryCore/Services/PenaltyService.cs index 424f25e8e..61105180a 100644 --- a/SharedLibraryCore/Services/PenaltyService.cs +++ b/SharedLibraryCore/Services/PenaltyService.cs @@ -62,12 +62,13 @@ namespace SharedLibraryCore.Services throw new NotImplementedException(); } - public async Task> GetRecentPenalties(int count, int offset, EFPenalty.PenaltyType showOnly = EFPenalty.PenaltyType.Any) + public async Task> GetRecentPenalties(int count, int offset, EFPenalty.PenaltyType showOnly = EFPenalty.PenaltyType.Any, bool ignoreAutomated = true) { using (var context = new DatabaseContext(true)) { var iqPenalties = context.Penalties .Where(p => showOnly == EFPenalty.PenaltyType.Any ? p.Type != EFPenalty.PenaltyType.Any : p.Type == showOnly) + .Where(_penalty => ignoreAutomated ? _penalty.PunisherId != 1 : true) .OrderByDescending(p => p.When) .Skip(offset) .Take(count) diff --git a/WebfrontCore/Controllers/PenaltyController.cs b/WebfrontCore/Controllers/PenaltyController.cs index 97f3e1da3..a7b32c3f1 100644 --- a/WebfrontCore/Controllers/PenaltyController.cs +++ b/WebfrontCore/Controllers/PenaltyController.cs @@ -18,21 +18,23 @@ namespace WebfrontCore.Controllers } - public IActionResult List(PenaltyType showOnly = PenaltyType.Any) + public IActionResult List(PenaltyType showOnly = PenaltyType.Any, bool hideAutomatedPenalties = true) { ViewBag.Description = "List of all the recent penalties (bans, kicks, warnings) on IW4MAdmin"; ViewBag.Title = Localization["WEBFRONT_PENALTY_TITLE"]; ViewBag.Keywords = "IW4MAdmin, penalties, ban, kick, warns"; + ViewBag.HideAutomatedPenalties = hideAutomatedPenalties; return View(showOnly); } - public async Task ListAsync(int offset = 0, PenaltyType showOnly = PenaltyType.Any) + public async Task ListAsync(int offset = 0, PenaltyType showOnly = PenaltyType.Any, bool hideAutomatedPenalties = true) { return await Task.FromResult(View("_List", new ViewModels.PenaltyFilterInfo() { Offset = offset, - ShowOnly = showOnly + ShowOnly = showOnly, + IgnoreAutomated = hideAutomatedPenalties })); } diff --git a/WebfrontCore/ViewComponents/PenaltyListViewComponent.cs b/WebfrontCore/ViewComponents/PenaltyListViewComponent.cs index 443f2dfb8..930748573 100644 --- a/WebfrontCore/ViewComponents/PenaltyListViewComponent.cs +++ b/WebfrontCore/ViewComponents/PenaltyListViewComponent.cs @@ -9,9 +9,9 @@ namespace WebfrontCore.ViewComponents { private const int PENALTY_COUNT = 15; - public async Task InvokeAsync(int offset, EFPenalty.PenaltyType showOnly) + public async Task InvokeAsync(int offset, EFPenalty.PenaltyType showOnly, bool ignoreAutomated) { - var penalties = await Program.Manager.GetPenaltyService().GetRecentPenalties(PENALTY_COUNT, offset, showOnly); + var penalties = await Program.Manager.GetPenaltyService().GetRecentPenalties(PENALTY_COUNT, offset, showOnly, ignoreAutomated); penalties = User.Identity.IsAuthenticated ? penalties : penalties.Where(p => !p.Sensitive).ToList(); return View("_List", penalties); diff --git a/WebfrontCore/ViewModels/PenaltyFilterInfo.cs b/WebfrontCore/ViewModels/PenaltyFilterInfo.cs index 7ea11b798..ad1d64369 100644 --- a/WebfrontCore/ViewModels/PenaltyFilterInfo.cs +++ b/WebfrontCore/ViewModels/PenaltyFilterInfo.cs @@ -2,9 +2,24 @@ namespace WebfrontCore.ViewModels { + /// + /// helper class to determine the filters to apply to penalties + /// public class PenaltyFilterInfo { + /// + /// number of items offset from the start of the list + /// public int Offset { get; set; } + + /// + /// show only a certain type of penalty + /// public PenaltyType ShowOnly { get; set; } + + /// + /// ignore penalties that are automated + /// + public bool IgnoreAutomated { get; set; } } } diff --git a/WebfrontCore/Views/Penalty/List.cshtml b/WebfrontCore/Views/Penalty/List.cshtml index 776666fbf..0966054c4 100644 --- a/WebfrontCore/Views/Penalty/List.cshtml +++ b/WebfrontCore/Views/Penalty/List.cshtml @@ -4,35 +4,54 @@ }

@ViewBag.Title

- + @{ + foreach (var penaltyType in Enum.GetValues(typeof(SharedLibraryCore.Database.Models.EFPenalty.PenaltyType))) { - if (Model == SharedLibraryCore.Database.Models.EFPenalty.PenaltyType.Any) + if ((SharedLibraryCore.Database.Models.EFPenalty.PenaltyType)penaltyType == SharedLibraryCore.Database.Models.EFPenalty.PenaltyType.Any) { - + if (Model == SharedLibraryCore.Database.Models.EFPenalty.PenaltyType.Any) + { + + } + else + { + + } } else { - - } - } - else - { - if ((SharedLibraryCore.Database.Models.EFPenalty.PenaltyType)penaltyType == Model) - { - - } - else - { - + if ((SharedLibraryCore.Database.Models.EFPenalty.PenaltyType)penaltyType == Model) + { + + } + else + { + + } } } } - } - + +
+ +
+
+ @loc["WEBFRONT_PENALTY_HIDE_AUTOMATED"] +
+
@@ -49,7 +68,8 @@ @await Component.InvokeAsync("PenaltyList", new WebfrontCore.ViewModels.PenaltyFilterInfo() { Offset = 0, - ShowOnly = Model + ShowOnly = Model, + IgnoreAutomated = ViewBag.HideAutomatedPenalties })
diff --git a/WebfrontCore/Views/Penalty/_List.cshtml b/WebfrontCore/Views/Penalty/_List.cshtml index 08d898f96..57658559b 100644 --- a/WebfrontCore/Views/Penalty/_List.cshtml +++ b/WebfrontCore/Views/Penalty/_List.cshtml @@ -4,4 +4,4 @@ @model WebfrontCore.ViewModels.PenaltyFilterInfo -@await Component.InvokeAsync("PenaltyList", new { offset = Model.Offset, showOnly = Model.ShowOnly }) \ No newline at end of file +@await Component.InvokeAsync("PenaltyList", new { offset = Model.Offset, showOnly = Model.ShowOnly, ignoreAutomated = Model.IgnoreAutomated }) \ No newline at end of file diff --git a/WebfrontCore/wwwroot/css/src/main.scss b/WebfrontCore/wwwroot/css/src/main.scss index f044f4834..33e7ee9a2 100644 --- a/WebfrontCore/wwwroot/css/src/main.scss +++ b/WebfrontCore/wwwroot/css/src/main.scss @@ -112,7 +112,7 @@ form *, select { border-left: none !important; border-right: none !important; border-bottom: none !important; - border-top: 2px solid $blue !important; + border-top: 1px solid $text-muted; } .oi-fix-navbar { @@ -341,3 +341,53 @@ title { color: #ff0000; } } + +.toggle-switch input { + opacity: 0; + width: 0; + height: 0; + margin:0; + padding: 0; +} +label.toggle-switch { + margin: 0; +} + +.toggle-switch { + position: relative; + height: calc(1.5em + 0.75rem + 2px); + width: 6rem; + border: 1px solid $text-muted; +} + +.toggle-switch-slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: $dark; + -webkit-transition: .4s; + transition: .4s; +} + +.toggle-switch-slider:before { + position: absolute; + content: ""; + height: calc(1.5em + 0.75rem); + width: 3em; + background-color: $light; + -webkit-transition: 0.25s; + transition: 0.25s; +} + +input:checked + .toggle-switch-slider { + background-color: $primary; +} + +input:checked + .toggle-switch-slider:before { + -webkit-transform: translateX(3em); + -ms-transform: translateX(3em); + transform: translateX(3em); +} diff --git a/WebfrontCore/wwwroot/js/penalty.js b/WebfrontCore/wwwroot/js/penalty.js index 91987e98d..ec2376063 100644 --- a/WebfrontCore/wwwroot/js/penalty.js +++ b/WebfrontCore/wwwroot/js/penalty.js @@ -23,7 +23,11 @@ function loadMorePenalties() { showLoader(); isLoading = true; - $.get('/Penalty/ListAsync', { offset: offset, showOnly : $('#penalty_filter_selection').val() }) + $.get('/Penalty/ListAsync', { + offset: offset, + showOnly: $('#penalty_filter_selection').val(), + hideAutomatedPenalties: document.getElementById('hide_automated_penalties_checkbox').checked + }) .done(function (response) { $('#penalty_table').append(response); if (response.trim().length === 0) { @@ -40,9 +44,13 @@ function loadMorePenalties() { } if ($('#penalty_table').length === 1) { - - $('#penalty_filter_selection').change(function() { - location = location.href.split('?')[0] + "?showOnly=" + $('#penalty_filter_selection').val(); + + $('#penalty_filter_selection').change(function () { + location = location.href.split('?')[0] + "?showOnly=" + $('#penalty_filter_selection').val() + '&hideAutomatedPenalties=' + document.getElementById('hide_automated_penalties_checkbox').checked; + }); + + $('#hide_automated_penalties_checkbox').click(function () { + location = location.href.split('?')[0] + "?showOnly=" + $('#penalty_filter_selection').val() + '&hideAutomatedPenalties=' + document.getElementById('hide_automated_penalties_checkbox').checked; }); /*