diff --git a/Content.Client/Administration/Logs/AdminLogSystem.cs b/Content.Client/Administration/Logs/AdminLogSystem.cs new file mode 100644 index 00000000000..895fd629251 --- /dev/null +++ b/Content.Client/Administration/Logs/AdminLogSystem.cs @@ -0,0 +1,7 @@ +using Content.Shared.Administration.Logs; + +namespace Content.Client.Administration.Logs; + +public class AdminLogSystem : SharedAdminLogSystem +{ +} diff --git a/Content.Client/Administration/UI/CustomControls/AdminLogImpactButton.cs b/Content.Client/Administration/UI/CustomControls/AdminLogImpactButton.cs new file mode 100644 index 00000000000..be4b1983471 --- /dev/null +++ b/Content.Client/Administration/UI/CustomControls/AdminLogImpactButton.cs @@ -0,0 +1,16 @@ +using Content.Shared.Administration.Logs; +using Robust.Client.UserInterface.Controls; + +namespace Content.Client.Administration.UI.CustomControls; + +public class AdminLogImpactButton : Button +{ + public AdminLogImpactButton(LogImpact impact) + { + Impact = impact; + ToggleMode = true; + Pressed = true; + } + + public LogImpact Impact { get; } +} diff --git a/Content.Client/Administration/UI/CustomControls/AdminLogLabel.cs b/Content.Client/Administration/UI/CustomControls/AdminLogLabel.cs new file mode 100644 index 00000000000..029d414a679 --- /dev/null +++ b/Content.Client/Administration/UI/CustomControls/AdminLogLabel.cs @@ -0,0 +1,33 @@ +using Content.Shared.Administration.Logs; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.Controls; + +namespace Content.Client.Administration.UI.CustomControls; + +public class AdminLogLabel : RichTextLabel +{ + public AdminLogLabel(ref SharedAdminLog log, HSeparator separator) + { + Log = log; + Separator = separator; + + SetMessage(log.Message); + OnVisibilityChanged += VisibilityChanged; + } + + public SharedAdminLog Log { get; } + + public HSeparator Separator { get; } + + private void VisibilityChanged(Control control) + { + Separator.Visible = Visible; + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + + OnVisibilityChanged -= VisibilityChanged; + } +} diff --git a/Content.Client/Administration/UI/CustomControls/AdminLogPlayerButton.cs b/Content.Client/Administration/UI/CustomControls/AdminLogPlayerButton.cs new file mode 100644 index 00000000000..a6606a066a8 --- /dev/null +++ b/Content.Client/Administration/UI/CustomControls/AdminLogPlayerButton.cs @@ -0,0 +1,17 @@ +using System; +using Robust.Client.UserInterface.Controls; + +namespace Content.Client.Administration.UI.CustomControls; + +public class AdminLogPlayerButton : Button +{ + public AdminLogPlayerButton(Guid id) + { + Id = id; + ClipText = true; + ToggleMode = true; + Pressed = true; + } + + public Guid Id { get; } +} diff --git a/Content.Client/Administration/UI/CustomControls/AdminLogTypeButton.cs b/Content.Client/Administration/UI/CustomControls/AdminLogTypeButton.cs new file mode 100644 index 00000000000..0ad83eb0eab --- /dev/null +++ b/Content.Client/Administration/UI/CustomControls/AdminLogTypeButton.cs @@ -0,0 +1,16 @@ +using Content.Shared.Administration.Logs; +using Robust.Client.UserInterface.Controls; + +namespace Content.Client.Administration.UI.CustomControls; + +public class AdminLogTypeButton : Button +{ + public AdminLogTypeButton(LogType type) + { + Type = type; + ToggleMode = true; + Pressed = true; + } + + public LogType Type { get; } +} diff --git a/Content.Client/Administration/UI/CustomControls/HSeparator.cs b/Content.Client/Administration/UI/CustomControls/HSeparator.cs new file mode 100644 index 00000000000..3e7005942dc --- /dev/null +++ b/Content.Client/Administration/UI/CustomControls/HSeparator.cs @@ -0,0 +1,25 @@ +using Robust.Client.Graphics; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.Controls; +using Robust.Shared.Maths; + +namespace Content.Client.Administration.UI.CustomControls; + +public class HSeparator : Control +{ + private static readonly Color SeparatorColor = Color.FromHex("#3D4059"); + + public HSeparator(Color color) + { + AddChild(new PanelContainer + { + PanelOverride = new StyleBoxFlat + { + BackgroundColor = color, + ContentMarginBottomOverride = 2, ContentMarginLeftOverride = 2 + } + }); + } + + public HSeparator() : this(SeparatorColor) { } +} diff --git a/Content.Client/Administration/UI/CustomControls/VSeparator.cs b/Content.Client/Administration/UI/CustomControls/VSeparator.cs new file mode 100644 index 00000000000..b413cacd495 --- /dev/null +++ b/Content.Client/Administration/UI/CustomControls/VSeparator.cs @@ -0,0 +1,25 @@ +using Robust.Client.Graphics; +using Robust.Client.UserInterface.Controls; +using Robust.Shared.Maths; + +namespace Content.Client.Administration.UI.CustomControls; + +public class VSeparator : PanelContainer +{ + private static readonly Color SeparatorColor = Color.FromHex("#3D4059"); + + public VSeparator(Color color) + { + MinSize = (2, 5); + + AddChild(new PanelContainer + { + PanelOverride = new StyleBoxFlat + { + BackgroundColor = color + } + }); + } + + public VSeparator() : this(SeparatorColor) { } +} diff --git a/Content.Client/Administration/UI/Logs/AdminLogsEui.cs b/Content.Client/Administration/UI/Logs/AdminLogsEui.cs new file mode 100644 index 00000000000..a40a248f3c9 --- /dev/null +++ b/Content.Client/Administration/UI/Logs/AdminLogsEui.cs @@ -0,0 +1,106 @@ +using Content.Client.Eui; +using Content.Shared.Administration; +using Content.Shared.Administration.Logs; +using Content.Shared.Eui; +using JetBrains.Annotations; +using static Content.Shared.Administration.AdminLogsEuiMsg; + +namespace Content.Client.Administration.UI.Logs; + +[UsedImplicitly] +public class AdminLogsEui : BaseEui +{ + public AdminLogsEui() + { + Window = new AdminLogsWindow(); + Window.OnClose += () => SendMessage(new Close()); + Window.LogSearch.OnTextEntered += _ => RequestLogs(); + Window.RefreshButton.OnPressed += _ => RequestLogs(); + Window.NextButton.OnPressed += _ => NextLogs(); + } + + private AdminLogsWindow Window { get; } + + private bool FirstState { get; set; } = true; + + private void RequestLogs() + { + var round = Window.GetSelectedRoundId(); + var types = Window.GetSelectedLogTypes(); + var players = Window.GetSelectedPlayerIds(); + + var request = new LogsRequest( + round, + types, + null, + null, + null, + players, + null, + null, + DateOrder.Descending); + + SendMessage(request); + } + + private void NextLogs() + { + var request = new NextLogsRequest(); + SendMessage(request); + } + + private void TrySetFirstState(AdminLogsEuiState state) + { + if (!FirstState) + { + return; + } + + FirstState = false; + Window.SetCurrentRound(state.RoundId); + Window.SetRoundSpinBox(state.RoundId); + } + + public override void Opened() + { + Window.OpenCentered(); + } + + public override void HandleState(EuiStateBase state) + { + var s = (AdminLogsEuiState) state; + + TrySetFirstState(s); + + if (s.IsLoading) + { + return; + } + + Window.SetCurrentRound(s.RoundId); + Window.SetPlayers(s.Players); + } + + public override void HandleMessage(EuiMessageBase msg) + { + base.HandleMessage(msg); + + switch (msg) + { + case NewLogs {Replace: true} newLogs: + Window.SetLogs(newLogs.Logs); + break; + case NewLogs {Replace: false} newLogs: + Window.AddLogs(newLogs.Logs); + break; + } + } + + public override void Closed() + { + base.Closed(); + + Window.Close(); + Window.Dispose(); + } +} diff --git a/Content.Client/Administration/UI/Logs/AdminLogsWindow.xaml b/Content.Client/Administration/UI/Logs/AdminLogsWindow.xaml new file mode 100644 index 00000000000..345e30cd27d --- /dev/null +++ b/Content.Client/Administration/UI/Logs/AdminLogsWindow.xaml @@ -0,0 +1,55 @@ + + + + +