Add non-players button to log viewer (#14097)
* add include non-players button to log viewer * breakout player filter check * fix sending player logs with no players selected * fix default not returning player logs, causing test issue
This commit is contained in:
@@ -32,6 +32,8 @@
|
|||||||
<BoxContainer Orientation="Vertical" MinWidth="200">
|
<BoxContainer Orientation="Vertical" MinWidth="200">
|
||||||
<LineEdit Name="PlayerSearch" Access="Public" StyleClasses="actionSearchBox"
|
<LineEdit Name="PlayerSearch" Access="Public" StyleClasses="actionSearchBox"
|
||||||
HorizontalExpand="true" PlaceHolder="{Loc admin-logs-search-players-placeholder}"/>
|
HorizontalExpand="true" PlaceHolder="{Loc admin-logs-search-players-placeholder}"/>
|
||||||
|
<Button Name="IncludeNonPlayersButton" Text="{Loc admin-logs-include-non-player}"
|
||||||
|
MinWidth="100" StyleClasses="ButtonSquare" ToggleMode="True" />
|
||||||
<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" />
|
MinWidth="100" StyleClasses="ButtonSquare" />
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public sealed partial class AdminLogsControl : Control
|
|||||||
SelectAllTypesButton.OnPressed += SelectAllTypes;
|
SelectAllTypesButton.OnPressed += SelectAllTypes;
|
||||||
SelectNoTypesButton.OnPressed += SelectNoTypes;
|
SelectNoTypesButton.OnPressed += SelectNoTypes;
|
||||||
|
|
||||||
|
IncludeNonPlayersButton.OnPressed += IncludeNonPlayers;
|
||||||
SelectAllPlayersButton.OnPressed += SelectAllPlayers;
|
SelectAllPlayersButton.OnPressed += SelectAllPlayers;
|
||||||
SelectNoPlayersButton.OnPressed += SelectNoPlayers;
|
SelectNoPlayersButton.OnPressed += SelectNoPlayers;
|
||||||
|
|
||||||
@@ -53,6 +54,7 @@ public sealed partial class AdminLogsControl : Control
|
|||||||
public string Search => LogSearch.Text;
|
public string Search => LogSearch.Text;
|
||||||
private int ShownLogs { get; set; }
|
private int ShownLogs { get; set; }
|
||||||
private int TotalLogs { get; set; }
|
private int TotalLogs { get; set; }
|
||||||
|
public bool IncludeNonPlayerLogs { get; set; }
|
||||||
|
|
||||||
public HashSet<LogType> SelectedTypes { get; } = new();
|
public HashSet<LogType> SelectedTypes { get; } = new();
|
||||||
|
|
||||||
@@ -139,6 +141,13 @@ public sealed partial class AdminLogsControl : Control
|
|||||||
UpdateLogs();
|
UpdateLogs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void IncludeNonPlayers(ButtonEventArgs args)
|
||||||
|
{
|
||||||
|
IncludeNonPlayerLogs = args.Button.Pressed;
|
||||||
|
|
||||||
|
UpdateLogs();
|
||||||
|
}
|
||||||
|
|
||||||
private void SelectAllPlayers(ButtonEventArgs args)
|
private void SelectAllPlayers(ButtonEventArgs args)
|
||||||
{
|
{
|
||||||
SelectedPlayers.Clear();
|
SelectedPlayers.Clear();
|
||||||
@@ -259,12 +268,33 @@ public sealed partial class AdminLogsControl : Control
|
|||||||
button.Text.Contains(PlayerSearch.Text, StringComparison.OrdinalIgnoreCase);
|
button.Text.Contains(PlayerSearch.Text, StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool LogMatchesPlayerFilter(AdminLogLabel label)
|
||||||
|
{
|
||||||
|
if (label.Log.Players.Length == 0)
|
||||||
|
return SelectedPlayers.Count == 0 || IncludeNonPlayerLogs;
|
||||||
|
|
||||||
|
return SelectedPlayers.Overlaps(label.Log.Players);
|
||||||
|
}
|
||||||
|
|
||||||
private bool ShouldShowLog(AdminLogLabel label)
|
private bool ShouldShowLog(AdminLogLabel label)
|
||||||
{
|
{
|
||||||
return SelectedTypes.Contains(label.Log.Type) &&
|
// Check log type
|
||||||
(SelectedPlayers.Count + label.Log.Players.Length == 0 || SelectedPlayers.Overlaps(label.Log.Players)) &&
|
if (!SelectedTypes.Contains(label.Log.Type))
|
||||||
SelectedImpacts.Contains(label.Log.Impact) &&
|
return false;
|
||||||
label.Log.Message.Contains(LogSearch.Text, StringComparison.OrdinalIgnoreCase);
|
|
||||||
|
// Check players
|
||||||
|
if (!LogMatchesPlayerFilter(label))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Check impact
|
||||||
|
if (!SelectedImpacts.Contains(label.Log.Impact))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Check search
|
||||||
|
if (!label.Log.Message.Contains(LogSearch.Text, StringComparison.OrdinalIgnoreCase))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TypeButtonPressed(ButtonEventArgs args)
|
private void TypeButtonPressed(ButtonEventArgs args)
|
||||||
@@ -481,6 +511,7 @@ public sealed partial class AdminLogsControl : Control
|
|||||||
SelectAllTypesButton.OnPressed -= SelectAllTypes;
|
SelectAllTypesButton.OnPressed -= SelectAllTypes;
|
||||||
SelectNoTypesButton.OnPressed -= SelectNoTypes;
|
SelectNoTypesButton.OnPressed -= SelectNoTypes;
|
||||||
|
|
||||||
|
IncludeNonPlayersButton.OnPressed -= IncludeNonPlayers;
|
||||||
SelectAllPlayersButton.OnPressed -= SelectAllPlayers;
|
SelectAllPlayersButton.OnPressed -= SelectAllPlayers;
|
||||||
SelectNoPlayersButton.OnPressed -= SelectNoPlayers;
|
SelectNoPlayersButton.OnPressed -= SelectNoPlayers;
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,10 @@ public sealed class AdminLogsEui : BaseEui
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
LogsControl.SelectedPlayers.Count != 0,
|
||||||
LogsControl.SelectedPlayers.ToArray(),
|
LogsControl.SelectedPlayers.ToArray(),
|
||||||
null,
|
null,
|
||||||
|
LogsControl.IncludeNonPlayerLogs,
|
||||||
null,
|
null,
|
||||||
DateOrder.Descending);
|
DateOrder.Descending);
|
||||||
|
|
||||||
|
|||||||
@@ -122,14 +122,25 @@ public sealed partial class AdminLogManager
|
|||||||
query = query.Where(log => log.Date > filter.After);
|
query = query.Where(log => log.Date > filter.After);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filter.IncludePlayers)
|
||||||
|
{
|
||||||
if (filter.AnyPlayers != null)
|
if (filter.AnyPlayers != null)
|
||||||
{
|
{
|
||||||
query = query.Where(log => filter.AnyPlayers.Any(filterPlayer => log.Players.Contains(filterPlayer)));
|
query = query.Where(log =>
|
||||||
|
filter.AnyPlayers.Any(filterPlayer => log.Players.Contains(filterPlayer)) ||
|
||||||
|
log.Players.Length == 0 && filter.IncludeNonPlayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.AllPlayers != null)
|
if (filter.AllPlayers != null)
|
||||||
{
|
{
|
||||||
query = query.Where(log => filter.AllPlayers.All(filterPlayer => log.Players.Contains(filterPlayer)));
|
query = query.Where(log =>
|
||||||
|
filter.AllPlayers.All(filterPlayer => log.Players.Contains(filterPlayer)) ||
|
||||||
|
log.Players.Length == 0 && filter.IncludeNonPlayers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
query = query.Where(log => log.Players.Length == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.LogsSent != 0)
|
if (filter.LogsSent != 0)
|
||||||
|
|||||||
@@ -119,8 +119,10 @@ public sealed class AdminLogsEui : BaseEui
|
|||||||
Impacts = request.Impacts,
|
Impacts = request.Impacts,
|
||||||
Before = request.Before,
|
Before = request.Before,
|
||||||
After = request.After,
|
After = request.After,
|
||||||
|
IncludePlayers = request.IncludePlayers,
|
||||||
AnyPlayers = request.AnyPlayers,
|
AnyPlayers = request.AnyPlayers,
|
||||||
AllPlayers = request.AllPlayers,
|
AllPlayers = request.AllPlayers,
|
||||||
|
IncludeNonPlayers = request.IncludeNonPlayers,
|
||||||
LastLogId = 0,
|
LastLogId = 0,
|
||||||
Limit = _clientBatchSize
|
Limit = _clientBatchSize
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,10 +20,14 @@ public sealed class LogFilter
|
|||||||
|
|
||||||
public DateTime? After { get; set; }
|
public DateTime? After { get; set; }
|
||||||
|
|
||||||
|
public bool IncludePlayers { get; set; } = true;
|
||||||
|
|
||||||
public Guid[]? AnyPlayers { get; set; }
|
public Guid[]? AnyPlayers { get; set; }
|
||||||
|
|
||||||
public Guid[]? AllPlayers { get; set; }
|
public Guid[]? AllPlayers { get; set; }
|
||||||
|
|
||||||
|
public bool IncludeNonPlayers { get; set; }
|
||||||
|
|
||||||
public int? LastLogId { get; set; }
|
public int? LastLogId { get; set; }
|
||||||
|
|
||||||
public int LogsSent { get; set; }
|
public int LogsSent { get; set; }
|
||||||
|
|||||||
@@ -740,14 +740,25 @@ namespace Content.Server.Database
|
|||||||
query = query.Where(log => log.Date > filter.After);
|
query = query.Where(log => log.Date > filter.After);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filter.IncludePlayers)
|
||||||
|
{
|
||||||
if (filter.AnyPlayers != null)
|
if (filter.AnyPlayers != null)
|
||||||
{
|
{
|
||||||
query = query.Where(log => log.Players.Any(p => filter.AnyPlayers.Contains(p.PlayerUserId)));
|
query = query.Where(log =>
|
||||||
|
log.Players.Any(p => filter.AnyPlayers.Contains(p.PlayerUserId)) ||
|
||||||
|
log.Players.Count == 0 && filter.IncludeNonPlayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.AllPlayers != null)
|
if (filter.AllPlayers != null)
|
||||||
{
|
{
|
||||||
query = query.Where(log => log.Players.All(p => filter.AllPlayers.Contains(p.PlayerUserId)));
|
query = query.Where(log =>
|
||||||
|
log.Players.All(p => filter.AllPlayers.Contains(p.PlayerUserId)) ||
|
||||||
|
log.Players.Count == 0 && filter.IncludeNonPlayers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
query = query.Where(log => log.Players.Count == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.LastLogId != null)
|
if (filter.LastLogId != null)
|
||||||
|
|||||||
@@ -67,8 +67,10 @@ public static class AdminLogsEuiMsg
|
|||||||
HashSet<LogImpact>? impacts,
|
HashSet<LogImpact>? impacts,
|
||||||
DateTime? before,
|
DateTime? before,
|
||||||
DateTime? after,
|
DateTime? after,
|
||||||
|
bool includePlayers,
|
||||||
Guid[]? anyPlayers,
|
Guid[]? anyPlayers,
|
||||||
Guid[]? allPlayers,
|
Guid[]? allPlayers,
|
||||||
|
bool includeNonPlayers,
|
||||||
int? lastLogId,
|
int? lastLogId,
|
||||||
DateOrder dateOrder)
|
DateOrder dateOrder)
|
||||||
{
|
{
|
||||||
@@ -78,8 +80,10 @@ public static class AdminLogsEuiMsg
|
|||||||
Impacts = impacts;
|
Impacts = impacts;
|
||||||
Before = before;
|
Before = before;
|
||||||
After = after;
|
After = after;
|
||||||
|
IncludePlayers = includePlayers;
|
||||||
AnyPlayers = anyPlayers is { Length: > 0 } ? anyPlayers : null;
|
AnyPlayers = anyPlayers is { Length: > 0 } ? anyPlayers : null;
|
||||||
AllPlayers = allPlayers is { Length: > 0 } ? allPlayers : null;
|
AllPlayers = allPlayers is { Length: > 0 } ? allPlayers : null;
|
||||||
|
IncludeNonPlayers = includeNonPlayers;
|
||||||
LastLogId = lastLogId;
|
LastLogId = lastLogId;
|
||||||
DateOrder = dateOrder;
|
DateOrder = dateOrder;
|
||||||
}
|
}
|
||||||
@@ -90,8 +94,10 @@ public static class AdminLogsEuiMsg
|
|||||||
public HashSet<LogImpact>? Impacts { get; set; }
|
public HashSet<LogImpact>? Impacts { get; set; }
|
||||||
public DateTime? Before { get; set; }
|
public DateTime? Before { get; set; }
|
||||||
public DateTime? After { get; set; }
|
public DateTime? After { get; set; }
|
||||||
|
public bool IncludePlayers { get; set; }
|
||||||
public Guid[]? AnyPlayers { get; set; }
|
public Guid[]? AnyPlayers { get; set; }
|
||||||
public Guid[]? AllPlayers { get; set; }
|
public Guid[]? AllPlayers { get; set; }
|
||||||
|
public bool IncludeNonPlayers { get; set; }
|
||||||
public int? LastLogId { get; set; }
|
public int? LastLogId { get; set; }
|
||||||
public DateOrder DateOrder { get; set; }
|
public DateOrder DateOrder { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ admin-logs-select-none = None
|
|||||||
# Players
|
# Players
|
||||||
admin-logs-search-players-placeholder = Search Players (OR)
|
admin-logs-search-players-placeholder = Search Players (OR)
|
||||||
admin-logs-select-none = None
|
admin-logs-select-none = None
|
||||||
|
admin-logs-include-non-player = Include Non-players
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
admin-logs-search-logs-placeholder = Search Logs
|
admin-logs-search-logs-placeholder = Search Logs
|
||||||
|
|||||||
Reference in New Issue
Block a user