Files
DiunaBI/DiunaBI.UI.Shared/Components/LayerListComponent.razor.cs

65 lines
1.6 KiB
C#
Raw Normal View History

2025-11-06 10:20:00 +01:00
using DiunaBI.UI.Shared.Services;
using Microsoft.AspNetCore.Components;
using DiunaBI.Application.DTOModels;
using DiunaBI.Application.DTOModels.Common;
using MudBlazor;
namespace DiunaBI.UI.Shared.Components;
2025-11-20 21:03:19 +01:00
public partial class LayerListComponent : ComponentBase
2025-11-06 10:20:00 +01:00
{
[Inject] private LayerService LayerService { get; set; } = default!;
[Inject] private ISnackbar Snackbar { get; set; } = default!;
2025-11-20 21:03:19 +01:00
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
2025-11-06 10:20:00 +01:00
private PagedResult<LayerDto> layers = new();
private LayerFilterRequest filterRequest = new();
private bool isLoading = false;
protected override async Task OnInitializedAsync()
{
2025-11-19 18:51:09 +01:00
await LoadLayers();
2025-11-06 10:20:00 +01:00
}
2025-11-19 18:51:09 +01:00
private async Task LoadLayers()
2025-11-06 10:20:00 +01:00
{
isLoading = true;
try
{
layers = await LayerService.GetLayersAsync(filterRequest);
}
catch (Exception ex)
{
2025-11-19 18:51:09 +01:00
Console.WriteLine($"Loading layers failed: {ex.Message}");
2025-11-06 10:20:00 +01:00
}
finally
{
isLoading = false;
}
}
2025-11-19 18:51:09 +01:00
private async Task SearchLayers()
2025-11-06 10:20:00 +01:00
{
filterRequest.Page = 1;
2025-11-19 18:51:09 +01:00
await LoadLayers();
2025-11-06 10:20:00 +01:00
}
private async Task OnPageChanged(int page)
{
filterRequest.Page = page;
2025-11-19 18:51:09 +01:00
await LoadLayers();
2025-11-06 10:20:00 +01:00
}
private async Task ClearFilters()
{
filterRequest = new LayerFilterRequest();
2025-11-20 21:03:19 +01:00
await LoadLayers();
}
private void OnRowClick(LayerDto layer)
{
NavigationManager.NavigateTo($"/layers/{layer.Id}");
2025-11-06 10:20:00 +01:00
}
}