QOL updates for profile meta

implement filterable meta for issue #158
update translations and use humanizer lib with datetime/timespan for issue #80
This commit is contained in:
RaidMax
2020-08-17 21:21:11 -05:00
parent 1ef2ba5344
commit 778e339a61
78 changed files with 1800 additions and 775 deletions

View File

@ -1,6 +1,6 @@
namespace SharedLibraryCore.Dtos
{
public class FindClientRequest : PaginationInfo
public class FindClientRequest : PaginationRequest
{
/// <summary>
/// name of client

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SharedLibraryCore.Dtos.Meta.Requests
{
public class BaseClientMetaRequest : PaginationRequest
{
public int ClientId { get; set; }
}
}

View File

@ -0,0 +1,11 @@
using SharedLibraryCore.QueryHelper;
using System;
using System.Collections.Generic;
using System.Text;
namespace SharedLibraryCore.Dtos.Meta.Requests
{
public class ReceivedPenaltyRequest : BaseClientMetaRequest
{
}
}

View File

@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SharedLibraryCore.Dtos.Meta.Responses
{
public class AdministeredPenaltyResponse : ReceivedPenaltyResponse
{
}
}

View File

@ -0,0 +1,19 @@
using SharedLibraryCore.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
namespace SharedLibraryCore.Dtos.Meta.Responses
{
public class BaseMetaResponse : IClientMeta, IClientMetaResponse
{
public int MetaId { get; set; }
public int ClientId { get; set; }
public MetaType Type { get; set; }
public DateTime When { get; set; }
public bool IsSensitive { get; set; }
public bool ShouldDisplay { get; set; }
public int? Column { get; set; }
public int? Order { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using SharedLibraryCore.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
namespace SharedLibraryCore.Dtos.Meta.Responses
{
public class InformationResponse : BaseMetaResponse
{
public string Key { get; set; }
public string Value { get; set; }
public string ToolTipText { get; set; }
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SharedLibraryCore.Dtos.Meta.Responses
{
public class MessageResponse : BaseMetaResponse
{
public long ServerId { get; set; }
public string Message { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using System;
using static SharedLibraryCore.Database.Models.EFPenalty;
namespace SharedLibraryCore.Dtos.Meta.Responses
{
public class ReceivedPenaltyResponse : BaseMetaResponse
{
public int PenaltyId { get; set; }
public int OffenderClientId { get; set; }
public string OffenderName { get; set; }
public string PunisherName { get; set; }
public int PunisherClientId { get; set; }
public PenaltyType PenaltyType { get; set; }
public string Offense { get; set; }
public string AutomatedOffense { get; set; }
public DateTime? ExpirationDate { get; set; }
public string ExpiresInText => ExpirationDate.HasValue && ExpirationDate.Value > DateTime.UtcNow ? (ExpirationDate - DateTime.UtcNow).Value.HumanizeForCurrentCulture() : "";
public string LengthText => ExpirationDate.HasValue ? (ExpirationDate.Value.AddMinutes(1) - When).HumanizeForCurrentCulture() : "";
public bool IsLinked { get; set; }
public int LinkedClientId { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using System;
namespace SharedLibraryCore.Dtos.Meta.Responses
{
public class UpdatedAliasResponse : BaseMetaResponse
{
public string Name { get; set; }
public string IPAddress { get; set; } = "--";
public override bool Equals(object obj)
{
if (obj is UpdatedAliasResponse resp)
{
return resp.Name.StripColors() == Name.StripColors() && resp.IPAddress == IPAddress;
}
return false;
}
public override int GetHashCode() => HashCode.Combine(Name.StripColors(), IPAddress);
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SharedLibraryCore.Dtos.Meta
{
public class WebfrontTranslationHelper
{
public bool IsInterpolation { get; set; }
public string MatchValue { get; set; }
public string TranslationValue { get; set; }
}
}

View File

@ -1,9 +1,11 @@
namespace SharedLibraryCore.Dtos
using System;
namespace SharedLibraryCore.Dtos
{
/// <summary>
/// pagination information holder class
/// </summary>
public class PaginationInfo
public class PaginationRequest
{
/// <summary>
/// how many items to skip
@ -24,6 +26,8 @@
/// direction of ordering
/// </summary>
public SortDirection Direction { get; set; } = SortDirection.Descending;
public DateTime? Before { get; set; }
}
public enum SortDirection

View File

@ -21,8 +21,8 @@ namespace SharedLibraryCore.Dtos
public PenaltyType PenaltyType { get; set; }
public string PenaltyTypeText => PenaltyType.ToString();
public DateTime TimePunished { get; set; }
public string TimePunishedString => Utilities.GetTimePassed(TimePunished, true);
public string TimeRemaining => DateTime.UtcNow > Expires ? "" : $"{((Expires ?? DateTime.MaxValue).Year == DateTime.MaxValue.Year ? Utilities.GetTimePassed(TimePunished, true) : Utilities.TimeSpanText((Expires ?? DateTime.MaxValue) - DateTime.UtcNow))}";
public string TimePunishedString => TimePunished.HumanizeForCurrentCulture();
public string TimeRemaining => DateTime.UtcNow > Expires ? "" : $"{((Expires ?? DateTime.MaxValue).Year == DateTime.MaxValue.Year ? TimePunishedString : ((Expires ?? DateTime.MaxValue) - DateTime.UtcNow).HumanizeForCurrentCulture())}";
public bool Expired => Expires.HasValue && Expires <= DateTime.UtcNow;
public DateTime? Expires { get; set; }
public override bool Sensitive => PenaltyType == PenaltyType.Flag || PenaltyType == PenaltyType.Unflag;

View File

@ -1,8 +1,8 @@
using System;
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Dtos.Meta.Responses;
using SharedLibraryCore.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SharedLibraryCore.Dtos
{
@ -19,11 +19,13 @@ namespace SharedLibraryCore.Dtos
public bool HasActivePenalty { get; set; }
public string ActivePenaltyType { get; set; }
public bool Authenticated { get; set; }
public List<ProfileMeta> Meta { get; set; }
public List<InformationResponse> Meta { get; set; }
public EFPenalty ActivePenalty { get; set; }
public bool Online { get; set; }
public string TimeOnline { get; set; }
public DateTime LastConnection { get; set; }
public string LastConnectionText => Utilities.GetTimePassed(LastConnection, true);
public string LastConnectionText => (DateTime.UtcNow - LastConnection).HumanizeForCurrentCulture();
public IDictionary<int, long> LinkedAccounts { get; set; }
public MetaType? MetaFilterType { get; set; }
}
}

View File

@ -1,32 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SharedLibraryCore.Dtos
{
public class ProfileMeta : SharedInfo
{
public enum MetaType
{
Other,
Information,
AliasUpdate,
ChatMessage,
Penalized,
ReceivedPenalty,
QuickMessage
}
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; }
}
}