mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 17:11:10 +00:00
Adds basic notification system
This commit is contained in:
1 parent
493f34c883
commit
dc47386726
8 files changed
+304
-1
No files matched your search
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FluentValidation;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Services;
|
||||
using Lumina.Presentation.Web.Core.Services.UI;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Polly;
|
||||
@@ -51,6 +52,7 @@ public static class PresentationWebLayerServices
|
||||
.AddPolicyHandler(circuitBreakerPolicy);
|
||||
|
||||
services.AddSingleton<ComboboxService>();
|
||||
services.AddScoped<INotificationService, NotificationService>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace Lumina.Presentation.Web.Common.Enums.Notifications;
|
||||
|
||||
/// <summary>
|
||||
/// Enum for the types of notifications.
|
||||
/// </summary>
|
||||
public enum NotificationType
|
||||
{
|
||||
/// <summary>
|
||||
/// Informational notification.
|
||||
/// </summary>
|
||||
Info,
|
||||
|
||||
/// <summary>
|
||||
/// Success notification.
|
||||
/// </summary>
|
||||
Success,
|
||||
|
||||
/// <summary>
|
||||
/// Warning notification.
|
||||
/// </summary>
|
||||
Warning,
|
||||
|
||||
/// <summary>
|
||||
/// Error notification.
|
||||
/// </summary>
|
||||
Error
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Enums.Notifications;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.Models.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Model for notifications.
|
||||
/// </summary>
|
||||
/// <param name="Id">The id of the notification.</param>
|
||||
/// <param name="Message">The message of the notification.</param>
|
||||
/// <param name="Type">The type of the notification.</param>
|
||||
public record struct NotificationModel(Guid Id, string Message, NotificationType Type);
|
||||
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Enums.Notifications;
|
||||
using Lumina.Presentation.Web.Common.Models.Common;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the service for showing notifications.
|
||||
/// </summary>
|
||||
public interface INotificationService
|
||||
{
|
||||
#region ================================================================== FIELD MEMBERS ================================================================================
|
||||
event Action<NotificationModel>? OnNotification;
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Shows a notification.
|
||||
/// </summary>
|
||||
/// <param name="message">The message of the notification.</param>
|
||||
/// <param name="type">The type of the notification.</param>
|
||||
void Show(string message, NotificationType type);
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Enums.Notifications;
|
||||
using Lumina.Presentation.Web.Common.Models.Common;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Service for showing notifications.
|
||||
/// </summary>
|
||||
public class NotificationService : INotificationService
|
||||
{
|
||||
#region ================================================================== FIELD MEMBERS ================================================================================
|
||||
public event Action<NotificationModel>? OnNotification;
|
||||
#endregion
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Shows a notification.
|
||||
/// </summary>
|
||||
/// <param name="message">The message of the notification.</param>
|
||||
/// <param name="type">The type of the notification.</param>
|
||||
public void Show(string message, NotificationType type)
|
||||
{
|
||||
OnNotification?.Invoke(new NotificationModel { Message = message, Type = type, Id = Guid.NewGuid() });
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in new issue
Block a user