From 193861c9c5a9c6299d09c93e74f051d7e6d05821 Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Thu, 26 Sep 2024 19:58:08 +0300 Subject: [PATCH 1/4] Adds initial ASP.NET Core MVC replacement for Blazor WASM --- .../FileManagement/ThumbnailMappingConfig.cs | 27 + .../Queries/GetThumbnail/GetThumbnailQuery.cs | 14 + .../GetThumbnail/GetThumbnailQueryHandler.cs | 47 + .../FileManagement/ThumbnailResponse.cs | 14 + .../BookLibraryAggregate/ValueObjects/Isbn.cs | 8 +- .../Common/Utilities/MimeTypes.cs | 46 + .../FileManagement/ThumbnailsController.cs | 52 + src/Lumina.Presentation.Web/App.razor | 12 - .../Common/Api/ApiHttpClient.cs | 9 +- .../PresentationWebLayerConfiguration.cs | 25 +- .../PresentationWebLayerServices.cs | 2 + .../Components/EnlightenmentButton.razor | 18 - .../Components/EnlightenmentButton.razor.css | 161 --- .../Components/EnlightenmentCheckbox.razor | 27 - .../EnlightenmentCheckbox.razor.css | 33 - .../Components/EnlightenmentCombobox.razor | 91 -- .../EnlightenmentCombobox.razor.css | 154 --- .../Components/EnlightenmentInput.razor | 77 -- .../Components/EnlightenmentInput.razor.css | 56 - .../Components/FileSystemBrowser.razor | 921 ------------- .../Components/FileSystemBrowser.razor.css | 1146 ----------------- .../Components/FileSystemTreeViewNode.razor | 67 - .../FileSystemTreeViewNode.razor.css | 89 -- .../Components/Notifications.razor | 95 -- .../Components/Notifications.razor.css | 107 -- .../Controllers/HomeController.cs | 31 + .../Layout/MainLayout.razor | 13 - .../Layout/MainLayout.razor.css | 0 .../Layout/NavMenu.razor | 118 -- .../Layout/NavMenu.razor.css | 343 ----- .../Lumina.Presentation.Web.csproj | 30 +- .../Models/ErrorViewModel.cs | 8 + src/Lumina.Presentation.Web/Pages/Home.razor | 7 - .../Pages/Library/Management/Index.razor | 90 -- .../Pages/Library/Management/Item.razor | 195 --- .../BookLibrary/Books/Index.razor | 7 - .../BookLibrary/Books/Item.razor | 146 --- src/Lumina.Presentation.Web/Program.cs | 89 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/launchSettings.json | 42 +- .../Views/Home/Index.cshtml | 8 + .../Views/Home/Privacy.cshtml | 6 + .../Views/Shared/Error.cshtml | 25 + .../Views/Shared/_Layout.cshtml | 49 + .../Views/Shared/_Layout.cshtml.css | 48 + .../Shared/_ValidationScriptsPartial.cshtml | 2 + .../Views/_ViewImports.cshtml | 3 + .../Views/_ViewStart.cshtml | 3 + src/Lumina.Presentation.Web/_Imports.razor | 10 - src/Lumina.Presentation.Web/appsettings.json | 14 + .../wwwroot/appsettings.json | 7 - .../wwwroot/favicon.ico | Bin 0 -> 5430 bytes .../wwwroot/favicon.png | Bin 1148 -> 0 bytes .../wwwroot/icon-192.png | Bin 2626 -> 0 bytes .../wwwroot/index.html | 34 - src/Lumina.sln | 14 +- 56 files changed, 505 insertions(+), 4139 deletions(-) create mode 100644 src/Lumina.Application/Common/Mapping/FileManagement/ThumbnailMappingConfig.cs create mode 100644 src/Lumina.Application/Core/FileManagement/Thumbnails/Queries/GetThumbnail/GetThumbnailQuery.cs create mode 100644 src/Lumina.Application/Core/FileManagement/Thumbnails/Queries/GetThumbnail/GetThumbnailQueryHandler.cs create mode 100644 src/Lumina.Contracts/Responses/FileManagement/ThumbnailResponse.cs create mode 100644 src/Lumina.Presentation.Api/Common/Utilities/MimeTypes.cs create mode 100644 src/Lumina.Presentation.Api/Core/Controllers/FileManagement/ThumbnailsController.cs delete mode 100644 src/Lumina.Presentation.Web/App.razor delete mode 100644 src/Lumina.Presentation.Web/Components/EnlightenmentButton.razor delete mode 100644 src/Lumina.Presentation.Web/Components/EnlightenmentButton.razor.css delete mode 100644 src/Lumina.Presentation.Web/Components/EnlightenmentCheckbox.razor delete mode 100644 src/Lumina.Presentation.Web/Components/EnlightenmentCheckbox.razor.css delete mode 100644 src/Lumina.Presentation.Web/Components/EnlightenmentCombobox.razor delete mode 100644 src/Lumina.Presentation.Web/Components/EnlightenmentCombobox.razor.css delete mode 100644 src/Lumina.Presentation.Web/Components/EnlightenmentInput.razor delete mode 100644 src/Lumina.Presentation.Web/Components/EnlightenmentInput.razor.css delete mode 100644 src/Lumina.Presentation.Web/Components/FileSystemBrowser.razor delete mode 100644 src/Lumina.Presentation.Web/Components/FileSystemBrowser.razor.css delete mode 100644 src/Lumina.Presentation.Web/Components/FileSystemTreeViewNode.razor delete mode 100644 src/Lumina.Presentation.Web/Components/FileSystemTreeViewNode.razor.css delete mode 100644 src/Lumina.Presentation.Web/Components/Notifications.razor delete mode 100644 src/Lumina.Presentation.Web/Components/Notifications.razor.css create mode 100644 src/Lumina.Presentation.Web/Controllers/HomeController.cs delete mode 100644 src/Lumina.Presentation.Web/Layout/MainLayout.razor delete mode 100644 src/Lumina.Presentation.Web/Layout/MainLayout.razor.css delete mode 100644 src/Lumina.Presentation.Web/Layout/NavMenu.razor delete mode 100644 src/Lumina.Presentation.Web/Layout/NavMenu.razor.css create mode 100644 src/Lumina.Presentation.Web/Models/ErrorViewModel.cs delete mode 100644 src/Lumina.Presentation.Web/Pages/Home.razor delete mode 100644 src/Lumina.Presentation.Web/Pages/Library/Management/Index.razor delete mode 100644 src/Lumina.Presentation.Web/Pages/Library/Management/Item.razor delete mode 100644 src/Lumina.Presentation.Web/Pages/Library/WrittenContentLibrary/BookLibrary/Books/Index.razor delete mode 100644 src/Lumina.Presentation.Web/Pages/Library/WrittenContentLibrary/BookLibrary/Books/Item.razor create mode 100644 src/Lumina.Presentation.Web/Views/Home/Index.cshtml create mode 100644 src/Lumina.Presentation.Web/Views/Home/Privacy.cshtml create mode 100644 src/Lumina.Presentation.Web/Views/Shared/Error.cshtml create mode 100644 src/Lumina.Presentation.Web/Views/Shared/_Layout.cshtml create mode 100644 src/Lumina.Presentation.Web/Views/Shared/_Layout.cshtml.css create mode 100644 src/Lumina.Presentation.Web/Views/Shared/_ValidationScriptsPartial.cshtml create mode 100644 src/Lumina.Presentation.Web/Views/_ViewImports.cshtml create mode 100644 src/Lumina.Presentation.Web/Views/_ViewStart.cshtml delete mode 100644 src/Lumina.Presentation.Web/_Imports.razor create mode 100644 src/Lumina.Presentation.Web/appsettings.json delete mode 100644 src/Lumina.Presentation.Web/wwwroot/appsettings.json create mode 100644 src/Lumina.Presentation.Web/wwwroot/favicon.ico delete mode 100644 src/Lumina.Presentation.Web/wwwroot/favicon.png delete mode 100644 src/Lumina.Presentation.Web/wwwroot/icon-192.png delete mode 100644 src/Lumina.Presentation.Web/wwwroot/index.html diff --git a/src/Lumina.Application/Common/Mapping/FileManagement/ThumbnailMappingConfig.cs b/src/Lumina.Application/Common/Mapping/FileManagement/ThumbnailMappingConfig.cs new file mode 100644 index 00000000..abc48722 --- /dev/null +++ b/src/Lumina.Application/Common/Mapping/FileManagement/ThumbnailMappingConfig.cs @@ -0,0 +1,27 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Contracts.Responses.FileManagement; +using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects; +using Mapster; +#endregion + +namespace Lumina.Application.Common.Mapping.FileManagement; + +/// +/// Mapping configuration for file system thumbnails between the domain object and the presentation object. +/// +public class ThumbnailMappingConfig : IRegister +{ + #region ===================================================================== METHODS =================================================================================== + /// + /// Registers the mapping configuration. + /// + /// The type adapter configuration. + public void Register(TypeAdapterConfig config) + { + config.NewConfig() + .Map(dest => dest.Type, src => src.Type) + .Map(dest => dest.Bytes, src => src.Bytes) + .MapToConstructor(true); + } + #endregion +} diff --git a/src/Lumina.Application/Core/FileManagement/Thumbnails/Queries/GetThumbnail/GetThumbnailQuery.cs b/src/Lumina.Application/Core/FileManagement/Thumbnails/Queries/GetThumbnail/GetThumbnailQuery.cs new file mode 100644 index 00000000..16c725fc --- /dev/null +++ b/src/Lumina.Application/Core/FileManagement/Thumbnails/Queries/GetThumbnail/GetThumbnailQuery.cs @@ -0,0 +1,14 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +using Lumina.Contracts.Responses.FileManagement; +using Mediator; +#endregion + +namespace Lumina.Application.Core.FileManagement.Thumbnails.Queries.GetThumbnail; + +/// +/// Query for retrieving the thumbnail of a file at a path. +/// +/// The file path of the image to generate the thumbnail from. +/// The desired quality of the thumbnail image (e.g., resolution or compression level). +public record GetThumbnailQuery(string Path, int Quality) : IRequest>; diff --git a/src/Lumina.Application/Core/FileManagement/Thumbnails/Queries/GetThumbnail/GetThumbnailQueryHandler.cs b/src/Lumina.Application/Core/FileManagement/Thumbnails/Queries/GetThumbnail/GetThumbnailQueryHandler.cs new file mode 100644 index 00000000..c43e0f79 --- /dev/null +++ b/src/Lumina.Application/Core/FileManagement/Thumbnails/Queries/GetThumbnail/GetThumbnailQueryHandler.cs @@ -0,0 +1,47 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +using Lumina.Contracts.Responses.FileManagement; +using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services; +using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects; +using Mapster; +using Mediator; +using System.Threading; +using System.Threading.Tasks; +#endregion + +namespace Lumina.Application.Core.FileManagement.Thumbnails.Queries.GetThumbnail; + +/// +/// Handler for the query to get the file thumbnail. +/// +public class GetThumbnailQueryHandler : IRequestHandler> +{ + #region ================================================================== FIELD MEMBERS ================================================================================ + private readonly IThumbnailService _thumbnailsService; + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// Injected service for handling thumbnails. + public GetThumbnailQueryHandler(IThumbnailService thumbnailsService) + { + _thumbnailsService = thumbnailsService; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Gets the thumbnail for a file located at the specified path, with the specified quality. + /// + /// The query to be handled. + /// Cancellation token that can be used to stop the execution. + /// An containing either a thumbnail, or an error. + public async ValueTask> Handle(GetThumbnailQuery request, CancellationToken cancellationToken) + { + ErrorOr result = await _thumbnailsService.GetThumbnailAsync(request.Path, request.Quality, cancellationToken); + return await ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt()), errors => errors)); + } + #endregion +} diff --git a/src/Lumina.Contracts/Responses/FileManagement/ThumbnailResponse.cs b/src/Lumina.Contracts/Responses/FileManagement/ThumbnailResponse.cs new file mode 100644 index 00000000..1ab5d184 --- /dev/null +++ b/src/Lumina.Contracts/Responses/FileManagement/ThumbnailResponse.cs @@ -0,0 +1,14 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Contracts.Enums.PhotoLibrary; +using System.Diagnostics; +#endregion + +namespace Lumina.Contracts.Responses.FileManagement; + +/// +/// Data transfer object for thumbnails. +/// +/// The type of the thumbnail image. +/// The bytes representing the thumbail. +[DebuggerDisplay("{Type}")] +public record ThumbnailResponse(ImageType Type, byte[] Bytes); diff --git a/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/Isbn.cs b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/Isbn.cs index a2203d4b..d0b2c07c 100644 --- a/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/Isbn.cs +++ b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/ValueObjects/Isbn.cs @@ -17,8 +17,8 @@ namespace Lumina.Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggrega public sealed class Isbn : ValueObject { #region ================================================================== FIELD MEMBERS ================================================================================ - private static readonly Regex _isbn10Regex = new(@"^(?:ISBN(?:-10)?:? )?(?=[0-9X]{10}$|(?=(?:[0-9]+[-\ ]){3})[-\ 0-9X]{13}$)[0-9]{1,5}[-\ ]?[0-9]+[-\ ]?[0-9]+[-\ ]?[0-9X]$", RegexOptions.Compiled); - private static readonly Regex _isbn13Regex = new(@"^(?:ISBN(?:-13)?:? )?(?=[0-9]{13}$|(?=(?:[0-9]+[-\ ]){4})[-\ 0-9]{17}$)97[89][-\ ]?[0-9]{1,5}[-\ ]?[0-9]+[-\ ]?[0-9]+[-\ ]?[0-9]$", RegexOptions.Compiled); + private static readonly Regex s_isbn10Regex = new(@"^(?:ISBN(?:-10)?:? )?(?=[0-9X]{10}$|(?=(?:[0-9]+[-\ ]){3})[-\ 0-9X]{13}$)[0-9]{1,5}[-\ ]?[0-9]+[-\ ]?[0-9]+[-\ ]?[0-9X]$", RegexOptions.Compiled); + private static readonly Regex s_isbn13Regex = new(@"^(?:ISBN(?:-13)?:? )?(?=[0-9]{13}$|(?=(?:[0-9]+[-\ ]){4})[-\ 0-9]{17}$)97[89][-\ ]?[0-9]{1,5}[-\ ]?[0-9]+[-\ ]?[0-9]+[-\ ]?[0-9]$", RegexOptions.Compiled); #endregion #region ==================================================================== PROPERTIES ================================================================================= @@ -83,7 +83,7 @@ public sealed class Isbn : ValueObject /// if the ISBN-10 is valid, otherwise. public static bool IsValidIsbn10(string isbn) { - if (!_isbn10Regex.IsMatch(isbn)) + if (!s_isbn10Regex.IsMatch(isbn)) return false; // remove any hyphens or spaces isbn = isbn.Replace("-", "").Replace(" ", "").ToUpper(); @@ -105,7 +105,7 @@ public sealed class Isbn : ValueObject /// if the ISBN-13 is valid, otherwise. public static bool IsValidIsbn13(string isbn) { - if (!_isbn13Regex.IsMatch(isbn)) + if (!s_isbn13Regex.IsMatch(isbn)) return false; // remove any hyphens or spaces isbn = isbn.Replace("-", "").Replace(" ", ""); diff --git a/src/Lumina.Presentation.Api/Common/Utilities/MimeTypes.cs b/src/Lumina.Presentation.Api/Common/Utilities/MimeTypes.cs new file mode 100644 index 00000000..3f0f81a4 --- /dev/null +++ b/src/Lumina.Presentation.Api/Common/Utilities/MimeTypes.cs @@ -0,0 +1,46 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Contracts.Enums.PhotoLibrary; +using System.Collections.Frozen; +using System.Collections.Generic; +#endregion + +namespace Lumina.Presentation.Api.Common.Utilities; + +/// +/// Utility class for converting from domain image types to known image mime types. +/// +public static class MimeTypes +{ + #region ================================================================== FIELD MEMBERS ================================================================================ + private static readonly FrozenDictionary s_imageTypeToMimeType = new Dictionary + { + { ImageType.BMP, "image/bmp" }, + { ImageType.GIF, "image/gif" }, + { ImageType.PNG, "image/png" }, + { ImageType.TIFF, "image/tiff" }, + { ImageType.JPEG, "image/jpeg" }, + { ImageType.JPEG_CANON, "image/jpeg" }, + { ImageType.JPEG_UNKNOWN, "image/jpeg" }, + { ImageType.PICT, "image/x-pict" }, + { ImageType.ICO, "image/x-icon" }, + { ImageType.PSD, "image/vnd.adobe.photoshop" }, + { ImageType.JPEG2000, "image/jp2" }, + { ImageType.AVIF, "image/avif" }, + { ImageType.WEBP, "image/webp" }, + { ImageType.TGA, "image/x-tga" }, + { ImageType.SVG, "image/svg+xml" } + }.ToFrozenDictionary(); + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Gets the mime type of . + /// + /// The domain image type for which to get the mime type. + /// The mime type for . + public static string GetMimeType(ImageType type) + { + return s_imageTypeToMimeType.TryGetValue(type, out string? mimeType) ? mimeType : "application/octet-stream"; + } + #endregion +} diff --git a/src/Lumina.Presentation.Api/Core/Controllers/FileManagement/ThumbnailsController.cs b/src/Lumina.Presentation.Api/Core/Controllers/FileManagement/ThumbnailsController.cs new file mode 100644 index 00000000..35231a60 --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Controllers/FileManagement/ThumbnailsController.cs @@ -0,0 +1,52 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +using Lumina.Application.Core.FileManagement.Thumbnails.Queries.GetThumbnail; +using Lumina.Contracts.Responses.FileManagement; +using Lumina.Presentation.Api.Common.ModelBinders; +using Lumina.Presentation.Api.Common.Utilities; +using Lumina.Presentation.Api.Core.Controllers.Common; +using Mediator; +using Microsoft.AspNetCore.Mvc; +using System.Threading; +using System.Threading.Tasks; +#endregion + +namespace Lumina.Presentation.Api.Core.Controllers.FileManagement; + +/// +/// Controller for managing file system items thumbnails. +/// +[ApiVersion("1.0")] +[Route("api/v{version:apiVersion}/[controller]")] +public class ThumbnailsController : ApiController +{ + #region ================================================================== FIELD MEMBERS ================================================================================ + private readonly ISender _mediator; + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// Injected service for mediating commands and queries. + public ThumbnailsController(ISender mediator) + { + _mediator = mediator; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Gets the thumbnail of a file identified by of . + /// + /// The path of the file for which to get the thumbnail. + /// The quality to use for the thumbnail. + /// Cancellation token that can be used to stop the execution. + [HttpGet("get-thumbnail")] + public async Task GetThumbnail([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, [FromQuery] int quality, CancellationToken cancellationToken) + { + ErrorOr getResult = await _mediator.Send(new GetThumbnailQuery(path, quality), cancellationToken); + return getResult.Match(result => File(result.Bytes, MimeTypes.GetMimeType(result.Type)), errors => Problem(errors)); + } + #endregion +} diff --git a/src/Lumina.Presentation.Web/App.razor b/src/Lumina.Presentation.Web/App.razor deleted file mode 100644 index 623580d0..00000000 --- a/src/Lumina.Presentation.Web/App.razor +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - Not found - -

