1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-25 06:30:21 -05:00

continue rework of profile

start moving profile info out of javascript into componentview
rework meta data to include count and offset
This commit is contained in:
RaidMax
2019-03-27 19:40:26 -05:00
parent 4f77625889
commit 25472b06c3
17 changed files with 277 additions and 250 deletions

View File

@ -10,17 +10,19 @@ namespace SharedLibraryCore.Dtos
{
public string OffenderName { get; set; }
public int OffenderId { get; set; }
public ulong OffenderNetworkId { get; set; }
public string OffenderIPAddress { get; set; }
public string PunisherName { get; set; }
public int PunisherId { get; set; }
public ulong PunisherNetworkId { get; set; }
public string PunisherIPAddress { get; set; }
public string PunisherLevel { get; set; }
public int PunisherLevelId { get; set; }
public string Offense { get; set; }
public string AutomatedOffense { get; set; }
public string Type { get; set; }
public string PenaltyType { get; set; }
public string TimePunished { get; set; }
public string TimeRemaining { get; set; }
public bool Expired { get; set; }
public string IPAddress { get; set; }
public ulong NetworkId { get; set; }
}
}

View File

@ -18,10 +18,10 @@ namespace SharedLibraryCore.Dtos
public List<string> IPs { get; set; }
public bool HasActivePenalty { get; set; }
public string ActivePenaltyType { get; set; }
public int ConnectionCount { get; set; }
public string LastSeen { get; set; }
public string FirstSeen { get; set; }
public string TimePlayed { get; set; }
//public int ConnectionCount { get; set; }
//public string LastSeen { get; set; }
//public string FirstSeen { get; set; }
//public string TimePlayed { get; set; }
public bool Authenticated { get; set; }
public List<ProfileMeta> Meta { get; set; }
public bool Online { get; set; }

View File

@ -8,11 +8,22 @@ namespace SharedLibraryCore.Dtos
{
public class ProfileMeta : SharedInfo
{
public enum MetaType
{
Other,
Information,
AliasUpdate,
ChatMessage
}
public DateTime When { get; set; }
public string WhenString => Utilities.GetTimePassed(When, false);
public string Key { get; set; }
public dynamic Value { get; set; }
public string Extra { get; set; }
public virtual string Class => Value.GetType().ToString();
public MetaType Type { get; set; }
public int? Column { get; set; }
public int? Order { get; set; }
}
}

View File

@ -11,7 +11,7 @@ namespace SharedLibraryCore.Services
{
public class MetaService
{
private static List<Func<int, Task<List<ProfileMeta>>>> _metaActions = new List<Func<int, Task<List<ProfileMeta>>>>();
private static List<Func<int, int, int, Task<List<ProfileMeta>>>> _metaActions = new List<Func<int, int, int, Task<List<ProfileMeta>>>>();
/// <summary>
/// adds or updates meta key and value to the database
@ -71,7 +71,7 @@ namespace SharedLibraryCore.Services
/// aads a meta task to the runtime meta list
/// </summary>
/// <param name="metaAction"></param>
public static void AddRuntimeMeta(Func<int, Task<List<ProfileMeta>>> metaAction)
public static void AddRuntimeMeta(Func<int, int, int, Task<List<ProfileMeta>>> metaAction)
{
_metaActions.Add(metaAction);
}
@ -80,14 +80,16 @@ namespace SharedLibraryCore.Services
/// retrieves all the runtime meta information for given client idea
/// </summary>
/// <param name="clientId">id of the client</param>
/// <param name="count">number of meta items to retrieve</param>
/// <param name="offset">offset from the first item</param>
/// <returns></returns>
public static async Task<List<ProfileMeta>> GetRuntimeMeta(int clientId)
public static async Task<List<ProfileMeta>> GetRuntimeMeta(int clientId, int offset = 0, int count = int.MaxValue)
{
var meta = new List<ProfileMeta>();
foreach (var action in _metaActions)
{
meta.AddRange(await action(clientId));
meta.AddRange(await action(clientId, offset, count));
}
return meta;

View File

@ -195,7 +195,7 @@ namespace SharedLibraryCore.Services
PunisherName = punisherAlias.Name,
PunisherId = penalty.PunisherId,
Offense = penalty.Offense,
Type = penalty.Type.ToString(),
PenaltyType = penalty.Type.ToString(),
TimeRemaining = penalty.Expires.HasValue ? (now > penalty.Expires ? "" : penalty.Expires.ToString()) : DateTime.MaxValue.ToString(),
AutomatedOffense = penalty.AutomatedOffense,
Expired = penalty.Expires.HasValue && penalty.Expires <= DateTime.UtcNow
@ -208,9 +208,9 @@ namespace SharedLibraryCore.Services
list.ForEach(p =>
{
// todo: why does this have to be done?
if (((PenaltyInfo)p.Value).Type.Length < 2)
if (((PenaltyInfo)p.Value).PenaltyType.Length < 2)
{
((PenaltyInfo)p.Value).Type = ((Penalty.PenaltyType)Convert.ToInt32(((PenaltyInfo)p.Value).Type)).ToString();
((PenaltyInfo)p.Value).PenaltyType = ((Penalty.PenaltyType)Convert.ToInt32(((PenaltyInfo)p.Value).PenaltyType)).ToString();
}
var pi = ((PenaltyInfo)p.Value);
@ -251,7 +251,7 @@ namespace SharedLibraryCore.Services
PunisherName = punisherAlias.Name,
PunisherId = penalty.PunisherId,
Offense = penalty.Offense,
Type = penalty.Type.ToString(),
PenaltyType = penalty.Type.ToString(),
AutomatedOffense = penalty.AutomatedOffense
},
When = penalty.When,
@ -263,9 +263,9 @@ namespace SharedLibraryCore.Services
list.ForEach(p =>
{
// todo: why does this have to be done?
if (((PenaltyInfo)p.Value).Type.Length < 2)
if (((PenaltyInfo)p.Value).PenaltyType.Length < 2)
{
((PenaltyInfo)p.Value).Type = ((Penalty.PenaltyType)Convert.ToInt32(((PenaltyInfo)p.Value).Type)).ToString();
((PenaltyInfo)p.Value).PenaltyType = ((Penalty.PenaltyType)Convert.ToInt32(((PenaltyInfo)p.Value).PenaltyType)).ToString();
}
});