Permissions panel.
This commit is contained in:
@@ -58,7 +58,7 @@ namespace Content.Shared.Administration
|
||||
/// <summary>
|
||||
/// Makes you british.
|
||||
/// </summary>
|
||||
Piss = 1 << 9,
|
||||
//Piss = 1 << 9,
|
||||
|
||||
/// <summary>
|
||||
/// Dangerous host permissions like scsi.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Content.Shared.Administration
|
||||
@@ -11,10 +12,13 @@ namespace Content.Shared.Administration
|
||||
|
||||
public static readonly AdminFlags Everything;
|
||||
|
||||
public static readonly IReadOnlyList<AdminFlags> AllFlags;
|
||||
|
||||
static AdminFlagsExt()
|
||||
{
|
||||
var t = typeof(AdminFlags);
|
||||
var flags = (AdminFlags[]) Enum.GetValues(t);
|
||||
var allFlags = new List<AdminFlags>();
|
||||
|
||||
foreach (var value in flags)
|
||||
{
|
||||
@@ -25,10 +29,13 @@ namespace Content.Shared.Administration
|
||||
continue;
|
||||
}
|
||||
|
||||
allFlags.Add(value);
|
||||
Everything |= value;
|
||||
NameFlagsMap.Add(name, value);
|
||||
FlagsNameMap[BitOperations.Log2((uint) value)] = name;
|
||||
}
|
||||
|
||||
AllFlags = allFlags.ToArray();
|
||||
}
|
||||
|
||||
public static AdminFlags NamesToFlags(IEnumerable<string> names)
|
||||
@@ -69,5 +76,14 @@ namespace Content.Shared.Administration
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
public static string PosNegFlagsText(AdminFlags posFlags, AdminFlags negFlags)
|
||||
{
|
||||
var posFlagNames = FlagsToNames(posFlags).Select(f => (flag: f, fText: $"+{f}"));
|
||||
var negFlagNames = FlagsToNames(negFlags).Select(f => (flag: f, fText: $"-{f}"));
|
||||
|
||||
var flagsText = string.Join(' ', posFlagNames.Concat(negFlagNames).OrderBy(f => f.flag).Select(p => p.fText));
|
||||
return flagsText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
92
Content.Shared/Administration/PermissionsEuiState.cs
Normal file
92
Content.Shared/Administration/PermissionsEuiState.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Eui;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Administration
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class PermissionsEuiState : EuiStateBase
|
||||
{
|
||||
public bool IsLoading;
|
||||
|
||||
public AdminData[] Admins;
|
||||
public Dictionary<int, AdminRankData> AdminRanks;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public struct AdminData
|
||||
{
|
||||
public NetUserId UserId;
|
||||
public string UserName;
|
||||
public string Title;
|
||||
public AdminFlags PosFlags;
|
||||
public AdminFlags NegFlags;
|
||||
public int? RankId;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public struct AdminRankData
|
||||
{
|
||||
public string Name;
|
||||
public AdminFlags Flags;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PermissionsEuiMsg
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class Close : EuiMessageBase
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AddAdmin : EuiMessageBase
|
||||
{
|
||||
public string UserNameOrId;
|
||||
public string Title;
|
||||
public AdminFlags PosFlags;
|
||||
public AdminFlags NegFlags;
|
||||
public int? RankId;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class RemoveAdmin : EuiMessageBase
|
||||
{
|
||||
public NetUserId UserId;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class UpdateAdmin : EuiMessageBase
|
||||
{
|
||||
public NetUserId UserId;
|
||||
public string Title;
|
||||
public AdminFlags PosFlags;
|
||||
public AdminFlags NegFlags;
|
||||
public int? RankId;
|
||||
}
|
||||
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AddAdminRank : EuiMessageBase
|
||||
{
|
||||
public string Name;
|
||||
public AdminFlags Flags;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class RemoveAdminRank : EuiMessageBase
|
||||
{
|
||||
public int Id;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class UpdateAdminRank : EuiMessageBase
|
||||
{
|
||||
public int Id;
|
||||
|
||||
public string Name;
|
||||
public AdminFlags Flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user