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