diff --git a/DiunaBI.UI.Shared/Components/DataInboxListComponent.razor b/DiunaBI.UI.Shared/Components/DataInboxListComponent.razor index 48df964..943ab3a 100644 --- a/DiunaBI.UI.Shared/Components/DataInboxListComponent.razor +++ b/DiunaBI.UI.Shared/Components/DataInboxListComponent.razor @@ -33,6 +33,7 @@ Hover="true" Loading="isLoading" LoadingProgressColor="Color.Info" + OnRowClick="@((TableRowClickEventArgs args) => OnRowClick(args.Item))" T="DataInboxDto" Style="cursor: pointer;"> diff --git a/DiunaBI.UI.Shared/Components/DataInboxListComponent.razor.cs b/DiunaBI.UI.Shared/Components/DataInboxListComponent.razor.cs index 6984c72..6209ba5 100644 --- a/DiunaBI.UI.Shared/Components/DataInboxListComponent.razor.cs +++ b/DiunaBI.UI.Shared/Components/DataInboxListComponent.razor.cs @@ -57,4 +57,9 @@ public partial class DataInboxListComponent : ComponentBase filterRequest = new DataInboxFilterRequest(); await LoadDataInbox(); } + + private void OnRowClick(DataInboxDto dataInboxItem) + { + NavigationManager.NavigateTo($"/datainbox/{dataInboxItem.Id}"); + } } diff --git a/DiunaBI.UI.Shared/Pages/DataInboxDetailPage.razor b/DiunaBI.UI.Shared/Pages/DataInboxDetailPage.razor new file mode 100644 index 0000000..97b726c --- /dev/null +++ b/DiunaBI.UI.Shared/Pages/DataInboxDetailPage.razor @@ -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 + + + + + Data Inbox Details + + + Back to List + + + + @if (isLoading) + { + + } + else if (dataInbox == null) + { + Data Inbox item not found + } + else + { + + + + + + + + + + + + + + + Decoded Data + + @if (string.IsNullOrEmpty(decodedData)) + { + No data available + } + else if (hasDecodingError) + { + Error decoding Base64 data + + @dataInbox.Data + + } + else + { + + @decodedData + + } + } + + diff --git a/DiunaBI.UI.Shared/Pages/DataInboxDetailPage.razor.cs b/DiunaBI.UI.Shared/Pages/DataInboxDetailPage.razor.cs new file mode 100644 index 0000000..3e30298 --- /dev/null +++ b/DiunaBI.UI.Shared/Pages/DataInboxDetailPage.razor.cs @@ -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"); + } +}