-
Notifications
You must be signed in to change notification settings - Fork 16
Try2 #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try2 #161
Changes from 166 commits
cfd6106
8c33e1e
8073c5d
2b8a773
10f0874
357f8a7
ae3e026
5e8009c
60122e3
d9a5073
4941a55
5f0c684
76a72bf
872da7d
d43d2a5
97fe9b1
dc3712f
c129540
b246bc7
7870b59
810880d
2be2c15
80a07fe
a7d4d98
33fa47e
91ee381
db85e1c
f193b67
f0fe85d
9b55284
9985152
4a98501
86d3dcb
6995acd
8980440
581a51e
a106137
7560ae6
08e1a15
ce9a535
df595e1
894101e
cbd3f4d
df0cc19
7f5188f
e217653
863b965
ead4676
024b871
2e7c385
b345664
eb45cad
bb7b22f
da047e5
99a5b98
d1b427b
32981de
4299bcf
efa2c69
a8e0295
7225836
f8d7995
84ea983
4471e17
b699ea2
5f07969
be0fece
0cd0206
98f183b
42c4bb0
511a3ac
9b4b264
00d2e32
c05a974
6e02846
6c94e2a
9f871d3
3ac38a4
d5e53e9
1a300a1
f5dc4b5
e42addd
6dac602
ce7c4b1
16c9dc8
5fdfa2a
f268bc0
04862df
78e737f
95d6819
6a54467
ef52ced
c00fb53
42be836
566e840
b888527
f11dbc2
e8f57b4
7a24a09
e41f317
668f42a
2aa6e82
365f7be
3ae3c4d
68e15f9
75918fc
70033fc
ac7bd89
94b09d6
360db55
32437ab
d6ba36a
a0ac066
7bb8140
93eeca4
3b57458
394a1eb
76f8a19
adda0e0
abc2421
e1127e1
04a126a
8851193
203ec26
24cbd06
1e1b47f
7add23d
190030e
6098390
fd429b4
dabe904
461549c
bd23e0f
6ced034
13c1e01
88b47d2
746b6c8
b5ee0f4
53ebfe8
28f16b6
16c08f8
3a1c59e
3fe460c
5d7e6bd
8829c54
140fc65
2c65179
31964b6
9e510f0
77f96e7
dd6675d
86e6782
1227893
2bf19cf
e1efe46
9c3e4f7
9db6651
cb8df8c
34f47cb
21dd83c
dacfbb7
fbbb2ad
019cc24
45ab87a
3b9fa30
6879e50
9ba78c5
d7e3c04
2b0b875
485ecc5
50f87d4
9bef33b
17443d6
3279b3f
f28dfeb
a7678e3
d41c00a
0ffb2c2
956eb51
a1a26c3
3a7fc17
40362d2
8484420
49d6731
3247cae
79a58be
c18791f
d8c0cfd
296c728
475cc5b
2a677f1
e0eb768
0f9b47c
07f57f8
5be1633
bdc592d
6676405
404d09f
457309c
ad6fe1d
ff47dc4
680fb5c
c690177
622ea7d
6715542
0205813
f9efc75
dd2813d
e5fd140
67dbe36
5e43fdf
6306caf
7d05600
4d0b9fd
7dac6a0
977ee8c
51e7dc5
2543166
5851c1d
e6d8e2a
b8520ce
3869043
7b39c4b
1d9567f
8f2587e
021eae6
e809c51
c2b9616
222679c
703c455
34bfd8f
0ba8405
8fd019c
2b37908
a455602
eb1f2e6
ded69af
886546c
0ea4923
e69fe96
364ff75
deda3b8
55ae568
54b07bc
f8b2677
1032258
114f236
233e176
e3f8bc7
a08968c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
using Content.Shared.CartridgeLoader.Cartridges; | ||
using System.Linq; // DeltaV | ||
using Content.Client.DeltaV.CartridgeLoader.Cartridges; // DeltaV | ||
using Content.Shared.CartridgeLoader.Cartridges; | ||
using Content.Shared.DeltaV.CartridgeLoader.Cartridges; // DeltaV | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
@@ -13,10 +16,112 @@ public LogProbeUiFragment() | |
RobustXamlLoader.Load(this); | ||
} | ||
|
||
public void UpdateState(List<PulledAccessLog> logs) | ||
// DeltaV begin - Update to handle both types of data | ||
public void UpdateState(LogProbeUiState state) | ||
{ | ||
ProbedDeviceContainer.RemoveAllChildren(); | ||
|
||
if (state.NanoChatData != null) | ||
{ | ||
SetupNanoChatView(state.NanoChatData.Value); | ||
DisplayNanoChatData(state.NanoChatData.Value); | ||
} | ||
else | ||
{ | ||
SetupAccessLogView(); | ||
if (state.PulledLogs.Count > 0) | ||
DisplayAccessLogs(state.PulledLogs); | ||
} | ||
} | ||
|
||
private void SetupNanoChatView(NanoChatData data) | ||
{ | ||
TitleLabel.Text = Loc.GetString("log-probe-header-nanochat"); | ||
ContentLabel.Text = Loc.GetString("log-probe-label-message"); | ||
|
||
// Show card info if available | ||
var cardInfo = new List<string>(); | ||
if (data.CardNumber != null) | ||
cardInfo.Add(Loc.GetString("log-probe-card-number", ("number", $"#{data.CardNumber:D4}"))); | ||
|
||
// Add recipient count | ||
cardInfo.Add(Loc.GetString("log-probe-recipients", ("count", data.Recipients.Count))); | ||
|
||
CardNumberLabel.Text = string.Join(" | ", cardInfo); | ||
CardNumberLabel.Visible = true; | ||
} | ||
|
||
private void SetupAccessLogView() | ||
{ | ||
TitleLabel.Text = Loc.GetString("log-probe-header-access"); | ||
ContentLabel.Text = Loc.GetString("log-probe-label-accessor"); | ||
CardNumberLabel.Visible = false; | ||
} | ||
|
||
private void DisplayNanoChatData(NanoChatData data) | ||
{ | ||
// First add a recipient list entry | ||
var recipientsList = Loc.GetString("log-probe-recipient-list") + "\n" + string.Join("\n", | ||
data.Recipients.Values | ||
.OrderBy(r => r.Name) | ||
.Select(r => $" {r.Name}" + | ||
(string.IsNullOrEmpty(r.JobTitle) ? "" : $" ({r.JobTitle})") + | ||
$" | #{r.Number:D4}")); | ||
|
||
var recipientsEntry = new LogProbeUiEntry(0, "---", recipientsList); | ||
ProbedDeviceContainer.AddChild(recipientsEntry); | ||
|
||
var count = 1; | ||
foreach (var (partnerId, messages) in data.Messages) | ||
{ | ||
// Show only successfully delivered incoming messages | ||
var incomingMessages = messages | ||
.Where(msg => msg.SenderId == partnerId && !msg.DeliveryFailed) | ||
.OrderByDescending(msg => msg.Timestamp); | ||
|
||
foreach (var msg in incomingMessages) | ||
{ | ||
var messageText = Loc.GetString("log-probe-message-format", | ||
("sender", $"#{msg.SenderId:D4}"), | ||
("recipient", $"#{data.CardNumber:D4}"), | ||
("content", msg.Content)); | ||
|
||
var entry = new NanoChatLogEntry( | ||
count, | ||
TimeSpan.FromSeconds(Math.Truncate(msg.Timestamp.TotalSeconds)).ToString(), | ||
messageText); | ||
|
||
ProbedDeviceContainer.AddChild(entry); | ||
count++; | ||
} | ||
|
||
// Show only successfully delivered outgoing messages | ||
var outgoingMessages = messages | ||
.Where(msg => msg.SenderId == data.CardNumber && !msg.DeliveryFailed) | ||
.OrderByDescending(msg => msg.Timestamp); | ||
|
||
foreach (var msg in outgoingMessages) | ||
{ | ||
var messageText = Loc.GetString("log-probe-message-format", | ||
("sender", $"#{msg.SenderId:D4}"), | ||
("recipient", $"#{partnerId:D4}"), | ||
("content", msg.Content)); | ||
|
||
var entry = new NanoChatLogEntry( | ||
count, | ||
TimeSpan.FromSeconds(Math.Truncate(msg.Timestamp.TotalSeconds)).ToString(), | ||
messageText); | ||
|
||
ProbedDeviceContainer.AddChild(entry); | ||
count++; | ||
} | ||
} | ||
} | ||
// DeltaV end | ||
Comment on lines
+61
to
+119
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add null checks for In Apply this diff to fix the issue: + if (data.CardNumber == null)
+ return; Add this check at the beginning of
|
||
|
||
// DeltaV - Handle this in a separate method | ||
private void DisplayAccessLogs(List<PulledAccessLog> logs) | ||
{ | ||
//Reverse the list so the oldest entries appear at the bottom | ||
logs.Reverse(); | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,48 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
<BoxContainer | ||||||||||||||||||||||||||||||||||||||||||||||
xmlns="https://spacestation14.io" | ||||||||||||||||||||||||||||||||||||||||||||||
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client" | ||||||||||||||||||||||||||||||||||||||||||||||
HorizontalExpand="True"> | ||||||||||||||||||||||||||||||||||||||||||||||
<Button Name="ChatButton" | ||||||||||||||||||||||||||||||||||||||||||||||
StyleClasses="ButtonSquare" | ||||||||||||||||||||||||||||||||||||||||||||||
HorizontalExpand="True" | ||||||||||||||||||||||||||||||||||||||||||||||
MaxSize="137 64" | ||||||||||||||||||||||||||||||||||||||||||||||
Margin="0 1"> | ||||||||||||||||||||||||||||||||||||||||||||||
<BoxContainer Orientation="Horizontal" | ||||||||||||||||||||||||||||||||||||||||||||||
HorizontalExpand="True" | ||||||||||||||||||||||||||||||||||||||||||||||
VerticalExpand="True" | ||||||||||||||||||||||||||||||||||||||||||||||
MinWidth="132" | ||||||||||||||||||||||||||||||||||||||||||||||
Margin="6 4" | ||||||||||||||||||||||||||||||||||||||||||||||
VerticalAlignment="Center"> | ||||||||||||||||||||||||||||||||||||||||||||||
<!-- Unread indicator dot --> | ||||||||||||||||||||||||||||||||||||||||||||||
<PanelContainer Name="UnreadIndicator" | ||||||||||||||||||||||||||||||||||||||||||||||
MinSize="8 8" | ||||||||||||||||||||||||||||||||||||||||||||||
MaxSize="8 8" | ||||||||||||||||||||||||||||||||||||||||||||||
VerticalAlignment="Center" | ||||||||||||||||||||||||||||||||||||||||||||||
Margin="0 0 6 0"> | ||||||||||||||||||||||||||||||||||||||||||||||
<PanelContainer.PanelOverride> | ||||||||||||||||||||||||||||||||||||||||||||||
<graphics:StyleBoxFlat | ||||||||||||||||||||||||||||||||||||||||||||||
BackgroundColor="#17c622" | ||||||||||||||||||||||||||||||||||||||||||||||
BorderColor="#0f7a15" /> | ||||||||||||||||||||||||||||||||||||||||||||||
</PanelContainer.PanelOverride> | ||||||||||||||||||||||||||||||||||||||||||||||
</PanelContainer> | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+17
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use theme-aware colors for better accessibility. The unread indicator uses hardcoded colors ( Consider using theme-aware color resources: -BackgroundColor="#17c622"
-BorderColor="#0f7a15"
+BackgroundColor="{DynamicResource positiveGreenColor}"
+BorderColor="{DynamicResource positiveGreenDarkColor}" 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
<!-- Text container --> | ||||||||||||||||||||||||||||||||||||||||||||||
<BoxContainer Orientation="Vertical" | ||||||||||||||||||||||||||||||||||||||||||||||
HorizontalExpand="True" | ||||||||||||||||||||||||||||||||||||||||||||||
VerticalExpand="True" | ||||||||||||||||||||||||||||||||||||||||||||||
VerticalAlignment="Center"> | ||||||||||||||||||||||||||||||||||||||||||||||
<RichTextLabel Name="NameLabel" | ||||||||||||||||||||||||||||||||||||||||||||||
StyleClasses="LabelHeading" | ||||||||||||||||||||||||||||||||||||||||||||||
HorizontalExpand="True" | ||||||||||||||||||||||||||||||||||||||||||||||
HorizontalAlignment="Center" | ||||||||||||||||||||||||||||||||||||||||||||||
VerticalAlignment="Center" | ||||||||||||||||||||||||||||||||||||||||||||||
Margin="0 -2 0 0" /> | ||||||||||||||||||||||||||||||||||||||||||||||
<Label Name="JobLabel" | ||||||||||||||||||||||||||||||||||||||||||||||
StyleClasses="LabelSubText" | ||||||||||||||||||||||||||||||||||||||||||||||
HorizontalExpand="True" | ||||||||||||||||||||||||||||||||||||||||||||||
ClipText="False" | ||||||||||||||||||||||||||||||||||||||||||||||
HorizontalAlignment="Center" /> | ||||||||||||||||||||||||||||||||||||||||||||||
</BoxContainer> | ||||||||||||||||||||||||||||||||||||||||||||||
</BoxContainer> | ||||||||||||||||||||||||||||||||||||||||||||||
</Button> | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+5
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance accessibility and user feedback. The button lacks important accessibility features and visual feedback states:
Consider adding: <Button Name="ChatButton"
StyleClasses="ButtonSquare"
+ ToolTip="{Binding TooltipText}"
+ AccessibleName="{Binding Name}"
+ AccessibleDescription="{Binding JobTitle}"
HorizontalExpand="True"
|
||||||||||||||||||||||||||||||||||||||||||||||
</BoxContainer> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,39 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
using Content.Shared.DeltaV.CartridgeLoader.Cartridges; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
using Robust.Client.AutoGenerated; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
using Robust.Client.UserInterface.Controls; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
using Robust.Client.UserInterface.XAML; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
namespace Content.Client.DeltaV.CartridgeLoader.Cartridges; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
[GenerateTypedNameReferences] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
public sealed partial class NanoChatEntry : BoxContainer | ||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
public event Action<uint>? OnPressed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
private uint _number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
private Action<EventArgs>? _pressHandler; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
public NanoChatEntry() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
RobustXamlLoader.Load(this); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
public void SetRecipient(NanoChatRecipient recipient, uint number, bool isSelected) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
// Remove old handler if it exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||
if (_pressHandler != null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ChatButton.OnPressed -= _pressHandler; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
_number = number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
// Create and store new handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||
_pressHandler = _ => OnPressed?.Invoke(_number); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
ChatButton.OnPressed += _pressHandler; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+20
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add input validation for the recipient parameter The method should validate the input parameter to prevent potential null reference exceptions. Here's a suggested implementation: public void SetRecipient(NanoChatRecipient recipient, uint number, bool isSelected)
{
+ ArgumentNullException.ThrowIfNull(recipient);
+
// Remove old handler if it exists
if (_pressHandler != null)
ChatButton.OnPressed -= _pressHandler; 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
NameLabel.Text = recipient.Name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
JobLabel.Text = recipient.JobTitle ?? ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
JobLabel.Visible = !string.IsNullOrEmpty(recipient.JobTitle); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
UnreadIndicator.Visible = recipient.HasUnread; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
ChatButton.ModulateSelfOverride = isSelected ? NanoChatMessageBubble.OwnMessageColor : null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<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="Right" | ||
SetWidth="26" | ||
ClipText="True" /> | ||
<Label Name="TimeLabel" | ||
Align="Center" | ||
SetWidth="100" | ||
ClipText="True" /> | ||
<Label Name="MessageLabel" | ||
Align="Left" | ||
MinWidth="390" | ||
HorizontalExpand="True" | ||
ClipText="False" /> | ||
</BoxContainer> | ||
<customControls:HSeparator Margin="0 5 0 5" /> | ||
</BoxContainer> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add null/empty input handling
The number validation should explicitly handle null or empty input cases.
📝 Committable suggestion