Add shown/visible counter to admin logs control (#9276)
This commit is contained in:
@@ -51,6 +51,8 @@
|
||||
<BoxContainer Name="TopRightContainer">
|
||||
<BoxContainer Name="LogImpactContainer" Orientation="Horizontal"/>
|
||||
<Control HorizontalExpand="True"/>
|
||||
<Label Name="Count" Access="Public"/>
|
||||
<Control HorizontalExpand="True"/>
|
||||
<Button Name="PopOutButton" Access="Public" Text="{Loc admin-logs-pop-out}"/>
|
||||
</BoxContainer>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
|
||||
@@ -51,6 +51,8 @@ public sealed partial class AdminLogsControl : Control
|
||||
|
||||
public int SelectedRoundId => RoundSpinBox.Value;
|
||||
public string Search => LogSearch.Text;
|
||||
private int ShownLogs { get; set; }
|
||||
private int TotalLogs { get; set; }
|
||||
|
||||
public HashSet<LogType> SelectedTypes { get; } = new();
|
||||
|
||||
@@ -200,6 +202,8 @@ public sealed partial class AdminLogsControl : Control
|
||||
|
||||
private void UpdateLogs()
|
||||
{
|
||||
ShownLogs = 0;
|
||||
|
||||
foreach (var child in LogsContainer.Children)
|
||||
{
|
||||
if (child is not AdminLogLabel log)
|
||||
@@ -208,7 +212,13 @@ public sealed partial class AdminLogsControl : Control
|
||||
}
|
||||
|
||||
child.Visible = ShouldShowLog(log);
|
||||
if (child.Visible)
|
||||
{
|
||||
ShownLogs++;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateCount();
|
||||
}
|
||||
|
||||
private bool ShouldShowType(AdminLogTypeButton button)
|
||||
@@ -399,17 +409,41 @@ public sealed partial class AdminLogsControl : Control
|
||||
var label = new AdminLogLabel(ref log, separator);
|
||||
label.Visible = ShouldShowLog(label);
|
||||
|
||||
TotalLogs++;
|
||||
if (label.Visible)
|
||||
{
|
||||
ShownLogs++;
|
||||
}
|
||||
|
||||
LogsContainer.AddChild(label);
|
||||
LogsContainer.AddChild(separator);
|
||||
}
|
||||
|
||||
UpdateCount();
|
||||
}
|
||||
|
||||
public void SetLogs(List<SharedAdminLog> logs)
|
||||
{
|
||||
LogsContainer.RemoveAllChildren();
|
||||
UpdateCount(0, 0);
|
||||
AddLogs(logs);
|
||||
}
|
||||
|
||||
private void UpdateCount(int? shown = null, int? total = null)
|
||||
{
|
||||
if (shown != null)
|
||||
{
|
||||
ShownLogs = shown.Value;
|
||||
}
|
||||
|
||||
if (total != null)
|
||||
{
|
||||
TotalLogs = total.Value;
|
||||
}
|
||||
|
||||
Count.Text = Loc.GetString("admin-logs-count", ("showing", ShownLogs), ("total", TotalLogs));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
admin-logs-title = Admin Logs Panel
|
||||
admin-logs-count = Showing {$showing}/{$total}
|
||||
admin-logs-pop-out = Pop Out
|
||||
|
||||
# Round
|
||||
|
||||
Reference in New Issue
Block a user