From 3896afc38045ce81900c8caefab13c68ce985b93 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Thu, 18 Feb 2021 21:30:13 -0500 Subject: [PATCH] dynamizing UI --- .../Component/NodeInfoViewComponent.cs | 37 ++++++++++++++++++- .../Shared/Components/NodeInfo/Default.cshtml | 21 +++++++---- src/BirdsiteLive/wwwroot/css/pattern.css | 5 ++- 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/src/BirdsiteLive/Component/NodeInfoViewComponent.cs b/src/BirdsiteLive/Component/NodeInfoViewComponent.cs index b51c319..51156c2 100644 --- a/src/BirdsiteLive/Component/NodeInfoViewComponent.cs +++ b/src/BirdsiteLive/Component/NodeInfoViewComponent.cs @@ -2,15 +2,50 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using BirdsiteLive.Domain.Repository; using Microsoft.AspNetCore.Mvc; namespace BirdsiteLive.Component { public class NodeInfoViewComponent : ViewComponent { + private readonly IModerationRepository _moderationRepository; + + #region Ctor + public NodeInfoViewComponent(IModerationRepository moderationRepository) + { + _moderationRepository = moderationRepository; + } + #endregion + public IViewComponentResult Invoke() { - return View(null); + var followerPolicy = _moderationRepository.GetModerationType(ModerationEntityTypeEnum.Follower); + var twitterAccountPolicy = _moderationRepository.GetModerationType(ModerationEntityTypeEnum.TwitterAccount); + + var viewModel = new NodeInfoViewModel + { + BlacklistingEnabled = followerPolicy == ModerationTypeEnum.BlackListing || + twitterAccountPolicy == ModerationTypeEnum.BlackListing, + WhitelistingEnabled = followerPolicy == ModerationTypeEnum.WhiteListing || + twitterAccountPolicy == ModerationTypeEnum.WhiteListing, + InstanceSaturation = 16, + }; + + viewModel = new NodeInfoViewModel + { + BlacklistingEnabled = false, + WhitelistingEnabled = false, + InstanceSaturation = 175 + }; + return View(viewModel); } } + + public class NodeInfoViewModel + { + public bool BlacklistingEnabled { get; set; } + public bool WhitelistingEnabled { get; set; } + public int InstanceSaturation { get; set; } + } } diff --git a/src/BirdsiteLive/Views/Shared/Components/NodeInfo/Default.cshtml b/src/BirdsiteLive/Views/Shared/Components/NodeInfo/Default.cshtml index 60a6be0..a878772 100644 --- a/src/BirdsiteLive/Views/Shared/Components/NodeInfo/Default.cshtml +++ b/src/BirdsiteLive/Views/Shared/Components/NodeInfo/Default.cshtml @@ -1,15 +1,22 @@ -@* - For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 -*@ +@model BirdsiteLive.Component.NodeInfoViewModel
- Whitelisting Enabled - Blacklisting Enabled + @if (ViewData.Model.WhitelistingEnabled) + { + Whitelisting Enabled + } + @if (ViewData.Model.BlacklistingEnabled) + { + Blacklisting Enabled + }
Instance saturation:
-
-
15%
+
+
75 && ViewData.Model.InstanceSaturation < 100) ? "bg-danger ":"") + @((ViewData.Model.InstanceSaturation > 100) ? "bg-saturation-danger ":"")" style="width: @ViewData.Model.InstanceSaturation%">@ViewData.Model.InstanceSaturation%
diff --git a/src/BirdsiteLive/wwwroot/css/pattern.css b/src/BirdsiteLive/wwwroot/css/pattern.css index 161c812..05d4908 100644 --- a/src/BirdsiteLive/wwwroot/css/pattern.css +++ b/src/BirdsiteLive/wwwroot/css/pattern.css @@ -7,12 +7,15 @@ border-bottom: 1px solid #dee2e6; } - +.bg-saturation-danger { + background-color: #800000 !important; +} @media (max-width: 767px) { .node-progress-bar { display: block; width: 100%; + margin-top: 3px; margin-bottom: 7px; }