DataInbox Detail

This commit is contained in:
2025-12-01 13:00:01 +01:00
parent 3d654d972e
commit 4d7df85df1
4 changed files with 165 additions and 0 deletions

View File

@@ -33,6 +33,7 @@
Hover="true" Hover="true"
Loading="isLoading" Loading="isLoading"
LoadingProgressColor="Color.Info" LoadingProgressColor="Color.Info"
OnRowClick="@((TableRowClickEventArgs<DataInboxDto> args) => OnRowClick(args.Item))"
T="DataInboxDto" T="DataInboxDto"
Style="cursor: pointer;"> Style="cursor: pointer;">
<HeaderContent> <HeaderContent>

View File

@@ -57,4 +57,9 @@ public partial class DataInboxListComponent : ComponentBase
filterRequest = new DataInboxFilterRequest(); filterRequest = new DataInboxFilterRequest();
await LoadDataInbox(); await LoadDataInbox();
} }
private void OnRowClick(DataInboxDto dataInboxItem)
{
NavigationManager.NavigateTo($"/datainbox/{dataInboxItem.Id}");
}
} }

View File

@@ -0,0 +1,75 @@
@page "/datainbox/{id:guid}"
@using DiunaBI.UI.Shared.Services
@using DiunaBI.Application.DTOModels
@using MudBlazor
@inject DataInboxService DataInboxService
@inject NavigationManager NavigationManager
<MudCard>
<MudCardHeader>
<CardHeaderContent>
<MudText Typo="Typo.h5">Data Inbox Details</MudText>
</CardHeaderContent>
<CardHeaderActions>
<MudButton Variant="Variant.Text" OnClick="GoBack" StartIcon="@Icons.Material.Filled.ArrowBack">Back to List</MudButton>
</CardHeaderActions>
</MudCardHeader>
<MudCardContent>
@if (isLoading)
{
<MudProgressLinear Color="Color.Primary" Indeterminate="true" />
}
else if (dataInbox == null)
{
<MudAlert Severity="Severity.Error">Data Inbox item not found</MudAlert>
}
else
{
<MudGrid>
<MudItem xs="12" md="4">
<MudTextField @bind-Value="dataInbox.Name"
Label="Name"
Variant="Variant.Outlined"
ReadOnly="true"
FullWidth="true"/>
</MudItem>
<MudItem xs="12" md="4">
<MudTextField @bind-Value="dataInbox.Source"
Label="Source"
Variant="Variant.Outlined"
ReadOnly="true"
FullWidth="true"/>
</MudItem>
<MudItem xs="12" md="4">
<MudTextField Value="@dataInbox.CreatedAt.ToString("g")"
Label="Created At"
Variant="Variant.Outlined"
ReadOnly="true"
FullWidth="true"/>
</MudItem>
</MudGrid>
<MudDivider Class="my-4"/>
<MudText Typo="Typo.h6" Class="mb-2">Decoded Data</MudText>
@if (string.IsNullOrEmpty(decodedData))
{
<MudAlert Severity="Severity.Info">No data available</MudAlert>
}
else if (hasDecodingError)
{
<MudAlert Severity="Severity.Error">Error decoding Base64 data</MudAlert>
<MudPaper Class="pa-4 mt-2" Elevation="0">
<MudText Typo="Typo.body2" Style="font-family: monospace; white-space: pre-wrap; word-break: break-all;">@dataInbox.Data</MudText>
</MudPaper>
}
else
{
<MudPaper Class="pa-4" Elevation="0" Style="background-color: #f5f5f5; max-height: 600px; overflow-y: auto;">
<MudText Typo="Typo.body2" Style="font-family: monospace; white-space: pre-wrap; word-break: break-word;">@decodedData</MudText>
</MudPaper>
}
}
</MudCardContent>
</MudCard>

View File

@@ -0,0 +1,84 @@
using DiunaBI.Application.DTOModels;
using Microsoft.AspNetCore.Components;
using MudBlazor;
using System.Text;
namespace DiunaBI.UI.Shared.Pages;
public partial class DataInboxDetailPage : ComponentBase
{
[Parameter]
public Guid Id { get; set; }
[Inject]
private ISnackbar Snackbar { get; set; } = null!;
private DataInboxDto? dataInbox;
private string? decodedData;
private bool hasDecodingError = false;
private bool isLoading = false;
protected override async Task OnInitializedAsync()
{
await LoadDataInbox();
}
protected override async Task OnParametersSetAsync()
{
await LoadDataInbox();
}
private async Task LoadDataInbox()
{
isLoading = true;
StateHasChanged();
try
{
dataInbox = await DataInboxService.GetDataInboxByIdAsync(Id);
if (dataInbox != null)
{
DecodeData();
}
}
catch (Exception ex)
{
Console.Error.WriteLine($"Error loading data inbox: {ex.Message}");
Snackbar.Add("Error loading data inbox item", Severity.Error);
}
finally
{
isLoading = false;
StateHasChanged();
}
}
private void DecodeData()
{
if (dataInbox == null || string.IsNullOrEmpty(dataInbox.Data))
{
decodedData = null;
hasDecodingError = false;
return;
}
try
{
var base64Bytes = Convert.FromBase64String(dataInbox.Data);
decodedData = Encoding.UTF8.GetString(base64Bytes);
hasDecodingError = false;
}
catch (Exception ex)
{
Console.Error.WriteLine($"Error decoding Base64 data: {ex.Message}");
decodedData = null;
hasDecodingError = true;
}
}
private void GoBack()
{
NavigationManager.NavigateTo("/datainbox");
}
}