mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16:11:10 +00:00
Implements directory browser dialog, part 6: hidden file system items toggle
This commit is contained in:
1 parent
cd44f11d9e
commit
debad9ef74
74 files changed
+596
-427
No files matched your search
+14
-8
@@ -1,4 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectories;
|
||||
using Lumina.Application.Core.FileManagement.Directories.Queries.GetDirectoryTree;
|
||||
@@ -42,11 +42,13 @@ public class DirectoriesController : ApiController
|
||||
/// Gets the tree of expanded directories leading up to <paramref name="path"/>, with the additional list of drives, and children of the last child directory.
|
||||
/// </summary>
|
||||
/// <param name="path">The path for which to get the directory tree.</param>
|
||||
/// <param name="includeHiddenElements">Whether to include hidden file system elements or not.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
[HttpGet("get-directory-tree")]
|
||||
public async IAsyncEnumerable<FileSystemTreeNodeResponse> GetDirectoryTree([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, [FromQuery] bool includeFiles, [EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
public async IAsyncEnumerable<FileSystemTreeNodeResponse> GetDirectoryTree([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path,
|
||||
[FromQuery] bool includeFiles, [FromQuery] bool includeHiddenElements, [EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _mediator.Send(new GetDirectoryTreeQuery(path, includeFiles), cancellationToken).ConfigureAwait(false);
|
||||
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _mediator.Send(new GetDirectoryTreeQuery(path, includeFiles, includeHiddenElements), cancellationToken).ConfigureAwait(false);
|
||||
if (!result.IsError && result.Value is not null)
|
||||
{
|
||||
foreach (FileSystemTreeNodeResponse treeNode in result.Value)
|
||||
@@ -62,11 +64,13 @@ public class DirectoriesController : ApiController
|
||||
/// Gets the directories of <paramref name="path"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">The path for which to get the directories.</param>
|
||||
/// <param name="includeHiddenElements">Whether to include hidden file system elements or not.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
[HttpGet("get-tree-directories")]
|
||||
public async IAsyncEnumerable<FileSystemTreeNodeResponse> GetTreeDirectories([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, [EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
public async IAsyncEnumerable<FileSystemTreeNodeResponse> GetTreeDirectories([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path,
|
||||
[FromQuery] bool includeHiddenElements, [EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _mediator.Send(new GetTreeDirectoriesQuery(path), cancellationToken).ConfigureAwait(false);
|
||||
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _mediator.Send(new GetTreeDirectoriesQuery(path,includeHiddenElements), cancellationToken).ConfigureAwait(false);
|
||||
if (!result.IsError && result.Value is not null)
|
||||
{
|
||||
foreach (FileSystemTreeNodeResponse directory in result.Value)
|
||||
@@ -82,11 +86,13 @@ public class DirectoriesController : ApiController
|
||||
/// Gets the directories of <paramref name="path"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">The path for which to get the directories.</param>
|
||||
/// <param name="includeHiddenElements">Whether to include hidden file system elements or not.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
[HttpGet("get-directories")]
|
||||
public async IAsyncEnumerable<DirectoryResponse> GetDirectories([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, [EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
public async IAsyncEnumerable<DirectoryResponse> GetDirectories([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path,
|
||||
[FromQuery] bool includeHiddenElements, [EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<DirectoryResponse>> result = await _mediator.Send(new GetDirectoriesQuery(path), cancellationToken).ConfigureAwait(false);
|
||||
ErrorOr<IEnumerable<DirectoryResponse>> result = await _mediator.Send(new GetDirectoriesQuery(path, includeHiddenElements), cancellationToken).ConfigureAwait(false);
|
||||
if (!result.IsError && result.Value is not null)
|
||||
{
|
||||
foreach (DirectoryResponse directory in result.Value)
|
||||
@@ -98,4 +104,4 @@ public class DirectoriesController : ApiController
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Core.FileManagement.Drives.Queries.GetDrives;
|
||||
using Lumina.Contracts.Responses.FileManagement;
|
||||
@@ -43,7 +43,7 @@ public class DrivesController : ApiController
|
||||
public async Task<IActionResult> GetDrives(CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _mediator.Send(new GetDrivesQuery(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(Ok, Problem);
|
||||
return result.Match(result => Ok(result), errors => Problem(errors));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Core.FileManagement.Files.Queries.GetFiles;
|
||||
using Lumina.Application.Core.FileManagement.Files.Queries.GetTreeFiles;
|
||||
@@ -31,7 +31,7 @@ public class FilesController : ApiController
|
||||
/// Initializes a new instance of the <see cref="FilesController"/> class.
|
||||
/// </summary>
|
||||
/// <param name="mediator">Injected service for mediating commands and queries.</param>
|
||||
public FilesController(ISender mediator, IMapper mapper)
|
||||
public FilesController(ISender mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
}
|
||||
@@ -42,11 +42,13 @@ public class FilesController : ApiController
|
||||
/// Gets the files of <paramref name="path"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">The path for which to get the files.</param>
|
||||
/// <param name="includeHiddenElements">Whether to include hidden file system elements or not.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
[HttpGet("get-tree-files")]
|
||||
public async IAsyncEnumerable<FileSystemTreeNodeResponse> GetTreeFiles([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, [EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
public async IAsyncEnumerable<FileSystemTreeNodeResponse> GetTreeFiles([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path,
|
||||
[FromQuery] bool includeHiddenElements, [EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _mediator.Send(new GetTreeFilesQuery(path), cancellationToken).ConfigureAwait(false);
|
||||
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _mediator.Send(new GetTreeFilesQuery(path, includeHiddenElements), cancellationToken).ConfigureAwait(false);
|
||||
foreach (FileSystemTreeNodeResponse file in result.Value)
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
@@ -59,11 +61,13 @@ public class FilesController : ApiController
|
||||
/// Gets the files of <paramref name="path"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">The path for which to get the files.</param>
|
||||
/// <param name="includeHiddenElements">Whether to include hidden file system elements or not.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
[HttpGet("get-files")]
|
||||
public async IAsyncEnumerable<FileResponse> GetFiles([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, [EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
public async IAsyncEnumerable<FileResponse> GetFiles([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path,
|
||||
[FromQuery] bool includeHiddenElements, [EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<FileResponse>> result = await _mediator.Send(new GetFilesQuery(path), cancellationToken).ConfigureAwait(false);
|
||||
ErrorOr<IEnumerable<FileResponse>> result = await _mediator.Send(new GetFilesQuery(path, includeHiddenElements), cancellationToken).ConfigureAwait(false);
|
||||
if (!result.IsError)
|
||||
{
|
||||
foreach (FileResponse file in result.Value)
|
||||
@@ -75,4 +79,4 @@ public class FilesController : ApiController
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Core.FileManagement.Paths.Commands.CombinePath;
|
||||
using Lumina.Application.Core.FileManagement.Paths.Commands.SplitPath;
|
||||
@@ -51,7 +51,7 @@ public class PathController : ApiController
|
||||
public async Task<IActionResult> GetPathRoot([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<PathSegmentResponse> result = await _mediator.Send(new GetPathRootQuery(path), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(Ok, Problem);
|
||||
return result.Match(result => Ok(result), errors => Problem(errors));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -74,7 +74,7 @@ public class PathController : ApiController
|
||||
public async Task<IActionResult> GetPathParent([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _mediator.Send(new GetPathParentQuery(path), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(Ok, Problem);
|
||||
return result.Match(result => Ok(result), errors => Problem(errors));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -87,7 +87,7 @@ public class PathController : ApiController
|
||||
public async Task<IActionResult> CombinePath([FromQuery, ModelBinder(typeof(UrlStringBinder))] string originalPath, [FromQuery, ModelBinder(typeof(UrlStringBinder))] string newPath, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<PathSegmentResponse> result = await _mediator.Send(new CombinePathCommand(originalPath, newPath), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(Ok, Problem);
|
||||
return result.Match(result => Ok(result), errors => Problem(errors));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -99,7 +99,7 @@ public class PathController : ApiController
|
||||
public async Task<IActionResult> SplitPath([FromQuery, ModelBinder(typeof(UrlStringBinder))] string path, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _mediator.Send(new SplitPathCommand(path), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(Ok, Problem);
|
||||
return result.Match(result => Ok(result), errors => Problem(errors));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -126,4 +126,4 @@ public class PathController : ApiController
|
||||
return Ok(result);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -44,7 +44,7 @@ public class BooksController : ApiController
|
||||
public async Task<IActionResult> GetBooks()
|
||||
{
|
||||
ErrorOr.ErrorOr<System.Collections.Generic.IEnumerable<Domain.Core.Aggregates.WrittenContentLibrary.BookLibraryAggregate.Book>> result = await _mediator.Send(new GetBooksQuery()).ConfigureAwait(false);
|
||||
return result.Match(Ok, Problem);
|
||||
return result.Match(result => Ok(result), errors => Problem(errors));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -58,4 +58,4 @@ public class BooksController : ApiController
|
||||
return result.Match(result => Created($"/api/v1/books/{result.Id}", result), Problem);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user