|
|
|
@ -5,100 +5,92 @@
|
|
|
|
|
<h3>Access Queue Configuration</h3>
|
|
|
|
|
|
|
|
|
|
<EditForm Model="config" OnValidSubmit="HandleValidSubmit">
|
|
|
|
|
<DataAnnotationsValidator />
|
|
|
|
|
<ValidationSummary />
|
|
|
|
|
<div class="mb-3">
|
|
|
|
|
<label for="capacityLimit">Capacity Limit</label>
|
|
|
|
|
<TextInput Id="capacityLimit" Value="@capacityLimitInput" ValueChanged="@((string? v) => capacityLimitInput = v)" ValueExpression="@(() => capacityLimitInput)" Type="TextInputType.Number" OnInput="e => OnInputChanged(e, nameof(config.CapacityLimit))" />
|
|
|
|
|
@if (!isCapacityLimitValid)
|
|
|
|
|
{
|
|
|
|
|
<div class="text-danger">Please enter a positive integer.</div>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mb-3">
|
|
|
|
|
<label for="activitySeconds">Activity Seconds</label>
|
|
|
|
|
<TextInput Id="activitySeconds" Value="@activitySecondsInput" ValueChanged="@((string? v) => activitySecondsInput = v)" ValueExpression="@(() => activitySecondsInput)" Type="TextInputType.Number" OnInput="e => OnInputChanged(e, nameof(config.ActivitySeconds))" />
|
|
|
|
|
@if (!isActivitySecondsValid)
|
|
|
|
|
{
|
|
|
|
|
<div class="text-danger">Please enter a positive integer.</div>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mb-3">
|
|
|
|
|
<label for="expirationSeconds">Expiration Seconds</label>
|
|
|
|
|
<TextInput Id="expirationSeconds" Value="@expirationSecondsInput" ValueChanged="@((string? v) => expirationSecondsInput = v)" ValueExpression="@(() => expirationSecondsInput)" Type="TextInputType.Number" OnInput="e => OnInputChanged(e, nameof(config.ExpirationSeconds))" />
|
|
|
|
|
@if (!isExpirationSecondsValid)
|
|
|
|
|
{
|
|
|
|
|
<div class="text-danger">Please enter a positive integer.</div>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mb-3">
|
|
|
|
|
<Switch Id="rollingExpiration" @bind-Checked="rollingExpirationSwitch" Label="Rolling Expiration" />
|
|
|
|
|
</div>
|
|
|
|
|
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary" Disabled="@(!IsFormValid)">Save</Button>
|
|
|
|
|
@if (successMessage != null)
|
|
|
|
|
{
|
|
|
|
|
<Alert Color="AlertColor.Success" Class="mt-3">@successMessage</Alert>
|
|
|
|
|
}
|
|
|
|
|
<DataAnnotationsValidator />
|
|
|
|
|
<ValidationSummary />
|
|
|
|
|
<div class="mb-3">
|
|
|
|
|
<label for="capacityLimit">Capacity Limit</label>
|
|
|
|
|
<TextInput Id="capacityLimit" @bind-Value="config.CapacityLimit" Type="TextInputType.Number" />
|
|
|
|
|
@if (!isCapacityLimitValid)
|
|
|
|
|
{
|
|
|
|
|
<div class="text-danger">Please enter a positive integer.</div>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mb-3">
|
|
|
|
|
<label for="activitySeconds">Activity Seconds</label>
|
|
|
|
|
<TextInput Id="activitySeconds" @bind-Value="config.ActivitySeconds" Type="TextInputType.Number" />
|
|
|
|
|
@if (!isActivitySecondsValid)
|
|
|
|
|
{
|
|
|
|
|
<div class="text-danger">Please enter a positive integer.</div>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mb-3">
|
|
|
|
|
<label for="expirationSeconds">Expiration Seconds</label>
|
|
|
|
|
<TextInput Id="expirationSeconds" @bind-Value="config.ExpirationSeconds" Type="TextInputType.Number" />
|
|
|
|
|
@if (!isExpirationSecondsValid)
|
|
|
|
|
{
|
|
|
|
|
<div class="text-danger">Please enter a positive integer.</div>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mb-3">
|
|
|
|
|
<Switch Id="rollingExpiration" @bind-Value="config.RollingExpiration" Label="Rolling Expiration" />
|
|
|
|
|
</div>
|
|
|
|
|
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">Save</Button>
|
|
|
|
|
@if (successMessage != null)
|
|
|
|
|
{
|
|
|
|
|
<Alert Color="AlertColor.Success" Class="mt-3">@successMessage</Alert>
|
|
|
|
|
}
|
|
|
|
|
</EditForm>
|
|
|
|
|
|
|
|
|
|
@code {
|
|
|
|
|
private AccessQueueService.Models.AccessQueueConfig config = new();
|
|
|
|
|
private string? capacityLimitInput;
|
|
|
|
|
private string? activitySecondsInput;
|
|
|
|
|
private string? expirationSecondsInput;
|
|
|
|
|
private bool rollingExpirationSwitch;
|
|
|
|
|
private bool isCapacityLimitValid = true;
|
|
|
|
|
private bool isActivitySecondsValid = true;
|
|
|
|
|
private bool isExpirationSecondsValid = true;
|
|
|
|
|
private string? successMessage;
|
|
|
|
|
private ConfigModel config = new();
|
|
|
|
|
private bool isCapacityLimitValid = true;
|
|
|
|
|
private bool isActivitySecondsValid = true;
|
|
|
|
|
private bool isExpirationSecondsValid = true;
|
|
|
|
|
private string? successMessage;
|
|
|
|
|
|
|
|
|
|
protected override void OnInitialized()
|
|
|
|
|
{
|
|
|
|
|
var current = QueueManager.GetConfig();
|
|
|
|
|
config = current.Clone();
|
|
|
|
|
capacityLimitInput = config.CapacityLimit?.ToString();
|
|
|
|
|
activitySecondsInput = config.ActivitySeconds?.ToString();
|
|
|
|
|
expirationSecondsInput = config.ExpirationSeconds?.ToString();
|
|
|
|
|
rollingExpirationSwitch = config.RollingExpiration ?? true;
|
|
|
|
|
ValidateInputs();
|
|
|
|
|
}
|
|
|
|
|
protected override void OnInitialized()
|
|
|
|
|
{
|
|
|
|
|
var current = QueueManager.GetConfig();
|
|
|
|
|
config = new ConfigModel
|
|
|
|
|
{
|
|
|
|
|
ActivitySeconds = (current.ActivitySeconds ?? 0).ToString(),
|
|
|
|
|
CapacityLimit = (current.CapacityLimit ?? 0).ToString(),
|
|
|
|
|
ExpirationSeconds = (current.ExpirationSeconds ?? 0).ToString(),
|
|
|
|
|
RollingExpiration = current.RollingExpiration ?? false
|
|
|
|
|
};
|
|
|
|
|
ValidateInputs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool IsFormValid => isCapacityLimitValid && isActivitySecondsValid && isExpirationSecondsValid;
|
|
|
|
|
private bool IsFormValid => isCapacityLimitValid && isActivitySecondsValid && isExpirationSecondsValid;
|
|
|
|
|
|
|
|
|
|
private void ValidateInputs()
|
|
|
|
|
{
|
|
|
|
|
isCapacityLimitValid = int.TryParse(capacityLimitInput, out var cap) && cap > 0;
|
|
|
|
|
isActivitySecondsValid = int.TryParse(activitySecondsInput, out var act) && act > 0;
|
|
|
|
|
isExpirationSecondsValid = int.TryParse(expirationSecondsInput, out var exp) && exp > 0;
|
|
|
|
|
}
|
|
|
|
|
private void ValidateInputs()
|
|
|
|
|
{
|
|
|
|
|
isCapacityLimitValid = int.TryParse(config.CapacityLimit, out var cap) && cap > 0;
|
|
|
|
|
isActivitySecondsValid = int.TryParse(config.ActivitySeconds, out var act) && act > 0;
|
|
|
|
|
isExpirationSecondsValid = int.TryParse(config.ExpirationSeconds, out var exp) && exp > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task HandleValidSubmit()
|
|
|
|
|
{
|
|
|
|
|
ValidateInputs();
|
|
|
|
|
if (!IsFormValid)
|
|
|
|
|
return;
|
|
|
|
|
config.CapacityLimit = int.Parse(capacityLimitInput!);
|
|
|
|
|
config.ActivitySeconds = int.Parse(activitySecondsInput!);
|
|
|
|
|
config.ExpirationSeconds = int.Parse(expirationSecondsInput!);
|
|
|
|
|
config.RollingExpiration = rollingExpirationSwitch;
|
|
|
|
|
await Task.Run(() => QueueManager.UpdateConfig(config));
|
|
|
|
|
successMessage = "Configuration updated successfully.";
|
|
|
|
|
}
|
|
|
|
|
private async Task HandleValidSubmit()
|
|
|
|
|
{
|
|
|
|
|
successMessage = null;
|
|
|
|
|
ValidateInputs();
|
|
|
|
|
if (!IsFormValid)
|
|
|
|
|
return;
|
|
|
|
|
await Task.Run(() => QueueManager.UpdateConfig(new ()
|
|
|
|
|
{
|
|
|
|
|
ActivitySeconds = int.Parse(config.ActivitySeconds),
|
|
|
|
|
CapacityLimit = int.Parse(config.CapacityLimit),
|
|
|
|
|
ExpirationSeconds = int.Parse(config.ExpirationSeconds),
|
|
|
|
|
RollingExpiration = config.RollingExpiration
|
|
|
|
|
}));
|
|
|
|
|
successMessage = "Configuration updated successfully.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnInputChanged(ChangeEventArgs e, string field)
|
|
|
|
|
{
|
|
|
|
|
switch (field)
|
|
|
|
|
{
|
|
|
|
|
case nameof(config.CapacityLimit):
|
|
|
|
|
capacityLimitInput = e.Value?.ToString();
|
|
|
|
|
break;
|
|
|
|
|
case nameof(config.ActivitySeconds):
|
|
|
|
|
activitySecondsInput = e.Value?.ToString();
|
|
|
|
|
break;
|
|
|
|
|
case nameof(config.ExpirationSeconds):
|
|
|
|
|
expirationSecondsInput = e.Value?.ToString();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
ValidateInputs();
|
|
|
|
|
}
|
|
|
|
|
public class ConfigModel
|
|
|
|
|
{
|
|
|
|
|
public string CapacityLimit { get; set; } = "";
|
|
|
|
|
public string ActivitySeconds { get; set; } = "";
|
|
|
|
|
public string ExpirationSeconds { get; set; } = "";
|
|
|
|
|
public bool RollingExpiration { get; set; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|