finish initial rework of profile page with meta pagination
This commit is contained in:
parent
7b8126d57e
commit
8521df85f5
@ -6,7 +6,7 @@
|
|||||||
<RuntimeFrameworkVersion>2.2.2</RuntimeFrameworkVersion>
|
<RuntimeFrameworkVersion>2.2.2</RuntimeFrameworkVersion>
|
||||||
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
|
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
|
||||||
<PackageId>RaidMax.IW4MAdmin.Application</PackageId>
|
<PackageId>RaidMax.IW4MAdmin.Application</PackageId>
|
||||||
<Version>2.2.5.8</Version>
|
<Version>2.2.5.9</Version>
|
||||||
<Authors>RaidMax</Authors>
|
<Authors>RaidMax</Authors>
|
||||||
<Company>Forever None</Company>
|
<Company>Forever None</Company>
|
||||||
<Product>IW4MAdmin</Product>
|
<Product>IW4MAdmin</Product>
|
||||||
@ -31,7 +31,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ServerGarbageCollection>true</ServerGarbageCollection>
|
<ServerGarbageCollection>true</ServerGarbageCollection>
|
||||||
<TieredCompilation>true</TieredCompilation>
|
<TieredCompilation>true</TieredCompilation>
|
||||||
<AssemblyVersion>2.2.5.8</AssemblyVersion>
|
<AssemblyVersion>2.2.5.9</AssemblyVersion>
|
||||||
<FileVersion>2.2.5.8</FileVersion>
|
<FileVersion>2.2.5.8</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ using SharedLibraryCore.Events;
|
|||||||
using SharedLibraryCore.Exceptions;
|
using SharedLibraryCore.Exceptions;
|
||||||
using SharedLibraryCore.Helpers;
|
using SharedLibraryCore.Helpers;
|
||||||
using SharedLibraryCore.Interfaces;
|
using SharedLibraryCore.Interfaces;
|
||||||
|
using SharedLibraryCore.Objects;
|
||||||
using SharedLibraryCore.Services;
|
using SharedLibraryCore.Services;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -388,7 +389,7 @@ namespace IW4MAdmin.Application
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region META
|
#region META
|
||||||
async Task<List<ProfileMeta>> getProfileMeta(int clientId, int offset, int count)
|
async Task<List<ProfileMeta>> getProfileMeta(int clientId, int offset, int count, DateTime? startAt)
|
||||||
{
|
{
|
||||||
var metaList = new List<ProfileMeta>();
|
var metaList = new List<ProfileMeta>();
|
||||||
|
|
||||||
@ -400,6 +401,8 @@ namespace IW4MAdmin.Application
|
|||||||
|
|
||||||
var lastMapMeta = await _metaService.GetPersistentMeta("LastMapPlayed", new EFClient() { ClientId = clientId });
|
var lastMapMeta = await _metaService.GetPersistentMeta("LastMapPlayed", new EFClient() { ClientId = clientId });
|
||||||
|
|
||||||
|
if (lastMapMeta != null)
|
||||||
|
{
|
||||||
metaList.Add(new ProfileMeta()
|
metaList.Add(new ProfileMeta()
|
||||||
{
|
{
|
||||||
Id = lastMapMeta.MetaId,
|
Id = lastMapMeta.MetaId,
|
||||||
@ -408,9 +411,12 @@ namespace IW4MAdmin.Application
|
|||||||
Show = true,
|
Show = true,
|
||||||
Type = ProfileMeta.MetaType.Information
|
Type = ProfileMeta.MetaType.Information
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var lastServerMeta = await _metaService.GetPersistentMeta("LastServerPlayed", new EFClient() { ClientId = clientId });
|
var lastServerMeta = await _metaService.GetPersistentMeta("LastServerPlayed", new EFClient() { ClientId = clientId });
|
||||||
|
|
||||||
|
if (lastServerMeta != null)
|
||||||
|
{
|
||||||
metaList.Add(new ProfileMeta()
|
metaList.Add(new ProfileMeta()
|
||||||
{
|
{
|
||||||
Id = lastServerMeta.MetaId,
|
Id = lastServerMeta.MetaId,
|
||||||
@ -419,6 +425,7 @@ namespace IW4MAdmin.Application
|
|||||||
Show = true,
|
Show = true,
|
||||||
Type = ProfileMeta.MetaType.Information
|
Type = ProfileMeta.MetaType.Information
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var client = await GetClientService().Get(clientId);
|
var client = await GetClientService().Get(clientId);
|
||||||
|
|
||||||
@ -450,6 +457,7 @@ namespace IW4MAdmin.Application
|
|||||||
});
|
});
|
||||||
|
|
||||||
metaList.Add(new ProfileMeta()
|
metaList.Add(new ProfileMeta()
|
||||||
|
|
||||||
{
|
{
|
||||||
Id = client.ClientId,
|
Id = client.ClientId,
|
||||||
Key = Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CLIENT_META_CONNECTIONS"],
|
Key = Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CLIENT_META_CONNECTIONS"],
|
||||||
@ -458,10 +466,51 @@ namespace IW4MAdmin.Application
|
|||||||
Type = ProfileMeta.MetaType.Information
|
Type = ProfileMeta.MetaType.Information
|
||||||
});
|
});
|
||||||
|
|
||||||
|
metaList.Add(new ProfileMeta()
|
||||||
|
{
|
||||||
|
Key = Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CLIENT_META_MASKED"],
|
||||||
|
Value = client.Masked ? Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CLIENT_META_TRUE"] : Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CLIENT_META_FALSE"],
|
||||||
|
Sensitive = true,
|
||||||
|
Type = ProfileMeta.MetaType.Information
|
||||||
|
});
|
||||||
|
|
||||||
return metaList;
|
return metaList;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
async Task<List<ProfileMeta>> getPenaltyMeta(int clientId, int offset, int count, DateTime? startAt)
|
||||||
|
{
|
||||||
|
if (count <= 1)
|
||||||
|
{
|
||||||
|
return new List<ProfileMeta>();
|
||||||
|
}
|
||||||
|
|
||||||
|
var penalties = await GetPenaltyService().GetAllClientPenaltiesAsync(clientId, count, offset, startAt);
|
||||||
|
|
||||||
|
return penalties.Select(_penalty => new ProfileMeta()
|
||||||
|
{
|
||||||
|
Id = _penalty.PenaltyId,
|
||||||
|
Type = _penalty.PunisherId == clientId ? ProfileMeta.MetaType.Penalized : ProfileMeta.MetaType.ReceivedPenalty,
|
||||||
|
Value = new PenaltyInfo
|
||||||
|
{
|
||||||
|
Id = _penalty.PenaltyId,
|
||||||
|
OffenderName = _penalty.Offender.Name,
|
||||||
|
OffenderId = _penalty.OffenderId,
|
||||||
|
PunisherName = _penalty.Punisher.Name,
|
||||||
|
PunisherId = _penalty.PunisherId,
|
||||||
|
Offense = _penalty.Offense,
|
||||||
|
PenaltyType = _penalty.Type.ToString(),
|
||||||
|
TimeRemaining = _penalty.Expires.HasValue ? (DateTime.Now > _penalty.Expires ? "" : _penalty.Expires.ToString()) : DateTime.MaxValue.ToString(),
|
||||||
|
AutomatedOffense = _penalty.AutomatedOffense,
|
||||||
|
Expired = _penalty.Expires.HasValue && _penalty.Expires <= DateTime.UtcNow
|
||||||
|
},
|
||||||
|
When = _penalty.When,
|
||||||
|
Sensitive = _penalty.Type == Penalty.PenaltyType.Flag
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
MetaService.AddRuntimeMeta(getProfileMeta);
|
MetaService.AddRuntimeMeta(getProfileMeta);
|
||||||
|
MetaService.AddRuntimeMeta(getPenaltyMeta);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region INIT
|
#region INIT
|
||||||
|
@ -124,7 +124,7 @@ namespace IW4MAdmin.Plugins.Stats
|
|||||||
"/Stats/TopPlayersAsync");
|
"/Stats/TopPlayersAsync");
|
||||||
|
|
||||||
// meta data info
|
// meta data info
|
||||||
async Task<List<ProfileMeta>> getStats(int clientId, int offset, int count)
|
async Task<List<ProfileMeta>> getStats(int clientId, int offset, int count, DateTime? startAt)
|
||||||
{
|
{
|
||||||
if (count > 1)
|
if (count > 1)
|
||||||
{
|
{
|
||||||
@ -186,7 +186,7 @@ namespace IW4MAdmin.Plugins.Stats
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task<List<ProfileMeta>> getAnticheatInfo(int clientId, int offset, int count)
|
async Task<List<ProfileMeta>> getAnticheatInfo(int clientId, int offset, int count, DateTime? startAt)
|
||||||
{
|
{
|
||||||
if (count > 1)
|
if (count > 1)
|
||||||
{
|
{
|
||||||
@ -280,7 +280,7 @@ namespace IW4MAdmin.Plugins.Stats
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task<List<ProfileMeta>> getMessages(int clientId, int offset, int count)
|
async Task<List<ProfileMeta>> getMessages(int clientId, int offset, int count, DateTime? startAt)
|
||||||
{
|
{
|
||||||
if (count <= 1)
|
if (count <= 1)
|
||||||
{
|
{
|
||||||
@ -291,7 +291,8 @@ namespace IW4MAdmin.Plugins.Stats
|
|||||||
new ProfileMeta()
|
new ProfileMeta()
|
||||||
{
|
{
|
||||||
Key = Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_PROFILE_MESSAGES"],
|
Key = Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_PROFILE_MESSAGES"],
|
||||||
Value = await ctx.Set<EFClientMessage>().CountAsync(),
|
Value = await ctx.Set<EFClientMessage>()
|
||||||
|
.CountAsync(_message => _message.ClientId == clientId),
|
||||||
Type = ProfileMeta.MetaType.Information
|
Type = ProfileMeta.MetaType.Information
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -301,7 +302,9 @@ namespace IW4MAdmin.Plugins.Stats
|
|||||||
List<ProfileMeta> messageMeta;
|
List<ProfileMeta> messageMeta;
|
||||||
using (var ctx = new DatabaseContext(disableTracking: true))
|
using (var ctx = new DatabaseContext(disableTracking: true))
|
||||||
{
|
{
|
||||||
var messages = ctx.Set<EFClientMessage>().Where(m => m.ClientId == clientId)
|
var messages = ctx.Set<EFClientMessage>()
|
||||||
|
.Where(m => m.ClientId == clientId)
|
||||||
|
.Where(_message => _message.TimeSent < startAt)
|
||||||
.OrderByDescending(_message => _message.TimeSent)
|
.OrderByDescending(_message => _message.TimeSent)
|
||||||
.Skip(offset)
|
.Skip(offset)
|
||||||
.Take(count);
|
.Take(count);
|
||||||
|
@ -18,10 +18,6 @@ namespace SharedLibraryCore.Dtos
|
|||||||
public List<string> IPs { get; set; }
|
public List<string> IPs { get; set; }
|
||||||
public bool HasActivePenalty { get; set; }
|
public bool HasActivePenalty { get; set; }
|
||||||
public string ActivePenaltyType { 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 bool Authenticated { get; set; }
|
public bool Authenticated { get; set; }
|
||||||
public List<ProfileMeta> Meta { get; set; }
|
public List<ProfileMeta> Meta { get; set; }
|
||||||
public bool Online { get; set; }
|
public bool Online { get; set; }
|
||||||
|
@ -13,7 +13,9 @@ namespace SharedLibraryCore.Dtos
|
|||||||
Other,
|
Other,
|
||||||
Information,
|
Information,
|
||||||
AliasUpdate,
|
AliasUpdate,
|
||||||
ChatMessage
|
ChatMessage,
|
||||||
|
Penalized,
|
||||||
|
ReceivedPenalty,
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime When { get; set; }
|
public DateTime When { get; set; }
|
||||||
|
@ -11,7 +11,7 @@ namespace SharedLibraryCore.Services
|
|||||||
{
|
{
|
||||||
public class MetaService
|
public class MetaService
|
||||||
{
|
{
|
||||||
private static List<Func<int, int, int, Task<List<ProfileMeta>>>> _metaActions = new List<Func<int, int, int, Task<List<ProfileMeta>>>>();
|
private static List<Func<int, int, int, DateTime?, Task<List<ProfileMeta>>>> _metaActions = new List<Func<int, int, int, DateTime?, Task<List<ProfileMeta>>>>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// adds or updates meta key and value to the database
|
/// 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
|
/// aads a meta task to the runtime meta list
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="metaAction"></param>
|
/// <param name="metaAction"></param>
|
||||||
public static void AddRuntimeMeta(Func<int, int, int, Task<List<ProfileMeta>>> metaAction)
|
public static void AddRuntimeMeta(Func<int, int, int, DateTime?, Task<List<ProfileMeta>>> metaAction)
|
||||||
{
|
{
|
||||||
_metaActions.Add(metaAction);
|
_metaActions.Add(metaAction);
|
||||||
}
|
}
|
||||||
@ -83,16 +83,24 @@ namespace SharedLibraryCore.Services
|
|||||||
/// <param name="count">number of meta items to retrieve</param>
|
/// <param name="count">number of meta items to retrieve</param>
|
||||||
/// <param name="offset">offset from the first item</param>
|
/// <param name="offset">offset from the first item</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static async Task<List<ProfileMeta>> GetRuntimeMeta(int clientId, int offset = 0, int count = int.MaxValue)
|
public static async Task<List<ProfileMeta>> GetRuntimeMeta(int clientId, int offset = 0, int count = int.MaxValue, DateTime? startAt = null)
|
||||||
{
|
{
|
||||||
var meta = new List<ProfileMeta>();
|
var meta = new List<ProfileMeta>();
|
||||||
|
|
||||||
foreach (var action in _metaActions)
|
foreach (var action in _metaActions)
|
||||||
{
|
{
|
||||||
meta.AddRange(await action(clientId, offset, count));
|
var metaItems = await action(clientId, offset, count, startAt);
|
||||||
|
meta.AddRange(metaItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count == 1)
|
||||||
|
{
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return meta.OrderByDescending(_meta => _meta.When)
|
||||||
|
.Take(count)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,6 +159,24 @@ namespace SharedLibraryCore.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IList<EFPenalty>> GetAllClientPenaltiesAsync(int clientId, int count, int offset, DateTime? startAt)
|
||||||
|
{
|
||||||
|
using (var ctx = new DatabaseContext(true))
|
||||||
|
{
|
||||||
|
var iqPenalties = ctx.Penalties.AsNoTracking()
|
||||||
|
.Include(_penalty => _penalty.Offender.CurrentAlias)
|
||||||
|
.Include(_penalty => _penalty.Punisher.CurrentAlias)
|
||||||
|
.Where(_penalty => _penalty.Active)
|
||||||
|
.Where(_penalty => _penalty.OffenderId == clientId || _penalty.PunisherId == clientId)
|
||||||
|
.Where(_penalty => _penalty.When < startAt)
|
||||||
|
.OrderByDescending(_penalty => _penalty.When)
|
||||||
|
.Skip(offset)
|
||||||
|
.Take(count);
|
||||||
|
|
||||||
|
return await iqPenalties.ToListAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a read-only copy of client penalties
|
/// Get a read-only copy of client penalties
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -59,7 +59,7 @@ namespace WebfrontCore.Controllers
|
|||||||
{
|
{
|
||||||
ClientId = -1,
|
ClientId = -1,
|
||||||
Level = EFClient.Permission.User,
|
Level = EFClient.Permission.User,
|
||||||
CurrentAlias = new EFAlias() { Name = "Web Console Guest" }
|
CurrentAlias = new EFAlias() { Name = "Webfront Guest" }
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!HttpContext.Connection.RemoteIpAddress.GetAddressBytes().SequenceEqual(LocalHost))
|
if (!HttpContext.Connection.RemoteIpAddress.GetAddressBytes().SequenceEqual(LocalHost))
|
||||||
@ -70,6 +70,7 @@ namespace WebfrontCore.Controllers
|
|||||||
Client.NetworkId = User.Claims.First(_claim => _claim.Type == ClaimTypes.PrimarySid).Value.ConvertLong();
|
Client.NetworkId = User.Claims.First(_claim => _claim.Type == ClaimTypes.PrimarySid).Value.ConvertLong();
|
||||||
Client.Level = (EFClient.Permission)Enum.Parse(typeof(EFClient.Permission), User.Claims.First(c => c.Type == ClaimTypes.Role).Value);
|
Client.Level = (EFClient.Permission)Enum.Parse(typeof(EFClient.Permission), User.Claims.First(c => c.Type == ClaimTypes.Role).Value);
|
||||||
Client.CurrentAlias = new EFAlias() { Name = User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value };
|
Client.CurrentAlias = new EFAlias() { Name = User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value };
|
||||||
|
Authorized = Client.ClientId >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (InvalidOperationException)
|
catch (InvalidOperationException)
|
||||||
@ -93,7 +94,6 @@ namespace WebfrontCore.Controllers
|
|||||||
Authorized = true;
|
Authorized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Authorized = Client.ClientId >= 0;
|
|
||||||
ViewBag.Authorized = Authorized;
|
ViewBag.Authorized = Authorized;
|
||||||
ViewBag.Url = Manager.GetApplicationSettings().Configuration().WebfrontUrl;
|
ViewBag.Url = Manager.GetApplicationSettings().Configuration().WebfrontUrl;
|
||||||
ViewBag.User = Client;
|
ViewBag.User = Client;
|
||||||
|
@ -15,6 +15,7 @@ namespace WebfrontCore.Controllers
|
|||||||
public async Task<IActionResult> ProfileAsync(int id)
|
public async Task<IActionResult> ProfileAsync(int id)
|
||||||
{
|
{
|
||||||
var client = await Manager.GetClientService().Get(id);
|
var client = await Manager.GetClientService().Get(id);
|
||||||
|
|
||||||
if (client == null)
|
if (client == null)
|
||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound();
|
||||||
@ -22,10 +23,6 @@ namespace WebfrontCore.Controllers
|
|||||||
|
|
||||||
var activePenalties = await Manager.GetPenaltyService().GetActivePenaltiesAsync(client.AliasLinkId, client.IPAddress);
|
var activePenalties = await Manager.GetPenaltyService().GetActivePenaltiesAsync(client.AliasLinkId, client.IPAddress);
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
Authorized = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
var clientDto = new PlayerInfo()
|
var clientDto = new PlayerInfo()
|
||||||
{
|
{
|
||||||
Name = client.Name,
|
Name = client.Name,
|
||||||
@ -55,42 +52,7 @@ namespace WebfrontCore.Controllers
|
|||||||
LinkedAccounts = client.LinkedAccounts
|
LinkedAccounts = client.LinkedAccounts
|
||||||
};
|
};
|
||||||
|
|
||||||
var meta = await MetaService.GetRuntimeMeta(client.ClientId, 0, 1);
|
var meta = await MetaService.GetRuntimeMeta(client.ClientId, 0, 1, DateTime.UtcNow);
|
||||||
var penaltyMeta = await Manager.GetPenaltyService()
|
|
||||||
.ReadGetClientPenaltiesAsync(client.ClientId);
|
|
||||||
var administeredPenaltiesMeta = await Manager.GetPenaltyService()
|
|
||||||
.ReadGetClientPenaltiesAsync(client.ClientId, false);
|
|
||||||
|
|
||||||
if (Authorized && client.Level > EFClient.Permission.Trusted)
|
|
||||||
{
|
|
||||||
clientDto.Meta.Add(new ProfileMeta()
|
|
||||||
{
|
|
||||||
Key = Localization["WEBFRONT_CLIENT_META_MASKED"],
|
|
||||||
Value = client.Masked ? Localization["WEBFRONT_CLIENT_META_TRUE"] : Localization["WEBFRONT_CLIENT_META_FALSE"],
|
|
||||||
Sensitive = true,
|
|
||||||
When = DateTime.MinValue
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (Authorized)
|
|
||||||
//{
|
|
||||||
// clientDto.Meta.AddRange(client.AliasLink.Children
|
|
||||||
// .GroupBy(a => a.Name)
|
|
||||||
// .Select(a => a.First())
|
|
||||||
// .Select(a => new ProfileMeta()
|
|
||||||
// {
|
|
||||||
// Value = $"{Localization["WEBFRONT_CLIENT_META_JOINED"]} {a.Name}",
|
|
||||||
// Sensitive = true,
|
|
||||||
// When = a.DateAdded,
|
|
||||||
// Type = ProfileMeta.MetaType.AliasUpdate
|
|
||||||
// }));
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (Authorized)
|
|
||||||
{
|
|
||||||
penaltyMeta.ForEach(p => p.Value.Offense = p.Value.AutomatedOffense ?? p.Value.Offense);
|
|
||||||
administeredPenaltiesMeta.ForEach(p => p.Value.Offense = p.Value.AutomatedOffense ?? p.Value.Offense);
|
|
||||||
}
|
|
||||||
|
|
||||||
var currentPenalty = activePenalties.FirstOrDefault();
|
var currentPenalty = activePenalties.FirstOrDefault();
|
||||||
|
|
||||||
@ -105,19 +67,6 @@ namespace WebfrontCore.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
clientDto.Meta.AddRange(Authorized ? meta : meta.Where(m => !m.Sensitive));
|
clientDto.Meta.AddRange(Authorized ? meta : meta.Where(m => !m.Sensitive));
|
||||||
clientDto.Meta.AddRange(Authorized ? penaltyMeta : penaltyMeta.Where(m => !m.Sensitive));
|
|
||||||
clientDto.Meta.AddRange(Authorized ? administeredPenaltiesMeta : administeredPenaltiesMeta.Where(m => !m.Sensitive));
|
|
||||||
clientDto.Meta.AddRange(client.Meta.Select(m => new ProfileMeta()
|
|
||||||
{
|
|
||||||
When = m.Created,
|
|
||||||
Key = m.Key,
|
|
||||||
Value = m.Value,
|
|
||||||
Show = false,
|
|
||||||
}));
|
|
||||||
|
|
||||||
clientDto.Meta = clientDto.Meta
|
|
||||||
.OrderByDescending(m => m.When)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
ViewBag.Title = clientDto.Name.Substring(clientDto.Name.Length - 1).ToLower()[0] == 's' ?
|
ViewBag.Title = clientDto.Name.Substring(clientDto.Name.Length - 1).ToLower()[0] == 's' ?
|
||||||
clientDto.Name + "'" :
|
clientDto.Name + "'" :
|
||||||
@ -179,9 +128,9 @@ namespace WebfrontCore.Controllers
|
|||||||
return View("Find/Index", clientsDto);
|
return View("Find/Index", clientsDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> Meta(int id, int count, int offset)
|
public async Task<IActionResult> Meta(int id, int count, int offset, DateTime? startAt)
|
||||||
{
|
{
|
||||||
var meta = await MetaService.GetRuntimeMeta(id, offset, count);
|
var meta = await MetaService.GetRuntimeMeta(id, startAt == null ? offset : 0, count, startAt ?? DateTime.UtcNow);
|
||||||
|
|
||||||
if (meta.Count == 0)
|
if (meta.Count == 0)
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using SharedLibraryCore.Services;
|
using SharedLibraryCore.Services;
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace WebfrontCore.ViewComponents
|
namespace WebfrontCore.ViewComponents
|
||||||
{
|
{
|
||||||
public class ProfileMetaListViewComponent : ViewComponent
|
public class ProfileMetaListViewComponent : ViewComponent
|
||||||
{
|
{
|
||||||
public async Task<IViewComponentResult> InvokeAsync(int clientId, int count, int offset)
|
public async Task<IViewComponentResult> InvokeAsync(int clientId, int count, int offset, DateTime? startAt)
|
||||||
{
|
{
|
||||||
var meta = await MetaService.GetRuntimeMeta(clientId, offset, count);
|
var meta = await MetaService.GetRuntimeMeta(clientId, offset, count, startAt ?? DateTime.UtcNow);
|
||||||
return View("_List", meta);
|
return View("_List", meta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="profile_info" class="row d-block d-lg-flex flex-row border-bottom border-top pt-2 pb-2">
|
<div id="profile_info" class="row d-block d-lg-flex flex-row border-bottom border-top pt-2 pb-2">
|
||||||
|
|
||||||
<div id="profile_meta_0" class="text-center text-lg-left mr-0 mr-lg-4">
|
<div id="profile_meta_0" class="text-center text-lg-left mr-0 mr-lg-4">
|
||||||
@for (int i = 0; i < informationMeta.Count; i += 3)
|
@for (int i = 0; i < informationMeta.Count; i += 3)
|
||||||
{
|
{
|
||||||
@ -117,6 +116,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="oi oi-chevron-bottom text-center mt-2 btn btn-primary btn-block loader-load-more" title="Load more meta" data-action="unban" aria-hidden="true"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@section targetid {
|
@section targetid {
|
||||||
<input type="hidden" name="targetId" value="@Model.ClientId" />
|
<input type="hidden" name="targetId" value="@Model.ClientId" />
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,62 @@
|
|||||||
@model List<SharedLibraryCore.Dtos.ProfileMeta>
|
@model List<SharedLibraryCore.Dtos.ProfileMeta>
|
||||||
@{Layout = null;}
|
@{
|
||||||
|
Layout = null;
|
||||||
|
|
||||||
|
string formatPenalty(SharedLibraryCore.Dtos.ProfileMeta meta)
|
||||||
|
{
|
||||||
|
var penalty = meta.Value as SharedLibraryCore.Dtos.PenaltyInfo;
|
||||||
|
|
||||||
|
string localizationKey = meta.Type == SharedLibraryCore.Dtos.ProfileMeta.MetaType.Penalized ?
|
||||||
|
$"WEBFRONT_CLIENT_META_PENALIZED_{penalty.PenaltyType.ToUpper()}" :
|
||||||
|
$"WEBFRONT_CLIENT_META_WAS_PENALIZED_{penalty.PenaltyType.ToUpper()}";
|
||||||
|
|
||||||
|
string localizationMessage = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex[localizationKey];
|
||||||
|
var regexMatch = System.Text.RegularExpressions.Regex.Match(localizationMessage, @"^{{([^{}]+)}}.+$");
|
||||||
|
string penaltyType = regexMatch.Groups[1].Value.ToString();
|
||||||
|
|
||||||
|
localizationMessage = localizationMessage.Replace(penaltyType, $"<span class='penalties-color-{penalty.PenaltyType.ToLower()}'>{penaltyType}</span>");
|
||||||
|
|
||||||
|
return meta.Type == SharedLibraryCore.Dtos.ProfileMeta.MetaType.Penalized ?
|
||||||
|
string.Format(localizationMessage,
|
||||||
|
$"<span class='text-highlight'><a class='link-inverse' href='{penalty.OffenderId}'>{penalty.OffenderName}</a></span>",
|
||||||
|
$"<span class='automated-penalty-info-detailed text-white' data-clientid='{penalty.OffenderId}'>{penalty.Offense}</span>")
|
||||||
|
.Replace("{", "")
|
||||||
|
.Replace("}", "") :
|
||||||
|
string.Format(localizationMessage,
|
||||||
|
$"<span class='text-highlight'><a class='link-inverse' href='{penalty.PunisherId}'>{penalty.PunisherName}</a></span>",
|
||||||
|
$"<span class='automated-penalty-info-detailed text-white' data-clientid='{penalty.OffenderId}'>{penalty.Offense}</span>",
|
||||||
|
penalty.Offense)
|
||||||
|
.Replace("{", "")
|
||||||
|
.Replace("}", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (Model.Count > 0)
|
||||||
|
{
|
||||||
<div class="p2 text-white profile-event-timestep">
|
<div class="p2 text-white profile-event-timestep">
|
||||||
<span class="text-primary">—</span>
|
<span class="text-primary">—</span>
|
||||||
<span>@SharedLibraryCore.Utilities.GetTimePassed(Model.FirstOrDefault()?.When ?? DateTime.Now, true)</span>
|
<span>@SharedLibraryCore.Utilities.GetTimePassed(Model.First().When, true)</span>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
@foreach (var meta in Model)
|
@if (Model.Count == 0)
|
||||||
|
{
|
||||||
|
<div class="p2 text-muted profile-event-timestep">@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CLIENT_META_NONE"]</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@foreach (var meta in Model.OrderByDescending(_meta => _meta.When))
|
||||||
{
|
{
|
||||||
@switch (meta.Type)
|
@switch (meta.Type)
|
||||||
{
|
{
|
||||||
case SharedLibraryCore.Dtos.ProfileMeta.MetaType.ChatMessage:
|
case SharedLibraryCore.Dtos.ProfileMeta.MetaType.ChatMessage:
|
||||||
<div>
|
<div class="profile-meta-entry loader-data-time" data-time="@meta.When">
|
||||||
<span style="color:white;">></span>
|
<span style="color:white;">></span>
|
||||||
<span class="client-message text-muted" data-serverid="@meta.Extra" data-when="@meta.When"> @meta.Value</span>
|
<span class="client-message text-muted" data-serverid="@meta.Extra" data-when="@meta.When"> @meta.Value</span>
|
||||||
</div>
|
</div>
|
||||||
break;
|
break;
|
||||||
|
case SharedLibraryCore.Dtos.ProfileMeta.MetaType.ReceivedPenalty:
|
||||||
|
case SharedLibraryCore.Dtos.ProfileMeta.MetaType.Penalized:
|
||||||
|
<div class="profile-meta-entry loader-data-time" data-time="@meta.When">@Html.Raw(formatPenalty(meta))</div>
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6375,6 +6375,9 @@ form *, select {
|
|||||||
padding: 5px;
|
padding: 5px;
|
||||||
visibility: hidden; }
|
visibility: hidden; }
|
||||||
|
|
||||||
|
.loader-load-more {
|
||||||
|
border-radius: 0; }
|
||||||
|
|
||||||
.input-border-transition {
|
.input-border-transition {
|
||||||
-webkit-transition: border 500ms ease-out;
|
-webkit-transition: border 500ms ease-out;
|
||||||
-moz-transition: border 500ms ease-out;
|
-moz-transition: border 500ms ease-out;
|
||||||
|
@ -163,6 +163,10 @@ form *, select {
|
|||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.loader-load-more {
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.input-border-transition {
|
.input-border-transition {
|
||||||
-webkit-transition: border 500ms ease-out;
|
-webkit-transition: border 500ms ease-out;
|
||||||
-moz-transition: border 500ms ease-out;
|
-moz-transition: border 500ms ease-out;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
let loaderOffset = 10;
|
let loaderOffset = 10;
|
||||||
let loadCount = 10;
|
let loadCount = 10;
|
||||||
|
let startAt = null;
|
||||||
let isLoaderLoading = false;
|
let isLoaderLoading = false;
|
||||||
let loadUri = '';
|
let loadUri = '';
|
||||||
let loaderResponseId = '';
|
let loaderResponseId = '';
|
||||||
@ -19,13 +20,14 @@ function loadMoreItems() {
|
|||||||
|
|
||||||
showLoader();
|
showLoader();
|
||||||
isLoaderLoading = true;
|
isLoaderLoading = true;
|
||||||
$.get(loadUri, { offset: loaderOffset, count : loadCount })
|
$.get(loadUri, { offset: loaderOffset, count: loadCount, startAt: startAt })
|
||||||
.done(function (response) {
|
.done(function (response) {
|
||||||
$(loaderResponseId).append(response);
|
$(loaderResponseId).append(response);
|
||||||
if (response.trim().length === 0) {
|
if (response.trim().length === 0) {
|
||||||
staleLoader();
|
staleLoader();
|
||||||
}
|
}
|
||||||
$(document).trigger("loaderFinished", response);
|
$(document).trigger("loaderFinished", response);
|
||||||
|
startAt = $(response).filter('.loader-data-time').last().data('time');
|
||||||
hideLoader();
|
hideLoader();
|
||||||
isLoaderLoading = false;
|
isLoaderLoading = false;
|
||||||
})
|
})
|
||||||
@ -64,6 +66,11 @@ if ($(loaderResponseId).length === 1) {
|
|||||||
$window
|
$window
|
||||||
.off('scroll', ScrollHandler)
|
.off('scroll', ScrollHandler)
|
||||||
.on('scroll', ScrollHandler);
|
.on('scroll', ScrollHandler);
|
||||||
|
$('.loader-load-more').click(function (e) {
|
||||||
|
if (!isLoaderLoading) {
|
||||||
|
loadMoreItems();
|
||||||
|
}
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
function ScrollHandler(e) {
|
function ScrollHandler(e) {
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
/*
|
/*
|
||||||
* load context of chat
|
* load context of chat
|
||||||
*/
|
*/
|
||||||
|
$(document).off('click', '.client-message');
|
||||||
$(document).on('click', '.client-message', function (e) {
|
$(document).on('click', '.client-message', function (e) {
|
||||||
showLoader();
|
showLoader();
|
||||||
const location = $(this);
|
const location = $(this);
|
||||||
@ -33,6 +34,7 @@
|
|||||||
/*
|
/*
|
||||||
* load info on ban/flag
|
* load info on ban/flag
|
||||||
*/
|
*/
|
||||||
|
$(document).off('click', '.automated-penalty-info-detailed');
|
||||||
$(document).on('click', '.automated-penalty-info-detailed', function (e) {
|
$(document).on('click', '.automated-penalty-info-detailed', function (e) {
|
||||||
showLoader();
|
showLoader();
|
||||||
const location = $(this).parent();
|
const location = $(this).parent();
|
||||||
|
Loading…
Reference in New Issue
Block a user