DataInbox list

This commit is contained in:
2025-12-01 12:55:47 +01:00
parent a71b6feefc
commit 3d654d972e
9 changed files with 292 additions and 15 deletions

View File

@@ -0,0 +1,75 @@
@using MudBlazor.Internal
<MudExpansionPanels Class="mb-4">
<MudExpansionPanel Icon="@Icons.Material.Filled.FilterList"
Text="Filters"
Expanded="true">
<MudGrid>
<MudItem xs="12" sm="6" md="4">
<MudTextField @bind-Value="filterRequest.Search"
Label="Search"
Placeholder="Name, source..."
Immediate="true"
DebounceInterval="500"
OnDebounceIntervalElapsed="SearchDataInbox"
Clearable="true"/>
</MudItem>
<MudItem xs="12" sm="6" md="4">
<MudButton Variant="Variant.Outlined"
OnClick="ClearFilters"
StartIcon="Icons.Material.Filled.Clear">
Clear filters
</MudButton>
</MudItem>
</MudGrid>
</MudExpansionPanel>
</MudExpansionPanels>
<MudDivider Class="my-4"></MudDivider>
<MudTable Items="dataInbox.Items"
Dense="true"
Hover="true"
Loading="isLoading"
LoadingProgressColor="Color.Info"
T="DataInboxDto"
Style="cursor: pointer;">
<HeaderContent>
<MudTh>Name</MudTh>
<MudTh>Source</MudTh>
<MudTh>Created At</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="Name">@context.Name</MudTd>
<MudTd DataLabel="Source">@context.Source</MudTd>
<MudTd DataLabel="Created At">@context.CreatedAt.ToString("yyyy-MM-dd HH:mm:ss")</MudTd>
</RowTemplate>
<NoRecordsContent>
<MudText>No data inbox items to display</MudText>
</NoRecordsContent>
<LoadingContent>
Loading...
</LoadingContent>
</MudTable>
@if (dataInbox.TotalCount > 0)
{
<MudGrid Class="mt-4" AlignItems="Center.Center">
<MudItem xs="12" sm="6">
<MudText Typo="Typo.body2">
Results @((dataInbox.Page - 1) * dataInbox.PageSize + 1) - @Math.Min(dataInbox.Page * dataInbox.PageSize, dataInbox.TotalCount)
of @dataInbox.TotalCount
</MudText>
</MudItem>
<MudItem xs="12" sm="6" Class="d-flex justify-end">
<MudPagination Count="dataInbox.TotalPages"
Selected="dataInbox.Page"
SelectedChanged="OnPageChanged"
ShowFirstButton="true"
ShowLastButton="true"
Variant="Variant.Outlined"
/>
</MudItem>
</MudGrid>
}

View File

@@ -0,0 +1,60 @@
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;
public partial class DataInboxListComponent : ComponentBase
{
[Inject] private DataInboxService DataInboxService { get; set; } = default!;
[Inject] private ISnackbar Snackbar { get; set; } = default!;
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
private PagedResult<DataInboxDto> dataInbox = new();
private DataInboxFilterRequest filterRequest = new();
private bool isLoading = false;
protected override async Task OnInitializedAsync()
{
await LoadDataInbox();
}
private async Task LoadDataInbox()
{
isLoading = true;
try
{
dataInbox = await DataInboxService.GetDataInboxAsync(filterRequest);
}
catch (Exception ex)
{
Console.WriteLine($"Loading data inbox failed: {ex.Message}");
}
finally
{
isLoading = false;
}
}
private async Task SearchDataInbox()
{
filterRequest.Page = 1;
await LoadDataInbox();
}
private async Task OnPageChanged(int page)
{
filterRequest.Page = page;
await LoadDataInbox();
}
private async Task ClearFilters()
{
filterRequest = new DataInboxFilterRequest();
await LoadDataInbox();
}
}

View File

@@ -1,10 +0,0 @@
@using Microsoft.AspNetCore.Components.Routing
@using MudBlazor
<MudNavMenu>
<MudNavLink href="dashboard" Icon="@Icons.Material.Filled.Dashboard" Match="NavLinkMatch.All">
Dashboard
</MudNavLink>
<MudNavLink Href="layers" Icon="@Icons.Material.Filled.List" Match="NavLinkMatch.All">
Layers
</MudNavLink>
</MudNavMenu>