Directory Picker Rework (#1325)
* Started on the directory picker refactor. * Coded some basic working version. Needs styling and variable cleanup * code cleanup * Implemented the ability to expose swagger on non-development servers. * Implemented the ability to expose swagger on non-development servers.
This commit is contained in:
parent
0f5a7ee6fa
commit
9c851b0f0e
18 changed files with 189 additions and 85 deletions
|
|
@ -6,6 +6,8 @@ using System.IO.Abstractions;
|
|||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using API.DTOs.System;
|
||||
using API.Entities.Enums;
|
||||
using API.Extensions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
|
@ -29,7 +31,7 @@ namespace API.Services
|
|||
/// </summary>
|
||||
/// <param name="rootPath">Absolute path of directory to scan.</param>
|
||||
/// <returns>List of folder names</returns>
|
||||
IEnumerable<string> ListDirectory(string rootPath);
|
||||
IEnumerable<DirectoryDto> ListDirectory(string rootPath);
|
||||
Task<byte[]> ReadFileAsync(string path);
|
||||
bool CopyFilesToDirectory(IEnumerable<string> filePaths, string directoryPath, string prepend = "");
|
||||
bool Exists(string directory);
|
||||
|
|
@ -434,14 +436,18 @@ namespace API.Services
|
|||
/// </summary>
|
||||
/// <param name="rootPath"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<string> ListDirectory(string rootPath)
|
||||
public IEnumerable<DirectoryDto> ListDirectory(string rootPath)
|
||||
{
|
||||
if (!FileSystem.Directory.Exists(rootPath)) return ImmutableList<string>.Empty;
|
||||
if (!FileSystem.Directory.Exists(rootPath)) return ImmutableList<DirectoryDto>.Empty;
|
||||
|
||||
var di = FileSystem.DirectoryInfo.FromDirectoryName(rootPath);
|
||||
var dirs = di.GetDirectories()
|
||||
.Where(dir => !(dir.Attributes.HasFlag(FileAttributes.Hidden) || dir.Attributes.HasFlag(FileAttributes.System)))
|
||||
.Select(d => d.Name).ToImmutableList();
|
||||
.Select(d => new DirectoryDto()
|
||||
{
|
||||
Name = d.Name,
|
||||
FullPath = d.FullName,
|
||||
}).ToImmutableList();
|
||||
|
||||
return dirs;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue