Add access logs (IC ones) (#17810)

This commit is contained in:
Chief-Engineer
2023-12-26 16:24:53 -06:00
committed by GitHub
parent 4d42d00194
commit 476ea14e8a
28 changed files with 438 additions and 81 deletions

View File

@@ -0,0 +1,28 @@
using Content.Client.UserInterface.Fragments;
using Content.Shared.CartridgeLoader.Cartridges;
using Robust.Client.UserInterface;
namespace Content.Client.CartridgeLoader.Cartridges;
public sealed partial class LogProbeUi : UIFragment
{
private LogProbeUiFragment? _fragment;
public override Control GetUIFragmentRoot()
{
return _fragment!;
}
public override void Setup(BoundUserInterface userInterface, EntityUid? fragmentOwner)
{
_fragment = new LogProbeUiFragment();
}
public override void UpdateState(BoundUserInterfaceState state)
{
if (state is not LogProbeUiState logProbeUiState)
return;
_fragment?.UpdateState(logProbeUiState.PulledLogs);
}
}

View File

@@ -0,0 +1,20 @@
<BoxContainer xmlns="https://spacestation14.io"
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
Margin="4"
Orientation="Vertical">
<BoxContainer Orientation="Horizontal">
<Label Name="NumberLabel"
Align="Center"
SetWidth="60"
ClipText="True"/>
<Label Name="TimeLabel"
Align="Center"
SetWidth="280"
ClipText="True"/>
<Label Name="AccessorLabel"
Align="Center"
SetWidth="110"
ClipText="True"/>
</BoxContainer>
<customControls:HSeparator Margin="0 5 0 5"/>
</BoxContainer>

View File

@@ -0,0 +1,17 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.CartridgeLoader.Cartridges;
[GenerateTypedNameReferences]
public sealed partial class LogProbeUiEntry : BoxContainer
{
public LogProbeUiEntry(int numberLabel, string timeText, string accessorText)
{
RobustXamlLoader.Load(this);
NumberLabel.Text = numberLabel.ToString();
TimeLabel.Text = timeText;
AccessorLabel.Text = accessorText;
}
}

View File

@@ -0,0 +1,21 @@
<cartridges:LogProbeUiFragment xmlns="https://spacestation14.io"
xmlns:cartridges="clr-namespace:Content.Client.CartridgeLoader.Cartridges"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
Orientation="Vertical"
VerticalExpand="True">
<PanelContainer>
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#000000FF"
BorderColor="#5a5a5a"
BorderThickness="0 0 0 1"/>
</PanelContainer.PanelOverride>
<BoxContainer Orientation="Horizontal" Align="Center" Margin="8">
<Label HorizontalExpand="True" Text="{Loc 'log-probe-label-number'}"/>
<Label HorizontalExpand="True" Text="{Loc 'log-probe-label-time'}"/>
<Label HorizontalExpand="True" Text="{Loc 'log-probe-label-accessor'}"/>
</BoxContainer>
</PanelContainer>
<ScrollContainer VerticalExpand="True" HScrollEnabled="True">
<BoxContainer Orientation="Vertical" Name="ProbedDeviceContainer"/>
</ScrollContainer>
</cartridges:LogProbeUiFragment>

View File

@@ -0,0 +1,39 @@
using Content.Shared.CartridgeLoader.Cartridges;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.CartridgeLoader.Cartridges;
[GenerateTypedNameReferences]
public sealed partial class LogProbeUiFragment : BoxContainer
{
public LogProbeUiFragment()
{
RobustXamlLoader.Load(this);
}
public void UpdateState(List<PulledAccessLog> logs)
{
ProbedDeviceContainer.RemoveAllChildren();
//Reverse the list so the oldest entries appear at the bottom
logs.Reverse();
var count = 1;
foreach (var log in logs)
{
AddAccessLog(log, count);
count++;
}
}
private void AddAccessLog(PulledAccessLog log, int numberLabelText)
{
var timeLabelText = TimeSpan.FromSeconds(Math.Truncate(log.Time.TotalSeconds)).ToString();
var accessorLabelText = log.Accessor;
var entry = new LogProbeUiEntry(numberLabelText, timeLabelText, accessorLabelText);
ProbedDeviceContainer.AddChild(entry);
}
}