diff --git a/src/Lumina.Application/Common/Errors/Errors.Authorization.cs b/src/Lumina.Application/Common/Errors/Errors.Authorization.cs index 88303d4c..7fada6c8 100644 --- a/src/Lumina.Application/Common/Errors/Errors.Authorization.cs +++ b/src/Lumina.Application/Common/Errors/Errors.Authorization.cs @@ -15,6 +15,7 @@ public static partial class Errors public static Error AdminAccountAlreadyCreated => Error.Conflict(description: nameof(AdminAccountAlreadyCreated)); public static Error AdminAccountNotFound => Error.NotFound(description: nameof(AdminAccountNotFound)); public static Error AdminRoleNotFound => Error.NotFound(description: nameof(AdminRoleNotFound)); + public static Error AdminRoleCannotBeDeleted => Error.Forbidden(description: nameof(AdminRoleCannotBeDeleted)); public static Error RoleNotFound => Error.NotFound(description: nameof(RoleNotFound)); public static Error PermissionAlreadyExists => Error.Unauthorized(description: nameof(PermissionAlreadyExists)); public static Error RoleAlreadyExists => Error.Conflict(description: nameof(RoleAlreadyExists)); diff --git a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserEntityMapping.cs b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserEntityMapping.cs index 7a08efc6..c6453b9b 100644 --- a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserEntityMapping.cs +++ b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserEntityMapping.cs @@ -1,6 +1,8 @@ #region ========================================================================= USING ===================================================================================== using Lumina.Application.Common.DataAccess.Entities.UsersManagement; using Lumina.Contracts.Responses.UsersManagement.Users; +using System.Collections.Generic; +using System.Linq; #endregion namespace Lumina.Application.Common.Mapping.UsersManagement.Users; @@ -24,4 +26,14 @@ public static class UserEntityMapping repositoryEntity.UpdatedOnUtc ); } + + /// + /// Converts to a collection of . + /// + /// The repository entities to be converted. + /// The converted responses. + public static IEnumerable ToResponses(this IEnumerable repositoryEntities) + { + return repositoryEntities.Select(role => role.ToResponse()); + } } diff --git a/src/Lumina.Application/Core/Admin/Authorization/Roles/Commands/DeleteRole/DeleteRoleCommandHandler.cs b/src/Lumina.Application/Core/Admin/Authorization/Roles/Commands/DeleteRole/DeleteRoleCommandHandler.cs index 940b88bc..7ff3ea27 100644 --- a/src/Lumina.Application/Core/Admin/Authorization/Roles/Commands/DeleteRole/DeleteRoleCommandHandler.cs +++ b/src/Lumina.Application/Core/Admin/Authorization/Roles/Commands/DeleteRole/DeleteRoleCommandHandler.cs @@ -62,7 +62,8 @@ public class DeleteRoleCommandHandler : IRequestHandler deleteRoleResult = await roleRepository.DeleteByIdAsync(request.RoleId, cancellationToken).ConfigureAwait(false); if (deleteRoleResult.IsError) diff --git a/src/Lumina.Application/Core/UsersManagement/Authentication/Queries/GetUsers/GetUsersQuery.cs b/src/Lumina.Application/Core/UsersManagement/Authentication/Queries/GetUsers/GetUsersQuery.cs new file mode 100644 index 00000000..3361cc85 --- /dev/null +++ b/src/Lumina.Application/Core/UsersManagement/Authentication/Queries/GetUsers/GetUsersQuery.cs @@ -0,0 +1,13 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +using Lumina.Contracts.Responses.UsersManagement.Users; +using Mediator; +using System.Collections.Generic; +#endregion + +namespace Lumina.Application.Core.UsersManagement.Authentication.Queries.GetUsers; + +/// +/// Query for retrieving the list of users. +/// +public record GetUsersQuery() : IRequest>>; diff --git a/src/Lumina.Application/Core/UsersManagement/Authentication/Queries/GetUsers/GetUsersQueryHandler.cs b/src/Lumina.Application/Core/UsersManagement/Authentication/Queries/GetUsers/GetUsersQueryHandler.cs new file mode 100644 index 00000000..dcd26431 --- /dev/null +++ b/src/Lumina.Application/Core/UsersManagement/Authentication/Queries/GetUsers/GetUsersQueryHandler.cs @@ -0,0 +1,59 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +using Lumina.Application.Common.DataAccess.Entities.UsersManagement; +using Lumina.Application.Common.DataAccess.Repositories.Users; +using Lumina.Application.Common.DataAccess.UoW; +using Lumina.Application.Common.Errors; +using Lumina.Application.Common.Infrastructure.Authentication; +using Lumina.Application.Common.Infrastructure.Authorization; +using Lumina.Application.Common.Mapping.Authorization; +using Lumina.Application.Common.Mapping.UsersManagement.Users; +using Lumina.Contracts.Responses.UsersManagement.Users; +using Mediator; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +#endregion + +namespace Lumina.Application.Core.UsersManagement.Authentication.Queries.GetUsers; + +/// +/// Handler for the query to retrieve the list of users. +/// +public class GetUsersQueryHandler : IRequestHandler>> +{ + private readonly ICurrentUserService _currentUserService; + private readonly IAuthorizationService _authorizationService; + private readonly IUserRepository _userRepository; + + /// + /// Initializes a new instance of the class. + /// + /// Injected service for authorization related functionality. + /// Injected service to retrieve the current user information. + /// Injected unit of work for interacting with the data access layer repositories. + public GetUsersQueryHandler(IAuthorizationService authorizationService, ICurrentUserService currentUserService, IUnitOfWork unitOfWork) + { + _authorizationService = authorizationService; + _currentUserService = currentUserService; + _userRepository = unitOfWork.GetRepository(); + } + + /// + /// Handles the query to retrieve the list of users. + /// + /// The request to be handled. + /// Cancellation token that can be used to stop the execution. + /// + /// An containing either a collection of , or an error message. + /// + public async ValueTask>> Handle(GetUsersQuery request, CancellationToken cancellationToken) + { + // only admins can see the list of users + bool isAdmin = await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false); + if (!isAdmin) + return Errors.Authorization.NotAuthorized; + ErrorOr> getRolesResult = await _userRepository.GetAllAsync(cancellationToken).ConfigureAwait(false); + return getRolesResult.Match(value => ErrorOrFactory.From(value.ToResponses()), errors => errors); + } +} diff --git a/src/Lumina.Application/Lumina.Application.csproj b/src/Lumina.Application/Lumina.Application.csproj index eb1ee147..e4b4642a 100644 --- a/src/Lumina.Application/Lumina.Application.csproj +++ b/src/Lumina.Application/Lumina.Application.csproj @@ -1,4 +1,4 @@ - + net9.0 disable diff --git a/src/Lumina.Presentation.Api/Common/Routes/UsersManagement/ApiRoutes.Authentication.cs b/src/Lumina.Presentation.Api/Common/Routes/UsersManagement/ApiRoutes.Authentication.cs index e2827ea1..3a922fa5 100644 --- a/src/Lumina.Presentation.Api/Common/Routes/UsersManagement/ApiRoutes.Authentication.cs +++ b/src/Lumina.Presentation.Api/Common/Routes/UsersManagement/ApiRoutes.Authentication.cs @@ -14,5 +14,6 @@ public static partial class ApiRoutes public const string LOGIN_ACCOUNT = "/auth/login"; public const string RECOVER_PASSWORD = "/auth/recover-password"; public const string CHANGE_PASSWORD = "/auth/change-password"; + public const string USERS = "/auth/users"; } } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Admin/Authorization/Roles/DeleteRole/DeleteRoleEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Admin/Authorization/Roles/DeleteRole/DeleteRoleEndpointSummary.cs new file mode 100644 index 00000000..d19571a7 --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Admin/Authorization/Roles/DeleteRole/DeleteRoleEndpointSummary.cs @@ -0,0 +1,122 @@ +#region ========================================================================= USING ===================================================================================== +using FastEndpoints; +using Lumina.Contracts.Requests.Authorization; +using Lumina.Contracts.Responses.Authorization; +using Lumina.Domain.Common.Enums.Authorization; +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +#endregion + +namespace Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Roles.DeleteRole; + +/// +/// Class used for providing a textual description for the API endpoint, for OpenAPI. +/// +[ExcludeFromCodeCoverage] +public class DeleteRoleEndpointSummary : Summary +{ + /// + /// Initializes a new instance of the class. + /// + public DeleteRoleEndpointSummary() + { + Summary = "Deletes an authorization role."; + Description = "Deletes an of authorization role and its associated permissions."; + + ExampleRequest = new DeleteRoleRequest( + RoleId: Guid.NewGuid() + ); + + RequestParam(r => r.RoleId, "The Id of the role. Required."); + + Response(204, "The authorization role was successfully deleted."); + + Response(401, "Authentication required.", "application/problem+json", + example: new[] + { + new + { + type = "https://tools.ietf.org/html/rfc7235#section-3.1", + status = 401, + title = "Unauthorized", + detail = "You are not authorized", + instance = "/api/v1/roles" + }, + new + { + type = "https://tools.ietf.org/html/rfc7235#section-3.1", + status = 401, + title = "Unauthorized", + detail = "Invalid token: The token expired at '01/01/2024 01:00:00'", + instance = "/api/v1/roles" + }, + new + { + type = "https://tools.ietf.org/html/rfc7235#section-3.1", + status = 401, + title = "Unauthorized", + detail = "The token is invalid", + instance = "/api/v1/roles" + } + } + ); + + Response(403, "The request failed because the Admin role cannot be deleted, or current user is not an Admin.", "application/problem+json", + example: new[] + { + new + { + type = "https://tools.ietf.org/html/rfc9110#section-15.5.4", + title = "General.Failure", + status = 403, + detail = "AdminRoleCannotBeDeleted", + instance = "/api/v1/roles", + traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00" + }, + new + { + type = "https://tools.ietf.org/html/rfc9110#section-15.5.4", + title = "General.Failure", + status = 403, + detail = "NotAuthorized", + instance = "/api/v1/roles", + traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00" + } + } + ); + + Response(404, "The request failed because the provided role does not exist.", "application/problem+json", + example: new + { + type = "https://tools.ietf.org/html/rfc9110#section-15.5.5", + title = "General.NotFound", + status = 404, + detail = "RoleNotFound", + instance = "/api/v1/roles", + traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00" + } + ); + + Response(422, "The request did not pass validation checks.", "application/problem+json", + example: new + { + type = "https://tools.ietf.org/html/rfc4918#section-11.2", + title = "General.Validation", + status = 422, + detail = "OneOrMoreValidationErrorsOccurred", + instance = "/api/v1/roles", + errors = new Dictionary + { + { + "General.Validation", new[] + { + "RoleIdCannotBeEmpty" + } + } + }, + traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00" + } + ); + } +} diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Admin/Authorization/Roles/UpdateRole/UpdateRoleEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Admin/Authorization/Roles/UpdateRole/UpdateRoleEndpointSummary.cs index c089a068..9158b6c4 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Admin/Authorization/Roles/UpdateRole/UpdateRoleEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Admin/Authorization/Roles/UpdateRole/UpdateRoleEndpointSummary.cs @@ -115,6 +115,7 @@ public class UpdateRoleEndpointSummary : Summary +/// API endpoint for the /auth/users route. +/// +public class GetUsersEndpoint : BaseEndpoint +{ + private readonly ISender _sender; + + /// + /// Initializes a new instance of the class. + /// + /// Injected service for mediating commands and queries. + public GetUsersEndpoint(ISender sender) + { + _sender = sender; + } + + /// + /// Configures the API endpoint. + /// + public override void Configure() + { + Verbs(Http.GET); + Routes(ApiRoutes.Authentication.USERS); + Version(1); + DontCatchExceptions(); + } + + /// + /// Gets the list of authorization roles. + /// + /// Cancellation token that can be used to stop the execution. + public override async Task ExecuteAsync(EmptyRequest _, CancellationToken cancellationToken) + { + ErrorOr> result = await _sender.Send(new GetUsersQuery(), cancellationToken).ConfigureAwait(false); + return result.Match(success => TypedResults.Ok(success), Problem); + } +} diff --git a/src/Lumina.Presentation.Web/Common/Models/UsersManagement/UserModel.cs b/src/Lumina.Presentation.Web/Common/Models/UsersManagement/UserModel.cs new file mode 100644 index 00000000..681d041d --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/UsersManagement/UserModel.cs @@ -0,0 +1,15 @@ +#region ========================================================================= USING ===================================================================================== +using System; +#endregion + +namespace Lumina.Presentation.Web.Common.Models.UsersManagement; + +/// +/// Represents a model for a user. +/// +/// The Id of the user. +/// The username of the user. +public record UserModel( + Guid Id, + string Username +); diff --git a/src/Lumina.Presentation.Web/Controllers/AdminController.cs b/src/Lumina.Presentation.Web/Controllers/AdminController.cs index 14c4c3b0..9a9adc64 100644 --- a/src/Lumina.Presentation.Web/Controllers/AdminController.cs +++ b/src/Lumina.Presentation.Web/Controllers/AdminController.cs @@ -2,6 +2,7 @@ using Lumina.Presentation.Web.Common.Api; using Lumina.Presentation.Web.Common.Attributes; using Lumina.Presentation.Web.Common.Models.Authorization; +using Lumina.Presentation.Web.Common.Models.UsersManagement; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System; @@ -50,7 +51,8 @@ public class AdminController : Controller [HttpGet("manage-permissions")] public async Task ManagePermissions(CancellationToken cancellationToken) { - ViewData["Roles"] = await _apiHttpClient.GetAsync($"roles/", cancellationToken).ConfigureAwait(false); + ViewData["users"] = await _apiHttpClient.GetAsync($"auth/users", cancellationToken).ConfigureAwait(false); + ViewData["roles"] = await _apiHttpClient.GetAsync($"roles/", cancellationToken).ConfigureAwait(false); return View(); } @@ -94,7 +96,7 @@ public class AdminController : Controller /// /// The model containing the data of the role to be updated. /// Cancellation token that can be used to stop the execution. - [HttpPost("update-role")] + [HttpPut("update-role")] public async Task UpdateRole([FromBody] UpdateRoleRequestModel model, CancellationToken cancellationToken) { RolePermissionsModel response = await _apiHttpClient.PutAsync($"roles/", model, cancellationToken).ConfigureAwait(false); diff --git a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.de-DE.resx b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.de-DE.resx index ba2e4042..2056881e 100644 --- a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.de-DE.resx +++ b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.de-DE.resx @@ -120,6 +120,9 @@ Administrator-Konto wurde bereits erstellt! + + Die Admin-Rolle kann nicht gelöscht werden! + Anwendungsdesign darf nicht leer sein! diff --git a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.en-US.resx b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.en-US.resx index 97680230..294177a5 100644 --- a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.en-US.resx +++ b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.en-US.resx @@ -120,6 +120,9 @@ Admin account already created! + + Admin role cannot be deleted! + Application theme cannot be empty! diff --git a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.es-ES.resx b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.es-ES.resx index 4fcd97b5..e4103588 100644 --- a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.es-ES.resx +++ b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.es-ES.resx @@ -120,6 +120,9 @@ ¡La cuenta de administrador ya está creada! + + ¡El rol de administrador no puede ser eliminado! + ¡El tema de la aplicación no puede estar vacío! diff --git a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.fr-FR.resx b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.fr-FR.resx index 1105a663..8f7eb643 100644 --- a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.fr-FR.resx +++ b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.fr-FR.resx @@ -120,6 +120,9 @@ Le compte administrateur existe déjà! + + Le rôle d'administrateur ne peut pas être supprimé ! + Le thème de l'application ne peut pas être vide! diff --git a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.it-IT.resx b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.it-IT.resx index b84db79c..5e866ae4 100644 --- a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.it-IT.resx +++ b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.it-IT.resx @@ -120,6 +120,9 @@ L'account amministratore è già stato creato! + + Il ruolo di amministratore non può essere eliminato! + Il tema dell'applicazione non può essere vuoto! diff --git a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ja-JP.resx b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ja-JP.resx index dfcdd212..f2b85a76 100644 --- a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ja-JP.resx +++ b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ja-JP.resx @@ -120,6 +120,9 @@ 管理者アカウントは既に作成されています! + + 管理者ロールは削除できません! + アプリケーションのテーマを選択してください! diff --git a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.resx b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.resx index fc587539..099db804 100644 --- a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.resx +++ b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.resx @@ -120,6 +120,9 @@ Admin account already created! + + Admin role cannot be deleted! + Application theme cannot be empty! diff --git a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ro-RO.resx b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ro-RO.resx index 40a8e244..be845649 100644 --- a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ro-RO.resx +++ b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ro-RO.resx @@ -120,6 +120,9 @@ Contul de administrator a fost deja creat! + + Rolul de administrator nu poate fi șters! + Tema aplicației nu poate fi goală! diff --git a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ru-RU.resx b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ru-RU.resx index 0cbd1c0c..64347b3d 100644 --- a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ru-RU.resx +++ b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ru-RU.resx @@ -120,6 +120,9 @@ Учетная запись администратора уже создана! + + Роль администратора не может быть удалена! + Тема приложения не может быть пустой! diff --git a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.zh-CN.resx b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.zh-CN.resx index 9332a998..b55e2162 100644 --- a/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.zh-CN.resx +++ b/src/Lumina.Presentation.Web/Resources/Common/Middlewares/ExceptionHandlingMiddleware.zh-CN.resx @@ -120,6 +120,9 @@ 管理员账号已创建! + + 管理员角色无法删除! + 应用主题不能为空! @@ -438,6 +441,9 @@ 重发行年份必须在1到9999之间! + + 角色已存在! + 角色类别不能为空! diff --git a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.de-DE.resx b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.de-DE.resx index 000d1929..3eb44e11 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.de-DE.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.de-DE.resx @@ -132,6 +132,9 @@ Rolle löschen + + Sind Sie sicher, dass Sie die ausgewählte Rolle löschen möchten? + Die Rolle wurde erstellt! diff --git a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.en-US.resx b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.en-US.resx index deb2f415..6e704f38 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.en-US.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.en-US.resx @@ -132,6 +132,9 @@ Delete role + + Are you sure you want to delete the selected role? + The role has been created! diff --git a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.es-ES.resx b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.es-ES.resx index 7f9ce17f..fbaaee5f 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.es-ES.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.es-ES.resx @@ -132,6 +132,9 @@ Eliminar rol + + ¿Está seguro de que desea eliminar el rol seleccionado? + ¡El rol ha sido creado! diff --git a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.fr-FR.resx b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.fr-FR.resx index 1df32972..54eda429 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.fr-FR.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.fr-FR.resx @@ -132,6 +132,9 @@ Supprimer le rôle + + Êtes-vous sûr de vouloir supprimer le rôle sélectionné ? + Le rôle a été créé ! diff --git a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.it-IT.resx b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.it-IT.resx index 9ce689f0..7aa36d29 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.it-IT.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.it-IT.resx @@ -132,6 +132,9 @@ Elimina ruolo + + Sei sicuro di voler eliminare il ruolo selezionato? + Il ruolo è stato creato! diff --git a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.ja-JP.resx b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.ja-JP.resx index 11e06e6f..efbe9027 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.ja-JP.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.ja-JP.resx @@ -132,6 +132,9 @@ ロールを削除する + + 選択したロールを削除してもよろしいですか? + ロールが作成されました! diff --git a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.resx b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.resx index deb2f415..6e704f38 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.resx @@ -132,6 +132,9 @@ Delete role + + Are you sure you want to delete the selected role? + The role has been created! diff --git a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.ro-RO.resx b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.ro-RO.resx index 147df845..e0688295 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.ro-RO.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.ro-RO.resx @@ -132,6 +132,9 @@ Ștergere rol + + Sunteți sigur că doriți să ștergeți rolul selectat? + Rolul a fost creat! diff --git a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.ru-RU.resx b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.ru-RU.resx index 94eb9c57..30d5a8be 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.ru-RU.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.ru-RU.resx @@ -132,6 +132,9 @@ Удалить роль + + Вы уверены, что хотите удалить выбранную роль? + Роль была создана! diff --git a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.zh-CN.resx b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.zh-CN.resx index 64d5a85a..ef61be7c 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.zh-CN.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Admin/ManageRoles.zh-CN.resx @@ -132,6 +132,9 @@ 删除角色 + + 您确定要删除选定的角色吗? + 角色已创建! diff --git a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.de-DE.resx b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.de-DE.resx index 08ab2b5c..e9ac8596 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.de-DE.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.de-DE.resx @@ -117,13 +117,46 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Abbrechen + + + Abbrechen + + + Bestätigung + + + Fehler + + + Ignorieren + + + Information + Navigation fehlgeschlagen! + + Nein + + + OK + + + Wiederholen + Vollhöhe Umschalten Sichtbarkeit Umschalten + + Warnung + + + Ja + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.en-US.resx b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.en-US.resx index 81fc5d9b..6b99cf65 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.en-US.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.en-US.resx @@ -117,13 +117,46 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Abort + + + Cancel + + + Confirmation + + + Error + + + Ignore + + + Information + Navigation failed! + + No + + + OK + + + Retry + Toggle Full Height Toggle Visibility + + Warning + + + Yes + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.es-ES.resx b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.es-ES.resx index 9cab8f6e..4f09682d 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.es-ES.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.es-ES.resx @@ -117,13 +117,46 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Anular + + + Cancelar + + + Confirmación + + + Error + + + Ignorar + + + Información + ¡Navegación fallida! + + No + + + Aceptar + + + Reintentar + Alternar Altura Completa Alternar Visibilidad + + Advertencia + + + Sí + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.fr-FR.resx b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.fr-FR.resx index ea280d95..70581855 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.fr-FR.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.fr-FR.resx @@ -117,13 +117,46 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Abandonner + + + Annuler + + + Confirmation + + + Erreur + + + Ignorer + + + Information + Navigation échouée ! + + Non + + + OK + + + Réessayer + Basculer Hauteur Complète Basculer Visibilité + + Avertissement + + + Oui + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.it-IT.resx b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.it-IT.resx index f0352b09..3e510bb1 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.it-IT.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.it-IT.resx @@ -117,13 +117,46 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Interrompi + + + Annulla + + + Conferma + + + Errore + + + Ignora + + + Informazione + Navigazione fallita! + + No + + + OK + + + Riprova + Attiva/Disattiva Altezza Piena Attiva/Disattiva Visibilità + + Avviso + + + Sì + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.ja-JP.resx b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.ja-JP.resx index b0acd12c..25aed7bb 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.ja-JP.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.ja-JP.resx @@ -117,13 +117,46 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 中止する + + + キャンセル + + + 確認 + + + エラー + + + 無視する + + + 情報 + ナビゲーションに失敗しました! + + いいえ + + + OK + + + 再試行 + 全高表示切替 表示切替 + + 警告 + + + はい + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.resx b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.resx index 81fc5d9b..6b99cf65 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.resx @@ -117,13 +117,46 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Abort + + + Cancel + + + Confirmation + + + Error + + + Ignore + + + Information + Navigation failed! + + No + + + OK + + + Retry + Toggle Full Height Toggle Visibility + + Warning + + + Yes + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.ro-RO.resx b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.ro-RO.resx index e9909c0d..24855322 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.ro-RO.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.ro-RO.resx @@ -117,13 +117,46 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Anulare + + + Anulare + + + Confirmare + + + Eroare + + + Ignorare + + + Informație + Navigarea a eșuat! + + Nu + + + OK + + + Reîncercare + Comutare Înălțime Completă Comutare Vizibilitate + + Avertizare + + + Da + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.ru-RU.resx b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.ru-RU.resx index acd3b566..4d3fc8d6 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.ru-RU.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.ru-RU.resx @@ -117,13 +117,46 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Прервать + + + Отмена + + + Подтверждение + + + Ошибка + + + Игнорировать + + + Информация + Навигация не удалась! + + Нет + + + OK + + + Повторить + Переключить Полную Высоту Переключить Видимость + + Предупреждение + + + Да + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.zh-CN.resx b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.zh-CN.resx index f2cfaa6a..12bb510a 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.zh-CN.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Shared/_Layout.zh-CN.resx @@ -117,10 +117,46 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 中止 + + + 取消 + + + 确认 + + + 错误 + + + 忽略 + + + 信息 + + + 导航失败! + + + 否 + + + 确定 + + + 重试 + 切换全高 切换可见性 + + 警告 + + + 是 + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Views/Admin/ManageRoles.cshtml b/src/Lumina.Presentation.Web/Views/Admin/ManageRoles.cshtml index 083ba10e..5a4bf223 100644 --- a/src/Lumina.Presentation.Web/Views/Admin/ManageRoles.cshtml +++ b/src/Lumina.Presentation.Web/Views/Admin/ManageRoles.cshtml @@ -110,9 +110,10 @@ }; const isRoleSelected = formData.roleId !== ''; - const url = isRoleSelected ? '@_urlService.GetAbsoluteUrl("UpdateRole", "Admin")' : '@_urlService.GetAbsoluteUrl("CreateRole", "Admin")'; - const data = await callApiPostAsync(url, formData); + const data = isRoleSelected ? + await callApiPutAsync('@_urlService.GetAbsoluteUrl("UpdateRole", "Admin")', formData) : + await callApiPostAsync('@_urlService.GetAbsoluteUrl("CreateRole", "Admin")', formData); if (data) { await fetchRoles(); notificationService.show(isRoleSelected ? '@_localizer["RoleUpdated"]' : '@_localizer["RoleCreated"]', NotificationType.SUCCESS); @@ -121,21 +122,15 @@ btnDeleteRole.addEventListener('click', async function(e) { const roleId = document.getElementById('authorization-roles-selected-id').value; - - // const confirmDelete = await showDialog( - // translationService.Translate(Terms.ConfirmRoleDelete), - // translationService.Translate(Terms.Confirmation), - // 'YES_NO' - // ); - - // if (confirmDelete) { - const url = '@_urlService.GetAbsoluteUrl("DeleteRole", "Admin", new { roleId = default(Guid) })'; - const success = await callApiDeleteAsync(url.replace('/@(default(Guid))', `/${roleId}`)); // roleId needs to be replaced here, because GetAbsoluteUrl is server side, roleId is client side - if (success) { - await fetchRoles(); - notificationService.show('@_localizer["RoleDeleted"]', NotificationType.SUCCESS); - } - // } + // ask the user for confirmation before deleting the role + if (await dialogService.show('@_localizer["DeleteRoleConfirm"]', jsLocalizedDialogs.confirmation, DialogButtons.YES_NO_CANCEL, DialogIcon.QUESTION) === DialogButton.YES) { + const url = '@_urlService.GetAbsoluteUrl("DeleteRole", "Admin", new { roleId = default(Guid) })'; + const success = await callApiDeleteAsync(url.replace('/@(default(Guid))', `/${roleId}`)); // roleId needs to be replaced here, because GetAbsoluteUrl is server side, roleId is client side + if (success) { + await fetchRoles(); + notificationService.show('@_localizer["RoleDeleted"]', NotificationType.SUCCESS); + } + } }); // on role dropdown change diff --git a/src/Lumina.Presentation.Web/Views/Shared/_Layout.cshtml b/src/Lumina.Presentation.Web/Views/Shared/_Layout.cshtml index b2028567..fd2f1255 100644 --- a/src/Lumina.Presentation.Web/Views/Shared/_Layout.cshtml +++ b/src/Lumina.Presentation.Web/Views/Shared/_Layout.cshtml @@ -16,6 +16,7 @@ + @@ -51,8 +52,25 @@ var jsLocalizedMessages = { navigationFailed: '@_localizer["NavigationFailed"]', }; + var jsLocalizedDialogs = { + // button texts + ok: '@_localizer["Ok"]', + cancel: '@_localizer["Cancel"]', + yes: '@_localizer["Yes"]', + no: '@_localizer["No"]', + retry: '@_localizer["Retry"]', + abort: '@_localizer["Abort"]', + ignore: '@_localizer["Ignore"]', + // default titles + confirmation: '@_localizer["Confirmation"]', + warning: '@_localizer["Warning"]', + error: '@_localizer["Error"]', + information: '@_localizer["Information"]' + }; + +
@await RenderSectionAsync("Scripts", required: false) diff --git a/src/Lumina.Presentation.Web/wwwroot/css/dialog.css b/src/Lumina.Presentation.Web/wwwroot/css/dialog.css new file mode 100644 index 00000000..10092deb --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/css/dialog.css @@ -0,0 +1,121 @@ +.dialog-modal-background { + display: none; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: #000000; + opacity: 0.6; + z-index: 1998; +} + +.dialog-container { + display: none; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + z-index: 999; + width: 400px; + max-width: 90%; +} + +.dialog { + background: linear-gradient(135deg, #404040, #232323); + border-radius: 4px; + border-top: 1px solid #505050; + border-left: 1px solid #505050; + border-right: 1px solid #000; + border-bottom: 1px solid #000; + box-shadow: 5px 5px 5px var(--shadow-color); + overflow: hidden; + animation: fadeIn 0.3s ease-out; + position: relative; +} + +.dialog-content { + padding: 20px; +} + +.dialog-header { + padding-bottom: 15px; + border-bottom: 1px solid #000; + position: relative; +} + + .dialog-header h2 { + margin: 0; + color: var(--text-foreground); + font-family: monospace; + font-size: 1.1rem; + } + +.dialog-shine-effect { + background: linear-gradient(to right, transparent, #fff, transparent); + width: 100%; + top: -1px; + height: 1px; + position: absolute; + pointer-events: none; +} + +.dialog-body { + padding: 20px; + color: var(--text-foreground); + font-family: monospace; + display: flex; + gap: 15px; + align-items: flex-start; +} + +.dialog-icon { + width: 24px; + height: 24px; + flex-shrink: 0; +} + + .dialog-icon.info { + background-image: url('path-to-info-icon.svg'); + } + + .dialog-icon.warning { + background-image: url('path-to-warning-icon.svg'); + } + + .dialog-icon.error { + background-image: url('path-to-error-icon.svg'); + } + + .dialog-icon.question { + background-image: url('path-to-question-icon.svg'); + } + +.dialog-message { + flex-grow: 1; + word-wrap: break-word; + overflow-wrap: break-word; + word-break: break-word; + hyphens: auto; + white-space: pre-wrap; +} + +.dialog-buttons { + display: flex; + justify-content: flex-end; + padding-top: 15px; + gap: 10px; + border-top: 1px solid #000; +} + +.dialog-button { + padding: 2px 16px; + font-weight: 500; +} + +@keyframes dialogAppear { + to { + opacity: 1; + transform: translateY(0); + } +} diff --git a/src/Lumina.Presentation.Web/wwwroot/js/dialogs.js b/src/Lumina.Presentation.Web/wwwroot/js/dialogs.js new file mode 100644 index 00000000..2b1d8b21 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/js/dialogs.js @@ -0,0 +1,182 @@ +/** + * Enum-like object for dialog buttons. + * @readonly + * @enum {string} + */ +const DialogButton = { + OK: 'ok', + CANCEL: 'cancel', + YES: 'yes', + NO: 'no', + RETRY: 'retry', + ABORT: 'abort', + IGNORE: 'ignore' +}; + +/** + * Enum-like object for dialog icons. + * @readonly + * @enum {string} + */ +const DialogIcon = { + NONE: 'none', + INFO: 'info', + WARNING: 'warning', + ERROR: 'error', + QUESTION: 'question' +}; + +/** + * Enum-like object for predefined button combinations. + * @readonly + * @enum {Array} + */ +const DialogButtons = { + OK: [DialogButton.OK], + OK_CANCEL: [DialogButton.OK, DialogButton.CANCEL], + YES_NO: [DialogButton.YES, DialogButton.NO], + YES_NO_CANCEL: [DialogButton.YES, DialogButton.NO, DialogButton.CANCEL], + RETRY_CANCEL: [DialogButton.RETRY, DialogButton.CANCEL], + ABORT_RETRY_IGNORE: [DialogButton.ABORT, DialogButton.RETRY, DialogButton.IGNORE] +}; + +/** + * Manages the creation and display of modal dialogs. + */ +class DialogService { + constructor() { + this.dialogQueue = []; + this.isDialogOpen = false; + + // create dialog container inside the article element + const articleElement = document.querySelector('article'); + this.container = document.createElement('div'); + this.container.className = 'dialog-container'; + articleElement.appendChild(this.container); + } + + /** + * Shows a modal dialog and returns a Promise that resolves with the clicked button. + * @param {string} message - The message to display in the dialog. + * @param {string} title - The title of the dialog. + * @param {Array} buttons - Array of buttons to display. + * @param {DialogIcon} icon - The icon to display. + * @returns {Promise} A promise that resolves with the clicked button. + */ + show(message, title = jsLocalizedDialogs.confirmation, buttons = DialogButtons.OK, icon = DialogIcon.NONE) { + const dialogPromise = new Promise((resolve) => { + const dialog = { + message, + title, + buttons, + icon, + resolve + }; + + this.dialogQueue.push(dialog); + if (!this.isDialogOpen) + this.showNextDialog(); + }); + + return dialogPromise; + } + + /** + * Shows the next dialog in the queue. + * @private + */ + showNextDialog() { + if (this.dialogQueue.length === 0) { + this.isDialogOpen = false; + return; + } + + this.isDialogOpen = true; + const dialog = this.dialogQueue[0]; + this.displayDialog(dialog); + } + + /** + * Creates and displays a dialog element in the DOM. + * @private + * @param {Object} dialog - The dialog configuration object. + */ + displayDialog(dialog) { + const modalBackground = document.getElementById('modal-background-article'); + modalBackground.style.display = 'block'; + this.container.style.display = 'block'; + const dialogElement = document.createElement('div'); + dialogElement.className = 'dialog'; + + dialogElement.innerHTML = ` +
+
+

${dialog.title}

+
+
+ ${dialog.icon !== DialogIcon.NONE ? `
` : ''} +
${dialog.message}
+
+
+ ${dialog.buttons.map(button => + `` + ).join('')} +
+
+ `; + + // add click handlers for buttons + const buttons = dialogElement.querySelectorAll('.dialog-button'); + buttons.forEach(button => { + button.addEventListener('click', () => this.handleButtonClick(button.dataset.button)); + }); + + // add keyboard support + const keyHandler = (e) => { + if (e.key === 'Escape' && dialog.buttons.includes(DialogButton.CANCEL)) + this.handleButtonClick(DialogButton.CANCEL); + if (e.key === 'Enter' && dialog.buttons.includes(DialogButton.OK)) + this.handleButtonClick(DialogButton.OK); + }; + document.addEventListener('keydown', keyHandler); + + this.container.appendChild(dialogElement); + } + + /** + * Handles button clicks and resolves the dialog promise. + * @private + * @param {DialogButton} buttonType - The type of button clicked. + */ + handleButtonClick(buttonType) { + const currentDialog = this.dialogQueue.shift(); + const dialogElement = this.container.querySelector('.dialog'); + + if (dialogElement) + dialogElement.remove(); + + if (this.dialogQueue.length === 0) { + const modalBackground = document.getElementById('modal-background-article'); + modalBackground.style.display = 'none'; + this.container.style.display = 'none'; + } + + currentDialog.resolve(buttonType); + this.showNextDialog(); + } + + /** + * Gets the localized text for a button type. + * @private + * @param {DialogButton} buttonType - The button type. + * @returns {string} The localized button text. + */ + getLocalizedButtonText(buttonType) { + return jsLocalizedDialogs[buttonType.toLowerCase()] || buttonType; + } +} + +// create a global instance of the DialogService +const dialogService = new DialogService();