DataInbox Detail
This commit is contained in:
84
DiunaBI.UI.Shared/Pages/DataInboxDetailPage.razor.cs
Normal file
84
DiunaBI.UI.Shared/Pages/DataInboxDetailPage.razor.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user