Added cache setting to config page
This commit is contained in:
parent
f3f599c5df
commit
f06994b3c2
|
@ -31,6 +31,14 @@
|
|||
<div class="text-danger">Please enter a positive integer.</div>
|
||||
}
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="cacheMillis">Cache Milliseconds</label>
|
||||
<TextInput Id="cacheMillis" @bind-Value="config.CacheMilliseconds" Type="TextInputType.Number" />
|
||||
@if (!isCacheMillisValid)
|
||||
{
|
||||
<div class="text-danger">Please enter a positive integer or zero.</div>
|
||||
}
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<Switch Id="rollingExpiration" @bind-Value="config.RollingExpiration" Label="Rolling Expiration" />
|
||||
</div>
|
||||
|
@ -46,6 +54,7 @@
|
|||
private bool isCapacityLimitValid = true;
|
||||
private bool isActivitySecondsValid = true;
|
||||
private bool isExpirationSecondsValid = true;
|
||||
private bool isCacheMillisValid = true;
|
||||
private string? successMessage;
|
||||
|
||||
protected override void OnInitialized()
|
||||
|
@ -56,18 +65,20 @@
|
|||
ActivitySeconds = (current.ActivitySeconds ?? 0).ToString(),
|
||||
CapacityLimit = (current.CapacityLimit ?? 0).ToString(),
|
||||
ExpirationSeconds = (current.ExpirationSeconds ?? 0).ToString(),
|
||||
CacheMilliseconds = (current.CacheMilliseconds ?? 0).ToString(),
|
||||
RollingExpiration = current.RollingExpiration ?? false
|
||||
};
|
||||
ValidateInputs();
|
||||
}
|
||||
|
||||
private bool IsFormValid => isCapacityLimitValid && isActivitySecondsValid && isExpirationSecondsValid;
|
||||
private bool IsFormValid => isCapacityLimitValid && isActivitySecondsValid && isExpirationSecondsValid && isCacheMillisValid;
|
||||
|
||||
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;
|
||||
isCacheMillisValid = int.TryParse(config.CacheMilliseconds, out var cache) && cache >= 0;
|
||||
}
|
||||
|
||||
private async Task HandleValidSubmit()
|
||||
|
@ -81,6 +92,7 @@
|
|||
ActivitySeconds = int.Parse(config.ActivitySeconds),
|
||||
CapacityLimit = int.Parse(config.CapacityLimit),
|
||||
ExpirationSeconds = int.Parse(config.ExpirationSeconds),
|
||||
CacheMilliseconds = int.Parse(config.CacheMilliseconds),
|
||||
RollingExpiration = config.RollingExpiration
|
||||
}));
|
||||
successMessage = "Configuration updated successfully.";
|
||||
|
@ -91,6 +103,7 @@
|
|||
public string CapacityLimit { get; set; } = "";
|
||||
public string ActivitySeconds { get; set; } = "";
|
||||
public string ExpirationSeconds { get; set; } = "";
|
||||
public string CacheMilliseconds { get; set; } = "";
|
||||
public bool RollingExpiration { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue