From 0c527a5f6590ef918de946b9dbb947f7028c7109 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sun, 24 Feb 2019 19:07:56 -0600 Subject: [PATCH] Add lock menu icon for tempbanned players issue #62 --- SharedLibraryCore/Services/MetaService.cs | 28 +++++++++++++++++-- .../Views/Client/Profile/Index.cshtml | 15 ++++++++-- WebfrontCore/wwwroot/css/profile.css | 9 ++++-- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/SharedLibraryCore/Services/MetaService.cs b/SharedLibraryCore/Services/MetaService.cs index 90350cfa2..d1e9b0eb8 100644 --- a/SharedLibraryCore/Services/MetaService.cs +++ b/SharedLibraryCore/Services/MetaService.cs @@ -2,7 +2,6 @@ using SharedLibraryCore.Database; using SharedLibraryCore.Database.Models; using SharedLibraryCore.Dtos; -using SharedLibraryCore.Interfaces; using System; using System.Collections.Generic; using System.Linq; @@ -14,11 +13,21 @@ namespace SharedLibraryCore.Services { private static List>>> _metaActions = new List>>>(); + /// + /// adds or updates meta key and value to the database + /// + /// key of meta data + /// value of the meta data + /// client to save the meta for + /// public async Task AddPersistentMeta(string metaKey, string metaValue, EFClient client) { using (var ctx = new DatabaseContext()) { - var existingMeta = await ctx.EFMeta.FirstOrDefaultAsync(_meta => _meta.ClientId == client.ClientId && _meta.Key == metaKey); + var existingMeta = await ctx.EFMeta + .Where(_meta => _meta.Key == metaKey) + .Where(_meta => _meta.ClientId == client.ClientId) + .FirstOrDefaultAsync(); if (existingMeta != null) { @@ -41,6 +50,12 @@ namespace SharedLibraryCore.Services } } + /// + /// retrieves meta data for given client and key + /// + /// key to retrieve value for + /// client to retrieve meta for + /// public async Task GetPersistentMeta(string metaKey, EFClient client) { using (var ctx = new DatabaseContext(disableTracking:true)) @@ -52,11 +67,20 @@ namespace SharedLibraryCore.Services } } + /// + /// aads a meta task to the runtime meta list + /// + /// public static void AddRuntimeMeta(Func>> metaAction) { _metaActions.Add(metaAction); } + /// + /// retrieves all the runtime meta information for given client idea + /// + /// id of the client + /// public static async Task> GetRuntimeMeta(int clientId) { var meta = new List(); diff --git a/WebfrontCore/Views/Client/Profile/Index.cshtml b/WebfrontCore/Views/Client/Profile/Index.cshtml index affacc556..5e84faf98 100644 --- a/WebfrontCore/Views/Client/Profile/Index.cshtml +++ b/WebfrontCore/Views/Client/Profile/Index.cshtml @@ -4,10 +4,11 @@ string shortCode = match == string.Empty ? "?" : match; var loc = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex; string gravatarUrl = Model.Meta.FirstOrDefault(m => m.Key == "GravatarEmail")?.Value; + bool isTempBanned = Model.ActivePenaltyType == "TempBan"; }
-
+
@if (string.IsNullOrEmpty(gravatarUrl)) { @shortCode @@ -44,7 +45,15 @@ @if (Model.LevelInt < (int)ViewBag.User.Level && Model.HasActivePenalty) { - + @if (isTempBanned) + { + + + } + else + { + + } }
@@ -73,7 +82,7 @@ }
-
@Model.Level
+
@Model.Level @(isTempBanned ? $"&emdash; {loc["WEBFRONT_PROFILE_TEMPBAN"]}" : "")
@loc["WEBFRONT_PROFILE_PLAYER"] @Model.TimePlayed @loc["GLOBAL_TIME_HOURS"] diff --git a/WebfrontCore/wwwroot/css/profile.css b/WebfrontCore/wwwroot/css/profile.css index 858edb759..dcae199d1 100644 --- a/WebfrontCore/wwwroot/css/profile.css +++ b/WebfrontCore/wwwroot/css/profile.css @@ -111,8 +111,13 @@ } .penalties-color-tempban { - color: #fd9c38; - color: rgba(253, 139, 22, 0.85); + color: #fe7e4c; + color: rgba(254, 126, 76, 0.85); +} + +.penalties-bgcolor-tempban { + background-color: #fe7e4c; + background-color: rgba(254, 126, 76, 0.85); } .penalties-color-flag {