Move admin logs into their own separate window
This commit is contained in:
@@ -4,6 +4,10 @@ using Content.Shared.Administration;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Eui;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.IoC;
|
||||
using static Content.Shared.Administration.AdminLogsEuiMsg;
|
||||
|
||||
namespace Content.Client.Administration.UI.Logs;
|
||||
@@ -11,28 +15,54 @@ namespace Content.Client.Administration.UI.Logs;
|
||||
[UsedImplicitly]
|
||||
public class AdminLogsEui : BaseEui
|
||||
{
|
||||
[Dependency] private readonly IClyde _clyde = default!;
|
||||
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
|
||||
|
||||
public AdminLogsEui()
|
||||
{
|
||||
Window = new AdminLogsWindow();
|
||||
Window.OnClose += () => SendMessage(new Close());
|
||||
Window.LogSearch.OnTextEntered += _ => RequestLogs();
|
||||
Window.RefreshButton.OnPressed += _ => RequestLogs();
|
||||
Window.NextButton.OnPressed += _ => NextLogs();
|
||||
var monitor = _clyde.EnumerateMonitors().First();
|
||||
|
||||
ClydeWindow = _clyde.CreateWindow(new WindowCreateParameters
|
||||
{
|
||||
Maximized = true,
|
||||
Title = "Admin Logs",
|
||||
Monitor = monitor
|
||||
});
|
||||
|
||||
ClydeWindow.RequestClosed += OnRequestClosed;
|
||||
ClydeWindow.DisposeOnClose = true;
|
||||
|
||||
LogsWindow = new AdminLogsWindow();
|
||||
LogsWindow.LogSearch.OnTextEntered += _ => RequestLogs();
|
||||
LogsWindow.RefreshButton.OnPressed += _ => RequestLogs();
|
||||
LogsWindow.NextButton.OnPressed += _ => NextLogs();
|
||||
|
||||
Root = _uiManager.CreateWindowRoot(ClydeWindow);
|
||||
Root.AddChild(LogsWindow);
|
||||
}
|
||||
|
||||
private AdminLogsWindow Window { get; }
|
||||
private WindowRoot Root { get; }
|
||||
|
||||
private IClydeWindow ClydeWindow { get; }
|
||||
|
||||
private AdminLogsWindow LogsWindow { get; }
|
||||
|
||||
private bool FirstState { get; set; } = true;
|
||||
|
||||
private void OnRequestClosed(WindowRequestClosedEventArgs args)
|
||||
{
|
||||
SendMessage(new Close());
|
||||
}
|
||||
|
||||
private void RequestLogs()
|
||||
{
|
||||
var request = new LogsRequest(
|
||||
Window.SelectedRoundId,
|
||||
Window.SelectedTypes.ToList(),
|
||||
LogsWindow.SelectedRoundId,
|
||||
LogsWindow.SelectedTypes.ToList(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
Window.SelectedPlayers.ToArray(),
|
||||
LogsWindow.SelectedPlayers.ToArray(),
|
||||
null,
|
||||
null,
|
||||
DateOrder.Descending);
|
||||
@@ -54,16 +84,11 @@ public class AdminLogsEui : BaseEui
|
||||
}
|
||||
|
||||
FirstState = false;
|
||||
Window.SetCurrentRound(state.RoundId);
|
||||
Window.SetRoundSpinBox(state.RoundId);
|
||||
LogsWindow.SetCurrentRound(state.RoundId);
|
||||
LogsWindow.SetRoundSpinBox(state.RoundId);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Opened()
|
||||
{
|
||||
Window.OpenCentered();
|
||||
}
|
||||
|
||||
public override void HandleState(EuiStateBase state)
|
||||
{
|
||||
var s = (AdminLogsEuiState) state;
|
||||
@@ -75,8 +100,8 @@ public class AdminLogsEui : BaseEui
|
||||
return;
|
||||
}
|
||||
|
||||
Window.SetCurrentRound(s.RoundId);
|
||||
Window.SetPlayers(s.Players);
|
||||
LogsWindow.SetCurrentRound(s.RoundId);
|
||||
LogsWindow.SetPlayers(s.Players);
|
||||
|
||||
if (first)
|
||||
{
|
||||
@@ -91,10 +116,10 @@ public class AdminLogsEui : BaseEui
|
||||
switch (msg)
|
||||
{
|
||||
case NewLogs {Replace: true} newLogs:
|
||||
Window.SetLogs(newLogs.Logs);
|
||||
LogsWindow.SetLogs(newLogs.Logs);
|
||||
break;
|
||||
case NewLogs {Replace: false} newLogs:
|
||||
Window.AddLogs(newLogs.Logs);
|
||||
LogsWindow.AddLogs(newLogs.Logs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -103,7 +128,10 @@ public class AdminLogsEui : BaseEui
|
||||
{
|
||||
base.Closed();
|
||||
|
||||
Window.Close();
|
||||
Window.Dispose();
|
||||
ClydeWindow.RequestClosed -= OnRequestClosed;
|
||||
|
||||
LogsWindow.Dispose();
|
||||
Root.Dispose();
|
||||
ClydeWindow.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
<SS14Window xmlns="https://spacestation14.io"
|
||||
<Control xmlns="https://spacestation14.io"
|
||||
xmlns:aui="clr-namespace:Content.Client.Administration.UI.CustomControls"
|
||||
Title="{Loc admin-logs-title}"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||
MinWidth="1000"
|
||||
MinHeight="400">
|
||||
<PanelContainer>
|
||||
<PanelContainer.PanelOverride>
|
||||
<gfx:StyleBoxFlat BackgroundColor="#25252add"/>
|
||||
</PanelContainer.PanelOverride>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<BoxContainer Orientation="Horizontal" MinWidth="400">
|
||||
@@ -32,7 +36,7 @@
|
||||
HorizontalExpand="true" PlaceHolder="{Loc admin-logs-search-players-placeholder}"/>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Button Name="SelectAllPlayersButton" Text="{Loc admin-logs-select-all}"
|
||||
MinWidth="100" StyleClasses="ButtonSquare"></Button>
|
||||
MinWidth="100" StyleClasses="ButtonSquare" />
|
||||
<Button Name="SelectNoPlayersButton" Text="{Loc admin-logs-select-none}"
|
||||
MinWidth="100" StyleClasses="ButtonSquare"/>
|
||||
</BoxContainer>
|
||||
@@ -56,4 +60,5 @@
|
||||
</ScrollContainer>
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
</SS14Window>
|
||||
</PanelContainer>
|
||||
</Control>
|
||||
|
||||
@@ -5,8 +5,8 @@ using Content.Client.Administration.UI.CustomControls;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Database;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Localization;
|
||||
using static Robust.Client.UserInterface.Controls.BaseButton;
|
||||
@@ -15,7 +15,7 @@ using static Robust.Client.UserInterface.Controls.LineEdit;
|
||||
namespace Content.Client.Administration.UI.Logs;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class AdminLogsWindow : SS14Window
|
||||
public partial class AdminLogsWindow : Control
|
||||
{
|
||||
private readonly Comparer<AdminLogTypeButton> _adminLogTypeButtonComparer =
|
||||
Comparer<AdminLogTypeButton>.Create((a, b) =>
|
||||
|
||||
Reference in New Issue
Block a user