#10 added config display to UI
This commit is contained in:
parent
ffedc09471
commit
365e4a882c
|
@ -6,7 +6,15 @@
|
|||
@inject IAccessQueueManager Manager
|
||||
|
||||
<PageTitle>AccessQueue Playground</PageTitle>
|
||||
|
||||
@if (Config != null)
|
||||
{
|
||||
<h4>Config</h4>
|
||||
<p>
|
||||
<b>Expiration Seconds:</b> @Config.ExpirationSeconds,
|
||||
<b>Activity Seconds:</b> @Config.ActivitySeconds,
|
||||
<b>Capacity Limit:</b> @Config.CapacityLimit
|
||||
</p>
|
||||
}
|
||||
<p>
|
||||
<Button Color="ButtonColor.Success" @onclick="AddUser">Add User</Button>
|
||||
<Button Color="ButtonColor.Danger" @onclick="RevokeAllAccess">Revoke All</Button>
|
||||
|
@ -73,11 +81,12 @@
|
|||
|
||||
@code {
|
||||
public AccessQueueStatus? Status;
|
||||
|
||||
public AccessQueueConfig? Config;
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
Manager.StatusUpdated += OnStatusUpdated;
|
||||
Status = Manager.GetStatus();
|
||||
Config = Manager.GetConfig();
|
||||
}
|
||||
|
||||
private void OnStatusUpdated()
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
namespace AccessQueuePlayground.Models
|
||||
{
|
||||
public class AccessQueueConfig
|
||||
{
|
||||
public int ActivitySeconds { get; set; }
|
||||
public int ExpirationSeconds { get; set; }
|
||||
public int CapacityLimit { get; set; }
|
||||
|
||||
}
|
||||
}
|
|
@ -2,12 +2,14 @@
|
|||
using AccessQueuePlayground.Models;
|
||||
using AccessQueueService.Models;
|
||||
using AccessQueueService.Services;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace AccessQueuePlayground.Services
|
||||
{
|
||||
public class AccessQueueManager : IAccessQueueManager
|
||||
{
|
||||
private readonly IAccessService _accessService;
|
||||
private readonly IConfiguration _config;
|
||||
private ConcurrentDictionary<Guid, User> _users;
|
||||
private AccessQueueStatus _status;
|
||||
public event Action? StatusUpdated;
|
||||
|
@ -17,15 +19,23 @@ namespace AccessQueuePlayground.Services
|
|||
StatusUpdated?.Invoke();
|
||||
}
|
||||
|
||||
public AccessQueueManager(IAccessService accessService)
|
||||
public AccessQueueManager(IAccessService accessService, IConfiguration config)
|
||||
{
|
||||
_accessService = accessService;
|
||||
_users = new ConcurrentDictionary<Guid, User>();
|
||||
_status = new AccessQueueStatus();
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public AccessQueueStatus GetStatus() => _status;
|
||||
|
||||
public AccessQueueConfig GetConfig() => new AccessQueueConfig
|
||||
{
|
||||
ActivitySeconds = _config.GetValue<int>("AccessQueue:ActivitySeconds"),
|
||||
ExpirationSeconds = _config.GetValue<int>("AccessQueue:ExpirationSeconds"),
|
||||
CapacityLimit = _config.GetValue<int>("AccessQueue:CapacityLimit")
|
||||
};
|
||||
|
||||
public Guid AddUser()
|
||||
{
|
||||
var id = Guid.NewGuid();
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace AccessQueuePlayground.Services
|
|||
public interface IAccessQueueManager
|
||||
{
|
||||
public event Action? StatusUpdated;
|
||||
public AccessQueueConfig GetConfig();
|
||||
public Task RecalculateStatus();
|
||||
public AccessQueueStatus GetStatus();
|
||||
public Guid AddUser();
|
||||
|
|
Loading…
Reference in New Issue