feature: Server error provider added, client notification service added

This commit is contained in:
Mikhail Shabanov committed 2021-05-16 22:04:42 +02:00
1 parent 3c67595d94
commit b928e0fec9
14 files changed
+200 -11

No files matched your search

@@ -1,18 +1,27 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Globalization;
using MediatR;
using Microsoft.AspNetCore.Components;
using Radzen;
using Radzen.Blazor;
using WotBlitzStatisticsPro.Blazor.Messages;
using WotBlitzStatisticsPro.Blazor.Model;
using WotBlitzStatisticsPro.Blazor.Services;
namespace WotBlitzStatisticsPro.Blazor.Shared
{
public class MainLayoutBase: LayoutComponentBase
public class MainLayoutBase: LayoutComponentBase, IDisposable
{
[Inject]
private IMediator Mediator { get; set; }
[Inject]
private INotificationsService NotificationsService { get; set; }
[Inject]
NotificationService RadzenNotificationService { get; set; }
public RadzenSidebar Sidebar0;
public RadzenBody Body0;
public bool SidebarExpanded { get; set; } = false;
@@ -52,7 +61,37 @@ namespace WotBlitzStatisticsPro.Blazor.Shared
// }
// }
//}
NotificationsService.MessageArrived += NotificationsService_MessageArrived;
}
private void NotificationsService_MessageArrived()
{
NotificationSeverity severity;
switch (NotificationsService.Type)
{
case NotificationType.Info:
severity = NotificationSeverity.Info;
break;
case NotificationType.Warning:
severity = NotificationSeverity.Warning;
break;
case NotificationType.Error:
severity = NotificationSeverity.Error;
break;
default:
severity = NotificationSeverity.Success;
break;
}
var message = new NotificationMessage
{
Severity = severity,
Summary = NotificationsService.Summary,
Detail = NotificationsService.Message,
Duration = 40000
};
RadzenNotificationService.Notify(message);
}
public void InvertSideBar()
@@ -68,5 +107,10 @@ namespace WotBlitzStatisticsPro.Blazor.Shared
CurrentCultureInfo = CultureInfos[item.Value];
}
}
public void Dispose()
{
NotificationsService.MessageArrived -= NotificationsService_MessageArrived;
}
}
}