85 lines
2.0 KiB
C#
85 lines
2.0 KiB
C#
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");
|
|
}
|
|
}
|