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