From 493f34c883e7c19b8ca5c9ea7d8b4aef3d5c8c5d Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Thu, 19 Sep 2024 17:40:33 +0300 Subject: [PATCH] Implements directory browser dialog, part 3: file system explorer --- .../FileManagement/DirectoryMappingConfig.cs | 35 +- .../FileManagement/FileMappingConfig.cs | 9 + .../Queries/GetDirectoriesQuery.cs | 2 +- .../Queries/GetDirectoriesQueryHandler.cs | 8 +- .../Queries/GetDirectoryTreeQuery.cs | 3 +- .../Queries/GetDirectoryTreeQueryHandler.cs | 36 +- .../Queries/GetTreeDirectoriesQuery.cs | 14 + .../Queries/GetTreeDirectoriesQueryHandler.cs | 51 ++ .../GetTreeDirectoriesQueryValidator.cs | 22 + .../Files/Queries/GetFilesQuery.cs | 2 +- .../Files/Queries/GetFilesQueryHandler.cs | 8 +- .../Files/Queries/GetTreeFilesQuery.cs | 14 + .../Files/Queries/GetTreeFilesQueryHandler.cs | 50 ++ .../Queries/GetTreeFilesQueryValidator.cs | 22 + .../FileManagement/FileSystemItemModel.cs | 16 + .../FileManagement/DirectoryResponse.cs | 19 + .../Responses/FileManagement/FileResponse.cs | 18 + .../FileManagement/DirectoriesController.cs | 30 +- .../FileManagement/FilesController.cs | 27 +- .../PresentationWebLayerServices.cs | 7 +- .../Enums/FileSystem/FileSystemIconSize.cs | 27 + .../Enums/FileSystem/FileSystemViewMode.cs | 22 + .../Models/FileManagement/DirectoryModel.cs | 20 + .../Common/Models/FileManagement/FileModel.cs | 19 + .../FileManagement/FileSystemItemModel.cs | 22 +- .../DirectoryBrowserComponent.razor | 319 ----------- .../Components/EnlightenmentInput.razor | 30 +- .../FileSystemBrowserComponent.razor | 506 ++++++++++++++++++ ...s => FileSystemBrowserComponent.razor.css} | 470 ++++++++++++++-- src/Lumina.Presentation.Web/Pages/Home.razor | 2 +- .../icons/Lyra/android-package-archive.svg | 23 + .../icons/Lyra/application-atom+xml.svg | 11 + .../icons/Lyra/application-certificate.svg | 11 + .../images/icons/Lyra/application-dicom.svg | 11 + .../icons/Lyra/application-epub+zip.svg | 11 + .../icons/Lyra/application-illustrator.svg | 11 + .../images/icons/Lyra/application-image.svg | 238 ++++++++ .../images/icons/Lyra/application-json.svg | 12 + .../icons/Lyra/application-mathml+xml.svg | 21 + .../icons/Lyra/application-msonenote.svg | 11 + .../icons/Lyra/application-msoutlook.svg | 11 + .../Lyra/application-msword-template.svg | 14 + .../icons/Lyra/application-octet-stream.svg | 26 + .../images/icons/Lyra/application-ogg.svg | 13 + .../images/icons/Lyra/application-pdf.svg | 13 + .../icons/Lyra/application-pgp-signature.svg | 17 + .../images/icons/Lyra/application-pgp.svg | 11 + .../icons/Lyra/application-photoshop.svg | 11 + .../icons/Lyra/application-postscript.svg | 11 + .../images/icons/Lyra/application-sql.svg | 16 + .../icons/Lyra/application-vnd.appimage.svg | 11 + .../Lyra/application-vnd.flatpak.ref.svg | 15 + .../icons/Lyra/application-vnd.iccprofile.svg | 14 + ...application-vnd.kde.bluedevil-sendfile.svg | 19 + .../icons/Lyra/application-vnd.ms-access.svg | 9 + .../application-vnd.ms-cab-compressed.svg | 18 + .../icons/Lyra/application-vnd.ms-excel.svg | 14 + .../Lyra/application-vnd.ms-htmlhelp.svg | 15 + .../Lyra/application-vnd.ms-infopath.svg | 11 + .../Lyra/application-vnd.ms-powerpoint.svg | 14 + .../Lyra/application-vnd.ms-publisher.svg | 14 + ...plication-vnd.oasis.opendocument.chart.svg | 15 + ...sis.opendocument.presentation-template.svg | 11 + ...asis.opendocument.spreadsheet-template.svg | 16 + ...n-vnd.oasis.opendocument.text-template.svg | 11 + ...on-vnd.oasis.opendocument.web-template.svg | 11 + .../icons/Lyra/application-vnd.snap.svg | 11 + .../icons/Lyra/application-vnd.visio.svg | 11 + .../icons/Lyra/application-vnd.xdgapp.svg | 17 + .../images/icons/Lyra/application-winhlp.svg | 15 + .../icons/Lyra/application-x-7z-ace.svg | 14 + .../images/icons/Lyra/application-x-addon.svg | 11 + .../wwwroot/images/icons/Lyra/directory.svg | 36 ++ .../wwwroot/images/icons/Lyra/drive.svg | 51 ++ .../wwwroot/images/icons/Lyra/file.svg | 25 + .../wwwroot/js/site.js | 72 ++- 76 files changed, 2377 insertions(+), 437 deletions(-) create mode 100644 src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectoriesQuery.cs create mode 100644 src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectoriesQueryHandler.cs create mode 100644 src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectoriesQueryValidator.cs create mode 100644 src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFilesQuery.cs create mode 100644 src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFilesQueryHandler.cs create mode 100644 src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFilesQueryValidator.cs create mode 100644 src/Lumina.Contracts/Models/FileManagement/FileSystemItemModel.cs create mode 100644 src/Lumina.Contracts/Responses/FileManagement/DirectoryResponse.cs create mode 100644 src/Lumina.Contracts/Responses/FileManagement/FileResponse.cs create mode 100644 src/Lumina.Presentation.Web/Common/Enums/FileSystem/FileSystemIconSize.cs create mode 100644 src/Lumina.Presentation.Web/Common/Enums/FileSystem/FileSystemViewMode.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/FileManagement/DirectoryModel.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/FileManagement/FileModel.cs delete mode 100644 src/Lumina.Presentation.Web/Components/DirectoryBrowserComponent.razor create mode 100644 src/Lumina.Presentation.Web/Components/FileSystemBrowserComponent.razor rename src/Lumina.Presentation.Web/Components/{DirectoryBrowserComponent.razor.css => FileSystemBrowserComponent.razor.css} (61%) create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/android-package-archive.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-atom+xml.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-certificate.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-dicom.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-epub+zip.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-illustrator.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-image.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-json.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-mathml+xml.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-msonenote.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-msoutlook.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-msword-template.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-octet-stream.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-ogg.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-pdf.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-pgp-signature.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-pgp.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-photoshop.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-postscript.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-sql.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.appimage.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.flatpak.ref.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.iccprofile.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.kde.bluedevil-sendfile.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-access.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-cab-compressed.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-excel.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-htmlhelp.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-infopath.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-powerpoint.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-publisher.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.chart.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.presentation-template.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.spreadsheet-template.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.text-template.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.web-template.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.snap.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.visio.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.xdgapp.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-winhlp.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-x-7z-ace.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-x-addon.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/directory.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/drive.svg create mode 100644 src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/file.svg diff --git a/src/Lumina.Application/Common/Mapping/FileManagement/DirectoryMappingConfig.cs b/src/Lumina.Application/Common/Mapping/FileManagement/DirectoryMappingConfig.cs index c97bce33..847bf78b 100644 --- a/src/Lumina.Application/Common/Mapping/FileManagement/DirectoryMappingConfig.cs +++ b/src/Lumina.Application/Common/Mapping/FileManagement/DirectoryMappingConfig.cs @@ -1,7 +1,11 @@ #region ========================================================================= USING ===================================================================================== +using Lumina.Contracts.Models.FileManagement; using Lumina.Contracts.Responses.FileManagement; +using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate; using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities; using Mapster; +using System; +using System.Collections.Generic; #endregion namespace Lumina.Application.Common.Mapping.FileManagement; @@ -19,13 +23,30 @@ public class DirectoryMappingConfig : IRegister public void Register(TypeAdapterConfig config) { config.NewConfig() - .Map(dest => dest.Name, src => src.Name) - .Map(dest => dest.Path, src => src.Id.Path) - .Map(dest => dest.ItemType, src => src.Type) - .Map(dest => dest.IsExpanded, () => false) - .Map(dest => dest.ChildrenLoaded, () => false) - .Map(dest => dest.Children, src => src.Items) - .MapToConstructor(true); + .Map(dest => dest.Name, src => src.Name) + .Map(dest => dest.Path, src => src.Id.Path) + .Map(dest => dest.ItemType, src => src.Type) + .Map(dest => dest.IsExpanded, () => false) + .Map(dest => dest.ChildrenLoaded, () => false) + .Map(dest => dest.Children, src => src.Items) + .MapToConstructor(true); + + config.NewConfig() + .MapWith(src => new DirectoryResponse( + src.Id.Path, + src.Name, + src.DateCreated.Value, + src.DateModified.Value, + src.Items.Adapt>() + )); + + config.NewConfig() + .MapWith(src => new FileSystemItemModel( + src.Id.Path, + src.Name, + DateTime.Now, + DateTime.Now + )); } #endregion } \ No newline at end of file diff --git a/src/Lumina.Application/Common/Mapping/FileManagement/FileMappingConfig.cs b/src/Lumina.Application/Common/Mapping/FileManagement/FileMappingConfig.cs index 4c32babc..633bdc7d 100644 --- a/src/Lumina.Application/Common/Mapping/FileManagement/FileMappingConfig.cs +++ b/src/Lumina.Application/Common/Mapping/FileManagement/FileMappingConfig.cs @@ -25,6 +25,15 @@ public class FileMappingConfig : IRegister .Map(dest => dest.IsExpanded, () => false) .Map(dest => dest.ChildrenLoaded, () => false) .MapToConstructor(true); + + config.NewConfig() + .MapWith(src => new FileResponse( + src.Id.Path, + src.Name, + src.DateCreated.HasValue ? src.DateCreated.Value : default, + src.DateModified.HasValue ? src.DateModified.Value : default, + src.Size + )); } #endregion } \ No newline at end of file diff --git a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoriesQuery.cs b/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoriesQuery.cs index fd8bfa61..5a4b749c 100644 --- a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoriesQuery.cs +++ b/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoriesQuery.cs @@ -11,4 +11,4 @@ namespace Lumina.Application.Core.FileManagement.Directories.Queries; /// Query for retrieving the list of directories at a path. /// /// The path for which to retrieve the list of directories. -public record GetDirectoriesQuery(string Path) : IRequest>>; \ No newline at end of file +public record GetDirectoriesQuery(string Path) : IRequest>>; \ No newline at end of file diff --git a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoriesQueryHandler.cs b/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoriesQueryHandler.cs index e6a4e361..b524a7fd 100644 --- a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoriesQueryHandler.cs +++ b/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoriesQueryHandler.cs @@ -16,7 +16,7 @@ namespace Lumina.Application.Core.FileManagement.Directories.Queries; /// /// Handler for the query to get all directories. /// -public class GetDirectoriesQueryHandler : IRequestHandler>> +public class GetDirectoriesQueryHandler : IRequestHandler>> { #region ================================================================== FIELD MEMBERS ================================================================================ private readonly IDirectoryService _directoryService; @@ -40,12 +40,12 @@ public class GetDirectoriesQueryHandler : IRequestHandlerThe query containing the requested path. /// Cancellation token that can be used to stop the execution. /// - /// An containing either a collection of , or an error message. + /// An containing either a collection of , or an error message. /// - public ValueTask>> Handle(GetDirectoriesQuery request, CancellationToken cancellationToken) + public ValueTask>> Handle(GetDirectoriesQuery request, CancellationToken cancellationToken) { ErrorOr> result = _directoryService.GetSubdirectories(request.Path); - return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt>()), errors => errors)); + return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt>()), errors => errors)); } #endregion } \ No newline at end of file diff --git a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTreeQuery.cs b/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTreeQuery.cs index aeaaa40e..cee1705e 100644 --- a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTreeQuery.cs +++ b/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTreeQuery.cs @@ -11,4 +11,5 @@ namespace Lumina.Application.Core.FileManagement.Directories.Queries; /// Query for retrieving the tree of directories of a path. /// /// The path for which to retrieve the tree of directories. -public record GetDirectoryTreeQuery(string Path) : IRequest>>; \ No newline at end of file +/// Whether to include files in the directory tree or not. +public record GetDirectoryTreeQuery(string Path, bool IncludeFiles) : IRequest>>; \ No newline at end of file diff --git a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTreeQueryHandler.cs b/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTreeQueryHandler.cs index 5df28bcf..34af48a2 100644 --- a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTreeQueryHandler.cs +++ b/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetDirectoryTreeQueryHandler.cs @@ -73,7 +73,7 @@ public class GetDirectoryTreeQueryHandler : IRequestHandler loadChildrenResult = LoadChildren(currentNode); + ErrorOr loadChildrenResult = LoadChildren(currentNode, request.IncludeFiles); if (loadChildrenResult.IsError) return loadChildrenResult.Errors; return await ValueTask.FromResult(result); @@ -135,8 +135,9 @@ public class GetDirectoryTreeQueryHandler : IRequestHandler /// The directory node to load children for. + /// Whether to include files in the directories or not. /// A result indicating a successful operation, or an error message. - private ErrorOr LoadChildren(FileSystemTreeNodeResponse node) + private ErrorOr LoadChildren(FileSystemTreeNodeResponse node, bool includeFiles) { // get subdirectories under the current node's path ErrorOr> subDirectoriesResult = _directoryService.GetSubdirectories(node.Path); @@ -155,22 +156,25 @@ public class GetDirectoryTreeQueryHandler : IRequestHandler> filesResult = _fileService.GetFiles(node.Path); - if (filesResult.IsError) - return filesResult.Errors; - // add each file as a child node of the current directory - foreach (File file in filesResult.Value) + if (includeFiles) { - FileSystemTreeNodeResponse fileNode = new FileSystemTreeNodeResponse + // get files under the current node's path + ErrorOr> filesResult = _fileService.GetFiles(node.Path); + if (filesResult.IsError) + return filesResult.Errors; + // add each file as a child node of the current directory + foreach (File file in filesResult.Value) { - Name = file.Name, - Path = file.Id.Path, - ItemType = FileSystemItemType.File, - IsExpanded = false, - ChildrenLoaded = true - }; - node.Children.Add(fileNode); + FileSystemTreeNodeResponse fileNode = new FileSystemTreeNodeResponse + { + Name = file.Name, + Path = file.Id.Path, + ItemType = FileSystemItemType.File, + IsExpanded = false, + ChildrenLoaded = true + }; + node.Children.Add(fileNode); + } } node.ChildrenLoaded = true; return Result.Success; diff --git a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectoriesQuery.cs b/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectoriesQuery.cs new file mode 100644 index 00000000..75722d48 --- /dev/null +++ b/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectoriesQuery.cs @@ -0,0 +1,14 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +using Lumina.Contracts.Responses.FileManagement; +using Mediator; +using System.Collections.Generic; +#endregion + +namespace Lumina.Application.Core.FileManagement.Directories.Queries; + +/// +/// Query for retrieving the list of directories at a path. +/// +/// The path for which to retrieve the list of directories. +public record GetTreeDirectoriesQuery(string Path) : IRequest>>; \ No newline at end of file diff --git a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectoriesQueryHandler.cs b/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectoriesQueryHandler.cs new file mode 100644 index 00000000..f3c49c67 --- /dev/null +++ b/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectoriesQueryHandler.cs @@ -0,0 +1,51 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +using Lumina.Contracts.Responses.FileManagement; +using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities; +using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services; +using Mapster; +using MapsterMapper; +using Mediator; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +#endregion + +namespace Lumina.Application.Core.FileManagement.Directories.Queries; + +/// +/// Handler for the query to get all directories. +/// +public class GetTreeDirectoriesQueryHandler : IRequestHandler>> +{ + #region ================================================================== FIELD MEMBERS ================================================================================ + private readonly IDirectoryService _directoryService; + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// Injected service for handling directories. + public GetTreeDirectoriesQueryHandler(IDirectoryService directoryService) + { + _directoryService = directoryService; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Gets the list of directories at the specified path. + /// + /// The query containing the requested path. + /// Cancellation token that can be used to stop the execution. + /// + /// An containing either a collection of , or an error message. + /// + public ValueTask>> Handle(GetTreeDirectoriesQuery request, CancellationToken cancellationToken) + { + ErrorOr> result = _directoryService.GetSubdirectories(request.Path); + return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt>()), errors => errors)); + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectoriesQueryValidator.cs b/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectoriesQueryValidator.cs new file mode 100644 index 00000000..3f75cb75 --- /dev/null +++ b/src/Lumina.Application/Core/FileManagement/Directories/Queries/GetTreeDirectoriesQueryValidator.cs @@ -0,0 +1,22 @@ +#region ========================================================================= USING ===================================================================================== +using FluentValidation; +using Lumina.Domain.Common.Errors; +#endregion + +namespace Lumina.Application.Core.FileManagement.Directories.Queries; + +/// +/// Validates the needed validation rules for . +/// +public class GetTreeDirectoriesQueryValidator : AbstractValidator +{ + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + public GetTreeDirectoriesQueryValidator() + { + RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code); + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetFilesQuery.cs b/src/Lumina.Application/Core/FileManagement/Files/Queries/GetFilesQuery.cs index 6b799f36..d45539bd 100644 --- a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetFilesQuery.cs +++ b/src/Lumina.Application/Core/FileManagement/Files/Queries/GetFilesQuery.cs @@ -11,4 +11,4 @@ namespace Lumina.Application.Core.FileManagement.Files.Queries; /// Query for retrieving the list of files at a path. /// /// The path for which to retrieve the list of files. -public record GetFilesQuery(string Path) : IRequest>>; \ No newline at end of file +public record GetFilesQuery(string Path) : IRequest>>; \ No newline at end of file diff --git a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetFilesQueryHandler.cs b/src/Lumina.Application/Core/FileManagement/Files/Queries/GetFilesQueryHandler.cs index 3585fad7..ba5f87c1 100644 --- a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetFilesQueryHandler.cs +++ b/src/Lumina.Application/Core/FileManagement/Files/Queries/GetFilesQueryHandler.cs @@ -15,7 +15,7 @@ namespace Lumina.Application.Core.FileManagement.Files.Queries; /// /// Handler for the query to get all files. /// -public class GetFilesQueryHandler : IRequestHandler>> +public class GetFilesQueryHandler : IRequestHandler>> { #region ================================================================== FIELD MEMBERS ================================================================================ private readonly IFileService _fileService; @@ -39,12 +39,12 @@ public class GetFilesQueryHandler : IRequestHandlerThe query containing the requested path. /// Cancellation token that can be used to stop the execution. /// - /// An containing either a collection of , or an error message. + /// An containing either a collection of , or an error message. /// - public ValueTask>> Handle(GetFilesQuery request, CancellationToken cancellationToken) + public ValueTask>> Handle(GetFilesQuery request, CancellationToken cancellationToken) { ErrorOr> result = _fileService.GetFiles(request.Path); - return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt>()), errors => errors)); + return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt>()), errors => errors)); } #endregion } \ No newline at end of file diff --git a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFilesQuery.cs b/src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFilesQuery.cs new file mode 100644 index 00000000..1f9f7e2a --- /dev/null +++ b/src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFilesQuery.cs @@ -0,0 +1,14 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +using Lumina.Contracts.Responses.FileManagement; +using Mediator; +using System.Collections.Generic; +#endregion + +namespace Lumina.Application.Core.FileManagement.Files.Queries; + +/// +/// Query for retrieving the list of files at a path. +/// +/// The path for which to retrieve the list of files. +public record GetTreeFilesQuery(string Path) : IRequest>>; \ No newline at end of file diff --git a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFilesQueryHandler.cs b/src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFilesQueryHandler.cs new file mode 100644 index 00000000..db1082b6 --- /dev/null +++ b/src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFilesQueryHandler.cs @@ -0,0 +1,50 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +using Lumina.Contracts.Responses.FileManagement; +using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities; +using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Services; +using Mapster; +using Mediator; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +#endregion + +namespace Lumina.Application.Core.FileManagement.Files.Queries; + +/// +/// Handler for the query to get all files. +/// +public class GetTreeFilesQueryHandler : IRequestHandler>> +{ + #region ================================================================== FIELD MEMBERS ================================================================================ + private readonly IFileService _fileService; + #endregion + + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + /// Injected service for handling files. + public GetTreeFilesQueryHandler(IFileService fileService) + { + _fileService = fileService; + } + #endregion + + #region ===================================================================== METHODS =================================================================================== + /// + /// Gets the list of files at the specified path. + /// + /// The query containing the requested path. + /// Cancellation token that can be used to stop the execution. + /// + /// An containing either a collection of , or an error message. + /// + public ValueTask>> Handle(GetTreeFilesQuery request, CancellationToken cancellationToken) + { + ErrorOr> result = _fileService.GetFiles(request.Path); + return ValueTask.FromResult(result.Match(values => ErrorOrFactory.From(result.Value.Adapt>()), errors => errors)); + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFilesQueryValidator.cs b/src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFilesQueryValidator.cs new file mode 100644 index 00000000..64eaef8f --- /dev/null +++ b/src/Lumina.Application/Core/FileManagement/Files/Queries/GetTreeFilesQueryValidator.cs @@ -0,0 +1,22 @@ +#region ========================================================================= USING ===================================================================================== +using FluentValidation; +using Lumina.Domain.Common.Errors; +#endregion + +namespace Lumina.Application.Core.FileManagement.Files.Queries; + +/// +/// Validates the needed validation rules for . +/// +public class GetTreeFilesQueryValidator : AbstractValidator +{ + #region ====================================================================== CTOR ===================================================================================== + /// + /// Initializes a new instance of the class. + /// + public GetTreeFilesQueryValidator() + { + RuleFor(x => x.Path).NotEmpty().WithMessage(Errors.FileManagement.PathCannotBeEmpty.Code); + } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Contracts/Models/FileManagement/FileSystemItemModel.cs b/src/Lumina.Contracts/Models/FileManagement/FileSystemItemModel.cs new file mode 100644 index 00000000..3267f046 --- /dev/null +++ b/src/Lumina.Contracts/Models/FileManagement/FileSystemItemModel.cs @@ -0,0 +1,16 @@ +#region ========================================================================= USING ===================================================================================== +using System; +using System.Diagnostics; +#endregion + +namespace Lumina.Contracts.Models.FileManagement; + +/// +/// Generic filesystem data transfer object. +/// +/// The path of the file system item. +/// The name of the file system item. +/// The creation date of the file system item. +/// The modification date of the file system item. +[DebuggerDisplay("{Name}")] +public record FileSystemItemModel(string Path, string Name, DateTime DateCreated, DateTime DateModified); \ No newline at end of file diff --git a/src/Lumina.Contracts/Responses/FileManagement/DirectoryResponse.cs b/src/Lumina.Contracts/Responses/FileManagement/DirectoryResponse.cs new file mode 100644 index 00000000..76227fb3 --- /dev/null +++ b/src/Lumina.Contracts/Responses/FileManagement/DirectoryResponse.cs @@ -0,0 +1,19 @@ +#region ========================================================================= USING ===================================================================================== +using System; +using System.Collections.Generic; +using System.Diagnostics; +using Lumina.Contracts.Models.FileManagement; +#endregion + +namespace Lumina.Contracts.Responses.FileManagement; + +/// +/// Represents a response containing a file system directory. +/// +/// The path of the directory. +/// The name of the directory. +/// The creation date of the directory. +/// The modification date of the directory. +/// The children items of the directory. +[DebuggerDisplay("{Name} (Directory)")] +public record DirectoryResponse(string Path, string Name, DateTime DateCreated, DateTime DateModified, List Items) : FileSystemItemModel(Path, Name, DateCreated, DateModified); \ No newline at end of file diff --git a/src/Lumina.Contracts/Responses/FileManagement/FileResponse.cs b/src/Lumina.Contracts/Responses/FileManagement/FileResponse.cs new file mode 100644 index 00000000..968317de --- /dev/null +++ b/src/Lumina.Contracts/Responses/FileManagement/FileResponse.cs @@ -0,0 +1,18 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Contracts.Models.FileManagement; +using System; +using System.Diagnostics; +#endregion + +namespace Lumina.Contracts.Responses.FileManagement; + +/// +/// Represents a response containing a file system file. +/// +/// The path of the file. +/// The name of the file. +/// The creation date of the file. +/// The modification date of the file. +/// The size of the file, in bytes. +[DebuggerDisplay("{Name} (File, Size: {Size} bytes)")] +public record FileResponse(string Path, string Name, DateTime DateCreated, DateTime DateModified, long Size) : FileSystemItemModel(Path, Name, DateCreated, DateModified); \ No newline at end of file diff --git a/src/Lumina.Presentation.Api/Core/Controllers/FileManagement/DirectoriesController.cs b/src/Lumina.Presentation.Api/Core/Controllers/FileManagement/DirectoriesController.cs index 87b89865..83752b8d 100644 --- a/src/Lumina.Presentation.Api/Core/Controllers/FileManagement/DirectoriesController.cs +++ b/src/Lumina.Presentation.Api/Core/Controllers/FileManagement/DirectoriesController.cs @@ -42,9 +42,9 @@ public class DirectoriesController : ApiController /// The path for which to get the directory tree. /// Cancellation token that can be used to stop the execution. [HttpGet("get-directory-tree")] - public async IAsyncEnumerable GetDirectoryTree([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, [EnumeratorCancellation] CancellationToken cancellationToken) + public async IAsyncEnumerable GetDirectoryTree([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, [FromQuery] bool includeFiles, [EnumeratorCancellation] CancellationToken cancellationToken) { - ErrorOr> result = await _mediator.Send(new GetDirectoryTreeQuery(path), cancellationToken).ConfigureAwait(false); + ErrorOr> result = await _mediator.Send(new GetDirectoryTreeQuery(path, includeFiles), cancellationToken).ConfigureAwait(false); if (!result.IsError && result.Value is not null) { foreach (var treeNode in result.Value) @@ -61,10 +61,30 @@ public class DirectoriesController : ApiController /// /// The path for which to get the directories. /// Cancellation token that can be used to stop the execution. - [HttpGet("get-directories")] - public async IAsyncEnumerable GetDirectories([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, [EnumeratorCancellation] CancellationToken cancellationToken) + [HttpGet("get-tree-directories")] + public async IAsyncEnumerable GetTreeDirectories([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, [EnumeratorCancellation] CancellationToken cancellationToken) { - ErrorOr> result = await _mediator.Send(new GetDirectoriesQuery(path), cancellationToken).ConfigureAwait(false); + ErrorOr> result = await _mediator.Send(new GetTreeDirectoriesQuery(path), cancellationToken).ConfigureAwait(false); + if (!result.IsError && result.Value is not null) + { + foreach (var directory in result.Value) + { + if (cancellationToken.IsCancellationRequested) + yield break; + yield return directory; + } + } + } + + /// + /// Gets the directories of . + /// + /// The path for which to get the directories. + /// Cancellation token that can be used to stop the execution. + [HttpGet("get-directories")] + public async IAsyncEnumerable GetDirectories([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, [EnumeratorCancellation] CancellationToken cancellationToken) + { + ErrorOr> result = await _mediator.Send(new GetDirectoriesQuery(path), cancellationToken).ConfigureAwait(false); if (!result.IsError && result.Value is not null) { foreach (var directory in result.Value) diff --git a/src/Lumina.Presentation.Api/Core/Controllers/FileManagement/FilesController.cs b/src/Lumina.Presentation.Api/Core/Controllers/FileManagement/FilesController.cs index b5b925a2..5dbcc690 100644 --- a/src/Lumina.Presentation.Api/Core/Controllers/FileManagement/FilesController.cs +++ b/src/Lumina.Presentation.Api/Core/Controllers/FileManagement/FilesController.cs @@ -1,4 +1,5 @@ #region ========================================================================= USING ===================================================================================== +using ErrorOr; using Lumina.Application.Core.FileManagement.Files.Queries; using Lumina.Contracts.Responses.FileManagement; using Lumina.Presentation.Api.Common.ModelBinders; @@ -41,10 +42,10 @@ public class FilesController : ApiController /// /// The path for which to get the files. /// Cancellation token that can be used to stop the execution. - [HttpGet("get-files")] - public async IAsyncEnumerable GetFiles([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, [EnumeratorCancellation] CancellationToken cancellationToken) + [HttpGet("get-tree-files")] + public async IAsyncEnumerable GetTreeFiles([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, [EnumeratorCancellation] CancellationToken cancellationToken) { - var result = await _mediator.Send(new GetFilesQuery(path), cancellationToken).ConfigureAwait(false); + ErrorOr> result = await _mediator.Send(new GetTreeFilesQuery(path), cancellationToken).ConfigureAwait(false); foreach (var file in result.Value) { if (cancellationToken.IsCancellationRequested) @@ -52,5 +53,25 @@ public class FilesController : ApiController yield return file; } } + + /// + /// Gets the files of . + /// + /// The path for which to get the files. + /// Cancellation token that can be used to stop the execution. + [HttpGet("get-files")] + public async IAsyncEnumerable GetFiles([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, [EnumeratorCancellation] CancellationToken cancellationToken) + { + ErrorOr> result = await _mediator.Send(new GetFilesQuery(path), cancellationToken).ConfigureAwait(false); + if (!result.IsError) + { + foreach (var file in result.Value) + { + if (cancellationToken.IsCancellationRequested) + yield break; + yield return file; + } + } + } #endregion } \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerServices.cs b/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerServices.cs index 62fec8ba..0ac63858 100644 --- a/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerServices.cs +++ b/src/Lumina.Presentation.Web/Common/DependencyInjection/PresentationWebLayerServices.cs @@ -26,11 +26,14 @@ public static class PresentationWebLayerServices { // scan the current assembly for validators and register them to the DI container services.AddValidatorsFromAssemblyContaining(ServiceLifetime.Singleton); - + // handle transient errors like network timeouts or intermittent failures var retryPolicy = Policy .Handle() - .OrResult(r => !r.IsSuccessStatusCode) + .OrResult(r => + !r.IsSuccessStatusCode && + r.StatusCode != HttpStatusCode.Forbidden && + r.StatusCode != HttpStatusCode.BadRequest) .WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))); diff --git a/src/Lumina.Presentation.Web/Common/Enums/FileSystem/FileSystemIconSize.cs b/src/Lumina.Presentation.Web/Common/Enums/FileSystem/FileSystemIconSize.cs new file mode 100644 index 00000000..9eac3cb3 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Enums/FileSystem/FileSystemIconSize.cs @@ -0,0 +1,27 @@ +namespace Lumina.Presentation.Web.Common.Enums.FileSystem; + +/// +/// Specifies the size options for file system icons. +/// +public enum FileSystemIconSize +{ + /// + /// Represents the smallest icon size, typically used in compact list views or when space is limited. + /// + Small, + + /// + /// Represents a medium-sized icon, balancing visibility and space efficiency. + /// + Medium, + + /// + /// Represents a large icon size, providing enhanced visibility and detail. + /// + Large, + + /// + /// Represents the largest icon size, offering maximum visibility and detail, suitable for high-resolution displays or thumbnail views. + /// + ExtraLarge +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Enums/FileSystem/FileSystemViewMode.cs b/src/Lumina.Presentation.Web/Common/Enums/FileSystem/FileSystemViewMode.cs new file mode 100644 index 00000000..8be7c1e3 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Enums/FileSystem/FileSystemViewMode.cs @@ -0,0 +1,22 @@ +namespace Lumina.Presentation.Web.Common.Enums.FileSystem; + +/// +/// Represents the different view modes for displaying file system items. +/// +public enum FileSystemViewMode +{ + /// + /// Displays file system items in a detailed view, typically including additional information such as file size, date modified, and permissions. + /// + Details, + + /// + /// Displays file system items in a compact list view, usually showing only the name of each item. + /// + List, + + /// + /// Displays file system items as icons, providing a visual representation of each item type. + /// + Icons +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Models/FileManagement/DirectoryModel.cs b/src/Lumina.Presentation.Web/Common/Models/FileManagement/DirectoryModel.cs new file mode 100644 index 00000000..6a5c5e46 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/FileManagement/DirectoryModel.cs @@ -0,0 +1,20 @@ +#region ========================================================================= USING ===================================================================================== +using System.Collections.Generic; +using System.Diagnostics; +#endregion + +namespace Lumina.Presentation.Web.Common.Models.FileManagement; + +/// +/// Model for directories displayed in custom directory/file browser dialogs. +/// +[DebuggerDisplay("{Path}")] +public class DirectoryModel : FileSystemItemModel +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets or sets the children items of the directory. + /// + public List Items { get; set; } = []; + #endregion +} diff --git a/src/Lumina.Presentation.Web/Common/Models/FileManagement/FileModel.cs b/src/Lumina.Presentation.Web/Common/Models/FileManagement/FileModel.cs new file mode 100644 index 00000000..b45db29d --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/FileManagement/FileModel.cs @@ -0,0 +1,19 @@ +#region ========================================================================= USING ===================================================================================== +using System.Diagnostics; +#endregion + +namespace Lumina.Presentation.Web.Common.Models.FileManagement; + +/// +/// Model for files displayed in custom directory/file browser dialogs. +/// +[DebuggerDisplay("{Path}")] +public class FileModel : FileSystemItemModel +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets or sets the size of the file, in bytes + /// + public long Size { get; set; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Models/FileManagement/FileSystemItemModel.cs b/src/Lumina.Presentation.Web/Common/Models/FileManagement/FileSystemItemModel.cs index 4d201622..360152a8 100644 --- a/src/Lumina.Presentation.Web/Common/Models/FileManagement/FileSystemItemModel.cs +++ b/src/Lumina.Presentation.Web/Common/Models/FileManagement/FileSystemItemModel.cs @@ -1,15 +1,16 @@ #region ========================================================================= USING ===================================================================================== using Lumina.Presentation.Web.Common.Enums.FileSystem; +using System; using System.Diagnostics; #endregion namespace Lumina.Presentation.Web.Common.Models.FileManagement; /// -/// Model for files and directories displayed in custom directory/file browser dialogs. +/// Base model for files and directories displayed in custom directory/file browser dialogs. /// [DebuggerDisplay("{Path}")] -public class FileSystemItemModel +public abstract class FileSystemItemModel { #region ==================================================================== PROPERTIES ================================================================================= /// @@ -18,23 +19,18 @@ public class FileSystemItemModel public string? Path { get; set; } /// - /// Gets the type of the file system element. + /// Gets or sets the name of the file system item. /// - public FileSystemItemType ItemType { get; set; } + public string? Name { get; set; } /// - /// Gets or sets the file extension of the item, if applicable (e.g., ".txt", ".jpg"). + /// Gets or sets the creation date of the file system item. /// - public string? Extension { get; set; } + public DateTime DateCreated { get; set; } /// - /// Gets or sets the source path or identifier for the icon representing the file system item. + /// Gets or sets the modification date of the file system item. /// - public string? IconSource { get; set; } - - /// - /// Gets or sets a friendly name for the file system item, which may be a user-friendly display name. - /// - public string? FriendlyName { get; set; } + public DateTime DateModified { get; set; } #endregion } \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Components/DirectoryBrowserComponent.razor b/src/Lumina.Presentation.Web/Components/DirectoryBrowserComponent.razor deleted file mode 100644 index c6de661f..00000000 --- a/src/Lumina.Presentation.Web/Components/DirectoryBrowserComponent.razor +++ /dev/null @@ -1,319 +0,0 @@ -@using Lumina.Presentation.Web.Common.Api -@using Lumina.Presentation.Web.Common.Enums.FileSystem -@using Lumina.Presentation.Web.Common.Exceptions -@using Lumina.Presentation.Web.Common.Models.Common -@using Lumina.Presentation.Web.Common.Models.FileManagement -@using Lumina.Presentation.Web.Common.Models.UI -@using Microsoft.AspNetCore.Components - -@inject IJSRuntime JSRuntime -@inject IApiHttpClient _apiHttpClient - -
-
-
-
-
-
- - - - - -
-
-
- -
-
-
- @foreach (FileSystemTreeNodeModel node in treeViewRootNodes) - { - - } -
-
- -
-
-
-
- -
-
-
- - -
-
- Cancel - Open -
-
-
- - - @*
- - - Cancel - Confirm *@ -
- - -@if (showPathSegmentDowpDown && expandedPathSegmentIndex.HasValue && pathSegmentsSubdirectoriesCache.ContainsKey(expandedPathSegmentIndex.Value)) -{ - -} -@code { - [Parameter] - public string? Path { get; set; } - - public EventCallback OnNodeSelected { get; set; } - - private List treeViewRootNodes = []; - private FileSystemTypeModel fileSystemType = null!; - private ComboboxItem? selectedValue; - private PathSegmentModel[]? pathSegments; - private string pathSeparator = "/"; - private string? selectedNodePath; - private string? _path; - private bool showPathSegmentDowpDown; - private int? expandedPathSegmentIndex; - private Dictionary> pathSegmentsSubdirectoriesCache = []; - - - /// - /// Initializes the component. - /// - protected override async Task OnInitializedAsync() - { - fileSystemType = await _apiHttpClient.GetAsync("file-system/get-type").ConfigureAwait(false); - // ask the API server for the system path separator - PathSeparatorModel apiPathSeparator = await _apiHttpClient.GetAsync("path/get-path-separator").ConfigureAwait(false); - pathSeparator = apiPathSeparator.Separator; // TODO: handle error - - // treeview - // on Windows, ask the list of drives - if (fileSystemType?.PlatformType == PlatformType.Windows) - { - List drives = await _apiHttpClient.GetAsync>("drives/get-drives").ConfigureAwait(false); - treeViewRootNodes.AddRange(drives); - } - else - { - // on UNIX, just add the root "/" - treeViewRootNodes.Add(new FileSystemTreeNodeModel() - { - Path = pathSeparator!, - IsExpanded = true, - ItemType = FileSystemItemType.Root, - Name = pathSeparator! - }); - } - if (Path is not null) - { - var isPathValidResponse = await _apiHttpClient.GetAsync($"path/validate?path={Uri.EscapeDataString(Path)}").ConfigureAwait(false); - if (!isPathValidResponse.IsValid) - { - // TODO: display error message to user - Console.WriteLine("specified path is not valid!"); - } - else - { - // if there was an initial path saved from a previous session, load the full tree up to that initial path - // ask the whole tree for the saved path - List initialTree = await _apiHttpClient.GetAsync>($"directories/get-directory-tree?path={Uri.EscapeDataString(Path!)}").ConfigureAwait(false); - if (initialTree is not null && initialTree.Count > 0) - { - pathSegments = await _apiHttpClient.GetAsync($"path/split?path={Uri.EscapeDataString(Path!)}").ConfigureAwait(false); - StateHasChanged(); - // take the root of the retrieved tree, and try to match it against a drive in the retrieved list of drives, on Windows; on Unix, add it as the unique root path - PathSegmentModel pathRoot = await _apiHttpClient.GetAsync($"path/get-path-root?path={Uri.EscapeDataString(Path!)}").ConfigureAwait(false); - if (fileSystemType?.PlatformType == PlatformType.Windows) - { - FileSystemTreeNodeModel? driveNode = treeViewRootNodes.FirstOrDefault(drive => drive.Path.Equals(pathRoot.Path, StringComparison.OrdinalIgnoreCase)); - // if a drive was matched, make the retrieved tree a child of it - if (driveNode is not null) - { - int index = treeViewRootNodes.IndexOf(driveNode); - treeViewRootNodes[index] = initialTree[0]; - } - } - else - treeViewRootNodes[0] = initialTree[0]; - } - } - } - await JSRuntime.InvokeVoidAsync("makeAddressBarHorizontallyScrollable").ConfigureAwait(false); - } - - /// - /// Expands or collapses a node in the tree view. - /// - /// The node to expand or collapse. - private async Task ExpandNode(FileSystemTreeNodeModel node) - { - if (!node.IsExpanded && !node.ChildrenLoaded) - { - node.Children = new List(); - node.IsExpanded = true; - StateHasChanged(); - try - { - await foreach (FileSystemTreeNodeModel? childNode in _apiHttpClient.GetAsyncEnumerable($"directories/get-directories?path={Uri.EscapeDataString(node.Path)}").ConfigureAwait(false)) - { - if (childNode is not null) - { - node.Children.Add(childNode); - StateHasChanged(); - } - } - await foreach (FileSystemTreeNodeModel? childNode in _apiHttpClient.GetAsyncEnumerable($"files/get-files?path={Uri.EscapeDataString(node.Path)}").ConfigureAwait(false)) - { - if (childNode is not null) - { - node.Children.Add(childNode); - StateHasChanged(); - } - } - } - catch (Exception ex) - { - Console.Error.WriteLine($"Error expanding node: {ex.Message}"); // TODO: display to the user when notification system is implemented - } - finally - { - node.ChildrenLoaded = true; - } - } - else - node.IsExpanded = !node.IsExpanded; - StateHasChanged(); - } - - /// - /// Handles the selection of a node in the tree view. - /// - /// The path of the selected node. - private async Task HandleNodeSelected(string path) - { - selectedNodePath = path; - Console.WriteLine($"Selected node: {path}"); - await OnNodeSelected.InvokeAsync(path).ConfigureAwait(false); - } - - /// - /// Handles the change event. - /// - /// The event arguments. - private async Task OnNavigatorPathSegmentCheckChangeHandler(ChangeEventArgs e, int toggledIndex) - { - await JSRuntime.InvokeVoidAsync("uncheckAllExcept", $"segment-toggle-{toggledIndex}").ConfigureAwait(false); - // check if the checkbox is checked - bool isChecked = (bool)e.Value!; - showPathSegmentDowpDown = isChecked; - expandedPathSegmentIndex = null; - // if it's checked, get the subdirectories for the toggled path segment - if (isChecked && pathSegments?.Length > 0) - { - // initialize the path with the first segment - string concatenatedPath = pathSegments[0].Path; - // concatenate only up to the toggled index - for (int i = 1; i <= toggledIndex; i++) - concatenatedPath = $"{(concatenatedPath != pathSeparator ? concatenatedPath : string.Empty)}{pathSeparator}{pathSegments[i].Path}"; - string parentConcatenatedPath = concatenatedPath; - try - { - if (concatenatedPath != pathSeparator) // on UNIX, dont get the parent, if we are at root path - { - List parentLocation = await _apiHttpClient.GetAsync>($"path/get-path-parent?path={Uri.EscapeDataString(concatenatedPath)}").ConfigureAwait(false); - parentConcatenatedPath = parentLocation[0].Path; - for (int i = 1; i < parentLocation.Count; i++) - parentConcatenatedPath = $"{(parentConcatenatedPath != pathSeparator ? parentConcatenatedPath : string.Empty)}{pathSeparator}{pathSegments[i].Path}"; - } - } - catch (ApiException ex) - { - Console.WriteLine(ex.Message); - } - // fetch directories for the expanded path segment - List directories = [ - new() { Path = concatenatedPath, Name = ".", }, // current directory - new() { Path = parentConcatenatedPath, Name = ".." } // parent directory - ]; - // add the rest of the subdirectories of the expanded path node - await foreach (FileSystemTreeNodeModel? directory in _apiHttpClient.GetAsyncEnumerable($"directories/get-directories?path={Uri.EscapeDataString(concatenatedPath)}").ConfigureAwait(false)) - if (directory is not null) - directories.Add(directory); - // store the directories for this segment - pathSegmentsSubdirectoriesCache[toggledIndex] = directories; - expandedPathSegmentIndex = toggledIndex; - StateHasChanged(); - // invoke the javascript function that positions the dropdown underneath the toggled path segment - await JSRuntime.InvokeVoidAsync("updateDropdownPosition", $"path-segment-{toggledIndex}").ConfigureAwait(false); - } - else - StateHasChanged(); - } -} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Components/EnlightenmentInput.razor b/src/Lumina.Presentation.Web/Components/EnlightenmentInput.razor index 02dcc8ba..d59ddca6 100644 --- a/src/Lumina.Presentation.Web/Components/EnlightenmentInput.razor +++ b/src/Lumina.Presentation.Web/Components/EnlightenmentInput.razor @@ -1,10 +1,14 @@ - 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; } /// - /// Handles the input event. + /// Handles the input change event. /// /// The event arguments. private async Task OnInputHandlerAsync(ChangeEventArgs e) @@ -35,4 +41,24 @@ Value = e.Value?.ToString(); await ValueChanged.InvokeAsync(Value).ConfigureAwait(false); } + + /// + /// Handles the key press event. + /// + /// The event arguments. + private async Task OnKeyPressAsync(KeyboardEventArgs e) + { + if (e.Key == "Enter") + await OnEnterPressed.InvokeAsync(); + } + + /// + /// Handles the key down event. + /// + /// The event arguments. + private async Task OnKeyDownAsync(KeyboardEventArgs e) + { + if (e.Key == "Escape") + await OnEscapePressed.InvokeAsync(Value); + } } \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Components/FileSystemBrowserComponent.razor b/src/Lumina.Presentation.Web/Components/FileSystemBrowserComponent.razor new file mode 100644 index 00000000..4c9fcd84 --- /dev/null +++ b/src/Lumina.Presentation.Web/Components/FileSystemBrowserComponent.razor @@ -0,0 +1,506 @@ +@using Lumina.Presentation.Web.Common.Api +@using Lumina.Presentation.Web.Common.Enums.FileSystem +@using Lumina.Presentation.Web.Common.Exceptions +@using Lumina.Presentation.Web.Common.Models.Common +@using Lumina.Presentation.Web.Common.Models.FileManagement +@using Lumina.Presentation.Web.Common.Models.UI +@using Microsoft.AspNetCore.Components + +@inject IJSRuntime JSRuntime +@inject IApiHttpClient _apiHttpClient + +
+
+
+
+
+
+ + + + + +
+
+
+ +
+
+
+ @foreach (FileSystemTreeNodeModel node in treeViewRootNodes) + { + + } +
+
+ +
+ +
+
+
+
+ Name +
+
+ @foreach (FileSystemItemModel fileSystemItem in fileSystemItems) + { + string iconSizeClass = "list-icons"; + if (viewMode == FileSystemViewMode.Details) + iconSizeClass = "details-icons"; + else if (viewMode == FileSystemViewMode.Icons) + { + if (iconSize == FileSystemIconSize.Small) + iconSizeClass = "small-icons"; + else if (iconSize == FileSystemIconSize.Medium) + iconSizeClass = "medium-icons"; + else if (iconSize == FileSystemIconSize.Large) + iconSizeClass = "large-icons"; + else if (iconSize == FileSystemIconSize.ExtraLarge) + iconSizeClass = "extra-large-icons"; + } + string itemType = fileSystemItem is FileModel ? "file" : "directory"; +
+
+
@fileSystemItem.Name
+ + +
+ } +
+
+
+
+
+
+
+ + +
+
+ Cancel + Open +
+
+
+ @*
+ + + Cancel + Confirm *@ +
+ + +@if (showPathSegmentDowpDown && expandedPathSegmentIndex.HasValue && pathSegmentsSubdirectoriesCache.ContainsKey(expandedPathSegmentIndex.Value)) +{ + +} +@code { + [Parameter] public string? Path { get; set; } + [Parameter] public bool IncludeFiles { get; set; } + + public EventCallback OnNodeSelected { get; set; } + + private List treeViewRootNodes = []; + private List fileSystemItems = []; + private FileSystemTypeModel fileSystemType = null!; + private ComboboxItem? selectedValue; + private PathSegmentModel[]? pathSegments; + private string pathSeparator = "/"; + private string? selectedNodePath; + private string? _path; + private bool showPathSegmentDowpDown; + private bool isNavigationPathEditMode; + private int? expandedPathSegmentIndex; + private FileSystemViewMode viewMode = FileSystemViewMode.List; // TODO: take from config + private FileSystemIconSize iconSize; + private Dictionary> pathSegmentsSubdirectoriesCache = []; + + /// + /// Initializes the component. + /// + protected override async Task OnInitializedAsync() + { + await GetFileSystemPropertiesAsync().ConfigureAwait(false); + if (Path is not null) + await NavigateToPathAsync(Path).ConfigureAwait(false); + await ChangeViewModeAsync(viewMode).ConfigureAwait(false); + // make the navigator path segments horizontally scrollable + await JSRuntime.InvokeVoidAsync("addHorizontalScrolling", "navigator-address-bar").ConfigureAwait(false); + } + + /// + /// Expands or collapses a node in the tree view. + /// + /// The node to expand or collapse. + private async Task ExpandNode(FileSystemTreeNodeModel node) + { + if (!node.IsExpanded && !node.ChildrenLoaded) + { + node.Children = new List(); + node.IsExpanded = true; + StateHasChanged(); + try + { + await foreach (FileSystemTreeNodeModel? childNode in _apiHttpClient.GetAsyncEnumerable($"directories/get-tree-directories?path={Uri.EscapeDataString(node.Path)}").ConfigureAwait(false)) + { + if (childNode is not null) + { + node.Children.Add(childNode); + StateHasChanged(); + } + } + if (IncludeFiles) + { + await foreach (FileSystemTreeNodeModel? childNode in _apiHttpClient.GetAsyncEnumerable($"files/get-tree-files?path={Uri.EscapeDataString(node.Path)}").ConfigureAwait(false)) + { + if (childNode is not null) + { + node.Children.Add(childNode); + StateHasChanged(); + } + } + } + } + catch (Exception ex) + { + Console.Error.WriteLine($"Error expanding node: {ex.Message}"); // TODO: display to the user when notification system is implemented + } + finally + { + node.ChildrenLoaded = true; + } + } + else + node.IsExpanded = !node.IsExpanded; + StateHasChanged(); + } + + /// + /// Handles the selection of a node in the tree view. + /// + /// The path of the selected node. + private async Task NavigateToPathAsync(string path) + { + selectedNodePath = path; + if (await CheckPathAsync(path).ConfigureAwait(false)) + { + _path = path; + await GetNavigatorPathAsync(path).ConfigureAwait(false); + await GetFileSystemTreeViewAsync(path).ConfigureAwait(false); + await GetFileSystemItemsAsync(path).ConfigureAwait(false); + Console.WriteLine($"Selected node: {path}"); + } + await OnNodeSelected.InvokeAsync(path).ConfigureAwait(false); + } + + /// + /// Gets the properties of the file system. + /// + private async Task GetFileSystemPropertiesAsync() + { + fileSystemType = await _apiHttpClient.GetAsync("file-system/get-type").ConfigureAwait(false); + // ask the API server for the system path separator + PathSeparatorModel apiPathSeparator = await _apiHttpClient.GetAsync("path/get-path-separator").ConfigureAwait(false); + pathSeparator = apiPathSeparator.Separator; // TODO: handle error + } + + /// + /// Checks if the specified path is a valid file system path. + /// + /// The path to check. + /// if the specified path is valid, otherwise. + private async Task CheckPathAsync(string path) + { + var isPathValidResponse = await _apiHttpClient.GetAsync($"path/validate?path={Uri.EscapeDataString(path)}").ConfigureAwait(false); + if (!isPathValidResponse.IsValid) + { + // TODO: display error message to user + Console.WriteLine("specified path is not valid!"); + } + return isPathValidResponse.IsValid; + } + + /// + /// Gets the navigator path segments. + /// + /// The path for which to get the navigator path segments. + private async Task GetNavigatorPathAsync(string path) + { + pathSegments = await _apiHttpClient.GetAsync($"path/split?path={Uri.EscapeDataString(path!)}").ConfigureAwait(false); + StateHasChanged(); + } + + /// + /// Gets the file system items that are displayed in the file system tree view pane. + /// + /// The path for which to get the file system items. + private async Task GetFileSystemTreeViewAsync(string path) + { + treeViewRootNodes = []; + // on Windows, ask the list of drives + if (fileSystemType?.PlatformType == PlatformType.Windows) + { + List drives = await _apiHttpClient.GetAsync>("drives/get-drives").ConfigureAwait(false); + treeViewRootNodes.AddRange(drives); + } + else + { + // on UNIX, just add the root "/" + treeViewRootNodes.Add(new FileSystemTreeNodeModel() + { + Path = pathSeparator!, + IsExpanded = true, + ItemType = FileSystemItemType.Root, + Name = pathSeparator! + }); + } + // if there was an initial path saved from a previous session, load the full tree up to that initial path + // ask the whole tree for the saved path + List initialTree = await _apiHttpClient.GetAsync>($"directories/get-directory-tree?path={Uri.EscapeDataString(path!)}&includeFiles={IncludeFiles}").ConfigureAwait(false); + if (initialTree is not null && initialTree.Count > 0) + { + // take the root of the retrieved tree, and try to match it against a drive in the retrieved list of drives, on Windows; on Unix, add it as the unique root path + PathSegmentModel pathRoot = await _apiHttpClient.GetAsync($"path/get-path-root?path={Uri.EscapeDataString(path!)}").ConfigureAwait(false); + if (fileSystemType?.PlatformType == PlatformType.Windows) + { + FileSystemTreeNodeModel? driveNode = treeViewRootNodes.FirstOrDefault(drive => drive.Path.Equals(pathRoot.Path, StringComparison.OrdinalIgnoreCase)); + // if a drive was matched, make the retrieved tree a child of it + if (driveNode is not null) + { + int index = treeViewRootNodes.IndexOf(driveNode); + treeViewRootNodes[index] = initialTree[0]; + } + } + else + treeViewRootNodes[0] = initialTree[0]; + } + } + + /// + /// Retrieves the files and directories for the specified path. + /// + /// The path for which to get the files and directories. + private async Task GetFileSystemItemsAsync(string path) + { + fileSystemItems.Clear(); + try + { + await foreach (DirectoryModel? directory in _apiHttpClient.GetAsyncEnumerable($"directories/get-directories?path={Uri.EscapeDataString(path)}").ConfigureAwait(false)) + { + if (directory is not null) + { + fileSystemItems.Add(directory); + StateHasChanged(); + } + } + if (IncludeFiles) + { + await foreach (FileModel? file in _apiHttpClient.GetAsyncEnumerable($"files/get-files?path={Uri.EscapeDataString(path)}").ConfigureAwait(false)) + { + if (file is not null) + { + fileSystemItems.Add(file); + StateHasChanged(); + } + } + } + } + catch (ApiException ex) + { + Console.Error.WriteLine($"Error expanding node: {ex.Message}"); // TODO: display to the user when notification system is implemented + } + } + + /// + /// Handles the change event. + /// + /// The event arguments. + private async Task OnNavigatorPathSegmentCheckChangeHandler(ChangeEventArgs e, int toggledIndex) + { + // uncheck all other path segment checkboxes + await JSRuntime.InvokeVoidAsync("uncheckAllExcept", $"segment-toggle-{toggledIndex}").ConfigureAwait(false); + // check if the checkbox is checked + bool isChecked = (bool)e.Value!; + showPathSegmentDowpDown = isChecked; + expandedPathSegmentIndex = null; + // if it's checked, get the subdirectories for the toggled path segment + if (isChecked && pathSegments?.Length > 0) + { + // initialize the path with the first segment + string concatenatedPath = pathSegments[0].Path; + // concatenate only up to the toggled index + for (int i = 1; i <= toggledIndex; i++) + concatenatedPath = $"{(concatenatedPath != pathSeparator ? concatenatedPath : string.Empty)}{pathSeparator}{pathSegments[i].Path}"; + string parentConcatenatedPath = concatenatedPath; + try + { + if (concatenatedPath != pathSeparator) // on UNIX, dont get the parent, if we are at root path + { + List parentLocation = await _apiHttpClient.GetAsync>($"path/get-path-parent?path={Uri.EscapeDataString(concatenatedPath)}").ConfigureAwait(false); + parentConcatenatedPath = parentLocation[0].Path; + for (int i = 1; i < parentLocation.Count; i++) + parentConcatenatedPath = $"{(parentConcatenatedPath != pathSeparator ? parentConcatenatedPath : string.Empty)}{pathSeparator}{pathSegments[i].Path}"; + } + } + catch (ApiException ex) + { + Console.WriteLine(ex.Message); + } + if (!concatenatedPath.EndsWith(pathSeparator)) + concatenatedPath += pathSeparator; + // fetch directories for the expanded path segment + List directories = [ + new() { Path = concatenatedPath, Name = ".", }, // current directory + new() { Path = parentConcatenatedPath, Name = ".." } // parent directory + ]; + // add the rest of the subdirectories of the expanded path node + await foreach (FileSystemTreeNodeModel? directory in _apiHttpClient.GetAsyncEnumerable($"directories/get-tree-directories?path={Uri.EscapeDataString(concatenatedPath)}").ConfigureAwait(false)) + if (directory is not null) + directories.Add(directory); + // store the directories for this segment + pathSegmentsSubdirectoriesCache[toggledIndex] = directories; + expandedPathSegmentIndex = toggledIndex; + StateHasChanged(); + // invoke the javascript function that positions the dropdown underneath the toggled path segment + await JSRuntime.InvokeVoidAsync("updateDropdownPosition", $"path-segment-{toggledIndex}").ConfigureAwait(false); + } + else + StateHasChanged(); + } + + /// + /// Changes the current file system explorer view. + /// + /// The new explorer view to change to. + private async Task ChangeViewModeAsync(FileSystemViewMode newViewMode) + { + viewMode = newViewMode; + if (viewMode == FileSystemViewMode.List) + await JSRuntime.InvokeVoidAsync("addHorizontalScrolling", "file-system-browser-file-system-explorer").ConfigureAwait(false); + else + await JSRuntime.InvokeVoidAsync("removeHorizontalScrolling", "file-system-browser-file-system-explorer").ConfigureAwait(false); + StateHasChanged(); + } + + /// + /// Changes the icon size for the file system items. + /// + /// Thew new icon size to change to. + private void ChangeIconSize(FileSystemIconSize newIconSize) + { + viewMode = FileSystemViewMode.Icons; + iconSize = newIconSize; + StateHasChanged(); + } + + /// + /// Enters the edit mode where the navigator path can be edited freely. + /// + private async Task EnterNavigationPathEditModeAsync() + { + isNavigationPathEditMode = true; + StateHasChanged(); + await InvokeAsync(async () => + { + await Task.Delay(50); // a small delay is necessary to ensure the DOM has updated + await SetFocusOnNavigatorAddressInputAsync().ConfigureAwait(false); + }); + } + + /// + /// Exits the edit mode where the navigator path can be edited freely. + /// + private async Task ExitNavigationPathEditModeAsync() + { + isNavigationPathEditMode = false; + StateHasChanged(); + if (Path is not null) + await NavigateToPathAsync(Path).ConfigureAwait(false); + } + + /// + /// Handles the Escape key being pressed in the navigator address input. + /// + private void HandleNavigatorInputEscapePressed() + { + Path = _path; + isNavigationPathEditMode = false; + StateHasChanged(); + } + + /// + /// Sets the focus to the navigator address input. + /// + public async Task SetFocusOnNavigatorAddressInputAsync() + { + await JSRuntime.InvokeVoidAsync("focusNavigatorInputElement"); + } +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Components/DirectoryBrowserComponent.razor.css b/src/Lumina.Presentation.Web/Components/FileSystemBrowserComponent.razor.css similarity index 61% rename from src/Lumina.Presentation.Web/Components/DirectoryBrowserComponent.razor.css rename to src/Lumina.Presentation.Web/Components/FileSystemBrowserComponent.razor.css index 5c095121..27d1909d 100644 --- a/src/Lumina.Presentation.Web/Components/DirectoryBrowserComponent.razor.css +++ b/src/Lumina.Presentation.Web/Components/FileSystemBrowserComponent.razor.css @@ -1,4 +1,4 @@ -#directory-browser-dialog { +#file-system-browser-dialog { position: absolute; top: 12.5%; bottom: 12.5%; @@ -9,7 +9,7 @@ box-shadow: 30px 30px 25px var(--shadow-color); } -#directory-browser-content { +#file-system-browser-content { margin: 0px; height: 100%; display: flex; @@ -18,11 +18,11 @@ align-items: center; align-content: center; gap: 0px; - flex: 1; + flex-grow: 1; min-height: 0; } -#directory-browser-header { +#file-system-browser-header { border-radius: 5px 5px 0 0; border: 1px solid; background: linear-gradient(to bottom, #505050 0%, #464646 35%, #404040 55%, #363636 100%); @@ -37,7 +37,7 @@ width: 100%; } -#directory-browser-header-navigation-container { +#file-system-browser-header-navigation-container { display: flex; flex-direction: row; flex-wrap: nowrap; @@ -48,7 +48,7 @@ margin: 5px; } -#directory-browser-header-address-bar-container { +#file-system-browser-header-address-bar-container { display: flex; flex-direction: row; flex-wrap: nowrap; @@ -58,13 +58,13 @@ flex-grow: 1; } -.directory-browser-header-address-bar-url { +.file-system-browser-header-address-bar-url { flex-grow: 1; flex-shrink: 1; min-width: 0; } -::deep .directory-browser-content-new-directory { +::deep .file-system-browser-content-new-directory { min-width: 35px; flex-basis: 35px; flex-shrink: 0; @@ -82,12 +82,12 @@ cursor: not-allowed; } -.directory-browser-header-navigation { +.file-system-browser-header-navigation { display: flex; gap: 5px; } -.directory-browser-header-address-bar-actions { +.file-system-browser-header-address-bar-actions { display: flex; align-items: center; gap: 5px; @@ -103,7 +103,7 @@ transition: filter 0.3s ease; } -#directory-browser-file-system-container { +#file-system-browser-file-system-container { width: 100%; flex-grow: 1; display: flex; @@ -112,11 +112,10 @@ align-items: stretch; overflow: hidden; gap: 0px; - flex: 1; min-height: 0; } -#directory-browser-file-system-treeview-container { +#file-system-browser-file-system-treeview-container { background-color: #131313; border-top: 1px solid var(--border-color-light); border-left: 1px solid var(--border-color-light); @@ -126,7 +125,7 @@ width: 400px; height: 100%; max-height: 100%; - flex-grow: 0; + flex-shrink: 0; display: flex; flex-direction: column; flex-wrap: nowrap; @@ -137,7 +136,7 @@ min-height: 0; } -#directory-browser-file-system-treeview { +#file-system-browser-file-system-treeview { background-color: #131313; border: 1px solid var(--border-color-light); border-top: 1px solid var(--border-color-dark); @@ -151,21 +150,20 @@ min-height: 0; } -::deep .directory-browser-file-system-sources { +::deep .file-system-browser-file-system-sources { flex-grow: 0; } -#directory-browser-file-system-directories-container { +#file-system-browser-file-system-directories-container { background-color: #131313; border-top: 1px solid var(--border-color-light); border-left: 1px solid var(--border-color-light-medium); flex-grow: 1; min-width: 135px; padding: 10px; - height: 100%; } -#directory-browser-file-system-directories { +#file-system-browser-file-system-directories { background-color: #262626; border: 1px solid var(--border-color-light); border-top: 1px solid var(--border-color-dark); @@ -173,9 +171,349 @@ width: 100%; height: 100%; box-shadow: inset 2px 2px 5px var(--shadow-color); + + + margin: auto; + width: 100%; + height: 100%; + + display: flex; + flex-direction: row; + flex-wrap: nowrap; + justify-content: left; + align-items: stretch; } -#directory-browser-actions-container { +#file-system-browser-file-system-explorer-container { + background-color: #232323; + /*border-right-color: #000000; + border-right-style: solid; + border-right-width: 1px; + border-left-color: #777777; + border-left-style: solid; + border-left-width: 1px;*/ + margin: auto; + width: 100%; + height: 100%; +} + +#file-system-browser-file-system-explorer-details-header { + color: deepskyblue; +} + +#file-system-browser-file-system-explorer { + +} + +div[id^="file-system-browser-file-system-explorer"]:not([id*="container"]) { + margin: 1px; + display: flex; + flex-direction: column; + flex-wrap: wrap; + border: 0px solid black; + padding: 0px; + gap: 0px 10px; +} + +.details { + width: 100% !important; + overflow-x: hidden; + height: auto !important; +} + +.list { + width: auto !important; + overflow-x: auto; + height: 100% !important; +} + +/*filesystem element*/ +.e { + font-family: monospace; + min-height: 16px; + white-space: nowrap; + padding: 1px 5px 1px 1px; + background-color: #191E21; + border-bottom-color: #000000; + border-bottom-style: solid; + border-bottom-width: 1px; + border-top-color: #444444; + border-top-style: solid; + border-top-width: 1px; + border-right-color: #000000; + border-right-style: solid; + border-right-width: 1px; + border-left-color: #444444; + border-left-style: solid; + border-left-width: 1px; + display: flex; + align-items: center; + user-select: none; +} + + .e.details-icons { + width: 100%; + display: flex; + align-items: center; + } + + .e.small-icons { + width: 320px; + align-items: center; + } + + .e.medium-icons { + width: 74px; + height: 115px; + flex-direction: column; + align-items: center; + padding: 5px; + } + + .e.large-icons { + width: 105px; + height: 161px; + flex-direction: column; + align-items: center; + padding: 5px; + } + + .e.extra-large-icons { + width: 270px; + height: 290px; + flex-direction: column; + align-items: center; + padding: 5px; + } + + .e.list-icons .icon { + width: 16px; + height: 16px; + display: flex; + align-items: center; + margin-right: 3px; + } + + .e.details-icons .icon { + width: 16px; + height: 16px; + display: flex; + align-items: center; + margin-right: 3px; + display: flex; + justify-content: center; + } + + .e.small-icons .icon { + width: 16px; + height: 16px; + display: flex; + align-items: center; + margin-right: 3px; + } + + .e.medium-icons .icon { + width: 100%; + height: 48px; + display: flex; + justify-content: center; + align-items: center; + padding-bottom: 5px; + } + + .e.large-icons .icon { + width: 100%; + height: 90px; + display: flex; + justify-content: center; + align-items: center; + padding-bottom: 5px; + } + + .e.extra-large-icons .icon { + width: 100%; + height: 240px; + display: flex; + justify-content: center; + align-items: center; + padding-bottom: 5px; + } + + .e.list-icons .icon img { + height: 16px; + width: 16px; + } + + .e.details-icons .icon img { + height: 16px; + width: 16px; + } + + .e.small-icons .icon img { + height: 16px; + width: 16px; + } + + .e.medium-icons .icon img { + height: 48px; + width: auto; + max-width: 100%; + } + + .e.large-icons .icon img { + height: 90px; + width: auto; + max-width: 100%; + } + + .e.extra-large-icons .icon img { + height: 240px; + width: auto; + max-width: 100%; + } + + .e.small-icons .text { + width: 293px; + display: flex; + align-items: center; + } + + .e.medium-icons .text { + width: 74px; + height: 67px; + display: flex; + justify-content: center; + align-items: center; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + + .e.large-icons .text { + width: 94px; + height: 66px; + display: flex; + justify-content: center; + align-items: center; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + + .e.extra-large-icons .text { + width: 256px; + height: 36px; + display: flex; + justify-content: center; + align-items: center; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + + .e.details-icons .text span { + overflow: hidden; + text-overflow: ellipsis; + } + + .e.small-icons .text span { + overflow: hidden; + text-overflow: ellipsis; + } + + .e.medium-icons .text span { + max-width: 74px; + max-height: 67px; + display: block; + white-space: pre-wrap; + word-wrap: break-word; + } + + .e.large-icons .text span { + max-width: 94px; + max-height: 66px; + display: block; + white-space: pre-wrap; + word-wrap: break-word; + } + + .e.extra-large-icons .text span { + max-width: 256px; + max-height: 36px; + display: block; + white-space: pre-wrap; + word-wrap: break-word; + } + + .e.details-icons .date-modified, + .e.details-icons .type, + .e.details-icons .size { + display: flex; + align-items: center; + padding-left: 10px; + overflow: hidden; + text-overflow: ellipsis; + text-align: right; + white-space: nowrap; + } + + .e.details-icons .text { + flex-grow: 1; + display: flex; + align-items: center; + padding-left: 1px; + } + + .e.details-icons .date-modified { + width: 180px; + padding-left: 10px; + } + + .e.details-icons .type { + width: 200px; + padding-left: 10px; + } + + .e.details-icons .size { + width: 100px; + padding-left: 10px; + padding-right: 10px; + display: flex; + justify-content: flex-end; + } + + .e:nth-child(even) { + background-color: #28292B; + } + + .e:hover { + background-color: #404040; + border-top-color: #999999; + border-left-color: #999999; + } + + .e.selected { + background-color: #4D4D4D; + border-top-color: #999999; + border-left-color: #999999; + } + +/*directory*/ +.d { + color: #6DCBFE; +} + +/*file*/ +.f { + color: #BBBBBB; +} + +/*filesystem item text*/ +.t { + user-select: none; +} + +#file-system-browser-actions-container { flex-grow: 0; display: flex; flex-direction: column; @@ -186,7 +524,7 @@ width: 100%; } -#directory-browser-actions { +#file-system-browser-actions { flex-grow: 0; display: flex; flex-direction: row; @@ -196,7 +534,7 @@ width: 100%; } -#directory-browser-actions-path-container { +#file-system-browser-actions-path-container { margin-top: 5px; display: flex; flex-direction: row; @@ -206,7 +544,7 @@ width: 100%; } -#directory-browser-shine-effect { +#file-system-browser-shine-effect { background: linear-gradient(to right, transparent, #fff, transparent); width: 100%; height: 1px; @@ -214,7 +552,7 @@ pointer-events: none; /* ensure it doesn't interfere with interactions */ } -#directory-browser-shine-spark { +#file-system-browser-shine-spark { position: absolute; top: -2px; left: -20px; /* start off-screen */ @@ -227,7 +565,7 @@ animation: spark-animation 30s cubic-bezier(0.25, 0.9, 0.9, 0.1) infinite; } - #directory-browser-shine-spark::before { + #file-system-browser-shine-spark::before { content: ''; position: absolute; top: 50%; @@ -241,7 +579,7 @@ animation: star-rotation 5s linear infinite; } - #directory-browser-shine-spark::after { + #file-system-browser-shine-spark::after { content: ''; position: absolute; top: 50%; @@ -325,12 +663,12 @@ } ::deep .navigator-navigate-button, -::deep .directory-browser-content-new-directory { +::deep .file-system-browser-content-new-directory { margin: 0px 10px 2px 0px; flex-shrink: 0; } -::deep .directory-browser-content-favorite-directory { +::deep .file-system-browser-content-favorite-directory { margin: 0px 2px 2px 0px; flex-shrink: 0; } @@ -411,7 +749,6 @@ ::deep .navigator-address-bar-input { - display: none; width: 100%; } @@ -508,7 +845,7 @@ } .navigator-selected-text { - flex: 1; + flex-grow: 1; text-align: right; white-space: nowrap; } @@ -618,30 +955,41 @@ opacity: 1; } + +.scroll-vertical { + overflow-x: hidden; + overflow-y: auto; +} + +.scroll-horizontal { + overflow-x: auto; + overflow-y: hidden; +} + @media screen and (max-width: 768px) { - #directory-browser-dialog { + #file-system-browser-dialog { top: 0; bottom: 0; left: 0; right: 0; } - #directory-browser-header { + #file-system-browser-header { height: auto; } - #directory-browser-header-navigation-container { + #file-system-browser-header-navigation-container { flex-wrap: wrap; align-items: flex-start; } #navigator-view-mode-container { - flex: 1; + flex-grow: 1; order: 1; } #navigator-navigation-controls-container { - flex: 1; + flex-grow: 1; order: 2; /*text-align: right;*/ justify-content: flex-end; @@ -653,31 +1001,31 @@ order: 3; } - #directory-browser-header-address-bar-container { + #file-system-browser-header-address-bar-container { flex-direction: column; align-items: stretch; width: 100%; } - .directory-browser-header-address-bar-url { + .file-system-browser-header-address-bar-url { width: 100%; margin-bottom: 5px; } - .directory-browser-header-navigation { + .file-system-browser-header-navigation { display: flex; gap: 5px; margin-bottom: 5px; } - .directory-browser-header-address-bar-actions { + .file-system-browser-header-address-bar-actions { display: flex; justify-content: space-between; align-items: center; width: 100%; } - ::deep .directory-browser-content-new-directory { + ::deep .file-system-browser-content-new-directory { min-width: 0; flex-basis: auto; margin-right: 10px; @@ -706,11 +1054,51 @@ #navigator-history { margin-right: 2px; } + + #file-system-browser-file-system-treeview-container { + flex-shrink: 1; + } } @media screen and (max-width: 399px) { - #directory-browser-dialog { + #file-system-browser-dialog { min-width: 400px } + + .e.extra-large-icons { + width: 100%; + } + + .e.extra-large-icons .text { + width: calc(100% - 14px); + } + + .e.extra-large-icons .text span { + max-width: 400px; + } + + .e.large-icons { + width: 164px; + } + + .e.large-icons .text { + width: calc(100% - 14px); + } + + .e.large-icons .text span { + width: calc(100% - 14px); + } + + .e.medium-icons { + width: 102px; + } + + .e.medium-icons .text { + width: calc(100% - 14px); + } + + .e.medium-icons .text span { + width: calc(100% - 14px); + } } \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Pages/Home.razor b/src/Lumina.Presentation.Web/Pages/Home.razor index 9a039b41..5af367a9 100644 --- a/src/Lumina.Presentation.Web/Pages/Home.razor +++ b/src/Lumina.Presentation.Web/Pages/Home.razor @@ -4,4 +4,4 @@ Lumina - Home - \ No newline at end of file + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/android-package-archive.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/android-package-archive.svg new file mode 100644 index 00000000..7daff150 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/android-package-archive.svg @@ -0,0 +1,23 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-atom+xml.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-atom+xml.svg new file mode 100644 index 00000000..009702f8 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-atom+xml.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-certificate.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-certificate.svg new file mode 100644 index 00000000..356a6307 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-certificate.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-dicom.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-dicom.svg new file mode 100644 index 00000000..215eb631 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-dicom.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-epub+zip.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-epub+zip.svg new file mode 100644 index 00000000..d7b2d93b --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-epub+zip.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-illustrator.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-illustrator.svg new file mode 100644 index 00000000..75d0bbf4 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-illustrator.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-image.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-image.svg new file mode 100644 index 00000000..4f91c1b4 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-image.svg @@ -0,0 +1,238 @@ + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-json.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-json.svg new file mode 100644 index 00000000..22af4f42 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-json.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-mathml+xml.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-mathml+xml.svg new file mode 100644 index 00000000..6c50c39d --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-mathml+xml.svg @@ -0,0 +1,21 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-msonenote.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-msonenote.svg new file mode 100644 index 00000000..51032c26 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-msonenote.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-msoutlook.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-msoutlook.svg new file mode 100644 index 00000000..4c114f29 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-msoutlook.svg @@ -0,0 +1,11 @@ + + + + + + + + + @ + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-msword-template.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-msword-template.svg new file mode 100644 index 00000000..805872c9 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-msword-template.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-octet-stream.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-octet-stream.svg new file mode 100644 index 00000000..6095e2c6 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-octet-stream.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-ogg.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-ogg.svg new file mode 100644 index 00000000..48a25876 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-ogg.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-pdf.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-pdf.svg new file mode 100644 index 00000000..2626d889 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-pdf.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-pgp-signature.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-pgp-signature.svg new file mode 100644 index 00000000..51b8971a --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-pgp-signature.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-pgp.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-pgp.svg new file mode 100644 index 00000000..882d80df --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-pgp.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-photoshop.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-photoshop.svg new file mode 100644 index 00000000..67a641c7 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-photoshop.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-postscript.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-postscript.svg new file mode 100644 index 00000000..cba209a3 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-postscript.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-sql.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-sql.svg new file mode 100644 index 00000000..52c40e02 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-sql.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.appimage.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.appimage.svg new file mode 100644 index 00000000..72b924ab --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.appimage.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.flatpak.ref.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.flatpak.ref.svg new file mode 100644 index 00000000..5b7c3184 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.flatpak.ref.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.iccprofile.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.iccprofile.svg new file mode 100644 index 00000000..26c24e61 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.iccprofile.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.kde.bluedevil-sendfile.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.kde.bluedevil-sendfile.svg new file mode 100644 index 00000000..9818620f --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.kde.bluedevil-sendfile.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-access.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-access.svg new file mode 100644 index 00000000..1526412b --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-access.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-cab-compressed.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-cab-compressed.svg new file mode 100644 index 00000000..2b13cd75 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-cab-compressed.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-excel.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-excel.svg new file mode 100644 index 00000000..729af608 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-excel.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-htmlhelp.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-htmlhelp.svg new file mode 100644 index 00000000..a092bdc0 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-htmlhelp.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-infopath.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-infopath.svg new file mode 100644 index 00000000..4b11ff8e --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-infopath.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-powerpoint.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-powerpoint.svg new file mode 100644 index 00000000..cf31caf4 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-powerpoint.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-publisher.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-publisher.svg new file mode 100644 index 00000000..d47dd994 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.ms-publisher.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.chart.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.chart.svg new file mode 100644 index 00000000..b8bfe543 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.chart.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.presentation-template.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.presentation-template.svg new file mode 100644 index 00000000..cda30343 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.presentation-template.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.spreadsheet-template.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.spreadsheet-template.svg new file mode 100644 index 00000000..35a872ff --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.spreadsheet-template.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.text-template.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.text-template.svg new file mode 100644 index 00000000..2bb659d0 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.text-template.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.web-template.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.web-template.svg new file mode 100644 index 00000000..bb23eab4 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.oasis.opendocument.web-template.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.snap.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.snap.svg new file mode 100644 index 00000000..0d89ca45 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.snap.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.visio.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.visio.svg new file mode 100644 index 00000000..df481af0 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.visio.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.xdgapp.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.xdgapp.svg new file mode 100644 index 00000000..02a7cac4 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-vnd.xdgapp.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-winhlp.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-winhlp.svg new file mode 100644 index 00000000..a092bdc0 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-winhlp.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-x-7z-ace.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-x-7z-ace.svg new file mode 100644 index 00000000..2b9a66d0 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-x-7z-ace.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-x-addon.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-x-addon.svg new file mode 100644 index 00000000..c1f2bf44 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/application-x-addon.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/directory.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/directory.svg new file mode 100644 index 00000000..78d45cd7 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/directory.svg @@ -0,0 +1,36 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/drive.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/drive.svg new file mode 100644 index 00000000..266c05ff --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/drive.svg @@ -0,0 +1,51 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/file.svg b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/file.svg new file mode 100644 index 00000000..60428766 --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/images/icons/Lyra/file.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Lumina.Presentation.Web/wwwroot/js/site.js b/src/Lumina.Presentation.Web/wwwroot/js/site.js index f125563a..dc5a4570 100644 --- a/src/Lumina.Presentation.Web/wwwroot/js/site.js +++ b/src/Lumina.Presentation.Web/wwwroot/js/site.js @@ -1,4 +1,6 @@ -/** +let windowWasClicked = false; + +/** * Adjusts the height of a dropdown identified by `comboboxId` to fit in the available space. * @param {string} comboboxId The Id of the combobox whose dropdown should be adjusted. */ @@ -25,8 +27,7 @@ function adjustDropdownHeight(comboboxId = null) { /** * Gets the position and size of an element relative to the viewport. - * - * @param {string} id - The ID of the element to get the offset for. + * @param {string} id - The Id of the element to get the offset for. * @returns {Object} An object with the top, left, width, and height of the element. */ function getElementOffset(id) { @@ -50,7 +51,6 @@ function getElementOffset(id) { /** * Updates the position and height of the dropdown relative to the specified path segment. - * * @param {string} pathSegmentId - The ID of the path segment element to position the dropdown relative to. */ function updateDropdownPosition(pathSegmentId) { @@ -69,30 +69,53 @@ function updateDropdownPosition(pathSegmentId) { } /** - * Unchecks all checkboxes except the one with the specified ID. - * + * Enables horizontal scrolling to the file system browser explorer tab. + */ +function addHorizontalScrolling(id) { + document.getElementById(id).addEventListener('wheel', function (event) { + event.preventDefault(); + this.scrollLeft += (event.deltaY > 0 ? 1 : -1) * 80; + }, { passive: false }); +} + +/** + * Disables horizontal scrolling to the file system browser explorer tab. + */ +function removeHorizontalScrolling(id) { + document.getElementById(id).removeEventListener('wheel', function (event) { + event.preventDefault(); + this.scrollLeft += (event.deltaY > 0 ? 1 : -1) * 80; + }, { passive: false }); +} + +/** + * Focuses the navigator address bar input. + */ +function focusNavigatorInputElement() { + const elements = document.getElementsByClassName('navigator-address-bar-input'); + if (elements.length > 0) + elements[0].focus(); +} + +/** + * Unchecks all checkboxes except the one with the specified Id. * @param {string} id - The Id of the checkbox to leave checked. */ function uncheckAllExcept(id) { const checkboxes = document.querySelectorAll('.navigator-toggle-checkbox'); checkboxes.forEach((checkbox) => { - if (checkbox.id !== id) { + if (checkbox.id !== id) checkbox.checked = false; - } }); } /** - * Enables horizontal scrolling for the address bar using the mouse wheel. + * Closes all navigator path segments. */ -function makeAddressBarHorizontallyScrollable() { - const addressBar = document.getElementById('navigator-address-bar'); - if (addressBar) { - addressBar.addEventListener('wheel', function (event) { - event.preventDefault(); - this.scrollLeft += (event.deltaY > 0 ? 1 : -1) * 80; - }, { passive: false }); - } +function closeNavigatorPathSegments() { + const checkboxes = document.getElementsByClassName('navigator-toggle-checkbox'); + for (let i = 0; i < checkboxes.length; i++) + checkboxes[i].checked = false; } /** @@ -107,4 +130,19 @@ window.addEventListener('resize', function () { if (pathSegmentId) updateDropdownPosition(pathSegmentId); } +}); + +/** + * Handles window click events. + * @param {MouseEvent} event - The click event triggered on the window. + */ +window.addEventListener('click', function (event) { + // check if the clicked element is not a checkbox or its label + if (!event.target.closest('.navigator-toggle-checkbox, .navigator-toggle')) { + windowWasClicked = true; + closeNavigatorPathSegments(); + const dropdown = document.getElementById('navigatorDropdown'); + if (dropdown) + dropdown.style.display = 'none'; + } }); \ No newline at end of file