New folder creation. Allow deletion of selected items.
parent
bd5f1a16ec
commit
0441f6a3da
|
@ -1,5 +1,6 @@
|
||||||
@using AntDesign.TableModels;
|
@using AntDesign.TableModels;
|
||||||
@inject ArchiveService ArchiveService
|
@inject ArchiveService ArchiveService
|
||||||
|
@inject IMessageService MessageService
|
||||||
|
|
||||||
<div class="file-manager">
|
<div class="file-manager">
|
||||||
<GridRow Class="file-manager-nav">
|
<GridRow Class="file-manager-nav">
|
||||||
|
@ -21,7 +22,7 @@
|
||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
<SpaceItem>
|
<SpaceItem>
|
||||||
<Tooltip Title="Refresh" MouseEnterDelay="2">
|
<Tooltip Title="Refresh" MouseEnterDelay="2">
|
||||||
<Button Type="@ButtonType.Text" Icon="@IconType.Outline.Reload" OnClick="() => ChangeDirectory(Path, false)" />
|
<Button Type="@ButtonType.Text" Icon="@IconType.Outline.Reload" OnClick="Refresh" />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
<SpaceItem Class="file-manager-nav-breadcrumbs">
|
<SpaceItem Class="file-manager-nav-breadcrumbs">
|
||||||
|
@ -34,7 +35,7 @@
|
||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
<SpaceItem>
|
<SpaceItem>
|
||||||
<Tooltip Title="New Folder" MouseEnterDelay="2">
|
<Tooltip Title="New Folder" MouseEnterDelay="2">
|
||||||
<Button Type="@ButtonType.Text" Icon="@IconType.Outline.FolderAdd" OnClick="NewFolder" />
|
<Button Type="@ButtonType.Text" Icon="@IconType.Outline.FolderAdd" OnClick="() => NewFolderModal.Open()" />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
<SpaceItem>
|
<SpaceItem>
|
||||||
|
@ -44,7 +45,7 @@
|
||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
<SpaceItem>
|
<SpaceItem>
|
||||||
<Tooltip Title="Delete" MouseEnterDelay="2">
|
<Tooltip Title="Delete" MouseEnterDelay="2">
|
||||||
<Button Type="@ButtonType.Text" Icon="@IconType.Outline.Delete" />
|
<Button Type="@ButtonType.Text" Icon="@IconType.Outline.Delete" OnClick="Delete" Disabled="@(Selected.Count() == 0)" />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
</Space>
|
</Space>
|
||||||
|
@ -109,6 +110,8 @@
|
||||||
</GridRow>
|
</GridRow>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<NewFolderModal @ref="NewFolderModal" OnFolderNameEntered="AddFolder" />
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
[Parameter] public Guid ArchiveId { get; set; }
|
[Parameter] public Guid ArchiveId { get; set; }
|
||||||
[Parameter] public string WorkingDirectory { get; set; }
|
[Parameter] public string WorkingDirectory { get; set; }
|
||||||
|
@ -125,6 +128,8 @@
|
||||||
List<IFileManagerEntry> Entries { get; set; } = new List<IFileManagerEntry>();
|
List<IFileManagerEntry> Entries { get; set; } = new List<IFileManagerEntry>();
|
||||||
HashSet<FileManagerDirectory> Directories { get; set; } = new HashSet<FileManagerDirectory>();
|
HashSet<FileManagerDirectory> Directories { get; set; } = new HashSet<FileManagerDirectory>();
|
||||||
|
|
||||||
|
NewFolderModal NewFolderModal;
|
||||||
|
|
||||||
Dictionary<string, object> OnRow(RowData<IFileManagerEntry> row) => new()
|
Dictionary<string, object> OnRow(RowData<IFileManagerEntry> row) => new()
|
||||||
{
|
{
|
||||||
["data-path"] = row.Data.Path,
|
["data-path"] = row.Data.Path,
|
||||||
|
@ -313,8 +318,47 @@
|
||||||
ChangeDirectory(Path.Parent, true);
|
ChangeDirectory(Path.Parent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewFolder()
|
void Refresh()
|
||||||
{
|
{
|
||||||
|
ChangeDirectory(Path, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddFolder(string name)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(System.IO.Path.Combine(Path.Path, name));
|
||||||
|
|
||||||
|
Refresh();
|
||||||
|
|
||||||
|
MessageService.Success("Folder created!");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
MessageService.Error("Error creating folder!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Delete()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var entry in Selected)
|
||||||
|
{
|
||||||
|
if (entry is FileManagerDirectory)
|
||||||
|
Directory.Delete(entry.Path);
|
||||||
|
else if (entry is FileManagerFile)
|
||||||
|
File.Delete(entry.Path);
|
||||||
|
}
|
||||||
|
|
||||||
|
Selected = new List<IFileManagerEntry>();
|
||||||
|
MessageService.Success("Deleted!");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
MessageService.Error("Error deleting!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<Modal Title="New Folder" Visible="@Visible" Draggable="true" DragInViewport="false" OnOk="OnOk" OnCancel="Close">
|
||||||
|
<Input @bind-Value="@Name" />
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter] public EventCallback<string> OnFolderNameEntered { get; set; }
|
||||||
|
|
||||||
|
bool Visible { get; set; } = false;
|
||||||
|
string Name { get; set; }
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
Name = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Open()
|
||||||
|
{
|
||||||
|
Name = "";
|
||||||
|
Visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async Task OnOk(MouseEventArgs e)
|
||||||
|
{
|
||||||
|
if (OnFolderNameEntered.HasDelegate)
|
||||||
|
await OnFolderNameEntered.InvokeAsync(Name);
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue