]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
add entity logs verb (#14170)
authorChief-Engineer <119664036+Chief-Engineer@users.noreply.github.com>
Sun, 19 Feb 2023 01:00:17 +0000 (19:00 -0600)
committerGitHub <noreply@github.com>
Sun, 19 Feb 2023 01:00:17 +0000 (19:00 -0600)
Content.Client/Administration/UI/Logs/AdminLogsControl.xaml.cs
Content.Client/Administration/UI/Logs/AdminLogsEui.cs
Content.Server/Administration/Logs/AdminLogsEui.cs
Content.Server/Administration/Systems/AdminVerbSystem.cs
Content.Shared/Administration/Logs/AdminLogsEuiState.cs
Resources/Locale/en-US/administration/admin-verbs.ftl

index 8372e3aa49d5cb3cd23eb0cc6eb3b15484de114e..35233e4ae3aa7fd7d908cc338505df2119386f8c 100644 (file)
@@ -174,6 +174,32 @@ public sealed partial class AdminLogsControl : Control
         UpdateLogs();
     }
 
+    public void SetTypesSelection(HashSet<LogType> selectedTypes, bool invert = false)
+    {
+        SelectedTypes.Clear();
+
+        foreach (var control in TypesContainer.Children)
+        {
+            if (control is not AdminLogTypeButton type)
+            {
+                continue;
+            }
+
+            if (selectedTypes.Contains(type.Type) ^ invert)
+            {
+                type.Pressed = true;
+                SelectedTypes.Add(type.Type);
+            }
+            else
+            {
+                type.Pressed = false;
+                type.Visible = ShouldShowType(type);
+            }
+        }
+
+        UpdateLogs();
+    }
+
     public void UpdateTypes()
     {
         foreach (var control in TypesContainer.Children)
index 0c0c87f6c26ffea22562bb78623fa919560c78ac..39faa2728411748136ab25149aef5873c5870bd8 100644 (file)
@@ -137,6 +137,15 @@ public sealed class AdminLogsEui : BaseEui
 
                 LogsControl.NextButton.Disabled = !newLogs.HasNext;
                 break;
+
+            case SetLogFilter setLogFilter:
+                if (setLogFilter.Search != null)
+                    LogsControl.LogSearch.SetText(setLogFilter.Search);
+
+                if (setLogFilter.Types != null)
+                    LogsControl.SetTypesSelection(setLogFilter.Types, setLogFilter.InvertTypes);
+
+                break;
         }
     }
 
index 8b0366faf1795bec4101ca9ff80efb386b35e658..47f6e8af017a6592a67cb050e20168dda33ceb8e 100644 (file)
@@ -7,6 +7,7 @@ using Content.Server.GameTicking;
 using Content.Shared.Administration;
 using Content.Shared.Administration.Logs;
 using Content.Shared.CCVar;
+using Content.Shared.Database;
 using Content.Shared.Eui;
 using Microsoft.Extensions.ObjectPool;
 using Robust.Shared.Configuration;
@@ -140,6 +141,16 @@ public sealed class AdminLogsEui : BaseEui
         }
     }
 
+    public void SetLogFilter(string? search = null, bool invertTypes = false, HashSet<LogType>? types = null)
+    {
+        var message = new SetLogFilter(
+            search,
+            invertTypes,
+            types);
+
+        SendMessage(message);
+    }
+
     private async void SendLogs(bool replace)
     {
         var stopwatch = new Stopwatch();
index 300dec0386722dd36809ffb9ff82e8e24059c51a..0ad22dbf5e66beb83abad5771785019ea838e2bd 100644 (file)
@@ -1,4 +1,5 @@
 using Content.Server.Administration.Commands;
+using Content.Server.Administration.Logs;
 using Content.Server.Administration.Managers;
 using Content.Server.Administration.UI;
 using Content.Server.Chemistry.Components.SolutionManager;
@@ -48,6 +49,7 @@ namespace Content.Server.Administration.Systems
         [Dependency] private readonly ArtifactSystem _artifactSystem = default!;
         [Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
         [Dependency] private readonly PrayerSystem _prayerSystem = default!;
+        [Dependency] private readonly EuiManager _eui = default!;
 
         private readonly Dictionary<IPlayerSession, EditSolutionsEui> _openSolutionUis = new();
 
@@ -119,6 +121,25 @@ namespace Content.Server.Administration.Systems
                     });
                 }
 
+                // Admin Logs
+                if (_adminManager.HasAdminFlag(player, AdminFlags.Logs))
+                {
+                    Verb logsVerbEntity = new()
+                    {
+                        Priority = -2,
+                        Text = Loc.GetString("admin-verbs-admin-logs-entity"),
+                        Category = VerbCategory.Admin,
+                        Act = () =>
+                        {
+                            var ui = new AdminLogsEui();
+                            _eui.OpenEui(ui, player);
+                            ui.SetLogFilter(search:args.Target.GetHashCode().ToString());
+                        },
+                        Impact = LogImpact.Low
+                    };
+                    args.Verbs.Add(logsVerbEntity);
+                }
+
                 // TeleportTo
                 args.Verbs.Add(new Verb
                 {
index 67017aca51bcf9eac8d1fc5b657466299e2aac7f..ec3c72c13b728b1b24b55d7bb18bdc6fc3e7ce9f 100644 (file)
@@ -27,6 +27,21 @@ public static class AdminLogsEuiMsg
     {
     }
 
+    [Serializable, NetSerializable]
+    public sealed class SetLogFilter : EuiMessageBase
+    {
+        public SetLogFilter(string? search = null, bool invertTypes = false, HashSet<LogType>? types = null)
+        {
+            Search = search;
+            InvertTypes = invertTypes;
+            Types = types;
+        }
+
+        public string? Search { get; set; }
+        public bool InvertTypes { get; set; }
+        public HashSet<LogType>? Types { get; set; }
+    }
+
     [Serializable, NetSerializable]
     public sealed class NewLogs : EuiMessageBase
     {
index 5bd9845e422830302bfd6a86f2d6e550b6c5df50..dab68eab4d749228a6cb9eb5392a740d17d93319 100644 (file)
@@ -2,6 +2,7 @@ delete-verb-get-data-text = Delete
 edit-solutions-verb-get-data-text = Edit Solutions
 explode-verb-get-data-text = Explode
 ahelp-verb-get-data-text = Message
+admin-verbs-admin-logs-entity = Entity Logs
 admin-verbs-teleport-to = Teleport To
 admin-verbs-teleport-here = Teleport Here
 admin-verbs-freeze = Freeze