dynamizing UI

This commit is contained in:
Nicolas Constant 2021-02-18 21:30:13 -05:00
parent 892be2c2b8
commit 3896afc380
No known key found for this signature in database
GPG key ID: 1E9F677FB01A5688
3 changed files with 54 additions and 9 deletions

View file

@ -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; }
}
}

View file

@ -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
<div>
<a href="#" class="badge badge-light" title="What does this mean?">Whitelisting Enabled</a>
<a href="#" class="badge badge-light" title="What does this mean?">Blacklisting Enabled</a>
@if (ViewData.Model.WhitelistingEnabled)
{
<a href="#" class="badge badge-light" title="What does this mean?">Whitelisting Enabled</a>
}
@if (ViewData.Model.BlacklistingEnabled)
{
<a href="#" class="badge badge-light" title="What does this mean?">Blacklisting Enabled</a>
}
<div class="node-progress-bar">
<div class="node-progress-bar__label">Instance saturation: </div>
<div class="progress node-progress-bar__bar">
<div class="progress-bar" style="width: 15%">15%</div>
<div class="progress node-progress-bar__bar">
<div class="progress-bar
@((ViewData.Model.InstanceSaturation > 50 && ViewData.Model.InstanceSaturation < 75) ? "bg-warning ":"")
@((ViewData.Model.InstanceSaturation > 75 && ViewData.Model.InstanceSaturation < 100) ? "bg-danger ":"")
@((ViewData.Model.InstanceSaturation > 100) ? "bg-saturation-danger ":"")" style="width: @ViewData.Model.InstanceSaturation%">@ViewData.Model.InstanceSaturation%</div>
</div>
</div>
</div>

View file

@ -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;
}