forked from Nyanotrasen/Nyanotrasen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add admin logging, models, migrations * Add logging damage changes * Add Log admin flag, LogFilter, Logs admin menu tab, message Refactor admin logging API * Change admin log get method names * Fix the name again * Minute amount of reorganization * Reset Postgres db snapshot * Reset Sqlite db snapshot * Make AdminLog have a composite primary key of round, id * Minute cleanup * Change admin system to do a type check instead of index check * Make admin logs use C# 10 interpolated string handlers * Implement UI on its own window Custom controls Searching Add admin log converters * Implement limits into the query * Change logs to be put into an OutputPanel instead for text wrapping * Add log <-> player m2m relationship back * UI improvements, make text wrap, add separators * Remove entity prefix from damaged log * Add explicit m2m model, fix any players filter * Add debug command to test bulk adding logs * Admin logs now just kinda go * Add histogram for database update time * Make admin log system update run every 5 seconds * Add a cap to the log queue and a metric for how many times it has been reached * Add metric for logs sent in a round * Make cvars out of admin logs queue send delay and cap * Merge fixes * Reset some changes * Add test for adding and getting a single log * Add tests for bulk adding logs * Add test for querying logs * Add CallerArgumentExpression to LogStringHandler methods and test * Improve UI, fix SQLite, add searching by round * Add entities to admin logs * Move distinct after orderby * Add migrations * ef core eat my ass * Add cvar for client logs batch size * Sort logs from newest to oldest by default * Merge fixes * Reorganize tests and add one for date ordering * Add note to log types to not change their numeric values * Add impacts to logs, better UI filtering * Make log add callable from shared for convenience * Get current round id directly from game ticker * Revert namespace change for DamageableSystem
- Loading branch information
1 parent
0f7e81b
commit 319aec1
Showing
65 changed files
with
7,018 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using Content.Shared.Administration.Logs; | ||
|
||
namespace Content.Client.Administration.Logs; | ||
|
||
public class AdminLogSystem : SharedAdminLogSystem | ||
{ | ||
} |
16 changes: 16 additions & 0 deletions
16
Content.Client/Administration/UI/CustomControls/AdminLogImpactButton.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; } | ||
} |
33 changes: 33 additions & 0 deletions
33
Content.Client/Administration/UI/CustomControls/AdminLogLabel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Content.Client/Administration/UI/CustomControls/AdminLogPlayerButton.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; } | ||
} |
16 changes: 16 additions & 0 deletions
16
Content.Client/Administration/UI/CustomControls/AdminLogTypeButton.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; } | ||
} |
25 changes: 25 additions & 0 deletions
25
Content.Client/Administration/UI/CustomControls/HSeparator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) { } | ||
} |
25 changes: 25 additions & 0 deletions
25
Content.Client/Administration/UI/CustomControls/VSeparator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
Content.Client/Administration/UI/Logs/AdminLogsWindow.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<SS14Window xmlns="https://spacestation14.io" | ||
xmlns:aui="clr-namespace:Content.Client.Administration.UI.CustomControls" | ||
Title="{Loc admin-logs-title}" | ||
MinWidth="1000" | ||
MinHeight="400"> | ||
<BoxContainer Orientation="Horizontal"> | ||
<BoxContainer Orientation="Vertical"> | ||
<BoxContainer Orientation="Horizontal" MinWidth="400"> | ||
<Label Text="{Loc admin-logs-round}"/> | ||
<SpinBox Name="RoundSpinBox" Value="0" MinWidth="150"/> | ||
<Control HorizontalExpand="True"/> | ||
<Button Name="ResetRoundButton" Text="{Loc admin-logs-reset}" HorizontalAlignment="Right" | ||
StyleClasses="OpenRight"/> | ||
</BoxContainer> | ||
<BoxContainer Orientation="Horizontal" VerticalExpand="True"> | ||
<BoxContainer Orientation="Vertical" MinWidth="200"> | ||
<LineEdit Name="TypeSearch" Access="Public" StyleClasses="actionSearchBox" | ||
HorizontalExpand="true" PlaceHolder="{Loc admin-logs-search-types-placeholder}"/> | ||
<BoxContainer Orientation="Horizontal"> | ||
<Button Name="SelectAllTypesButton" Text="{Loc admin-logs-select-all}" | ||
MinWidth="100" StyleClasses="ButtonSquare"/> | ||
<Button Name="SelectNoTypesButton" Text="{Loc admin-logs-select-none}" | ||
MinWidth="100" StyleClasses="ButtonSquare"/> | ||
</BoxContainer> | ||
<ScrollContainer VerticalExpand="True"> | ||
<BoxContainer Name="TypesContainer" Access="Public" Orientation="Vertical"/> | ||
</ScrollContainer> | ||
</BoxContainer> | ||
<aui:VSeparator/> | ||
<BoxContainer Orientation="Vertical" MinWidth="200"> | ||
<LineEdit Name="PlayerSearch" Access="Public" StyleClasses="actionSearchBox" | ||
HorizontalExpand="true" PlaceHolder="{Loc admin-logs-search-players-placeholder}"/> | ||
<Button Name="SelectNoPlayersButton" Text="{Loc admin-logs-select-none}" | ||
StyleClasses="ButtonSquare"/> | ||
<ScrollContainer VerticalExpand="True"> | ||
<BoxContainer Name="PlayersContainer" Access="Public" Orientation="Vertical"/> | ||
</ScrollContainer> | ||
</BoxContainer> | ||
<aui:VSeparator/> | ||
</BoxContainer> | ||
</BoxContainer> | ||
<BoxContainer Orientation="Vertical" HorizontalExpand="True"> | ||
<BoxContainer Name="LogImpactContainer" Orientation="Horizontal"/> | ||
<BoxContainer Orientation="Horizontal"> | ||
<LineEdit Name="LogSearch" Access="Public" StyleClasses="actionSearchBox" | ||
HorizontalExpand="true" PlaceHolder="{Loc admin-logs-search-logs-placeholder}"/> | ||
<Button Name="RefreshButton" Access="Public" Text="{Loc admin-logs-refresh}" StyleClasses="ButtonSquare"/> | ||
<Button Name="NextButton" Access="Public" Text="{Loc admin-logs-next}" StyleClasses="OpenLeft"/> | ||
</BoxContainer> | ||
<ScrollContainer VerticalExpand="True" HorizontalExpand="True" HScrollEnabled="False"> | ||
<BoxContainer Name="LogsContainer" Access="Public" Orientation="Vertical" VerticalExpand="True"/> | ||
</ScrollContainer> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</SS14Window> |
Oops, something went wrong.