117 lines
3.4 KiB
Plaintext
117 lines
3.4 KiB
Plaintext
@page "/"
|
|
@using AccessQueuePlayground.Models
|
|
@using AccessQueuePlayground.Services
|
|
@using BlazorBootstrap
|
|
|
|
@inject IAccessQueueManager Manager
|
|
|
|
<PageTitle>AccessQueue Playground</PageTitle>
|
|
|
|
<p>
|
|
<Button Color="ButtonColor.Success" @onclick="AddUser">Add User</Button>
|
|
<Button Color="ButtonColor.Danger" @onclick="RevokeAllAccess">Revoke All</Button>
|
|
<Button Color="ButtonColor.Warning" @onclick="Reset">Reset Data</Button>
|
|
</p>
|
|
@if (Status != null)
|
|
{
|
|
<h2>Users with access</h2>
|
|
<Grid TItem="User" Data="Status.AccessUsers" Class="table table-bordered mt-3" AllowSorting>
|
|
<GridColumns>
|
|
<GridColumn TItem="User" HeaderText="Id" PropertyName="Id" SortKeySelector="item => item.Id">
|
|
@context.Id
|
|
</GridColumn>
|
|
<GridColumn TItem="User" HeaderText="Expiration" PropertyName="LatestResponse?.ExpiresOn" SortKeySelector="item => item.LatestResponse.ExpiresOn">
|
|
@context.LatestResponse?.ExpiresOn
|
|
</GridColumn>
|
|
<GridColumn TItem="User" HeaderText="Active">
|
|
<ChildContent>
|
|
<Switch Value="context.Active" ValueExpression="() => context.Active" ValueChanged="(value) => SetUserActive(context.Id, value)" />
|
|
</ChildContent>
|
|
</GridColumn>
|
|
<GridColumn TItem="User" HeaderText="Revoke">
|
|
<ChildContent>
|
|
<Button Color="ButtonColor.Danger" @onclick="() => RevokeAccess(context.Id)">Revoke Access</Button>
|
|
</ChildContent>
|
|
</GridColumn>
|
|
</GridColumns>
|
|
</Grid>
|
|
<h2>Users in queue</h2>
|
|
<Grid TItem="User" Data="Status.QueuedUsers" Class="table table-bordered mt-3">
|
|
<GridColumns>
|
|
<GridColumn TItem="User" HeaderText="Id" PropertyName="Id">
|
|
@context.Id
|
|
</GridColumn>
|
|
<GridColumn TItem="User" HeaderText="Queue Postition" PropertyName="LatestResponse?.RequestsAhead">
|
|
@(context.LatestResponse?.RequestsAhead ?? 0 + 1)
|
|
</GridColumn>
|
|
<GridColumn TItem="User" HeaderText="Active">
|
|
<ChildContent>
|
|
<Switch Value="context.Active" ValueExpression="() => context.Active" ValueChanged="(value) => SetUserActive(context.Id, value)" />
|
|
</ChildContent>
|
|
</GridColumn>
|
|
<GridColumn TItem="User" HeaderText="Revoke">
|
|
<ChildContent>
|
|
<Button Color="ButtonColor.Danger" @onclick="() => RevokeAccess(context.Id)">Revoke Access</Button>
|
|
</ChildContent>
|
|
</GridColumn>
|
|
</GridColumns>
|
|
</Grid>
|
|
<h2>Inactive users</h2>
|
|
<Grid TItem="User" Data="Status.InactiveUsers" Class="table table-bordered mt-3" AllowSorting>
|
|
<GridColumns>
|
|
<GridColumn TItem="User" HeaderText="Id" PropertyName="Id" SortKeySelector="item => item.Id">
|
|
@context.Id
|
|
</GridColumn>
|
|
<GridColumn TItem="User" HeaderText="Active">
|
|
<ChildContent>
|
|
<Switch Value="context.Active" ValueExpression="() => context.Active" ValueChanged="(value) => SetUserActive(context.Id, value)" />
|
|
</ChildContent>
|
|
</GridColumn>
|
|
</GridColumns>
|
|
</Grid>
|
|
}
|
|
|
|
@code {
|
|
public AccessQueueStatus? Status;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
Manager.StatusUpdated += OnStatusUpdated;
|
|
Status = Manager.GetStatus();
|
|
}
|
|
|
|
private void OnStatusUpdated()
|
|
{
|
|
InvokeAsync(() =>
|
|
{
|
|
Status = Manager.GetStatus();
|
|
StateHasChanged();
|
|
});
|
|
}
|
|
|
|
public void AddUser()
|
|
{
|
|
Manager.AddUser();
|
|
Status = Manager.GetStatus();
|
|
}
|
|
|
|
public void SetUserActive(Guid userId, bool isActive)
|
|
{
|
|
Manager.SetUserActive(userId, isActive);
|
|
}
|
|
|
|
public void RevokeAccess(Guid userId)
|
|
{
|
|
Manager.RevokeAccess(userId);
|
|
}
|
|
|
|
public void RevokeAllAccess()
|
|
{
|
|
Manager.RevokeAllAccess();
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
Manager.Reset();
|
|
}
|
|
} |