MudTable
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using OI.Metrology.ClientHub.Models;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
|
||||
namespace OI.Metrology.ClientHub.Pages;
|
||||
|
||||
@ -7,7 +9,20 @@ public partial class AwaitingDisposition
|
||||
{
|
||||
|
||||
[Inject] protected IJSRuntime? JSRuntime { get; set; }
|
||||
[Inject] protected Models.AppSettings? AppSettings { get; set; }
|
||||
[Inject] protected HttpClient? HttpClient { get; set; }
|
||||
[Inject] protected AppSettings? AppSettings { get; set; }
|
||||
[Inject] protected ILogger<AwaitingDisposition>? Logger { get; set; }
|
||||
|
||||
private string? _ToolTypeFilter;
|
||||
private string? _ToolFilter;
|
||||
private string? _ReactorFilter;
|
||||
private string? _RdsFilter;
|
||||
private string? _PSNFilter;
|
||||
private string? _LayerFilter;
|
||||
private string? _ZoneFilter;
|
||||
private readonly List<Metrology.Shared.DataModels.AwaitingDisposition> _Records;
|
||||
|
||||
public AwaitingDisposition() => _Records = new();
|
||||
|
||||
protected override Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
@ -22,4 +37,46 @@ public partial class AwaitingDisposition
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private bool FilterRecords(Metrology.Shared.DataModels.AwaitingDisposition? record)
|
||||
{
|
||||
bool? result = _ToolTypeFilter is not null ? record?.ToolType?.Contains(_ToolTypeFilter, StringComparison.CurrentCultureIgnoreCase) : null;
|
||||
if (result is null || result.Value)
|
||||
result = _ToolFilter is not null ? record?.Tool?.Contains(_ToolFilter, StringComparison.CurrentCultureIgnoreCase) : null;
|
||||
if (result is null || result.Value)
|
||||
result = _ReactorFilter is not null ? record?.Reactor?.Contains(_ReactorFilter, StringComparison.CurrentCultureIgnoreCase) : null;
|
||||
if (result is null || result.Value)
|
||||
result = _RdsFilter is not null ? record?.RDS?.Contains(_RdsFilter, StringComparison.CurrentCultureIgnoreCase) : null;
|
||||
if (result is null || result.Value)
|
||||
result = _PSNFilter is not null ? record?.PSN?.Contains(_PSNFilter, StringComparison.CurrentCultureIgnoreCase) : null;
|
||||
if (result is null || result.Value)
|
||||
result = _LayerFilter is not null ? record?.Layer?.Contains(_LayerFilter, StringComparison.CurrentCultureIgnoreCase) : null;
|
||||
if (result is null || result.Value)
|
||||
result = _ZoneFilter is not null ? record?.Zone?.Contains(_ZoneFilter, StringComparison.CurrentCultureIgnoreCase) : null;
|
||||
result ??= true;
|
||||
return result.Value;
|
||||
}
|
||||
|
||||
private void RefreshClick() => _Records.Clear();
|
||||
|
||||
private async Task LoadClickAsync()
|
||||
{
|
||||
if (Logger is null)
|
||||
throw new NullReferenceException(nameof(Logger));
|
||||
if (HttpClient is null)
|
||||
throw new NullReferenceException(nameof(HttpClient));
|
||||
_Records.Clear();
|
||||
string controllerName = IAwaitingDispoController<object>.GetRouteName();
|
||||
try
|
||||
{
|
||||
Metrology.Shared.DataModels.AwaitingDisposition[]? collection = await HttpClient.GetFromJsonAsync<Metrology.Shared.DataModels.AwaitingDisposition[]>($"api/{controllerName}");
|
||||
if (collection is not null)
|
||||
_Records.AddRange(collection);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
string json = await HttpClient.GetStringAsync($"api/{controllerName}");
|
||||
Logger.LogInformation(message: json);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user