From d6aa832f6137a93dc1c0c12936cf7b315762c9cd Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 12 May 2025 01:26:31 -0400 Subject: [PATCH] Split users into separate grids --- .../Components/Pages/Home.razor | 58 ++++++++++++++++--- .../Models/AccessQueueStatus.cs | 7 +-- .../Services/AccessQueueManager.cs | 24 ++++++-- AccessQueuePlayground/appsettings.json | 6 +- 4 files changed, 77 insertions(+), 18 deletions(-) diff --git a/AccessQueuePlayground/Components/Pages/Home.razor b/AccessQueuePlayground/Components/Pages/Home.razor index eb3d92e..a3d4328 100644 --- a/AccessQueuePlayground/Components/Pages/Home.razor +++ b/AccessQueuePlayground/Components/Pages/Home.razor @@ -10,14 +10,53 @@ -@if(Status != null) +@if (Status != null) { - @foreach(var user in Status.Users) - { -
-

@user.Id @user.LatestResponse?.HasAccess @user.LatestResponse?.ExpiresOn

-
- } +

Users with access

+ + + + @context.Id + + + @context.LatestResponse?.ExpiresOn + + + + + + + + +

Users in queue

+ + + + @context.Id + + + @(context.LatestResponse?.RequestsAhead ?? 0 + 1) + + + + + + + + +

Inactive users

+ + + + @context.Id + + + + + + + + } @code { @@ -48,4 +87,9 @@ Manager.AddUser(); Status = Manager.GetStatus(); } + + public void ToggleUserActive(Guid userId) + { + Manager.ToggleUserActivity(userId); + } } \ No newline at end of file diff --git a/AccessQueuePlayground/Models/AccessQueueStatus.cs b/AccessQueuePlayground/Models/AccessQueueStatus.cs index 9b36ca8..c773658 100644 --- a/AccessQueuePlayground/Models/AccessQueueStatus.cs +++ b/AccessQueuePlayground/Models/AccessQueueStatus.cs @@ -4,9 +4,8 @@ namespace AccessQueuePlayground.Models { public class AccessQueueStatus { - public List Users { get; set; } = []; - public int QueueSize { get; set; } - public int ActiveTickets { get; set; } - public int UnexpiredTickets { get; set; } + public List AccessUsers { get; set; } = []; + public List QueuedUsers { get; set; } = []; + public List InactiveUsers { get; set; } = []; } } diff --git a/AccessQueuePlayground/Services/AccessQueueManager.cs b/AccessQueuePlayground/Services/AccessQueueManager.cs index 8490d51..69846b3 100644 --- a/AccessQueuePlayground/Services/AccessQueueManager.cs +++ b/AccessQueuePlayground/Services/AccessQueueManager.cs @@ -52,13 +52,29 @@ namespace AccessQueuePlayground.Services var newStatus = new AccessQueueStatus(); foreach (var user in userList) { - AccessResponse? response = user.LatestResponse; if (user.Active) { - response = await _accessService.RequestAccess(user.Id); - user.LatestResponse = response; + user.LatestResponse = await _accessService.RequestAccess(user.Id); + if (user.LatestResponse?.HasAccess ?? false) + { + newStatus.AccessUsers.Add(user); + } + else + { + newStatus.QueuedUsers.Add(user); + } + } + else + { + if(user.LatestResponse?.ExpiresOn != null && user.LatestResponse.ExpiresOn > DateTime.UtcNow) + { + newStatus.AccessUsers.Add(user); + } + else + { + newStatus.InactiveUsers.Add(user); + } } - newStatus.Users.Add(user); } _status = newStatus; NotifyStatusUpdated(); diff --git a/AccessQueuePlayground/appsettings.json b/AccessQueuePlayground/appsettings.json index 79dbb33..fcc9c4b 100644 --- a/AccessQueuePlayground/appsettings.json +++ b/AccessQueuePlayground/appsettings.json @@ -6,9 +6,9 @@ } }, "AccessQueue": { - "CapacityLimit": 10, // Maximum number of active users - "ActivitySeconds": 5, // Time since last access before a user is considered inactive - "ExpirationSeconds": 30, // 12 hours - Time before a user access is revoked + "CapacityLimit": 3, // Maximum number of active users + "ActivitySeconds": 2, // Time since last access before a user is considered inactive + "ExpirationSeconds": 10, // 12 hours - Time before a user access is revoked "RollingExpiration": true // Whether to extend expiration time on access }, "AllowedHosts": "*"