Sorry, there's nothing at this address.

-
-
-
diff --git a/src/Lumina.Presentation.Web/Common/Api/ApiHttpClient.cs b/src/Lumina.Presentation.Web/Common/Api/ApiHttpClient.cs index eb7095fa..f3be45b5 100644 --- a/src/Lumina.Presentation.Web/Common/Api/ApiHttpClient.cs +++ b/src/Lumina.Presentation.Web/Common/Api/ApiHttpClient.cs @@ -3,7 +3,6 @@ using Lumina.Presentation.Web.Common.Exceptions; using Lumina.Presentation.Web.Common.Models.Common; using Lumina.Presentation.Web.Common.Models.Configuration; using Lumina.Presentation.Web.Common.Models.FileManagement; -using Microsoft.AspNetCore.Components.WebAssembly.Http; using Microsoft.Extensions.Options; using System; using System.Collections.Generic; @@ -79,13 +78,7 @@ public class ApiHttpClient : IApiHttpClient /// An object, which allows for asynchronous iteration over the deserialized items. public async IAsyncEnumerable GetAsyncEnumerable(string endpoint, string? token = null, [EnumeratorCancellation] CancellationToken cancellationToken = default) { - using HttpRequestMessage request = new(HttpMethod.Get, endpoint); - // HttpClient is implemented differently in Blazor WASM, because there are no sockets in the browser, so its BrowserHttpHandler is implemented on top of Fetch API, - // which can provide response content in one of two forms: BrowserHttpContent, which is based on arrayBuffer method (this means that it will always read the response stream to its completion, - // before making the content available), and StreamContent that is wrapping WasmHttpReadStream, which is based on readable streams (this one allows for reading response as it comes). - // WasmHttpReadStream can only work when WebAssemblyEnableStreamingResponse is enabled on request, and only on browsers that support it - request.SetBrowserResponseStreamingEnabled(true); - + using HttpRequestMessage request = new(HttpMethod.Get, endpoint); if (!string.IsNullOrEmpty(token)) request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token); // send the request and expect only headers initially - this prevents the client from buffering the entire response diff --git a/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerConfiguration.cs b/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerConfiguration.cs index 73e4a8bb..bc8d87ef 100644 --- a/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerConfiguration.cs +++ b/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerConfiguration.cs @@ -1,6 +1,5 @@ -using Lumina.Presentation.Web.Common.Models.Configuration; +using Lumina.Presentation.Web.Common.Models.Configuration; using Lumina.Presentation.Web.Common.Utilities; -using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -12,30 +11,18 @@ namespace Lumina.Presentation.Web.Common.DependencyInjection; internal static class PresentationWebLayerConfiguration { #region ===================================================================== METHODS =================================================================================== - /// - /// Extension method for adding the Lumina.Presentation.Web configuration to the . - /// - /// The to add the configuration to. - /// The updated . - public static WebAssemblyHostBuilder AddConfiguration(this WebAssemblyHostBuilder builder) - { - // add the configuration sources to the configuration builder - builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); - builder.Configuration.AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true); - - builder.Services.BindConfiguration(builder.Configuration); - - return builder; - } - /// /// Extension method for registering the configuration options of the Lumina.Presentation.Web project into the Dependency Injection container. /// /// The to bind the configuration options to. /// The configuration to be bound. /// The updated . - internal static IServiceCollection BindConfiguration(this IServiceCollection serviceCollection, IConfiguration configuration) + internal static IServiceCollection BindConfiguration(this IServiceCollection serviceCollection, IConfigurationManager configuration) { + // add the configuration sources to the configuration builder + configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); + configuration.AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true); + serviceCollection.AddOptions() .Bind(configuration.GetRequiredSection(ServerConfigurationModel.SECTION_NAME)) .ValidateFluently() diff --git a/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerServices.cs b/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerServices.cs index 569cde7c..be130546 100644 --- a/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerServices.cs +++ b/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerServices.cs @@ -28,6 +28,8 @@ public static class PresentationWebLayerServices /// The updated . public static IServiceCollection AddPresentationWebLayerServices(this IServiceCollection services) { + services.AddControllersWithViews(); + // scan the current assembly for validators and register them to the DI container services.AddValidatorsFromAssemblyContaining(ServiceLifetime.Singleton); diff --git a/src/Lumina.Presentation.Web/Components/EnlightenmentButton.razor b/src/Lumina.Presentation.Web/Components/EnlightenmentButton.razor deleted file mode 100644 index cb40b148..00000000 --- a/src/Lumina.Presentation.Web/Components/EnlightenmentButton.razor +++ /dev/null @@ -1,18 +0,0 @@ - - -@code { - [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter] public EventCallback OnClick { get; set; } - [Parameter] public bool IsDisabled { get; set; } - [Parameter] public bool IsConfirmButton { get; set; } = true; - [Parameter] public bool UsesPercentForHeight { get; set; } - [Parameter] public bool UsesPercentForWidth { get; set; } - [Parameter] public int Width { get; set; } = 100; - [Parameter] public int Height { get; set; } = 22; - [Parameter] public string? CssClass { get; set; } -} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Components/EnlightenmentButton.razor.css b/src/Lumina.Presentation.Web/Components/EnlightenmentButton.razor.css deleted file mode 100644 index 15896c63..00000000 --- a/src/Lumina.Presentation.Web/Components/EnlightenmentButton.razor.css +++ /dev/null @@ -1,161 +0,0 @@ -.abort-button { - text-decoration: none; - border-radius: 4px; - border: solid 1px; - border-color: #006666 #004030 #003020 #006666; - background: linear-gradient(to bottom, #90AEA6 0%, #336659 50%, #004030 50%, #004030 100%); - color: #999999; - position: relative; - overflow: hidden; - transition: all 0.3s; - cursor: pointer; - outline: none; - box-shadow: 0 4px 4px rgba(0, 0, 0, 0.5); - z-index: 1; -} - - .abort-button:before { - content: ""; - position: absolute; - bottom: 0; - left: 0; - right: 0; - height: 50%; - background: radial-gradient(circle at center, #00FF00, transparent); - background-size: 120% 100%; - transform: translateY(100%); - background-position: center; - transition: transform 0.3s, opacity 0.8s; - pointer-events: none; - opacity: 0; - filter: blur(8px); - } - - .abort-button:hover { - color: #fff; - } - - .abort-button:hover:before { - transform: translateY(50%); - opacity: 1; - } - - .abort-button:active { - background: #CC009F58; - font-style: italic; - } - - .abort-button:disabled { - background: #333333; - border-color: #333333; - color: #777; - cursor: not-allowed; - } - - .abort-button:disabled:hover:before { - transform: translateY(100%); - opacity: 0; - } - - .abort-button:disabled:active { - font-style: normal; - } - - .abort-button[disabled] { - background: #333333; - border-color: #333333; - color: #777; - cursor: not-allowed; - pointer-events: none; - text-decoration: none; - } - - .abort-button[disabled]:hover:before { - transform: translateY(100%); - opacity: 0; - } - - .abort-button[disabled]:active { - font-style: normal; - } - -.confirm-button { - text-decoration: none; - border-radius: 4px; - border: solid 1px; - border-color: #363636 #000 #000 #363636; - background: linear-gradient(to bottom, #AAAAAA 0%, #363636 50%, #000 50%, #000 100%); - color: #AAAAAA; - position: relative; - overflow: hidden; - transition: all 0.3s; - cursor: pointer; - outline: none; - box-shadow: 0 4px 4px rgba(0, 0, 0, 0.5); - z-index: 1; -} - - .confirm-button:before { - content: ""; - position: absolute; - bottom: 0; - left: 0; - right: 0; - height: 50%; - background: radial-gradient(circle at center, #00FF8B, transparent); - background-size: 120% 100%; - transform: translateY(100%); - background-position: center; - transition: transform 0.3s, opacity 0.8s; - pointer-events: none; - opacity: 0; - filter: blur(8px); - } - - .confirm-button:hover { - color: #fff; - } - - .confirm-button:hover:before { - transform: translateY(50%); - opacity: 1; - } - - .confirm-button:active { - background: #CC000000; - font-style: italic; - } - - .confirm-button:disabled { - background: #333333; - border-color: #333333; - color: #777; - cursor: not-allowed; - } - - .confirm-button:disabled:hover:before { - transform: translateY(100%); - opacity: 0; - } - - .confirm-button:disabled:active { - font-style: normal; - } - -confirm-button[disabled] { - background: #333333; - border-color: #333333; - color: #777; - cursor: not-allowed; - pointer-events: none; - text-decoration: none; -} - -.confirm-button[disabled]:hover:before { - transform: translateY(100%); - opacity: 0; -} - -.confirm-button[disabled]:active { - font-style: normal; -} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Components/EnlightenmentCheckbox.razor b/src/Lumina.Presentation.Web/Components/EnlightenmentCheckbox.razor deleted file mode 100644 index b1bfa83b..00000000 --- a/src/Lumina.Presentation.Web/Components/EnlightenmentCheckbox.razor +++ /dev/null @@ -1,27 +0,0 @@ - - -@code { - [Parameter] public bool Checked { get; set; } - [Parameter] public EventCallback CheckedChanged { get; set; } - [Parameter] public string? Label { get; set; } - [Parameter] public bool Disabled { get; set; } - [Parameter] public string CssClass { get; set; } = ""; - - /// - /// Handles the change event. - /// - /// The event arguments. - private async Task OnChangeHandler(ChangeEventArgs e) - { - Checked = e?.Value != null ? (bool)e.Value : false; - await CheckedChanged.InvokeAsync(Checked).ConfigureAwait(false); - } -} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Components/EnlightenmentCheckbox.razor.css b/src/Lumina.Presentation.Web/Components/EnlightenmentCheckbox.razor.css deleted file mode 100644 index bd4515e1..00000000 --- a/src/Lumina.Presentation.Web/Components/EnlightenmentCheckbox.razor.css +++ /dev/null @@ -1,33 +0,0 @@ -.enlightenment-checkbox-label { - display: flex; - align-items: center; - cursor: pointer; - font-size: 14px; - color: #6DCBFE; - user-select: none; -} - -.enlightenment-checkbox-hidden { - display: none; -} - -.enlightenment-checkbox { - width: 14px; - height: 14px; - border-top: #000000 1px solid; - border-bottom: #333333 1px solid; - border-left: #000000 1px solid; - border-right: #333333 1px solid; - border-radius: 0; - margin-right: 10px; - position: relative; - background: linear-gradient(to bottom, #111, #222 50%, #333); -} - -.enlightenment-checkbox-hidden:checked + .enlightenment-checkbox { - background-image: linear-gradient(180deg, #5E5D5D, #505050, #424343); - border-top: #888888 1px solid; - border-bottom: #333333 1px solid; - border-left: #666666 1px solid; - border-right: #444444 1px solid; -} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Components/EnlightenmentCombobox.razor b/src/Lumina.Presentation.Web/Components/EnlightenmentCombobox.razor deleted file mode 100644 index 1192729b..00000000 --- a/src/Lumina.Presentation.Web/Components/EnlightenmentCombobox.razor +++ /dev/null @@ -1,91 +0,0 @@ -@using Lumina.Presentation.Web.Common.Models.UI -@using Lumina.Presentation.Web.Core.Services.UI - -@typeparam TValue - -@implements IDisposable - -@inject ComboboxService _comboboxService -@inject IJSRuntime JSRuntime - -
-
- - -
-
-
No item selected
- - @for (int i = 0; i < Items?.Count; i++) - { - var item = Items[i]; - var cssClass = $"enlightenment-item {(i == Items.Count - 1 ? "last-item" : string.Empty)} {(item.IsEnabled ? string.Empty : "disabled")}"; -
@item.Text
- } -
-
- -@code { - [Parameter] public List> Items { get; set; } = []; - [Parameter] public ComboboxItem? SelectedItem { get; set; } - [Parameter] public EventCallback> SelectedItemChanged { get; set; } - [Parameter] public string? CssClass { get; set; } - - private bool IsOpen { get; set; } - private Guid Id { get; set; } = Guid.NewGuid(); - - /// - /// Initializes the component. - /// - protected override void OnInitialized() - { - _comboboxService.ComboboxOpened += CloseIfNotThisAsync; - } - - /// - /// Toggles the dropdown state. - /// - private async Task ToggleDropdownAsync() - { - IsOpen = !IsOpen; - if (IsOpen) - { - _comboboxService.NotifyComboboxOpened("combobox_checkbox_" + Id); - await JSRuntime.InvokeVoidAsync("adjustDropdownHeight", "combobox_" + Id).ConfigureAwait(false); - } - } - - /// - /// Closes the dropdown if the provided is not the current , or if it's . - /// - /// The optional id of the combobox that initiated the dropdown state change. - private async Task CloseIfNotThisAsync(string? openedId) - { - if (openedId != "combobox_checkbox_" + Id && IsOpen) - { - IsOpen = false; - await InvokeAsync(StateHasChanged); - } - } - - /// - /// Selects the provided . - /// - /// The item to select. - private async Task SelectItem(ComboboxItem? item) - { - SelectedItem = item; - IsOpen = false; - await SelectedItemChanged.InvokeAsync(item).ConfigureAwait(false); - } - - /// - /// Disposes the component. - /// - public void Dispose() - { - _comboboxService.ComboboxOpened -= CloseIfNotThisAsync; - } -} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Components/EnlightenmentCombobox.razor.css b/src/Lumina.Presentation.Web/Components/EnlightenmentCombobox.razor.css deleted file mode 100644 index ca57e691..00000000 --- a/src/Lumina.Presentation.Web/Components/EnlightenmentCombobox.razor.css +++ /dev/null @@ -1,154 +0,0 @@ -.enlightenment-combobox { - position: relative; - font-family: Arial, sans-serif; - padding: 0; - margin: 0; - box-sizing: border-box; -} - -.enlightenment-toggle-checkbox { - display: none; -} - -.enlightenment-toggle { - display: flex; - align-items: center; - justify-content: space-between; - cursor: pointer; - font-family: Arial, sans-serif; - font-size: 14px; - border-radius: 3px; - box-shadow: 0 0 3px rgba(0, 0, 0, 0.5); - color: #6DCBFE; - padding: 3px 24px 3px 18px; - width: 100%; - border: none; - outline: none; - appearance: none; - border-top: #989898 1px solid; - border-bottom: #151515 1px solid; - border-left: #878787 1px solid; - border-right: #202020 1px solid; - background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%225%22%3E%3Cpath%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%222%22%20d%3D%22M2%2C0L6%2C4L10%2C0%22%2F%3E%3C%2Fsvg%3E'), url('../images/ui/scrollbar_dots_v.png'), linear-gradient(180deg, #606060, #555555, #4C4C4C, #414141); - background-repeat: no-repeat, no-repeat, repeat; - background-position: right 10px top 50%, left 7px top 50%, 0 0; - background-size: 12px 6px, 3px auto, 100%; - user-select: none; - box-sizing: border-box; -} - - .enlightenment-toggle:hover { - background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%225%22%3E%3Cpath%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%222%22%20d%3D%22M2%2C0L6%2C4L10%2C0%22%2F%3E%3C%2Fsvg%3E'), url('../images/ui/scrollbar_dots_lit_v.png'), linear-gradient(180deg, #606060, #555555, #4C4C4C, #414141); - background-repeat: no-repeat, no-repeat, repeat; - background-position: right 10px top 50%, left 7px top 50%, 0 0; - background-size: 12px 6px, 3px auto, 100%; - } - -.enlightenment-selected-text { - flex: 1; - text-align: right; -} - -.enlightenment-dropdown { - display: none; - position: absolute; - top: 100%; - left: 0; - width: 100%; - box-sizing: border-box; - background-image: url('../images/ui/metal-plate.png'), linear-gradient(180deg, #505050, #464646, #404040, #363636); - background-repeat: repeat, no-repeat; - background-position: 3px 3px, 0 0; /* offset the metal-plate image by 3 pixels from the top and left */ - background-clip: content-box, border-box; /* clip the metal-plate image to the content box */ - border-top: #989898 1px solid; - border-bottom: #151515 1px solid; - border-left: #878787 1px solid; - border-right: #202020 1px solid; - padding: 3px; - z-index: 999; - max-height: none; - overflow-y: auto; -} - - .enlightenment-dropdown > .shine-effect:first-child { - top: -4px; - } - -.enlightenment-item { - display: block; - border-left: 1px solid #232323; - border-right: 1px solid #777777; - border-top: 1px solid #232323; - border-bottom: 1px solid #777777; - color: #FFFFFF; - padding: 5px 10px; - width: 100%; - box-sizing: border-box; - user-select: none; - cursor: pointer; -} - - .enlightenment-item.first-item { - border-top: 1px solid #232323; - margin-top: -1px; - } - - .enlightenment-item.last-item { - border-bottom: 1px solid #777777; - } - - .enlightenment-item.disabled { - color: #AAAAAA; - } - - .enlightenment-item:hover { - background-image: none; - background: linear-gradient(to bottom, #505050, #464646, #404040, #363636); - color: #1D8AF9; - box-shadow: inset 1px 0 0 0 #777777, inset -1px 0 0 0 #232323, inset 0 1px 0 0 #989898, inset 0 -1px 0 0 #151515; - } - -.enlightenment-combobox.open .enlightenment-dropdown { - display: block; -} - -.enlightenment-combobox > .shine-effect:first-child { - top: 1px; - opacity: 0; - transition: opacity 0.5s; -} - -.enlightenment-combobox:hover > .shine-effect:first-child { - opacity: 1; -} - -.enlightenment-combobox > .shine-effect::before, -.enlightenment-combobox > .shine-effect::after { - content: ""; - position: absolute; - top: -1px; - left: 50%; - transform: translateX(-50%); - opacity: 0; - transition: opacity 0.5s; -} - -.enlightenment-combobox > .shine-effect::before { - width: 3px; - height: 2px; - border-radius: 5px 5px 0 0; - background-color: #FFFFFF; -} - -.enlightenment-combobox > .shine-effect::after { - width: 10px; - height: 3px; - border-radius: 5px 5px 0 0; - background-color: #FFFFFF; - filter: blur(3px); -} - -.enlightenment-combobox:hover > .shine-effect::before, -.enlightenment-combobox:hover > .shine-effect::after { - opacity: 1; -} diff --git a/src/Lumina.Presentation.Web/Components/EnlightenmentInput.razor b/src/Lumina.Presentation.Web/Components/EnlightenmentInput.razor deleted file mode 100644 index 96979481..00000000 --- a/src/Lumina.Presentation.Web/Components/EnlightenmentInput.razor +++ /dev/null @@ -1,77 +0,0 @@ -@inject IJSRuntime JSRuntime - - - -@code { - [Parameter] public string? Id { get; set; } - [Parameter] public string Type { get; set; } = "text"; - [Parameter] public bool UsesPercentForHeight { get; set; } - [Parameter] public bool UsesPercentForWidth { get; set; } = true; - [Parameter] public int Width { get; set; } = 100; - [Parameter] public int Height { get; set; } = 28; - [Parameter] public string? CssClass { get; set; } - [Parameter] public string? Name { get; set; } - [Parameter] public bool AutoComplete { get; set; } = true; - [Parameter] public string? Value { get; set; } - [Parameter] public EventCallback ValueChanged { get; set; } - [Parameter] public EventCallback OnEnterPressed { get; set; } - [Parameter] public EventCallback OnEscapePressed { get; set; } - [Parameter] public string? Placeholder { get; set; } - [Parameter] public bool IsDisabled { get; set; } - [Parameter] public bool IsReadOnly { get; set; } - [Parameter] public bool HasError { get; set; } - - private ElementReference inputElement; - - /// - /// Handles the event risen after the component was rendered. - /// - /// Indicates whether this is the first render or not. - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if (firstRender) - await JSRuntime.InvokeVoidAsync("windowKeyDownHandler", inputElement, DotNetObjectReference.Create(this)).ConfigureAwait(false); - } - - /// - /// Handles the input change event. - /// - /// The event arguments. - private async Task OnInputHandlerAsync(ChangeEventArgs e) - { - Value = e.Value?.ToString(); - await ValueChanged.InvokeAsync(Value).ConfigureAwait(false); - } - - /// - /// Handles the key down event. - /// - /// The event arguments. - private async Task OnKeyDownAsync(KeyboardEventArgs e) - { - if (e.Key == "Enter" || e.Code == "NumpadEnter") - await OnEnterPressed.InvokeAsync(); - } - - /// - /// Handles the Escape key pressed. - /// - [JSInvokable] - public void EscapePressed() - { - OnEscapePressed.InvokeAsync(Value); - } -} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Components/EnlightenmentInput.razor.css b/src/Lumina.Presentation.Web/Components/EnlightenmentInput.razor.css deleted file mode 100644 index d4d8b564..00000000 --- a/src/Lumina.Presentation.Web/Components/EnlightenmentInput.razor.css +++ /dev/null @@ -1,56 +0,0 @@ -.enlightenment-input { - font-size: 14px; - padding: 5px; - border: 1px solid; - border-color: var(--border-color-dark) var(--border-color-light) var(--border-color-light) var(--border-color-dark); - border-radius: 3px; - background: linear-gradient(0deg, #90c247, #509c00); - transition: background 0.3s, color 0.3s; - color: #000; - outline: none; - position: relative; - box-sizing: border-box; -} - - .enlightenment-input:hover { - background: var(--window-button-over-color); - } - - .enlightenment-input:not(:focus) { - background: linear-gradient(0deg, #6b7579, #576b65); - color: #000; - } - - .enlightenment-input:focus { - font-style: italic; - color: #333; - background: linear-gradient(0deg, #6AAFF8, #82E9F7); - box-shadow: inset 4px 6px 8px rgba(0,0,0,0.6); - border-color: var(--border-color-dark) var(--border-color-light) var(--border-color-light) var(--border-color-dark); - outline: none; - } - - .enlightenment-input::placeholder { - color: #999; - } - - .enlightenment-input:disabled { - color: #999; - background: var(--container-background); - } - - .enlightenment-input[readonly] { - color: #999; - background: var(--container-background); - border-color: var(--border-color-light) var(--border-color-dark) var(--border-color-dark) var(--border-color-light); - } - - .enlightenment-input[data-has-error="true"] { - border-color: #f00; - color: #FFF; - background: #700; - } - -textarea { - resize: none; -} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Components/FileSystemBrowser.razor b/src/Lumina.Presentation.Web/Components/FileSystemBrowser.razor deleted file mode 100644 index 67bf700c..00000000 --- a/src/Lumina.Presentation.Web/Components/FileSystemBrowser.razor +++ /dev/null @@ -1,921 +0,0 @@ -@using Lumina.Presentation.Web.Common.Models.Common -@using Lumina.Presentation.Web.Common.Api -@using Lumina.Presentation.Web.Common.Enums.FileSystem -@using Lumina.Presentation.Web.Common.Enums.Notifications -@using Lumina.Presentation.Web.Common.Exceptions -@using Lumina.Presentation.Web.Common.Models.FileManagement -@using Lumina.Presentation.Web.Common.Models.UI -@using Lumina.Presentation.Web.Common.Services -@using Microsoft.AspNetCore.Components -@using System.Text.Json -@using System.Text - -@implements IDisposable - -@inject IJSRuntime JSRuntime -@inject IApiHttpClient _apiHttpClient -@inject INotificationService _notificationService - -
-
-
-
-
-
- - -