99 lines
3.1 KiB
Plaintext
99 lines
3.1 KiB
Plaintext
@inherits LayoutComponentBase
|
|
|
|
@using Microsoft.AspNetCore.Authorization
|
|
@using TIAMSharedUI.Shared.Users
|
|
@using AyCode.Core.Extensions
|
|
@using AyCode.Interfaces.StorageHandlers;
|
|
@using AyCode.Services.Loggers
|
|
@using Newtonsoft.Json;
|
|
@using TIAMSharedUI.Pages
|
|
@using TIAMSharedUI.Shared.Components
|
|
@using TIAMWebApp.Shared.Application.Interfaces
|
|
@using TIAMWebApp.Shared.Application.Models.ClientSide;
|
|
@using AyCode.Blazor.Components;
|
|
@using TIAMWebApp.Shared.Application.Models;
|
|
@using TIAMWebApp.Shared.Application.Utility;
|
|
@using System.IdentityModel.Tokens.Jwt;
|
|
@using System.Runtime.CompilerServices
|
|
@using TIAM.Core.Loggers;
|
|
@using System.Diagnostics
|
|
@using AyCode.Utils.Extensions
|
|
@inject NavigationManager NavManager
|
|
@inject IJSRuntime jsRuntime
|
|
@inject ISecureStorageHandler SecureStorageHandler
|
|
@inject ISessionService sessionService
|
|
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
|
@inject IUserDataService userDataService
|
|
@attribute [Authorize]
|
|
|
|
|
|
<div class="page">
|
|
<TiamErrorBoundaryComponent OnError="HandleError">
|
|
<div class="my-sidebar">
|
|
|
|
<AdminNavMenu />
|
|
</div>
|
|
|
|
<main>
|
|
|
|
<article class="content">
|
|
|
|
@Body
|
|
</article>
|
|
</main>
|
|
</TiamErrorBoundaryComponent>
|
|
</div>
|
|
|
|
@code {
|
|
|
|
private ILogger _logger;
|
|
|
|
public PopupMessageBox PopupMessageBox { get; private set; } = default!;
|
|
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
_logger = new LoggerClient<MainLayout>(LogWriters.ToArray());
|
|
|
|
base.OnInitialized();
|
|
}
|
|
|
|
private void HandleError(Exception exception)//, [CallerMemberName] string? memberName = null)
|
|
{
|
|
exception.GetCategoryAndMemberNameFromStackTraceString(out var memberName, out var categoryName);
|
|
|
|
if (memberName.IsNullOrWhiteSpace()) memberName = "..."; //ne "HandleError" memberName-el logoljunk! - J.
|
|
|
|
try
|
|
{
|
|
_logger.Error($"An error occurred: {exception.Message}", exception, categoryName, memberName);
|
|
}
|
|
catch (Exception loggerException)
|
|
{
|
|
jsRuntime.InvokeVoidAsync("console.error", $"{nameof(MainLayout)}->HandleError; Logger error! {loggerException}");
|
|
|
|
jsRuntime.InvokeVoidAsync("console.error", $"{nameof(MainLayout)}->{memberName}; An error occurred: {exception}");
|
|
//jsRuntime.InvokeVoidAsync("console.warn", $"{nameof(MainLayout)}->{memberName}; Error details: {exception.StackTrace}");
|
|
}
|
|
|
|
// Log the error to server
|
|
//LogErrorToServer(exception);
|
|
|
|
// Show a notification on UI
|
|
ShowErrorNotification("An unexpected error occurred. Please try again later.");
|
|
|
|
//jsRuntime.InvokeVoidAsync("console.error", $"An error occurred: {exception.Message}");
|
|
//jsRuntime.InvokeVoidAsync("console.warn", $"Error details: {exception.StackTrace}");
|
|
}
|
|
|
|
// private void LogErrorToServer(Exception exception)
|
|
// {
|
|
// //_logger.Error($"An error occurred: {exception.Message}");
|
|
// }
|
|
|
|
private void ShowErrorNotification(string message)
|
|
{
|
|
jsRuntime.InvokeVoidAsync("alert", message);
|
|
}
|
|
}
|