diff --git a/docs/manual/using-lumina/index.md b/docs/manual/using-lumina/index.md index f00fa44c..02d614a0 100644 --- a/docs/manual/using-lumina/index.md +++ b/docs/manual/using-lumina/index.md @@ -153,7 +153,7 @@ Both book and music pages double as editors for the items that were scanned in. ## The file system browser -Wherever Lumina needs a folder or a file from the server, it opens the file system browser: a modal that lists the drives, a tree of folders, a pane of the items in the current folder, and an address bar you can walk with. It offers icon view modes, generates thumbnails for images, and can show or hide hidden files. You will meet it when you pick the content locations of a library, and anywhere else the interface asks you to point at a path on the server. +Wherever Lumina needs a folder or a file from the server, it opens the file system browser: a modal that lists the drives, a tree of folders, a pane of the items in the current folder, and an address bar you can walk with. It offers icon view modes, generates thumbnails for images, and can show or hide hidden files. Hidden entries are dimmed by the bundled themes. You will meet it when you pick the content locations of a library, and anywhere else the interface asks you to point at a path on the server. ## Settings and language diff --git a/docs/technical/api/file-system-management/Api.Directories.md b/docs/technical/api/file-system-management/Api.Directories.md index b1fc79e6..7d376fac 100644 --- a/docs/technical/api/file-system-management/Api.Directories.md +++ b/docs/technical/api/file-system-management/Api.Directories.md @@ -32,14 +32,16 @@ GET api/v1/directories/get-directories?path=C%3A%5CUsers%5C&shouldIncludeHiddenE "path": "/media/movies/The Matrix (1999)/", "name": "The Matrix", "dateCreated": "2025-01-01T13:50:38.3183787Z", - "dateModified": "2025-01-01T13:40:38.3183791Z" + "dateModified": "2025-01-01T13:40:38.3183791Z", + "isHidden": false }, { "items": [], "path": "/media/movies/The Lord of the Rings - The Fellowship of the Ring (2001)/", "name": "The Lord of the Rings - The Fellowship of the Ring (2001)", "dateCreated": "2025-01-01T13:50:38.3184681Z", - "dateModified": "2025-01-01T13:40:38.3184683Z" + "dateModified": "2025-01-01T13:40:38.3184683Z", + "isHidden": false } ] ``` diff --git a/docs/technical/api/file-system-management/Api.Drives.md b/docs/technical/api/file-system-management/Api.Drives.md index a2920563..cd884026 100644 --- a/docs/technical/api/file-system-management/Api.Drives.md +++ b/docs/technical/api/file-system-management/Api.Drives.md @@ -31,6 +31,7 @@ GET api/v1/drives/get-drives "path": "C:\\", "name": "C:\\", "itemType": "Root", + "isHidden": false, "isExpanded": false, "childrenLoaded": false, "children": [] @@ -39,6 +40,7 @@ GET api/v1/drives/get-drives "path": "D:\\", "name": "D:\\", "itemType": "Root", + "isHidden": false, "isExpanded": false, "childrenLoaded": false, "children": [] diff --git a/docs/technical/api/file-system-management/Api.Files.md b/docs/technical/api/file-system-management/Api.Files.md index 2b6ae344..f0f734ff 100644 --- a/docs/technical/api/file-system-management/Api.Files.md +++ b/docs/technical/api/file-system-management/Api.Files.md @@ -35,14 +35,16 @@ GET api/v1/files/get-files?path=C%3A%5CUsers%5C&shouldIncludeHiddenElements=true "path": "/media/movies/The Matrix (1999)/The Matrix.mkv", "name": "The Matrix.mkv", "dateCreated": "2025-01-01T13:50:38.3143711Z", - "dateModified": "2025-01-01T13:40:38.3143719Z" + "dateModified": "2025-01-01T13:40:38.3143719Z", + "isHidden": false }, { "size": 6897, "path": "/media/movies/The Matrix (1999)/The Matrix.en.srt", "name": "The Matrix.en.srt", "dateCreated": "2025-01-01T13:50:38.3145606Z", - "dateModified": "2025-01-01T13:40:38.3145609Z" + "dateModified": "2025-01-01T13:40:38.3145609Z", + "isHidden": false } ] ``` @@ -67,6 +69,7 @@ GET api/v1/files/get-tree-files?path=C%3A%5CUsers%5C&shouldIncludeHiddenElements "path": "/media/movies/The Matrix (1999)/The Matrix.mkv", "name": "The Matrix.mkv", "itemType": "File", + "isHidden": false, "isExpanded": false, "childrenLoaded": false, "children": [] @@ -75,6 +78,7 @@ GET api/v1/files/get-tree-files?path=C%3A%5CUsers%5C&shouldIncludeHiddenElements "path": "/media/movies/The Matrix (1999)/The Matrix.en.srt", "name": "The Matrix.en.srt", "itemType": "File", + "isHidden": false, "isExpanded": false, "childrenLoaded": false, "children": [] @@ -83,6 +87,7 @@ GET api/v1/files/get-tree-files?path=C%3A%5CUsers%5C&shouldIncludeHiddenElements "path": "/media/movies/The Matrix (1999)/poster.jpg", "name": "poster.jpg", "itemType": "File", + "isHidden": false, "isExpanded": false, "childrenLoaded": false, "children": [] diff --git a/docs/technical/theming/Theming.md b/docs/technical/theming/Theming.md index 5bc7917e..5de9e49f 100644 --- a/docs/technical/theming/Theming.md +++ b/docs/technical/theming/Theming.md @@ -86,7 +86,7 @@ The manifest is a JSON object describing the theme. The example below is the man "name": "Editorial Paper", "description": "A clean, readable proof of concept theme.", "author": "Lumina", - "version": "1.4.0", + "version": "1.5.61", "preview": "assets/preview.svg", "templates": { "default": "templates/index.html" @@ -511,8 +511,8 @@ The sub templates are rendered client side by the application script for each dy | Template | Fields | | --- | --- | -| `tree-node` | `path`, `name`, `itemType` (`Root`, `Directory` or `File`), `isRoot`, `isDirectory`, `isFile`, `isExpanded` and `icon`. The node must keep the `.tree-node` root with its `data-path`, the `.node-content`, `.expand-button` (or `.spacer` for files), `.node-icon` and `.node-name` elements, and the `.child-nodes` container. | -| `explorer-item` | `path`, `name`, `itemType` (`Directory` or `File`), `isDirectory`, `isFile`, `cssClass` (the active view mode, such as `large-icons`) and `iconUrl`. The item must keep the `.e` root with its `data-path` and `data-type`, and an `` element, which the script replaces with thumbnails for image files. | +| `tree-node` | `path`, `name`, `itemType` (`Root`, `Directory` or `File`), `isRoot`, `isDirectory`, `isFile`, `isHidden`, `isExpanded` and `icon`. The node must keep the `.tree-node` root with its `data-path`, the `.node-content`, `.expand-button` (or `.spacer` for files), `.node-icon` and `.node-name` elements, and the `.child-nodes` container. When `isHidden` is true the application also adds the `is-hidden` class to the root, so a theme can dim hidden nodes. | +| `explorer-item` | `path`, `name`, `itemType` (`Directory` or `File`), `isDirectory`, `isFile`, `isHidden`, `cssClass` (the active view mode, such as `large-icons`) and `iconUrl`. The item must keep the `.e` root with its `data-path` and `data-type`, and an `` element, which the script replaces with thumbnails for image files. When `isHidden` is true the application also adds the `is-hidden` class to the root, so a theme can dim hidden items. | | `path-segment` | `id`, `path` (the segment name), `dataPath` (the full path up to and including the segment), `toggleId` and `dropdownId`. The segment must keep the combobox structure with its `.navigator-combobox` (`data-path`), `.navigator-toggle-checkbox`, `.navigator-selected-text`, `.navigator-arrow` and `.navigator-dropdown` elements. | #### The file icons mapping (assets/file-icons.json) diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Directories/DirectoryMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Directories/DirectoryMapping.cs index 35f4b8d4..9c30a17d 100644 --- a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Directories/DirectoryMapping.cs +++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Directories/DirectoryMapping.cs @@ -26,10 +26,10 @@ public static class DirectoryMapping Name = domainEntity.Name, Path = domainEntity.Id.Path, ItemType = domainEntity.Type, + IsHidden = domainEntity.IsHidden, IsExpanded = false, ChildrenLoaded = false, - Children = domainEntity.Items.Select(item => item.ToTreeNodeResponse()) - .ToList() + Children = [.. domainEntity.Items.Select(item => item.ToTreeNodeResponse())] }; } @@ -55,8 +55,8 @@ public static class DirectoryMapping domainEntity.Name, domainEntity.DateCreated.Value, domainEntity.DateModified.Value, - domainEntity.Items.Select(fileSystemItem => fileSystemItem.ToFileSystemItemDto()) - .ToList() + [.. domainEntity.Items.Select(fileSystemItem => fileSystemItem.ToFileSystemItemDto())], + domainEntity.IsHidden ); } diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/FileSystemItemMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/FileSystemItemMapping.cs index 7149ecc5..52535ce1 100644 --- a/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/FileSystemItemMapping.cs +++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/FileSystemItemMapping.cs @@ -28,7 +28,8 @@ public static class FileSystemItemMapping domainEntity.Id.Path, domainEntity.Name, DateTime.Now, - DateTime.Now + DateTime.Now, + domainEntity.IsHidden ); } diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Files/FileMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Files/FileMapping.cs index a128da91..82e9dce6 100644 --- a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Files/FileMapping.cs +++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Files/FileMapping.cs @@ -25,6 +25,7 @@ public static class FileMapping Name = domainEntity.Name, Path = domainEntity.Id.Path, ItemType = domainEntity.Type, + IsHidden = domainEntity.IsHidden, IsExpanded = false, ChildrenLoaded = false }; @@ -52,7 +53,8 @@ public static class FileMapping domainEntity.Name, domainEntity.DateCreated.HasValue ? domainEntity.DateCreated.Value : default, domainEntity.DateModified.HasValue ? domainEntity.DateModified.Value : default, - domainEntity.Size + domainEntity.Size, + domainEntity.IsHidden ); } diff --git a/src/Lumina.Contracts/DTO/FileSystemManagement/FileSystemItemDto.cs b/src/Lumina.Contracts/DTO/FileSystemManagement/FileSystemItemDto.cs index 9188267e..794e0dca 100644 --- a/src/Lumina.Contracts/DTO/FileSystemManagement/FileSystemItemDto.cs +++ b/src/Lumina.Contracts/DTO/FileSystemManagement/FileSystemItemDto.cs @@ -12,10 +12,12 @@ namespace Lumina.Contracts.DTO.FileSystemManagement; /// The name of the file system item. /// The creation date of the file system item. /// The modification date of the file system item. +/// Whether the file system item is hidden. [DebuggerDisplay("Name: {Name}")] public record FileSystemItemDto( string Path, string Name, DateTime DateCreated, - DateTime DateModified + DateTime DateModified, + bool IsHidden ); diff --git a/src/Lumina.Contracts/Responses/FileSystemManagement/Common/FileSystemTreeNodeResponse.cs b/src/Lumina.Contracts/Responses/FileSystemManagement/Common/FileSystemTreeNodeResponse.cs index 615e8bb7..09649053 100644 --- a/src/Lumina.Contracts/Responses/FileSystemManagement/Common/FileSystemTreeNodeResponse.cs +++ b/src/Lumina.Contracts/Responses/FileSystemManagement/Common/FileSystemTreeNodeResponse.cs @@ -27,6 +27,11 @@ public class FileSystemTreeNodeResponse /// public FileSystemItemType ItemType { get; set; } + /// + /// Gets or sets a value indicating whether the file or directory is hidden. + /// + public bool IsHidden { get; set; } + /// /// Gets or sets a value indicating whether the node is expanded. /// diff --git a/src/Lumina.Contracts/Responses/FileSystemManagement/Directories/DirectoryResponse.cs b/src/Lumina.Contracts/Responses/FileSystemManagement/Directories/DirectoryResponse.cs index 602c898d..8030415d 100644 --- a/src/Lumina.Contracts/Responses/FileSystemManagement/Directories/DirectoryResponse.cs +++ b/src/Lumina.Contracts/Responses/FileSystemManagement/Directories/DirectoryResponse.cs @@ -15,11 +15,13 @@ namespace Lumina.Contracts.Responses.FileSystemManagement.Directories; /// The creation date of the directory. /// The modification date of the directory. /// The children items of the directory. +/// Whether the directory is hidden. [DebuggerDisplay("Name: {Name} (Directory)")] public record DirectoryResponse( string Path, string Name, DateTime DateCreated, DateTime DateModified, - List Items -) : FileSystemItemDto(Path, Name, DateCreated, DateModified); + List Items, + bool IsHidden +) : FileSystemItemDto(Path, Name, DateCreated, DateModified, IsHidden); diff --git a/src/Lumina.Contracts/Responses/FileSystemManagement/Files/FileResponse.cs b/src/Lumina.Contracts/Responses/FileSystemManagement/Files/FileResponse.cs index 0addc010..ff58d142 100644 --- a/src/Lumina.Contracts/Responses/FileSystemManagement/Files/FileResponse.cs +++ b/src/Lumina.Contracts/Responses/FileSystemManagement/Files/FileResponse.cs @@ -14,11 +14,13 @@ namespace Lumina.Contracts.Responses.FileSystemManagement.Files; /// The creation date of the file. /// The modification date of the file. /// The size of the file, in bytes. +/// Whether the file is hidden. [DebuggerDisplay("Name: {Name} (File, Size: {Size} bytes)")] public record FileResponse( string Path, string Name, DateTime DateCreated, DateTime DateModified, - long Size -) : FileSystemItemDto(Path, Name, DateCreated, DateModified); + long Size, + bool IsHidden +) : FileSystemItemDto(Path, Name, DateCreated, DateModified, IsHidden); diff --git a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Entities/Directory.cs b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Entities/Directory.cs index 363126f1..7222d01d 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Entities/Directory.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Entities/Directory.cs @@ -53,6 +53,7 @@ public sealed class Directory : FileSystemItem /// The date and time the directory was created. Can be optional if unknown. /// The date and time the directory was last modified. Can be optional if unknown. /// The status of the file system item. + /// Whether the directory is hidden. /// /// An containing either a successfully created , or an error message. /// @@ -61,9 +62,10 @@ public sealed class Directory : FileSystemItem string name, Optional dateCreated, Optional dateModified, - FileSystemItemStatus status = FileSystemItemStatus.Accessible) + FileSystemItemStatus status = FileSystemItemStatus.Accessible, + bool isHidden = false) { - // TODO: enforce invariants + // TODO: enforce invariants. Result createPathResult = FileSystemPathId.Create(path); if (createPathResult.IsFailure) return createPathResult.Errors; @@ -75,6 +77,9 @@ public sealed class Directory : FileSystemItem Result setStatusResult = newDirectory.SetStatus(status); if (setStatusResult.IsFailure) return setStatusResult.Errors; + Result setHiddenStateResult = newDirectory.SetHiddenState(isHidden); + if (setHiddenStateResult.IsFailure) + return setHiddenStateResult.Errors; return newDirectory; } @@ -85,6 +90,7 @@ public sealed class Directory : FileSystemItem /// The date and time the directory was created. Can be optional if unknown. /// The date and time the directory was last modified. Can be optional if unknown. /// The status of the file system item. + /// Whether the directory is hidden. /// /// An containing either a successfully created , or an error message. /// @@ -93,9 +99,10 @@ public sealed class Directory : FileSystemItem string name, Optional dateCreated, Optional dateModified, - FileSystemItemStatus status = FileSystemItemStatus.Accessible) + FileSystemItemStatus status = FileSystemItemStatus.Accessible, + bool isHidden = false) { - // TODO: enforce invariants + // TODO: enforce invariants. Directory newDirectory = new( id, name, @@ -104,6 +111,9 @@ public sealed class Directory : FileSystemItem Result setStatusResult = newDirectory.SetStatus(status); if (setStatusResult.IsFailure) return setStatusResult.Errors; + Result setHiddenStateResult = newDirectory.SetHiddenState(isHidden); + if (setHiddenStateResult.IsFailure) + return setHiddenStateResult.Errors; return newDirectory; } diff --git a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Entities/File.cs b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Entities/File.cs index 79086078..ba433f40 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Entities/File.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Entities/File.cs @@ -54,6 +54,7 @@ public sealed class File : FileSystemItem /// The date and time the file was last modified. Can be optional if unknown. /// The size of the file in bytes. /// The status of the file system item. + /// Whether the file is hidden. /// /// An containing either a successfully created , or an error message. /// @@ -63,7 +64,8 @@ public sealed class File : FileSystemItem Optional dateCreated, Optional dateModified, long size, - FileSystemItemStatus status = FileSystemItemStatus.Accessible) + FileSystemItemStatus status = FileSystemItemStatus.Accessible, + bool isHidden = false) { // TODO: enforce invariants Result createPathResult = FileSystemPathId.Create(path); @@ -78,6 +80,9 @@ public sealed class File : FileSystemItem Result setStatusResult = newFile.SetStatus(status); if (setStatusResult.IsFailure) return setStatusResult.Errors; + Result setHiddenStateResult = newFile.SetHiddenState(isHidden); + if (setHiddenStateResult.IsFailure) + return setHiddenStateResult.Errors; return newFile; } @@ -90,6 +95,7 @@ public sealed class File : FileSystemItem /// The date and time the file was last modified. Can be optional if unknown. /// The size of the file in bytes. /// The status of the file system item. + /// Whether the file is hidden. /// /// An containing either a successfully created , or an error message. /// @@ -99,7 +105,8 @@ public sealed class File : FileSystemItem Optional dateCreated, Optional dateModified, long size, - FileSystemItemStatus status = FileSystemItemStatus.Accessible) + FileSystemItemStatus status = FileSystemItemStatus.Accessible, + bool isHidden = false) { // TODO: enforce invariants File newFile = new( @@ -111,6 +118,9 @@ public sealed class File : FileSystemItem Result setStatusResult = newFile.SetStatus(status); if (setStatusResult.IsFailure) return setStatusResult.Errors; + Result setHiddenStateResult = newFile.SetHiddenState(isHidden); + if (setHiddenStateResult.IsFailure) + return setHiddenStateResult.Errors; return newFile; } diff --git a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/FileSystemItem.cs b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/FileSystemItem.cs index 653b644b..be8f8812 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/FileSystemItem.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/FileSystemItem.cs @@ -1,10 +1,9 @@ #region ========================================================================= USING ===================================================================================== -using Lumina.Domain.Common.Primitives; -using Lumina.Domain.SharedKernel.Common.Enums.FileSystem; using Lumina.Domain.Common.Errors; using Lumina.Domain.Common.Models.Core; - +using Lumina.Domain.Common.Primitives; using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects; +using Lumina.Domain.SharedKernel.Common.Enums.FileSystem; using System.Diagnostics; #endregion @@ -36,6 +35,11 @@ public abstract class FileSystemItem : AggregateRoot /// public FileSystemItemType Type { get; protected set; } + /// + /// Gets a value indicating whether the file system item is hidden. + /// + public bool IsHidden { get; private set; } + /// /// Initializes a new instance of the class. /// @@ -49,7 +53,7 @@ public abstract class FileSystemItem : AggregateRoot } /// - /// Sets the status of the filesystem item. + /// Sets the status of the file system item. /// /// The status to be set. /// An representing either a successful operation, or an error. @@ -60,7 +64,18 @@ public abstract class FileSystemItem : AggregateRoot } /// - /// Sets the parent of the filesystem item. + /// Sets the hidden state of the file system item. + /// + /// Whether the file system item is hidden. + /// An representing either a successful operation, or an error. + public Result SetHiddenState(bool isHidden) + { + IsHidden = isHidden; + return Result.Updated; + } + + /// + /// Sets the parent of the file system item. /// /// The file system item to be set as parent. /// An representing either a successful operation, or an error. diff --git a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/DirectoryProviderService.cs b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/DirectoryProviderService.cs index 89190f99..214ca1e6 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/DirectoryProviderService.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/DirectoryProviderService.cs @@ -1,10 +1,8 @@ #region ========================================================================= USING ===================================================================================== -using Lumina.Domain.Common.Primitives; -using Lumina.Domain.SharedKernel.Common.Enums.FileSystem; using Lumina.Domain.Common.Errors; - -using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services; +using Lumina.Domain.Common.Primitives; using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects; +using Lumina.Domain.SharedKernel.Common.Enums.FileSystem; using System; using System.Collections.Generic; using System.IO; @@ -54,6 +52,19 @@ internal class DirectoryProviderService : IDirectoryProviderService .AsEnumerable()); } + /// + /// Checks if the directory at the specified path is hidden. + /// + /// The path of the directory to check. + /// when the directory is hidden, otherwise , including when its attributes cannot be read. + public bool IsHidden(FileSystemPathId path) + { + // The hidden flag is metadata, so it follows the same read properties permission as the other metadata accessors. + if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties, false)) + return false; + return (GetAttributes(path.Path) & FileAttributes.Hidden) == FileAttributes.Hidden; + } + /// /// Gets the attributes of a file system item identified by . /// diff --git a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/DirectoryService.cs b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/DirectoryService.cs index 54c925c4..725ed369 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/DirectoryService.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/DirectoryService.cs @@ -1,12 +1,11 @@ #region ========================================================================= USING ===================================================================================== -using Lumina.Domain.Common.Primitives; -using Lumina.Domain.SharedKernel.Common.Enums.FileSystem; using Lumina.Domain.Common.Errors; - +using Lumina.Domain.Common.Primitives; +using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities; using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment; using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform; using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects; -using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities; +using Lumina.Domain.SharedKernel.Common.Enums.FileSystem; using System; using System.Collections.Generic; #endregion @@ -76,13 +75,15 @@ public class DirectoryService : IDirectoryService Result dirNameResult = _environmentContext.DirectoryProviderService.GetFileName(subPath); Result> dateModifiedResult = _environmentContext.DirectoryProviderService.GetLastWriteTime(subPath); Result> dateCreatedResult = _environmentContext.DirectoryProviderService.GetCreationTime(subPath); + // When hidden elements are excluded, the provider already filtered them out, so only an inclusive listing needs the attribute. + bool isHidden = shouldIncludeHiddenElements && _environmentContext.DirectoryProviderService.IsHidden(subPath); // If any error occurred, mark the directory as inaccessible. if (dirNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure) { Result errorDirResult = Directory.Create(subPath, !dirNameResult.IsFailure ? dirNameResult.Value : null!, !dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional.None(), - !dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional.None()); + !dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional.None(), isHidden: isHidden); if (errorDirResult.IsFailure) return errorDirResult.Errors; Result setStatusResult = errorDirResult.Value.SetStatus(FileSystemItemStatus.Inaccessible); @@ -92,7 +93,7 @@ public class DirectoryService : IDirectoryService } else { - Result subDirectoryResult = Directory.Create(subPath, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value); + Result subDirectoryResult = Directory.Create(subPath, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, isHidden: isHidden); if (subDirectoryResult.IsFailure) return subDirectoryResult.Errors; result.Add(subDirectoryResult.Value); @@ -141,12 +142,13 @@ public class DirectoryService : IDirectoryService Result dirNameResult = _environmentContext.DirectoryProviderService.GetFileName(newDirectoryPathResult.Value); Result> dateModifiedResult = _environmentContext.DirectoryProviderService.GetLastWriteTime(newDirectoryPathResult.Value); Result> dateCreatedResult = _environmentContext.DirectoryProviderService.GetCreationTime(newDirectoryPathResult.Value); + bool isHidden = _environmentContext.DirectoryProviderService.IsHidden(newDirectoryPathResult.Value); // If any error occurred, mark the directory as inaccessible. if (dirNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure) { Result errorDirResult = Directory.Create(newDirectoryPathResult.Value, !dirNameResult.IsFailure ? dirNameResult.Value : null!, !dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional.None(), - !dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional.None()); + !dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional.None(), isHidden: isHidden); if (errorDirResult.IsFailure) return errorDirResult.Errors; Result setStatusResult = errorDirResult.Value.SetStatus(FileSystemItemStatus.Inaccessible); @@ -155,7 +157,7 @@ public class DirectoryService : IDirectoryService return errorDirResult; } else - return Directory.Create(newDirectoryPathResult.Value, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value); + return Directory.Create(newDirectoryPathResult.Value, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, isHidden: isHidden); } } @@ -291,12 +293,13 @@ public class DirectoryService : IDirectoryService Result dirNameResult = _environmentContext.DirectoryProviderService.GetFileName(newDirectoryPathResult.Value); Result> dateModifiedResult = _environmentContext.DirectoryProviderService.GetLastWriteTime(newDirectoryPathResult.Value); Result> dateCreatedResult = _environmentContext.DirectoryProviderService.GetCreationTime(newDirectoryPathResult.Value); + bool isHidden = _environmentContext.DirectoryProviderService.IsHidden(newDirectoryPathResult.Value); // If any error occurred, mark the directory as inaccessible. if (dirNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure) { Result errorDirResult = Directory.Create(newDirectoryPathResult.Value, !dirNameResult.IsFailure ? dirNameResult.Value : null!, !dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional.None(), - !dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional.None()); + !dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional.None(), isHidden: isHidden); if (errorDirResult.IsFailure) return errorDirResult.Errors; Result setStatusResult = errorDirResult.Value.SetStatus(FileSystemItemStatus.Inaccessible); @@ -305,7 +308,7 @@ public class DirectoryService : IDirectoryService return errorDirResult; } else - return Directory.Create(newDirectoryPathResult.Value, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value); + return Directory.Create(newDirectoryPathResult.Value, dirNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, isHidden: isHidden); } } diff --git a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/FileProviderService.cs b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/FileProviderService.cs index e52a47ca..5d8a19fe 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/FileProviderService.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/FileProviderService.cs @@ -1,9 +1,8 @@ #region ========================================================================= USING ===================================================================================== -using Lumina.Domain.Common.Primitives; -using Lumina.Domain.SharedKernel.Common.Enums.FileSystem; using Lumina.Domain.Common.Errors; - +using Lumina.Domain.Common.Primitives; using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects; +using Lumina.Domain.SharedKernel.Common.Enums.FileSystem; using System; using System.Collections.Generic; using System.IO; @@ -52,6 +51,19 @@ internal class FileProviderService : IFileProviderService .AsEnumerable()); } + /// + /// Checks if the file at the specified path is hidden. + /// + /// The path of the file to check. + /// when the file is hidden, otherwise , including when its attributes cannot be read. + public bool IsHidden(FileSystemPathId path) + { + // The hidden flag is metadata, so it follows the same read properties permission as the other metadata accessors. + if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadProperties)) + return false; + return (GetAttributes(path.Path) & FileAttributes.Hidden) == FileAttributes.Hidden; + } + /// /// Gets the attributes of a file system item identified by . /// diff --git a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/FileService.cs b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/FileService.cs index b4404c1c..b2d098a9 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/FileService.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/FileService.cs @@ -78,12 +78,14 @@ public class FileService : IFileService Result> dateCreatedResult = _environmentContext.FileProviderService.GetCreationTime(filePath); Result sizeResult = _environmentContext.FileProviderService.GetSize(filePath); long size = !sizeResult.IsFailure ? sizeResult.Value ?? 0 : 0; + // When hidden elements are excluded, the provider already filtered them out, so only an inclusive listing needs the attribute. + bool isHidden = shouldIncludeHiddenElements && _environmentContext.FileProviderService.IsHidden(filePath); // If any of the details returned an error, set the inaccessible status. if (fileNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure || sizeResult.IsFailure) { Result errorFileResult = File.Create(filePath, !fileNameResult.IsFailure ? fileNameResult.Value : null!, !dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional.None(), - !dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional.None(), size); + !dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional.None(), size, isHidden: isHidden); if (errorFileResult.IsFailure) return errorFileResult.Errors; Result setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible); @@ -93,7 +95,7 @@ public class FileService : IFileService } else { - Result fileResult = File.Create(filePath, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size); + Result fileResult = File.Create(filePath, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size, isHidden: isHidden); if (fileResult.IsFailure) return fileResult.Errors; result.Add(fileResult.Value); @@ -150,12 +152,13 @@ public class FileService : IFileService Result> dateCreatedResult = _environmentContext.FileProviderService.GetCreationTime(copyFileResult.Value); Result sizeResult = _environmentContext.FileProviderService.GetSize(copyFileResult.Value); long size = !sizeResult.IsFailure ? sizeResult.Value ?? 0 : 0; + bool isHidden = _environmentContext.FileProviderService.IsHidden(copyFileResult.Value); // If any of the details returned an error, set the inaccessible status. if (fileNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure || sizeResult.IsFailure) { Result errorFileResult = File.Create(copyFileResult.Value, !fileNameResult.IsFailure ? fileNameResult.Value : null!, !dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional.None(), - !dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional.None(), size); + !dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional.None(), size, isHidden: isHidden); if (errorFileResult.IsFailure) return errorFileResult.Errors; Result setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible); @@ -164,7 +167,7 @@ public class FileService : IFileService return errorFileResult; } else - return File.Create(copyFileResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size); + return File.Create(copyFileResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size, isHidden: isHidden); } } @@ -216,12 +219,13 @@ public class FileService : IFileService Result> dateCreatedResult = _environmentContext.FileProviderService.GetCreationTime(moveFileResult.Value); Result sizeResult = _environmentContext.FileProviderService.GetSize(moveFileResult.Value); long size = !sizeResult.IsFailure ? sizeResult.Value ?? 0 : 0; + bool isHidden = _environmentContext.FileProviderService.IsHidden(moveFileResult.Value); // If any of the details returned an error, set the inaccessible status. if (fileNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure || sizeResult.IsFailure) { Result errorFileResult = File.Create(moveFileResult.Value, !fileNameResult.IsFailure ? fileNameResult.Value : null!, !dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional.None(), - !dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional.None(), size); + !dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional.None(), size, isHidden: isHidden); if (errorFileResult.IsFailure) return errorFileResult.Errors; Result setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible); @@ -230,7 +234,7 @@ public class FileService : IFileService return errorFileResult; } else - return File.Create(moveFileResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size); + return File.Create(moveFileResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size, isHidden: isHidden); } } @@ -276,12 +280,13 @@ public class FileService : IFileService Result> dateCreatedResult = _environmentContext.FileProviderService.GetCreationTime(newFilePathResult.Value); Result sizeResult = _environmentContext.FileProviderService.GetSize(newFilePathResult.Value); long size = !sizeResult.IsFailure ? sizeResult.Value ?? 0 : 0; + bool isHidden = _environmentContext.FileProviderService.IsHidden(newFilePathResult.Value); // If any of the details returned an error, set the inaccessible status. if (fileNameResult.IsFailure || dateModifiedResult.IsFailure || dateCreatedResult.IsFailure || sizeResult.IsFailure) { Result errorFileResult = File.Create(newFilePathResult.Value, !fileNameResult.IsFailure ? fileNameResult.Value : null!, !dateCreatedResult.IsFailure ? dateCreatedResult.Value : Optional.None(), - !dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional.None(), size); + !dateModifiedResult.IsFailure ? dateModifiedResult.Value : Optional.None(), size, isHidden: isHidden); if (errorFileResult.IsFailure) return errorFileResult.Errors; Result setStatusResult = errorFileResult.Value.SetStatus(FileSystemItemStatus.Inaccessible); @@ -290,7 +295,7 @@ public class FileService : IFileService return errorFileResult; } else - return File.Create(newFilePathResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size); + return File.Create(newFilePathResult.Value, fileNameResult.Value, dateCreatedResult.Value, dateModifiedResult.Value, size, isHidden: isHidden); } } diff --git a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/IDirectoryProviderService.cs b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/IDirectoryProviderService.cs index 38cee2d4..fea8cd00 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/IDirectoryProviderService.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/IDirectoryProviderService.cs @@ -21,6 +21,13 @@ public interface IDirectoryProviderService /// An containing either a collection of directory paths or an error. Result> GetSubdirectoryPaths(FileSystemPathId path, bool shouldIncludeHiddenElements); + /// + /// Checks if the directory at the specified path is hidden. + /// + /// The path of the directory to check. + /// when the directory is hidden, otherwise , including when its attributes cannot be read. + bool IsHidden(FileSystemPathId path); + /// /// Checks if a directory with the specified path exists. /// diff --git a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/IFileProviderService.cs b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/IFileProviderService.cs index a2b45416..92564661 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/IFileProviderService.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Services/IFileProviderService.cs @@ -21,6 +21,13 @@ public interface IFileProviderService /// An containing either a collection of file paths, or an error. Result> GetFilePaths(FileSystemPathId path, bool shouldIncludeHiddenElements); + /// + /// Checks if the file at the specified path is hidden. + /// + /// The path of the file to check. + /// when the file is hidden, otherwise , including when its attributes cannot be read. + bool IsHidden(FileSystemPathId path); + /// /// Retrieves the contents of a file at the specified path. /// diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectories/GetDirectoriesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectories/GetDirectoriesEndpointSummary.cs index c2846bfd..2f05e1a9 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectories/GetDirectoriesEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Directories/GetDirectories/GetDirectoriesEndpointSummary.cs @@ -37,8 +37,8 @@ public class GetDirectoriesEndpointSummary : Summary Response(200, "The list of file system drives is returned.", example: new FileSystemTreeNodeResponse[] { - new() { Path = "C:\\", Name = "C:\\", ItemType = FileSystemItemType.Root, IsExpanded = false, ChildrenLoaded = false, Children = [] }, - new() { Path = "D:\\", Name = "D:\\", ItemType = FileSystemItemType.Root, IsExpanded = false, ChildrenLoaded = false, Children = [] } + new() { Path = "C:\\", Name = "C:\\", ItemType = FileSystemItemType.Root, IsHidden = false, IsExpanded = false, ChildrenLoaded = false, Children = [] }, + new() { Path = "D:\\", Name = "D:\\", ItemType = FileSystemItemType.Root, IsHidden = false, IsExpanded = false, ChildrenLoaded = false, Children = [] } }); Response(401, "Authentication required.", "application/problem+json", diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointSummary.cs index 0616d7dc..5d8c71b8 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointSummary.cs @@ -1,7 +1,6 @@ #region ========================================================================= USING ===================================================================================== using FastEndpoints; using Lumina.Contracts.Requests.FileSystemManagement.Files; -using Lumina.Contracts.Responses.FileSystemManagement.Common; using Lumina.Contracts.Responses.FileSystemManagement.Files; using System; using System.Collections.Generic; @@ -38,8 +37,8 @@ public class GetFilesEndpointSummary : Summary public DateTime DateModified { get; set; } + + /// + /// Gets or sets a value indicating whether the file system item is hidden. + /// + public bool IsHidden { get; set; } } diff --git a/src/Lumina.Presentation.Web/Common/DTO/FileSystemManagement/FileSystemTreeNodeDto.cs b/src/Lumina.Presentation.Web/Common/DTO/FileSystemManagement/FileSystemTreeNodeDto.cs index 1188fda8..6e271a8d 100644 --- a/src/Lumina.Presentation.Web/Common/DTO/FileSystemManagement/FileSystemTreeNodeDto.cs +++ b/src/Lumina.Presentation.Web/Common/DTO/FileSystemManagement/FileSystemTreeNodeDto.cs @@ -27,6 +27,11 @@ public class FileSystemTreeNodeDto /// public FileSystemItemType ItemType { get; set; } + /// + /// Gets or sets a value indicating whether the file or directory is hidden. + /// + public bool IsHidden { get; set; } + /// /// Gets or sets a value indicating whether the node is expanded. /// diff --git a/src/Lumina.Presentation.Web/wwwroot/js/file-system-browser-dialog.js b/src/Lumina.Presentation.Web/wwwroot/js/file-system-browser-dialog.js index b9929cb3..71959b8f 100644 --- a/src/Lumina.Presentation.Web/wwwroot/js/file-system-browser-dialog.js +++ b/src/Lumina.Presentation.Web/wwwroot/js/file-system-browser-dialog.js @@ -1,10 +1,10 @@ -// because this script can be reused many times and only when needed, we need not polute the global space with the declarations - -// wrap everything in an IIFE (Immediately Invoked Function Expression), which creates a scope each time +// Because this script can be reused many times and only when needed, we need not polute the global space with the declarations - +// wrap everything in an IIFE (Immediately Invoked Function Expression), which creates a scope each time. (function () { console.log('Loaded File System Explorer script'); //+======================================================================================+ - //| DOM Elements | + //| DOM Elements. | //+======================================================================================+ const modalBackgroundMenu = document.getElementById('modal-background-menu'); @@ -61,16 +61,16 @@ const visibleSelectionRectangle = document.getElementById('visible-selection-rectangle'); //+======================================================================================+ - //| Variables | + //| Variables. | //+======================================================================================+ - // base URL of the file type icons of the active theme, empty when no theme is applied, in which case no icons are rendered + // Base URL of the file type icons of the active theme, empty when no theme is applied, in which case no icons are rendered. let iconBaseUrl = ''; - // URL of the theme file icons mapping, mapping file extensions to icon paths, empty when no theme is applied + // URL of the theme file icons mapping, mapping file extensions to icon paths, empty when no theme is applied. let fileIconsUrl = ''; - // the file extension to icon path mapping of the active theme, null until the mapping is loaded + // The file extension to icon path mapping of the active theme, null until the mapping is loaded. let fileIcons = null; - // the raw theme sub templates for the dynamic content, null when the theme does not provide a template and the built-in markup is used instead + // The raw theme sub templates for the dynamic content, null when the theme does not provide a template and the built-in markup is used instead. let treeNodeTemplate = null; let explorerItemTemplate = null; let pathSegmentTemplate = null; @@ -79,10 +79,12 @@ let _path; let pathSeparator = '/'; let platformType = 'Unix'; - let showFileSystemTreeView = true; // TODO: take from config - let showHiddenElements = true; // TODO: take from config - let includeFiles = true; // TODO: take from config - let viewMode = 'list-icons'; // TODO: take from config + let showFileSystemTreeView = true; // TODO: take from config. + let showHiddenElements = true; // TODO: take from config. + let includeFiles = true; // TODO: take from config. + let viewMode = 'list-icons'; // TODO: take from config. + // The classes that identify the active view mode on the explorer entries, swappable without touching the other entry classes. + const viewModeClasses = ['list-icons', 'details-icons', 'small-icons', 'medium-icons', 'large-icons', 'extra-large-icons']; let undoStack = []; let redoStack = []; @@ -91,20 +93,20 @@ let isSelecting = false; let isSelectionMode = false; - let scrollTimeout; // timeout to delay thumbnail loading after scrolling - let resizeTimeout; // timeout to delay thumbnail loading after resizing - let abortController; // allows the cancellation of thumbnail retrieval jobs - let hasScrolledAfterModeChange = false; // flag to track if scrolling occurred after a mode change - let showThumbnails = true; // whether to show thumbnails or not - let scrollThumbnailRetrievalTimeout = 1000; // the time span to wait after the last scroll, before getting thumbnails - let inspectFileForThumbnails = false; // whether to check the actual header bytes in order to determine if a file is an image, rather than its extension - let thumbnailsRetrievalBatchSize = 20; // the number of thumbnails to ask from the server, concurrently - let imagePreviewsQuality = 70; // the quality used for image thumbnails - let fullImageQuality = 90; // the quality used for full images + let scrollTimeout; // Timeout to delay thumbnail loading after scrolling. + let resizeTimeout; // Timeout to delay thumbnail loading after resizing. + let abortController; // Allows the cancellation of thumbnail retrieval jobs. + let hasScrolledAfterModeChange = false; // Flag to track if scrolling occurred after a mode change. + let showThumbnails = true; // Whether to show thumbnails or not. + let scrollThumbnailRetrievalTimeout = 1000; // The time span to wait after the last scroll, before getting thumbnails. + let inspectFileForThumbnails = false; // Whether to check the actual header bytes in order to determine if a file is an image, rather than its extension. + let thumbnailsRetrievalBatchSize = 20; // The number of thumbnails to ask from the server, concurrently. + let imagePreviewsQuality = 70; // The quality used for image thumbnails. + let fullImageQuality = 90; // The quality used for full images. //+======================================================================================+ - //| Initialization | + //| Initialization. | //+======================================================================================+ /** @@ -125,7 +127,7 @@ _path = initialPath; addressBarInput.value = initialPath; - showFileSystemTreeView = true; // TODO: take from config + showFileSystemTreeView = true; // TODO: take from config. addHorizontalScrolling(addressBar); switchViewMode(config.viewMode, config.viewMode === 'list' ? null : config.iconSize, true); @@ -151,10 +153,10 @@ const templateElement = document.getElementById(id); if (!templateElement) return null; - // the theme template engine may be absent on a partially loaded page, in which case the built-in markup is used + // The theme template engine may be absent on a partially loaded page, in which case the built-in markup is used. if (typeof renderThemeTemplate !== 'function') return null; - // an empty template element means the theme does not provide the template, in which case the built-in markup is used + // An empty template element means the theme does not provide the template, in which case the built-in markup is used. return templateElement.textContent || null; } @@ -206,17 +208,17 @@ await toggleFileSystemTreeViewAsync(false); await toggleShowFileSystemElementsThumbnailsAsync(false); await navigateToPathAsync(path, false, false); - // add click handler for confirm button + // Add click handler for confirm button. btnFileSystemBrowserConfirm.onclick = function () { const selectedPaths = selectedFileSystemElementsInput.value; if (onConfirmCallback && typeof onConfirmCallback === 'function') onConfirmCallback(selectedPaths); - // hide dialog + // Hide dialog. hideFileSystemBrowserDialog(); }; btnFileSystemBrowserCancel.onclick = hideFileSystemBrowserDialog; } else - notificationService.Show("Path cannot be null!", NotificationType.ERROR); // TODO: should ask error message from server when translation is implemented + notificationService.Show("Path cannot be null!", NotificationType.ERROR); // TODO: should ask error message from server when translation is implemented. } /** @@ -233,11 +235,11 @@ * @returns {Promise} A promise that resolves once the properties have been fetched. */ async function getFileSystemPropertiesAsync() { - // call the API to get the file system type (platform type) + // Call the API to get the file system type (platform type). const fileSystemTypeResponse = await callApiGetAsync(`${clientBasePath}file-system/api-get-type`); if (fileSystemTypeResponse !== undefined) platformType = fileSystemTypeResponse.platformType; - // call the API to get the path separator for the file system + // Call the API to get the path separator for the file system. const pathSeparatorResponse = await callApiGetAsync(`${clientBasePath}path/api-get-path-separator`); if (pathSeparatorResponse !== undefined) pathSeparator = pathSeparatorResponse.pathSeparator; @@ -251,21 +253,21 @@ async function checkPathAsync(path) { const pathValidResponse = await callApiGetAsync(`${clientBasePath}path/api-validate?path=${encodeURIComponent(path)}`); if (pathValidResponse === undefined) { - // the API rejected the path with a validation error (e.g. it is empty), treat it as invalid and restore the address bar + // The API rejected the path with a validation error (e.g. it is empty), treat it as invalid and restore the address bar. addressBarInput.value = _path; if (addressBarInput.value !== null && !addressBarInput.value.endsWith(pathSeparator)) addressBarInput.value += pathSeparator; return false; } if (!pathValidResponse.isValid) { - notificationService.show("Specified path is not valid!", NotificationType.ERROR); // TODO: should ask error message from server when translation is implemented + notificationService.show("Specified path is not valid!", NotificationType.ERROR); // TODO: should ask error message from server when translation is implemented. addressBarInput.value = _path; if (addressBarInput.value !== null && !addressBarInput.value.endsWith(pathSeparator)) addressBarInput.value += pathSeparator; } else { const pathExistsResponse = await callApiGetAsync(`${clientBasePath}path/api-check-path-exists?path=${encodeURIComponent(path)}&shouldIncludeHiddenElements=${showHiddenElements}`); if (pathExistsResponse !== undefined && !pathExistsResponse.exists) { - notificationService.show("Specified path does not exist!", NotificationType.ERROR); // TODO: should ask error message from server when translation is implemented + notificationService.show("Specified path does not exist!", NotificationType.ERROR); // TODO: should ask error message from server when translation is implemented. return false; } } @@ -273,24 +275,24 @@ } /** - * Navigates to the specified path, + * Navigates to the specified path. * @param {any} path The path o navigate to. * @param {any} isForwardNavigation Whether the Forward button was clicked, and navigation is done to a history location or not. * @param {any} isBackwardNavigation Whether the Back button was clicked, and navigation is done to a history location or not. */ async function navigateToPathAsync(path, isForwardNavigation, isBackwardNavigation) { if (await checkPathAsync(path)) { - // if there was a job for thumbnails retrieval, cancel it first + // If there was a job for thumbnails retrieval, cancel it first. if (abortController) { abortController.abort(); abortController = null; } - // check if backward navigation is possible + // Check if backward navigation is possible. if (isBackwardNavigation) { if (undoStack.length > 0) { - // get the first path in the backward navigation list + // Get the first path in the backward navigation list. const backwardPath = undoStack.pop(); - // put the current path in the forward navigationlist, before navigating to the backward path + // Put the current path in the forward navigationlist, before navigating to the backward path. if (addressBarInput.value !== null) { if (!addressBarInput.value.endsWith(pathSeparator)) addressBarInput.value += pathSeparator; @@ -299,11 +301,11 @@ path = backwardPath; } else return; - } else if (isForwardNavigation) { // check if forward navigation is possible + } else if (isForwardNavigation) { // Check if forward navigation is possible. if (redoStack.length > 0) { - // get the first path in the forward navigation list + // Get the first path in the forward navigation list. const forwardPath = redoStack.pop(); - // put the current path in the backward navigation list, before navigating to the forward path + // Put the current path in the backward navigation list, before navigating to the forward path. if (addressBarInput.value !== null) { if (!addressBarInput.value.endsWith(pathSeparator)) addressBarInput.value += pathSeparator; @@ -313,19 +315,19 @@ path = forwardPath; } else return; - } else { // navigation to a brand new location (up, directory browse, manual path edit, etc) + } else { // Navigation to a brand new location (up, directory browse, manual path edit, etc). redoStack = []; - if (addressBarInput.value !== null && addressBarInput.value !== path) { // when navigating up, addressBarInput.value will be set after navigation + if (addressBarInput.value !== null && addressBarInput.value !== path) { // When navigating up, addressBarInput.value will be set after navigation. if (undoStack.length === 0 || (undoStack.length > 0 && undoStack[undoStack.length - 1] !== addressBarInput.value)) undoStack.push(addressBarInput.value); - } else if (_path !== null && _path !== path) { // when editing the address, addressBarInput.value already comes set, check against control value + } else if (_path !== null && _path !== path) { // When editing the address, addressBarInput.value already comes set, check against control value. if (undoStack.length === 0 || (undoStack.length > 0 && undoStack[undoStack.length - 1] !== _path)) undoStack.push(_path); } } - _path = path; // we are about to navigate to the new path, store its value in the control variable - addressBarInput.style.display = 'none'; // hide #address-bar-input - addressBar.style.display = 'block'; // show #address-bar + _path = path; // We are about to navigate to the new path, store its value in the control variable. + addressBarInput.style.display = 'none'; // Hide #address-bar-input. + addressBar.style.display = 'block'; // Show #address-bar. await getNavigatorPathAsync(path); await getFileSystemItemsAsync(path); if (showFileSystemTreeView) @@ -339,14 +341,14 @@ } /** - * Navigates up one level from the current path + * Navigates up one level from the current path. */ async function navigateUpAsync() { if (addressBarInput.value !== null) { - // ask the API for the parent path + // Ask the API for the parent path. const parentLocationResponse = await callApiGetAsync(`${clientBasePath}path/api-get-path-parent?path=${encodeURIComponent(addressBarInput.value)}`); if (parentLocationResponse !== undefined && parentLocationResponse.pathSegments !== null) { - // if the answer was valid, and we can navigate up, reconstruct the provided path from its segments, and navigate to it + // If the answer was valid, and we can navigate up, reconstruct the provided path from its segments, and navigate to it. platformType = parentLocationResponse.pathSegments; let parentConcatenatedPath = parentLocationResponse.pathSegments[0].path; for (var i = 1; i < parentLocationResponse.pathSegments.length; i++) @@ -360,7 +362,7 @@ //+======================================================================================+ - //| Navigator | + //| Navigator. | //+======================================================================================+ /** @@ -378,16 +380,16 @@ * @param {Array} pathSegments - An array of path segments. */ function renderAddressBar(pathSegments) { - pathSegmentsContainer.removeEventListener('change', handlePathSegmentComboboxChangeAsync); // remove previous listeners - pathSegmentsContainer.addEventListener('change', handlePathSegmentComboboxChangeAsync); // add new listener - pathSegmentsContainer.innerHTML = ""; // clear existing segments + pathSegmentsContainer.removeEventListener('change', handlePathSegmentComboboxChangeAsync); // Remove previous listeners. + pathSegmentsContainer.addEventListener('change', handlePathSegmentComboboxChangeAsync); // Add new listener. + pathSegmentsContainer.innerHTML = ""; // Clear existing segments. if (pathSegments !== null) { pathSegments.forEach((segment, index) => { const li = renderPathSegment(segment, index, pathSegments); pathSegmentsContainer.appendChild(li); }); } else - pathSegmentsContainer.querySelectorAll('li').forEach(li => li.remove()); // no address, clear path segments + pathSegmentsContainer.querySelectorAll('li').forEach(li => li.remove()); // No address, clear path segments. } /** @@ -414,10 +416,10 @@ } const li = document.createElement("li"); li.id = `path-segment-${index}`; - // create the combobox + // Create the combobox. const combobox = document.createElement("div"); combobox.className = "navigator-combobox inline-block"; - // the shine effect + // The shine effect. const shineEffect = document.createElement("div"); shineEffect.className = "shine-effect"; shineEffect.style.top = "1px"; @@ -434,7 +436,7 @@ span.className = "navigator-selected-text"; span.innerText = segment.path; toggleLabel.appendChild(span); - // add the arrow element + // Add the arrow element. const arrowSpan = document.createElement("span"); arrowSpan.className = "navigator-arrow"; toggleLabel.appendChild(arrowSpan); @@ -452,10 +454,10 @@ /** * Handle the change event for the comboboxes inside the path-segments. * This function is triggered when any of the comboboxes (checkboxes) in the navigation bar is toggled. - * @param {Event} e - The change event object. + * @param {Event} e - The change event object. */ async function handlePathSegmentComboboxChangeAsync(e) { - // ensure the event was triggered by an element with the 'navigator-toggle-checkbox' class + // Ensure the event was triggered by an element with the 'navigator-toggle-checkbox' class. if (e.target.classList.contains('navigator-toggle-checkbox')) { const comboboxId = e.target.id; const dropdownId = comboboxId.replace('segment-toggle-', 'navigator-dropdown-'); @@ -463,26 +465,26 @@ reattachDropdown(); if (!e.target.checked) return; - const comboboxElement = e.target.closest('.navigator-combobox'); // get the closest parent (or self) with the specified class - const pathValue = comboboxElement.getAttribute('data-path'); // retrieve the data-path attribute value - // clear any existing dropdown elements + const comboboxElement = e.target.closest('.navigator-combobox'); // Get the closest parent (or self) with the specified class. + const pathValue = comboboxElement.getAttribute('data-path'); // Retrieve the data-path attribute value. + // Clear any existing dropdown elements. dropdown.innerHTML = ""; showBusyIndicator(); setupDropdown(dropdown, e.target); - // add combobox entry for current directory + // Add combobox entry for current directory. addDirectoryOption(dropdown, pathValue, ".", async () => { addressBarInput.value = pathValue; await navigateToPathAsync(pathValue, false, false); }); - // add combobox entry for parent directory + // Add combobox entry for parent directory. addDirectoryOption(dropdown, pathValue, "..", async () => { addressBarInput.value = pathValue; await navigateUpAsync(); }); - // fetch directory data for the path + // Fetch directory data for the path. try { await fetchFileSystemDirectoriesAsync(pathValue, (parsedItem) => { addDirectoryOption(dropdown, pathValue, parsedItem.name, async () => { @@ -506,19 +508,19 @@ * @param {HTMLElement} toggleElement - The element that triggered the dropdown. */ function setupDropdown(dropdown, toggleElement) { - // when drop down opens, need to show address bar overflow, otherwise clipping of drop down occurs + // When drop down opens, need to show address bar overflow, otherwise clipping of drop down occurs // store the id of the parent combobox of the dropdown - the dropdown will be reparented - // because of manadatory "overflow hidden" of scrollable area and clipping isues + // because of manadatory "overflow hidden" of scrollable area and clipping isues. dropdown.setAttribute('data-parent', toggleElement.id); dropdown.setAttribute('data-detached', true); const position = toggleElement.closest('.navigator-combobox').getBoundingClientRect(); - // detach dropdown and reposition + // Detach dropdown and reposition. document.body.appendChild(dropdown); dropdown.style.position = 'absolute'; dropdown.style.top = `${position.bottom}px`; dropdown.style.left = `${position.left}px`; dropdown.style.display = 'block'; - // handle addressBar scroll to adjust dropdown position + // Handle addressBar scroll to adjust dropdown position. addressBar.addEventListener('scroll', adjustDropdownPosition); } @@ -539,36 +541,36 @@ } /** - * Re-attaches the detached visible drop down to the path segment or platform combobox it originally belonged to + * Re-attaches the detached visible drop down to the path segment or platform combobox it originally belonged to. */ function reattachDropdown() { - // when the combobox closes, re-attach the detached dropdown + // When the combobox closes, re-attach the detached dropdown. const dropdown = document.querySelector('.navigator-dropdown[data-detached="true"], .enlightenment-dropdown[data-detached="true"]'); if (dropdown) { - // reset its absolute positioning and stuff + // Reset its absolute positioning and stuff. dropdown.style.position = ''; dropdown.style.top = ''; dropdown.style.left = ''; dropdown.style.display = ''; - // re-attach it to original parent + // Re-attach it to original parent. const dataParent = dropdown.getAttribute('data-parent'); dropdown.removeAttribute('data-detached'); const originalParent = document.getElementById(dataParent).parentNode; if (originalParent) originalParent.appendChild(dropdown); - // remove scroll event listener from the addressBar + // Remove scroll event listener from the addressBar. addressBar.removeEventListener('scroll', adjustDropdownPosition); } } /** - * Adjusts the position of a detached drop down, such that it is always just under its original - * path segment combobox, even when this parent is moved through scrolling + * Adjusts the position of a detached drop down, such that it is always just under its original + * path segment combobox, even when this parent is moved through scrolling. */ function adjustDropdownPosition() { const dropdown = document.querySelector('.navigator-dropdown[data-detached="true"]'); if (dropdown) { - const comboboxElement = document.getElementById(dropdown.getAttribute('data-parent')); // get the related combobox + const comboboxElement = document.getElementById(dropdown.getAttribute('data-parent')); // Get the related combobox. const position = comboboxElement.parentNode.getBoundingClientRect(); dropdown.style.top = position.bottom + 'px'; dropdown.style.left = position.left + 'px'; @@ -589,26 +591,26 @@ } //+======================================================================================+ - //| Tree View | + //| Tree View. | //+======================================================================================+ /** - * Gets the file system tree view + * Gets the file system tree view. * @param {string} initialPath - The initial path to expand in the tree view (optional). * @returns {Promise} */ async function getFileSystemTreeViewAsync(initialPath) { - // clear the existing tree view + // Clear the existing tree view. fileSystemBrowserTreeview.innerHTML = ''; - // fetch available drives asynchronously + // Fetch available drives asynchronously. const drives = await getFileSystemDrivesAsync(); - // iterate through each drive and add it to the tree view as root node + // Iterate through each drive and add it to the tree view as root node. for (const drive of drives) { - // create a tree node for the drive + // Create a tree node for the drive. const driveNode = createFileSystemTreeViewTreeNode(drive); - // append the drive node to the tree view + // Append the drive node to the tree view. fileSystemBrowserTreeview.appendChild(driveNode); - // if the initial path starts with this drive's path, expand the tree view to show the initial path + // If the initial path starts with this drive's path, expand the tree view to show the initial path. if (initialPath.toLowerCase().startsWith(drive.path.toLowerCase())) await expandInitialTreeViewPathAsync(driveNode, initialPath); } @@ -638,13 +640,17 @@ isRoot: nodeData.itemType === 'Root', isDirectory: nodeData.itemType !== 'File', isFile: nodeData.itemType === 'File', + isHidden: !!nodeData.isHidden, isExpanded: !!nodeData.isExpanded, icon: getNodeIcon(nodeData) }); const container = document.createElement("div"); container.innerHTML = html; const treeNodeDiv = container.firstElementChild; - // the theme template must keep the DOM contract the script binds its events to + // Hidden entries keep a distinct class even when the theme template does not apply it itself. + if (nodeData.isHidden) + treeNodeDiv.classList.add('is-hidden'); + // The theme template must keep the DOM contract the script binds its events to. const nodeContent = treeNodeDiv.querySelector('.node-content'); if (nodeContent) nodeContent.addEventListener('click', handleNodeClickAsync); @@ -654,7 +660,7 @@ return treeNodeDiv; } const treeNodeDiv = document.createElement("div"); - treeNodeDiv.className = "tree-node"; + treeNodeDiv.className = nodeData.isHidden ? "tree-node is-hidden" : "tree-node"; treeNodeDiv.setAttribute('data-path', nodeData.path); const nodeContent = document.createElement("span"); @@ -673,7 +679,7 @@ nodeName.className = "node-name"; nodeName.textContent = nodeData.name; - // assemble the node structure + // Assemble the node structure. nodeContent.appendChild(expandButton); nodeContent.appendChild(nodeIcon); nodeContent.appendChild(nodeName); @@ -691,15 +697,15 @@ * @param {Event} e - The click event object. */ async function handleNodeClickAsync(e) { - // get the node that was clicked + // Get the node that was clicked. const treeNode = e.target.closest('.tree-node'); - // retrieve the path stored on the clicked node + // Retrieve the path stored on the clicked node. selectedPath = treeNode.getAttribute('data-path'); if (selectedPath !== null) { - // ensure path ends with separator + // Ensure path ends with separator. if (!selectedPath.endsWith(pathSeparator)) selectedPath += pathSeparator; - // set the retrieved path as the navigator path, and navigate to it + // Set the retrieved path as the navigator path, and navigate to it. addressBarInput.value = selectedPath; await navigateToPathAsync(selectedPath, false, false); } @@ -711,21 +717,21 @@ */ async function toggleFileSysemTreeViewNodeExpandAsync(e) { e.stopPropagation(); - // get the node that was clicked + // Get the node that was clicked. const treeNode = e.target.closest('.tree-node'); const treeNodeIcon = treeNode.querySelector('.node-icon'); const nodeData = { itemType: 'Directory' }; const expandButton = e.target; - // get the div that hosts child nodes in tthe clicked node + // Get the div that hosts child nodes in tthe clicked node. const childNodes = treeNode.querySelector('.child-nodes'); const path = treeNode.getAttribute('data-path'); - // get the current expanded state of the clicked node, and toggle it + // Get the current expanded state of the clicked node, and toggle it. const isExpanded = expandButton.classList.contains('expanded'); nodeData.isExpanded = !isExpanded; if (treeNodeIcon) treeNodeIcon.textContent = getNodeIcon(nodeData); - // expand or collapse the node + // Expand or collapse the node. if (isExpanded) { expandButton.classList.remove('expanded'); if (childNodes) @@ -734,7 +740,7 @@ expandButton.classList.add('expanded'); if (childNodes) { childNodes.style.display = 'block'; - // if node is expanded and child nodes are not yet loaded, load them + // If node is expanded and child nodes are not yet loaded, load them. if (childNodes.children.length === 0) await loadFileSystemTreeViewChildNodesAsync(treeNode, path); } @@ -747,15 +753,15 @@ * @param {string} path - The file system path to load children from. */ async function loadFileSystemTreeViewChildNodesAsync(parentNode, path) { - // get the div that hosts child nodes + // Get the div that hosts child nodes. const childNodes = parentNode.querySelector('.child-nodes'); if (!childNodes) return; - // clear existing child nodes + // Clear existing child nodes. childNodes.innerHTML = ''; try { showBusyIndicator(); - // fetch directory information and create nodes for each + // Fetch directory information and create nodes for each. await fetchFileSystemDirectoriesAsync(path, (dir) => { dir.itemType = 'Directory'; const dirNode = createFileSystemTreeViewTreeNode(dir); @@ -791,7 +797,7 @@ * Fetches and processes JSON data from a given URL. * This function handles the data by processing all items in the response.data array * and passing them through the callback function. - * + * * @param {string} url - The URL to fetch JSON data from. * @param {Function} callback - Function to call for each processed item. * @param {string} itemType - Type of item being processed ('File' or 'Directory'). @@ -799,11 +805,11 @@ async function fetchJsonDataAsync(url, callback, itemType) { const response = await callApiGetAsync(url); if (response !== undefined) { - // process each item in the response.data array + // Process each item in the response.data array. for (let item of response) { - // manually specify the type to the parsed object + // Manually specify the type to the parsed object. item.itemType = itemType; - // call the provided callback function with the processed item + // Call the provided callback function with the processed item. callback(item); } } @@ -816,40 +822,40 @@ */ async function expandInitialTreeViewPathAsync(node, targetPath) { const nodePath = node.getAttribute('data-path'); - // exit if the target path doesn't start with the node path + // Exit if the target path doesn't start with the node path. if (!targetPath.toLowerCase().startsWith(nodePath.toLowerCase())) return; - // expand the current node if it's not already expanded + // Expand the current node if it's not already expanded. const expandButton = node.querySelector('.expand-button'); if (expandButton && !expandButton.classList.contains('expanded')) await toggleFileSysemTreeViewNodeExpandAsync({ target: expandButton, stopPropagation: () => { } }); - // split the remaining path into segments, using the separator of the file system the browser is showing + // Split the remaining path into segments, using the separator of the file system the browser is showing. const pathSegments = targetPath.slice(nodePath.length).split(pathSeparator).filter(Boolean); let currentNode = node; - // iterate through each path segment + // Iterate through each path segment. for (let i = 0; i < pathSegments.length; i++) { const segment = pathSegments[i]; const childNodes = currentNode.querySelector('.child-nodes'); let found = false; - // search for the child node matching the current path segment + // Search for the child node matching the current path segment. for (const childNode of childNodes.children) { if (childNode.querySelector('.node-name').textContent.toLowerCase() === segment.toLowerCase()) { currentNode = childNode; found = true; if (i === pathSegments.length - 1) { - // if this is the last segment (target node) - childNode.scrollIntoView(); // bring it into view, if its not already - // mark it as selected + // If this is the last segment (target node). + childNode.scrollIntoView(); // Bring it into view, if its not already. + // Mark it as selected. childNode.querySelector('.node-content').classList.add('selected'); - // toggle this last node, because all its children will be loaded + // Toggle this last node, because all its children will be loaded. const expandChildButton = childNode.querySelector('.expand-button'); if (expandChildButton) await toggleFileSysemTreeViewNodeExpandAsync({ target: expandChildButton, stopPropagation: () => { } }); - // load the node's children + // Load the node's children. await loadFileSystemTreeViewChildNodesAsync(childNode, childNode.getAttribute('data-path')); } else { - // if this is an intermediate node, expand it if necessary + // If this is an intermediate node, expand it if necessary. const childExpandButton = childNode.querySelector('.expand-button'); if (childExpandButton && !childExpandButton.classList.contains('expanded')) await toggleFileSysemTreeViewNodeExpandAsync({ target: childExpandButton, stopPropagation: () => { } }); @@ -857,14 +863,14 @@ break; } } - // if the current segment wasn't found, stop expanding + // If the current segment wasn't found, stop expanding. if (!found) break; } } //+======================================================================================+ - //| File System | + //| File System. | //+======================================================================================+ /** @@ -872,12 +878,12 @@ * @param {string} path - The path to fetch items from. */ async function getFileSystemItemsAsync(path) { - // clear the current contents of the file system explorer + // Clear the current contents of the file system explorer. fileSystemExplorer.innerHTML = ''; try { showBusyIndicator(); - // fetch file system items and create explorer items for each + // Fetch file system items and create explorer items for each. await fetchFileSystemItemsAsync(path, (item) => { const newItem = createFileSystemExplorerItem(item); fileSystemExplorer.appendChild(newItem); @@ -915,36 +921,40 @@ itemType: itemType, isDirectory: itemType === 'Directory', isFile: itemType === 'File', + isHidden: !!item.isHidden, cssClass: viewMode, iconUrl: resolveIconUrl(item.path, itemType) }); const container = document.createElement('div'); container.innerHTML = html; const itemDiv = container.firstElementChild; - // add event listeners for mouse interactions + // Hidden entries keep a distinct class even when the theme template does not apply it itself. + if (item.isHidden) + itemDiv.classList.add('is-hidden'); + // Add event listeners for mouse interactions. itemDiv.onmouseup = handleFileSystemEntityMouseUpAsync; itemDiv.onmousedown = handleFileSystemEntityMouseDown; return itemDiv; } const itemDiv = document.createElement('div'); - // set up the main item div with appropriate classes and data attributes - itemDiv.className = `e ${viewMode}`; + // Set up the main item div with appropriate classes and data attributes. + itemDiv.className = item.isHidden ? `e ${viewMode} is-hidden` : `e ${viewMode}`; itemDiv.setAttribute('data-path', item.path); itemDiv.setAttribute('data-type', itemType); - // create and set up the icon div + // Create and set up the icon div. const iconDiv = document.createElement('div'); iconDiv.className = 'icon'; const iconUrl = resolveIconUrl(item.path, itemType); iconDiv.innerHTML = iconUrl !== '' ? `` : ''; - // create and set up the text div + // Create and set up the text div. const textDiv = document.createElement('div'); textDiv.className = 'text'; - // use different class for directory ('d') and file ('f') + // Use different class for directory ('d') and file ('f'). textDiv.innerHTML = `${item.name}`; - // assemble the item structure + // Assemble the item structure. itemDiv.appendChild(iconDiv); itemDiv.appendChild(textDiv); - // add event listeners for mouse interactions + // Add event listeners for mouse interactions. itemDiv.onmouseup = handleFileSystemEntityMouseUpAsync; itemDiv.onmousedown = handleFileSystemEntityMouseDown; return itemDiv; @@ -962,75 +972,75 @@ const allEClassElements = Array.from(fileSystemExplorer.querySelectorAll('.e')); const currentIndex = allEClassElements.indexOf(e.currentTarget); - // if a previous click timestamp exists, check the time difference + // If a previous click timestamp exists, check the time difference. const previousTime = parseInt(e.currentTarget.dataset.selectionStartTime || 0); const currentTime = new Date().getTime(); const timeDifference = currentTime - previousTime; // TODO: needs to account for when the element is already selected, and a double click occurs - on first click it would check the difference and go to rename - - // maybe just wait half second before performing action + // maybe just wait half second before performing action. - // if time difference is less than 300ms, treat it as a double-click + // If time difference is less than 300ms, treat it as a double-click. if (timeDifference < 300) { - if (e.currentTarget.dataset.type === 'Directory') { // directories + if (e.currentTarget.dataset.type === 'Directory') { // Directories. addressBarInput.value = e.currentTarget.dataset.path; - await navigateToPathAsync(addressBarInput.value, false, false); // TODO: add to undo + await navigateToPathAsync(addressBarInput.value, false, false); // TODO: add to undo. return; - } else { // files + } else { // Files. } - // reset the timestamp used to track double clicks + // Reset the timestamp used to track double clicks. e.currentTarget.dataset.selectionStartTime = 0; return; } else - e.currentTarget.dataset.selectionStartTime = currentTime; // element was single clicked, update the selection start time to now - if (e.ctrlKey || isSelectionMode) { // when CTRL key is pressed - // toggle selection for the current clicked item + e.currentTarget.dataset.selectionStartTime = currentTime; // Element was single clicked, update the selection start time to now. + if (e.ctrlKey || isSelectionMode) { // When CTRL key is pressed. + // Toggle selection for the current clicked item. e.currentTarget.classList.toggle('selected'); - // set the selection start if it's not already set + // Set the selection start if it's not already set. if (fileSystemExplorer.dataset.selectionStart === undefined) fileSystemExplorer.dataset.selectionStart = currentIndex; } - else if ((e.shiftKey && fileSystemExplorer.dataset.selectionStart !== undefined) || isSelectionMode) { // when SHIFT key is pressed + else if ((e.shiftKey && fileSystemExplorer.dataset.selectionStart !== undefined) || isSelectionMode) { // When SHIFT key is pressed. const start = parseInt(fileSystemExplorer.dataset.selectionStart); - // remove all selections + // Remove all selections. allEClassElements.forEach(elem => { elem.classList.remove('selected'); }); - // define the range to select items from and to + // Define the range to select items from and to. const [from, to] = start < currentIndex ? [start, currentIndex] : [currentIndex, start]; - // add the 'selected' class to items in the range + // Add the 'selected' class to items in the range. for (let i = from; i <= to; i++) allEClassElements[i].classList.add('selected'); } - else { // when neither CTRL nor SHIFT keys are pressed + else { // When neither CTRL nor SHIFT keys are pressed. if (!isSelectionMode) { - // get all elements that are selected + // Get all elements that are selected. const selectedElements = allEClassElements.filter(element => element.classList.contains('selected')); - // add 'selected' class to the current clicked item + // Add 'selected' class to the current clicked item. e.currentTarget.classList.add('selected'); - // if there are no selected elements, or if there are more than one, deselect all of them, and select just the clicked one + // If there are no selected elements, or if there are more than one, deselect all of them, and select just the clicked one. if ((selectedElements.length === 1 && e.currentTarget !== selectedElements[0]) || selectedElements.length !== 1) { - // deselect all items + // Deselect all items. selectedElements.forEach(elem => { if (elem !== e.currentTarget) { elem.classList.remove('selected'); - // remove selectionStartTime from all items + // Remove selectionStartTime from all items. delete elem.dataset.selectionStartTime; } }); - // set the current item as the selection start + // Set the current item as the selection start. fileSystemExplorer.dataset.selectionStart = currentIndex; - // store the current timestamp for future double-click checks + // Store the current timestamp for future double-click checks. e.currentTarget.dataset.selectionStartTime = currentTime; } } - else // if its selection mode, just toggle selection of item, when clicked + else // If its selection mode, just toggle selection of item, when clicked. e.currentTarget.classList.toggle('selected'); } const selectedElements = document.querySelectorAll('.e.selected'); - btnFileSystemBrowserConfirm.disabled = selectedElements.length === 0; // disable Confirm button if no item is selected + btnFileSystemBrowserConfirm.disabled = selectedElements.length === 0; // Disable Confirm button if no item is selected. if (selectedElements.length > 0) { var selectedPaths = '"'; selectedElements.forEach((element) => { @@ -1047,12 +1057,12 @@ * @param {MouseEvent} e - The mouse event whose propagation is stopped. */ function handleFileSystemEntityMouseDown(e) { - // stop the event from bubbling up to the explorer - we dont want to start selection rectangles when clicking files or directories + // Stop the event from bubbling up to the explorer - we dont want to start selection rectangles when clicking files or directories. e.stopPropagation(); } //+======================================================================================+ - //| View Mode | + //| View Mode. | //+======================================================================================+ /** @@ -1062,13 +1072,13 @@ * @param {boolean} isManualSet - Indicates whether the mode change is triggered manually (by clicking a mode change icon) or automatically. */ function switchViewMode(mode, iconSize, isManualSet) { - hasScrolledAfterModeChange = false; // reset the flag indicating a mode change + hasScrolledAfterModeChange = false; // Reset the flag indicating a mode change. setViewMode(mode, iconSize); - // check if content has been scrolled after the mode change; since scroll is the one triggering thumbnails retrieval, - // and there is no initial scroll when mode is changed, we need to trigger the retrieval manually + // Check if content has been scrolled after the mode change; since scroll is the one triggering thumbnails retrieval, + // and there is no initial scroll when mode is changed, we need to trigger the retrieval manually. setTimeout(() => { if (!hasScrolledAfterModeChange && showThumbnails && isManualSet) getFileSystemVisibleItems(); - }, 50); // wait 50ms to ensure all other events have processed + }, 50); // Wait 50ms to ensure all other events have processed. } /** @@ -1097,7 +1107,9 @@ mode === 'list' ? addHorizontalScrolling(fileSystemExplorer) : removeHorizontalScrolling(fileSystemExplorer); fileSystemExplorer.querySelectorAll('.e').forEach(el => { - el.className = `e ${iconClass}`; + // Swap only the view mode class, so that the selection and hidden entry flags survive the mode change. + el.classList.remove(...viewModeClasses); + el.classList.add(iconClass); }); mode === 'details' ? showExtraDetails() : hideExtraDetails(); } @@ -1145,7 +1157,7 @@ } //+======================================================================================+ - //| Selection | + //| Selection. | //+======================================================================================+ /** @@ -1163,18 +1175,18 @@ function startSelection(e) { const explorerScrollbars = hasScrollbars(fileSystemExplorer); const containerExplorerScrollbars = hasScrollbars(fileSystemExplorerContainer); - // check if clicked on the horizontal or vertical scrollbar + // Check if clicked on the horizontal or vertical scrollbar. if (explorerScrollbars.horizontal && e.clientY > fileSystemExplorer.getBoundingClientRect().top + fileSystemExplorer.offsetHeight - scrollbarHeight) return; if (containerExplorerScrollbars.vertical && e.clientX > fileSystemExplorerContainer.getBoundingClientRect().left + fileSystemExplorerContainer.offsetWidth - scrollbarWidth) return; - // store information about selection start + // Store information about selection start. isSelecting = true; - document.body.style.overflowY = 'hidden'; // needed in order to not put a vertical scrollbar on the document, while in vertical layout selection + document.body.style.overflowY = 'hidden'; // Needed in order to not put a vertical scrollbar on the document, while in vertical layout selection. document.documentElement.style.overflowY = 'hidden'; selectionStartPosition.x = e.pageX + fileSystemExplorer.scrollLeft; - selectionStartPosition.y = (e.pageY - getThemeTopOffset()) + fileSystemExplorerContainer.scrollTop; // not a mistake - in vertical mode, this is the overflow container! - // place the selection rectangle at the clicked location (relative to the whole page, and taking into account scroll offset), with 0 size + selectionStartPosition.y = (e.pageY - getThemeTopOffset()) + fileSystemExplorerContainer.scrollTop; // Not a mistake - in vertical mode, this is the overflow container! + // Place the selection rectangle at the clicked location (relative to the whole page, and taking into account scroll offset), with 0 size. visibleSelectionRectangle.style.left = e.pageX + 'px'; visibleSelectionRectangle.style.top = (e.pageY - getThemeTopOffset()) + 'px'; visibleSelectionRectangle.style.width = '0px'; @@ -1203,7 +1215,7 @@ * Handler for the file system browser dialog selection end. */ function endSelection() { - // selection ended, hide the selection rectangle + // Selection ended, hide the selection rectangle. isSelecting = false; document.body.style.removeProperty('overflow-y'); document.documentElement.style.removeProperty('overflow-y'); @@ -1219,13 +1231,13 @@ visibleSelectionRectangle.style.top = '0px'; visibleSelectionRectangle.style.width = '0px'; visibleSelectionRectangle.style.height = '0px'; - // go through each .e item that was inside the selection rectangle, and mark it as selected + // Go through each .e item that was inside the selection rectangle, and mark it as selected. fileSystemExplorer.querySelectorAll('.e.selection-hover').forEach(item => { item.classList.add('selected'); item.classList.remove('selection-hover'); }); const selectedElements = document.querySelectorAll('.e.selected'); - btnFileSystemBrowserConfirm.disabled = selectedElements.length === 0; // disable Confirm button if no item is selected + btnFileSystemBrowserConfirm.disabled = selectedElements.length === 0; // Disable Confirm button if no item is selected. if (selectedElements.length > 0) { var selectedPaths = '"'; selectedElements.forEach((element) => { @@ -1241,21 +1253,21 @@ * Function for handling the file system browser dialog selection. */ function handleSelection() { - if (!isSelecting) // only relevant when we have a selection initialized + if (!isSelecting) // Only relevant when we have a selection initialized. return; - // calculate dimensions of the selection rectangle + // Calculate dimensions of the selection rectangle. const currentX = currentMousePosition.x; const currentY = currentMousePosition.y; const width = currentX - (selectionStartPosition.x - fileSystemExplorer.scrollLeft); const height = currentY - (selectionStartPosition.y - fileSystemExplorerContainer.scrollTop); - // update selection rectangle dimensions + // Update selection rectangle dimensions. visibleSelectionRectangle.style.width = Math.abs(width) + 'px'; visibleSelectionRectangle.style.height = Math.abs(height) + 'px'; selectionRectangle.style.width = Math.abs(width) + 'px'; selectionRectangle.style.height = Math.abs(height) + 'px'; - // adjust position based on selection direction + // Adjust position based on selection direction. if (width < 0) { selectionRectangle.style.left = currentX + 'px'; visibleSelectionRectangle.style.left = currentX + 'px'; @@ -1271,7 +1283,7 @@ visibleSelectionRectangle.style.top = (selectionStartPosition.y - fileSystemExplorerContainer.scrollTop) + 'px'; } - // do not let the selection rectangle go outside of explorer container, clip it if needed + // Do not let the selection rectangle go outside of explorer container, clip it if needed. const containerRect = fileSystemExplorerContainer.getBoundingClientRect(); const left = parseFloat(visibleSelectionRectangle.style.left); const top = parseFloat(visibleSelectionRectangle.style.top) + 1; @@ -1294,17 +1306,17 @@ if (bottom > containerRect.bottom) visibleSelectionRectangle.style.height = (containerRect.bottom - top) + 'px'; - // change color of items that fall within selection rectangle + // Change color of items that fall within selection rectangle. const selectionRect = selectionRectangle.getBoundingClientRect(); - // go through each .e item which has not had its thumbnail retrieved yet + // Go through each .e item which has not had its thumbnail retrieved yet. fileSystemExplorer.querySelectorAll('.e').forEach(item => { const itemRect = item.getBoundingClientRect(); - // check if the item is fully or partially visible horizontally and vertically + // Check if the item is fully or partially visible horizontally and vertically. const isFullyVisibleHorizontally = itemRect.left >= selectionRect.left && itemRect.right <= selectionRect.right; const isFullyVisibleVertically = itemRect.top >= selectionRect.top && itemRect.bottom <= selectionRect.bottom; const isPartiallyVisibleHorizontally = itemRect.left < selectionRect.right && itemRect.right > selectionRect.left; const isPartiallyVisibleVertically = itemRect.top < selectionRect.bottom && itemRect.bottom > selectionRect.top; - // if the item is fully or partially visible in both directions, add it to our list + // If the item is fully or partially visible in both directions, add it to our list. if ((isFullyVisibleHorizontally || isPartiallyVisibleHorizontally) && (isFullyVisibleVertically || isPartiallyVisibleVertically)) item.classList.add('selection-hover'); else @@ -1327,22 +1339,22 @@ } /** - * Handler for the mouse up event of the file system browser dialog explorer + * Handler for the mouse up event of the file system browser dialog explorer. * @param {MouseEvent} e - The mouseup event object. */ function handleFileSystemExplorerMouseUp(e) { const explorerScrollbars = hasScrollbars(fileSystemExplorer); - // check if clicked on the horizontal scrollbar + // Check if clicked on the horizontal scrollbar. if (explorerScrollbars.horizontal && e.clientY > fileSystemExplorer.getBoundingClientRect().top + fileSystemExplorer.offsetHeight - scrollbarHeight) return; if (!e.ctrlKey && !e.shiftKey && !isSelectionMode) { - // deselect all file system elements when their explorer is clicked + // Deselect all file system elements when their explorer is clicked. fileSystemExplorer.querySelectorAll('.e.selected').forEach(item => { item.classList.remove('selected'); }); - // do not store information about what item was clicked first, in context of Shift-selection + // Do not store information about what item was clicked first, in context of Shift-selection. fileSystemExplorer.removeAttribute('data-selection-start'); - btnFileSystemBrowserConfirm.disabled = document.querySelectorAll('.e.selected').length === 0; // disable Confirm button if no item is selected + btnFileSystemBrowserConfirm.disabled = document.querySelectorAll('.e.selected').length === 0; // Disable Confirm button if no item is selected. } } @@ -1351,14 +1363,14 @@ * Clears any previous timeout and creates a new one to fetch visible items. */ function handleFileSystemBrowserScrollEvent() { - // clear any previously set timeouts to debounce the getFileSystemVisibleItems call + // Clear any previously set timeouts to debounce the getFileSystemVisibleItems call. if (scrollTimeout) clearTimeout(scrollTimeout); - // if there's an ongoing operation, abort it + // If there's an ongoing operation, abort it. if (abortController) { abortController.abort(); abortController = null; } - // set a timeout to call getFileSystemVisibleItems once the user stops scrolling + // Set a timeout to call getFileSystemVisibleItems once the user stops scrolling. scrollTimeout = setTimeout(() => { if (showThumbnails) getFileSystemVisibleItems(); @@ -1371,14 +1383,14 @@ * Clears any previous timeout and creates a new one to fetch file system browser visible items. */ function handleFileSystemBrowserResizeEvent() { - // clear any previously set timeouts to debounce the getFileSystemVisibleItems call during resize + // Clear any previously set timeouts to debounce the getFileSystemVisibleItems call during resize. if (resizeTimeout) clearTimeout(resizeTimeout); - // if there's an ongoing operation, abort it + // If there's an ongoing operation, abort it. if (abortController) { abortController.abort(); abortController = null; } - // set a timeout to call getFileSystemVisibleItems once the user stops resizing + // Set a timeout to call getFileSystemVisibleItems once the user stops resizing. resizeTimeout = setTimeout(() => { if (showThumbnails) getFileSystemVisibleItems(); @@ -1386,7 +1398,7 @@ } //+======================================================================================+ - //| Thumbnails | + //| Thumbnails. | //+======================================================================================+ /** @@ -1397,22 +1409,22 @@ function getFileSystemVisibleItems() { const containerRect = fileSystemExplorerContainer.getBoundingClientRect(); const visibleItems = []; - // go through each .e item which has not had its thumbnail retrieved yet + // Go through each .e item which has not had its thumbnail retrieved yet. const fileElements = Array.from(fileSystemExplorer.querySelectorAll('.e:not([data-thumbnail-retrieved])[data-type="File"]')); - // if the option for checking file header bytes is disabled, filter images by extension + // If the option for checking file header bytes is disabled, filter images by extension. const itemsToProcess = inspectFileForThumbnails ? fileElements : fileElements.filter(item => isImageFile(item.getAttribute('data-path'))); itemsToProcess.forEach(item => { const itemPath = item.getAttribute('data-path'); const itemRect = item.getBoundingClientRect(); - // check if the item is fully or partially visible horizontally and vertically + // Check if the item is fully or partially visible horizontally and vertically. const isFullyVisibleHorizontally = itemRect.left >= containerRect.left && itemRect.right <= containerRect.right; const isFullyVisibleVertically = itemRect.top >= containerRect.top && itemRect.bottom <= containerRect.bottom; const isPartiallyVisibleHorizontally = itemRect.left < containerRect.right && itemRect.right > containerRect.left; const isPartiallyVisibleVertically = itemRect.top < containerRect.bottom && itemRect.bottom > containerRect.top; - // if the item is fully or partially visible in both directions, add it to our list + // If the item is fully or partially visible in both directions, add it to our list. if ((isFullyVisibleHorizontally || isPartiallyVisibleHorizontally) && (isFullyVisibleVertically || isPartiallyVisibleVertically)) { - // skip entries without an image element, which happens when the active theme does not provide icons + // Skip entries without an image element, which happens when the active theme does not provide icons. const imgElement = item.querySelector('img'); if (imgElement) { visibleItems.push({ @@ -1422,7 +1434,7 @@ } } }); - // process the list of visible items + // Process the list of visible items. processVisibleItems(visibleItems); } @@ -1438,11 +1450,11 @@ async function processItem(item, visibleItems) { try { const result = await getThumbnailApiCall(item.path, imagePreviewsQuality); - // update the item's thumbnail using the retrieved data + // Update the item's thumbnail using the retrieved data. if (typeof result.base64Data !== "undefined") item.img.src = `data:${result.mimeType};base64,${result.base64Data}`; item.img.closest('.e').setAttribute('data-thumbnail-retrieved', 'true'); - // continue with next item if there are more in the queue + // Continue with next item if there are more in the queue. if (visibleItems.length > 0) { const nextItem = visibleItems.shift(); processItem(nextItem, visibleItems); @@ -1451,7 +1463,7 @@ if (error.name === 'AbortError') { // console.log('Fetch operation was aborted.'); } else { - // on error, revert the icons to the default ones of the active theme + // On error, revert the icons to the default ones of the active theme. let itemType = item.img.closest('.e').getAttribute('data-type'); const iconUrl = resolveIconUrl('', itemType); if (iconUrl !== '') @@ -1468,13 +1480,13 @@ * @throws {Error} - Throws an error if the API call fails. */ async function getThumbnailApiCall(path, quality) { - // fetch the thumbnail for the given item from the server, through the Web application, which proxies the request with the authentication of the current user + // Fetch the thumbnail for the given item from the server, through the Web application, which proxies the request with the authentication of the current user. const response = await fetch(`${clientBasePath}thumbnails/api-get-thumbnail?path=` + encodeURIComponent(path) + '&quality=' + quality, { - signal: abortController.signal // use the abort signal + signal: abortController.signal // Use the abort signal. }); if (!response.ok) throw new Error('Failed to fetch the thumbnail'); - // convert the response to a JSON object + // Convert the response to a JSON object. const blob = await response.blob(); const base64Data = await blobToBase64Async(blob); const mimeType = response.headers.get('Content-Type'); @@ -1485,13 +1497,13 @@ } /** - * Initiates the processing of visible items. Processing is batched based on thumbnailsRetrievalBatchSize. * + * Initiates the processing of visible items. Processing is batched based on thumbnailsRetrievalBatchSize. * * @param {Array} visibleItemsList - List of visible items to be processed. */ async function processVisibleItems(visibleItemsList) { const visibleItems = [...visibleItemsList]; - abortController = new AbortController(); // create a new AbortController - // process items in batches determined by thumbnailsRetrievalBatchSize + abortController = new AbortController(); // Create a new AbortController. + // Process items in batches determined by thumbnailsRetrievalBatchSize. for (let i = 0; i < Math.min(thumbnailsRetrievalBatchSize, visibleItems.length); i++) { const item = visibleItems.shift(); processItem(item, visibleItems); @@ -1500,7 +1512,7 @@ //+======================================================================================+ - //| Miscellaneous | + //| Miscellaneous. | //+======================================================================================+ /** @@ -1516,7 +1528,7 @@ showFileSystemTreeView ? element.classList.add('enabled') : element.classList.remove('enabled'); }); showFileSystemTreeView ? fileSystemTreeViewContainer.classList.remove('collapsed') : fileSystemTreeViewContainer.classList.add('collapsed'); - // if file system treeview needs to be displayed, get its file system tree structure from the API + // If file system treeview needs to be displayed, get its file system tree structure from the API. if (showFileSystemTreeView && isManualSet && addressBarInput.value !== null) { if (!addressBarInput.value.endsWith(pathSeparator)) addressBarInput.value += pathSeparator; @@ -1579,7 +1591,7 @@ } //+======================================================================================+ - //| Event Handlers | + //| Event Handlers. | //+======================================================================================+ /** @@ -1594,7 +1606,7 @@ element.addEventListener(eventName, handler, options); } - // event handlers for changing file system view modes + // Event handlers for changing file system view modes. addEventListenerIfPresent(btnListView, 'click', () => switchViewMode('list', null, true)); addEventListenerIfPresent(btnDetailsView, 'click', () => switchViewMode('details', null, true)); addEventListenerIfPresent(btnSmallIconsView, 'click', () => switchViewMode('icons', 'small', true)); @@ -1661,11 +1673,11 @@ * Event handler for the addressbar Click event. */ addEventListenerIfPresent(addressBar, 'click', function (e) { - // if the clicked element is the ul itself or one of its direct children (but not deeper nested children) + // If the clicked element is the ul itself or one of its direct children (but not deeper nested children). if (e.target === e.currentTarget || e.target.parentElement === e.currentTarget) { - this.style.display = 'none'; // hide #addressBar - addressBarInput.style.display = 'block'; // show #addressBarInput - addressBarInput.focus(); // focus on the input + this.style.display = 'none'; // Hide #addressBar. + addressBarInput.style.display = 'block'; // Show #addressBarInput. + addressBarInput.focus(); // Focus on the input. } }); @@ -1674,7 +1686,7 @@ */ window.addEventListener('resize', function () { handleFileSystemBrowserResizeEvent(); - // update all dropdowns' positions on resize + // Update all dropdowns' positions on resize. const dropdown = document.querySelector('.navigator-dropdown[data-detached="true"]'); if (dropdown) { const pathSegmentId = dropdown.getAttribute('data-path-segment-id'); @@ -1683,7 +1695,7 @@ } }); - // expose the functions and DOM elements that need to be accessed globally + // Expose the functions and DOM elements that need to be accessed globally. window.initFileSystemBrowser = initFileSystemBrowser; window.showFileSystemBrowserDialogAsync = showFileSystemBrowserDialogAsync; window.addressBar = addressBar; diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/FileSystemManagement/FileSystemItemDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/FileSystemManagement/FileSystemItemDtoFixture.cs index 97c82f4a..afcd741d 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/FileSystemManagement/FileSystemItemDtoFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/FileSystemManagement/FileSystemItemDtoFixture.cs @@ -19,14 +19,16 @@ public class FileSystemItemDtoFixture /// /// Creates a random valid . /// + /// Optional. Whether the file system item is hidden. If not provided, a random value is generated. /// The created . - public FileSystemItemDto Create() + public FileSystemItemDto Create(bool? isHidden = null) { return new FileSystemItemDto( _faker.System.FilePath(), _faker.System.FileName(), _faker.Date.Past(), - _faker.Date.Recent() + _faker.Date.Recent(), + isHidden ?? _faker.Random.Bool() ); } diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Common/FileSystemTreeNodeResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Common/FileSystemTreeNodeResponseFixture.cs index 41deb723..b3c03c95 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Common/FileSystemTreeNodeResponseFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Common/FileSystemTreeNodeResponseFixture.cs @@ -23,14 +23,16 @@ public class FileSystemTreeNodeResponseFixture /// The current depth in the tree structure. Default is 0 (root level). /// The maximum depth of the tree structure. Default is 2. /// The maximum number of children for each node. Default is 3. + /// Optional. Whether the node is hidden. If not provided, a random value is generated. /// A with a nested structure. - public FileSystemTreeNodeResponse Create(int currentDepth = 0, int maxDepth = 2, int maxChildren = 3) + public FileSystemTreeNodeResponse Create(int currentDepth = 0, int maxDepth = 2, int maxChildren = 3, bool? isHidden = null) { FileSystemTreeNodeResponse response = new() { Path = _faker.System.FilePath(), Name = _faker.System.FileName(), ItemType = FileSystemItemType.Directory, + IsHidden = isHidden ?? _faker.Random.Bool(), IsExpanded = _faker.Random.Bool(), ChildrenLoaded = true, Children = [] diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Directories/DirectoryResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Directories/DirectoryResponseFixture.cs index 3c25eb76..fab2be04 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Directories/DirectoryResponseFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Directories/DirectoryResponseFixture.cs @@ -22,15 +22,17 @@ public class DirectoryResponseFixture /// Creates a random valid . /// /// Optional. The number of children elements to create. + /// Optional. Whether the directory is hidden. If not provided, a random value is generated. /// The created . - public DirectoryResponse Create(int itemCount = 3) + public DirectoryResponse Create(int itemCount = 3, bool? isHidden = null) { return new DirectoryResponse( _faker.System.FilePath(), _faker.System.FileName(), _faker.Date.Past(), _faker.Date.Recent(), - _fileSystemItemDtoFixture.CreateMany(itemCount) + _fileSystemItemDtoFixture.CreateMany(itemCount), + isHidden ?? _faker.Random.Bool() ); } diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Files/FileResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Files/FileResponseFixture.cs index 1eae9a14..519531e6 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Files/FileResponseFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Files/FileResponseFixture.cs @@ -19,15 +19,17 @@ public class FileResponseFixture /// /// Creates a random valid . /// + /// Optional. Whether the file is hidden. If not provided, a random value is generated. /// The created . - public FileResponse Create() + public FileResponse Create(bool? isHidden = null) { return new FileResponse( _faker.System.FilePath(), _faker.System.FileName(), _faker.Date.Past(), _faker.Date.Recent(), - _faker.Random.Long() + _faker.Random.Long(), + isHidden ?? _faker.Random.Bool() ); } diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Entities/DirectoryFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Entities/DirectoryFixture.cs index a69d050d..1bce6bdc 100644 --- a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Entities/DirectoryFixture.cs +++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Entities/DirectoryFixture.cs @@ -28,6 +28,7 @@ public class DirectoryFixture /// Optional. The directory's creation date. If not provided, a random past date is generated. /// Optional. The directory's modification date. If not provided, a recent date is generated. /// Optional. The directory's status. If not provided, a random status is assigned. + /// Optional. Whether the directory is hidden. If not provided, a random value is generated. /// Optional. A list of child items to be added to the directory. /// A newly created instance. /// Thrown if the creation fails. @@ -37,6 +38,7 @@ public class DirectoryFixture Optional? dateCreated = null, Optional? dateModified = null, FileSystemItemStatus? status = null, + bool? isHidden = null, List? childItems = null) { path ??= _faker.System.FilePath(); @@ -44,8 +46,9 @@ public class DirectoryFixture dateCreated ??= Optional.Some(_faker.Date.Past()); dateModified ??= Optional.Some(_faker.Date.Recent()); status ??= _faker.PickRandom(); + isHidden ??= _faker.Random.Bool(); - Result directoryResult = Directory.Create(path, name, dateCreated.Value, dateModified.Value, status.Value); + Result directoryResult = Directory.Create(path, name, dateCreated.Value, dateModified.Value, status.Value, isHidden.Value); if (directoryResult.IsFailure) throw new InvalidOperationException("Failed to create Directory: " + string.Join(", ", directoryResult.Errors)); diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Entities/FileFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Entities/FileFixture.cs index bf8ed020..4a037194 100644 --- a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Entities/FileFixture.cs +++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/FileSystemManagementBoundedContext/FileSystemManagementAggregate/Entities/FileFixture.cs @@ -28,6 +28,7 @@ public class FileFixture /// Optional. The file's modification date. If not provided, a recent date is generated. /// Optional. The file size. If not provided, a random size is generated. /// Optional. The file's status. If not provided, a random status is assigned. + /// Optional. Whether the file is hidden. If not provided, a random value is generated. /// Whether the creation and modification dates should be included, or left unset. /// The created . public File Create( @@ -37,6 +38,7 @@ public class FileFixture Optional? dateModified = null, long? size = null, FileSystemItemStatus? status = null, + bool? isHidden = null, bool includeDates = true) { path ??= _faker.System.FilePath(); @@ -45,8 +47,9 @@ public class FileFixture dateModified ??= includeDates ? Optional.Some(_faker.Date.Recent()) : Optional.None(); size ??= _faker.Random.Long(); status ??= _faker.PickRandom(); + isHidden ??= _faker.Random.Bool(); - Result fileResult = File.Create(path, name, dateCreated.Value, dateModified.Value, size.Value, status.Value); + Result fileResult = File.Create(path, name, dateCreated.Value, dateModified.Value, size.Value, status.Value, isHidden.Value); if (fileResult.IsFailure) throw new InvalidOperationException("Failed to create File: " + string.Join(", ", fileResult.Errors)); diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/DirectoryDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/DirectoryDtoFixture.cs index c49df938..2b4adb95 100644 --- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/DirectoryDtoFixture.cs +++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/DirectoryDtoFixture.cs @@ -22,12 +22,14 @@ public class DirectoryDtoFixture /// /// Optional. The full path to the directory. /// Optional. The name of the directory. + /// Optional. Whether the directory is hidden. If not provided, a random value is generated. /// Optional. The children items of the directory. /// Whether the children items should be included, or forced to an empty collection. /// The created . public DirectoryDto Create( string? path = null, string? name = null, + bool? isHidden = null, List? items = null, bool includeItems = false) { @@ -38,6 +40,7 @@ public class DirectoryDtoFixture Name = name ?? Path.GetFileName(generatedPath), DateCreated = _faker.Date.Past(), DateModified = _faker.Date.Recent(), + IsHidden = isHidden ?? _faker.Random.Bool(), Items = includeItems ? (items ?? []) : [] }; } diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileDtoFixture.cs index 412b7678..733446a9 100644 --- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileDtoFixture.cs +++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileDtoFixture.cs @@ -23,11 +23,13 @@ public class FileDtoFixture /// Optional. The full path to the file. /// Optional. The name of the file. /// Optional. The size of the file, in bytes. + /// Optional. Whether the file is hidden. If not provided, a random value is generated. /// A configured instance. public FileDto Create( string? path = null, string? name = null, - long? size = null) + long? size = null, + bool? isHidden = null) { string generatedPath = _faker.System.FilePath(); return new FileDto @@ -36,6 +38,7 @@ public class FileDtoFixture Name = name ?? Path.GetFileName(generatedPath), DateCreated = _faker.Date.Past(), DateModified = _faker.Date.Recent(), + IsHidden = isHidden ?? _faker.Random.Bool(), Size = size ?? _faker.Random.Long(0, 10_000_000) }; } diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileSystemTreeNodeDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileSystemTreeNodeDtoFixture.cs index 277615e0..341a10b3 100644 --- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileSystemTreeNodeDtoFixture.cs +++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileSystemTreeNodeDtoFixture.cs @@ -24,11 +24,13 @@ public class FileSystemTreeNodeDtoFixture /// Optional. The full path of the file or directory. /// Optional. The name of the file or directory. /// Optional. The type of the item, indicating whether it is a file, directory, or drive. + /// Optional. Whether the node is hidden. If not provided, a random value is generated. /// A configured instance. public FileSystemTreeNodeDto Create( string? path = null, string? name = null, - FileSystemItemType? itemType = null) + FileSystemItemType? itemType = null, + bool? isHidden = null) { string generatedPath = _faker.System.FilePath(); return new FileSystemTreeNodeDto @@ -36,6 +38,7 @@ public class FileSystemTreeNodeDtoFixture Path = path ?? generatedPath, Name = name ?? Path.GetFileName(generatedPath), ItemType = itemType ?? _faker.PickRandom(), + IsHidden = isHidden ?? _faker.Random.Bool(), IsExpanded = _faker.Random.Bool(), ChildrenLoaded = _faker.Random.Bool(), Children = [] diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoriesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoriesEndpointTests.cs index ea77f98e..15134d84 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoriesEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectoriesEndpointTests.cs @@ -58,7 +58,7 @@ public class GetDirectoriesEndpointTests : IClassFixture