@@ -60,6 +60,11 @@ namespace Content.Shared.Administration
|
||||
/// </summary>
|
||||
//Piss = 1 << 9,
|
||||
|
||||
/// <summary>
|
||||
/// Lets you view admin logs.
|
||||
/// </summary>
|
||||
Logs = 1 << 9,
|
||||
|
||||
/// <summary>
|
||||
/// Dangerous host permissions like scsi.
|
||||
/// </summary>
|
||||
|
||||
85
Content.Shared/Administration/AdminLogsEuiState.cs
Normal file
85
Content.Shared/Administration/AdminLogsEuiState.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Eui;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Administration;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class AdminLogsEuiState : EuiStateBase
|
||||
{
|
||||
public AdminLogsEuiState(int roundId, Dictionary<Guid, string> players)
|
||||
{
|
||||
RoundId = roundId;
|
||||
Players = players;
|
||||
}
|
||||
|
||||
public bool IsLoading { get; set; }
|
||||
|
||||
public int RoundId { get; }
|
||||
|
||||
public Dictionary<Guid, string> Players { get; }
|
||||
}
|
||||
|
||||
public static class AdminLogsEuiMsg
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class Close : EuiMessageBase
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class NewLogs : EuiMessageBase
|
||||
{
|
||||
public NewLogs(SharedAdminLog[] logs, bool replace)
|
||||
{
|
||||
Logs = logs;
|
||||
Replace = replace;
|
||||
}
|
||||
|
||||
public SharedAdminLog[] Logs { get; set; }
|
||||
public bool Replace { get; set; }
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class LogsRequest : EuiMessageBase
|
||||
{
|
||||
public LogsRequest(
|
||||
int? roundId,
|
||||
List<LogType>? types,
|
||||
List<LogImpact>? impacts,
|
||||
DateTime? before,
|
||||
DateTime? after,
|
||||
Guid[]? anyPlayers,
|
||||
Guid[]? allPlayers,
|
||||
int? lastLogId,
|
||||
DateOrder dateOrder)
|
||||
{
|
||||
RoundId = roundId;
|
||||
Types = types;
|
||||
Impacts = impacts;
|
||||
Before = before;
|
||||
After = after;
|
||||
AnyPlayers = anyPlayers is { Length: > 0 } ? anyPlayers : null;
|
||||
AllPlayers = allPlayers is { Length: > 0 } ? allPlayers : null;
|
||||
LastLogId = lastLogId;
|
||||
DateOrder = dateOrder;
|
||||
}
|
||||
|
||||
public int? RoundId { get; set; }
|
||||
public List<LogType>? Types { get; set; }
|
||||
public List<LogImpact>? Impacts { get; set; }
|
||||
public DateTime? Before { get; set; }
|
||||
public DateTime? After { get; set; }
|
||||
public Guid[]? AnyPlayers { get; set; }
|
||||
public Guid[]? AllPlayers { get; set; }
|
||||
public int? LastLogId { get; set; }
|
||||
public DateOrder DateOrder { get; set; }
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class NextLogsRequest : EuiMessageBase
|
||||
{
|
||||
}
|
||||
}
|
||||
7
Content.Shared/Administration/Logs/DateOrder.cs
Normal file
7
Content.Shared/Administration/Logs/DateOrder.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Content.Shared.Administration.Logs;
|
||||
|
||||
public enum DateOrder
|
||||
{
|
||||
Ascending = 0,
|
||||
Descending
|
||||
}
|
||||
10
Content.Shared/Administration/Logs/LogImpact.cs
Normal file
10
Content.Shared/Administration/Logs/LogImpact.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Content.Shared.Administration.Logs;
|
||||
|
||||
// DO NOT CHANGE THE NUMERIC VALUES OF THESE
|
||||
public enum LogImpact : sbyte
|
||||
{
|
||||
Low = -1,
|
||||
Medium = 0,
|
||||
High = 1,
|
||||
Extreme = 2 // Nar'Sie just dropped
|
||||
}
|
||||
110
Content.Shared/Administration/Logs/LogStringHandler.cs
Normal file
110
Content.Shared/Administration/Logs/LogStringHandler.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Content.Shared.Administration.Logs;
|
||||
|
||||
[InterpolatedStringHandler]
|
||||
public ref struct LogStringHandler
|
||||
{
|
||||
private DefaultInterpolatedStringHandler _handler;
|
||||
public readonly Dictionary<string, object?> Values;
|
||||
|
||||
public LogStringHandler(int literalLength, int formattedCount)
|
||||
{
|
||||
_handler = new DefaultInterpolatedStringHandler(literalLength, formattedCount);
|
||||
Values = new Dictionary<string, object?>();
|
||||
}
|
||||
|
||||
public LogStringHandler(int literalLength, int formattedCount, IFormatProvider? provider)
|
||||
{
|
||||
_handler = new DefaultInterpolatedStringHandler(literalLength, formattedCount, provider);
|
||||
Values = new Dictionary<string, object?>();
|
||||
}
|
||||
|
||||
public LogStringHandler(int literalLength, int formattedCount, IFormatProvider? provider, Span<char> initialBuffer)
|
||||
{
|
||||
_handler = new DefaultInterpolatedStringHandler(literalLength, formattedCount, provider, initialBuffer);
|
||||
Values = new Dictionary<string, object?>();
|
||||
}
|
||||
|
||||
private void AddFormat<T>(string? format, T value, string? argument = null)
|
||||
{
|
||||
if (format == null)
|
||||
{
|
||||
if (argument == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
format = argument[0] == '@' ? argument[1..] : argument;
|
||||
}
|
||||
|
||||
Values.Add(format, value);
|
||||
}
|
||||
|
||||
public void AppendLiteral(string value)
|
||||
{
|
||||
_handler.AppendLiteral(value);
|
||||
}
|
||||
|
||||
public void AppendFormatted<T>(T value, [CallerArgumentExpression("value")] string? argument = null)
|
||||
{
|
||||
AddFormat(null, value, argument);
|
||||
_handler.AppendFormatted(value);
|
||||
}
|
||||
|
||||
public void AppendFormatted<T>(T value, string? format, [CallerArgumentExpression("value")] string? argument = null)
|
||||
{
|
||||
AddFormat(format, value, argument);
|
||||
_handler.AppendFormatted(value, format);
|
||||
}
|
||||
|
||||
public void AppendFormatted<T>(T value, int alignment, [CallerArgumentExpression("value")] string? argument = null)
|
||||
{
|
||||
AddFormat(null, value, argument);
|
||||
_handler.AppendFormatted(value, alignment);
|
||||
}
|
||||
|
||||
public void AppendFormatted<T>(T value, int alignment, string? format, [CallerArgumentExpression("value")] string? argument = null)
|
||||
{
|
||||
AddFormat(format, value, argument);
|
||||
_handler.AppendFormatted(value, alignment, format);
|
||||
}
|
||||
|
||||
public void AppendFormatted(ReadOnlySpan<char> value)
|
||||
{
|
||||
_handler.AppendFormatted(value);
|
||||
}
|
||||
|
||||
// ReSharper disable once MethodOverloadWithOptionalParameter
|
||||
public void AppendFormatted(ReadOnlySpan<char> value, int alignment = 0, string? format = null)
|
||||
{
|
||||
AddFormat(format, value.ToString());
|
||||
_handler.AppendFormatted(value, alignment, format);
|
||||
}
|
||||
|
||||
public void AppendFormatted(string? value)
|
||||
{
|
||||
_handler.AppendFormatted(value);
|
||||
}
|
||||
|
||||
// ReSharper disable once MethodOverloadWithOptionalParameter
|
||||
public void AppendFormatted(string? value, int alignment = 0, string? format = null)
|
||||
{
|
||||
AddFormat(format, value);
|
||||
_handler.AppendFormatted(value, alignment, format);
|
||||
}
|
||||
|
||||
public void AppendFormatted(object? value, int alignment = 0, string? format = null)
|
||||
{
|
||||
AddFormat(null, value, format);
|
||||
_handler.AppendFormatted(value, alignment, format);
|
||||
}
|
||||
|
||||
public string ToStringAndClear()
|
||||
{
|
||||
Values.Clear();
|
||||
return _handler.ToStringAndClear();
|
||||
}
|
||||
}
|
||||
8
Content.Shared/Administration/Logs/LogType.cs
Normal file
8
Content.Shared/Administration/Logs/LogType.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Content.Shared.Administration.Logs;
|
||||
|
||||
// DO NOT CHANGE THE NUMERIC VALUES OF THESE
|
||||
public enum LogType
|
||||
{
|
||||
Unknown = 0, // do not use
|
||||
DamageChange = 1
|
||||
}
|
||||
13
Content.Shared/Administration/Logs/SharedAdminLog.cs
Normal file
13
Content.Shared/Administration/Logs/SharedAdminLog.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Administration.Logs;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public readonly record struct SharedAdminLog(
|
||||
int Id,
|
||||
LogType Type,
|
||||
LogImpact Impact,
|
||||
DateTime Date,
|
||||
string Message,
|
||||
Guid[] Players);
|
||||
17
Content.Shared/Administration/Logs/SharedAdminLogSystem.cs
Normal file
17
Content.Shared/Administration/Logs/SharedAdminLogSystem.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Globalization;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Shared.Administration.Logs;
|
||||
|
||||
public abstract class SharedAdminLogSystem : EntitySystem
|
||||
{
|
||||
public virtual void Add(LogType type, LogImpact impact, ref LogStringHandler handler)
|
||||
{
|
||||
// noop
|
||||
}
|
||||
|
||||
public virtual void Add(LogType type, ref LogStringHandler handler)
|
||||
{
|
||||
// noop
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user