Switch archive file inputs to use new file manager
parent
d3f13c6493
commit
3b7a0db74e
|
@ -1,14 +0,0 @@
|
||||||
@inherits FeedbackComponent<ArchiveBrowserOptions, IEnumerable<ZipArchiveEntry>>
|
|
||||||
@using System.IO.Compression;
|
|
||||||
@using LANCommander.Models;
|
|
||||||
|
|
||||||
<ArchiveBrowser ArchiveId="Options.ArchiveId" @bind-SelectedFiles="SelectedFiles" Select="Options.Select" Multiple="Options.Multiple" AllowDirectories="Options.AllowDirectories" />
|
|
||||||
|
|
||||||
@code {
|
|
||||||
private IEnumerable<ZipArchiveEntry> SelectedFiles { get; set; }
|
|
||||||
|
|
||||||
public override async Task OnFeedbackOkAsync(ModalClosingEventArgs args)
|
|
||||||
{
|
|
||||||
await base.OkCancelRefWithResult!.OnOk(SelectedFiles);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,5 @@
|
||||||
@using LANCommander.Models;
|
@using LANCommander.Components.FileManagerComponents;
|
||||||
|
@using LANCommander.Models;
|
||||||
@using System.IO.Compression;
|
@using System.IO.Compression;
|
||||||
@inject ModalService ModalService
|
@inject ModalService ModalService
|
||||||
@inject ArchiveService ArchiveService
|
@inject ArchiveService ArchiveService
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
[Parameter] public Guid ArchiveId { get; set; }
|
[Parameter] public Guid ArchiveId { get; set; }
|
||||||
[Parameter] public string ArchiveBrowserTitle { get; set; } = "Choose File";
|
[Parameter] public string ArchiveBrowserTitle { get; set; } = "Choose File";
|
||||||
[Parameter] public bool AllowDirectories { get; set; } = false;
|
[Parameter] public bool AllowDirectories { get; set; } = false;
|
||||||
|
[Parameter] public string Prefix { get; set; }
|
||||||
|
|
||||||
bool ArchiveExists { get; set; } = false;
|
bool ArchiveExists { get; set; } = false;
|
||||||
|
|
||||||
|
@ -32,15 +34,16 @@
|
||||||
private async void BrowseForFile()
|
private async void BrowseForFile()
|
||||||
{
|
{
|
||||||
var modalOptions = new ModalOptions()
|
var modalOptions = new ModalOptions()
|
||||||
{
|
{
|
||||||
Title = ArchiveBrowserTitle,
|
Title = ArchiveBrowserTitle,
|
||||||
Maximizable = false,
|
Maximizable = false,
|
||||||
DefaultMaximized = true,
|
DefaultMaximized = true,
|
||||||
Closable = true,
|
Closable = true,
|
||||||
OkText = "Select File"
|
OkText = "Select File",
|
||||||
};
|
WrapClassName = "archive-file-picker-dialog"
|
||||||
|
};
|
||||||
|
|
||||||
var browserOptions = new ArchiveBrowserOptions()
|
var browserOptions = new ArchiveFilePickerOptions()
|
||||||
{
|
{
|
||||||
ArchiveId = ArchiveId,
|
ArchiveId = ArchiveId,
|
||||||
Select = true,
|
Select = true,
|
||||||
|
@ -48,11 +51,12 @@
|
||||||
AllowDirectories = AllowDirectories
|
AllowDirectories = AllowDirectories
|
||||||
};
|
};
|
||||||
|
|
||||||
var modalRef = await ModalService.CreateModalAsync<ArchiveBrowserDialog, ArchiveBrowserOptions, IEnumerable<ZipArchiveEntry>>(modalOptions, browserOptions);
|
var modalRef = await ModalService.CreateModalAsync<ArchiveFilePickerDialog, ArchiveFilePickerOptions, IEnumerable<IFileManagerEntry>>(modalOptions, browserOptions);
|
||||||
|
|
||||||
modalRef.OnOk = async (results) =>
|
modalRef.OnOk = async (results) =>
|
||||||
{
|
{
|
||||||
Value = "{InstallDir}/" + results.FirstOrDefault().FullName;
|
if (!String.IsNullOrWhiteSpace(Prefix))
|
||||||
|
Value = "{InstallDir}/" + results.FirstOrDefault().Path;
|
||||||
|
|
||||||
if (ValueChanged.HasDelegate)
|
if (ValueChanged.HasDelegate)
|
||||||
await ValueChanged.InvokeAsync(Value);
|
await ValueChanged.InvokeAsync(Value);
|
|
@ -0,0 +1,23 @@
|
||||||
|
@inherits FeedbackComponent<ArchiveFilePickerOptions, IEnumerable<IFileManagerEntry>>
|
||||||
|
@using System.IO.Compression;
|
||||||
|
@using LANCommander.Components.FileManagerComponents;
|
||||||
|
@using LANCommander.Models;
|
||||||
|
|
||||||
|
<FileManager ArchiveId="Options.ArchiveId" @bind-Selected="SelectedFiles" EntryVisible="IsEntryVisible" SelectMultiple="Options.Multiple" Features="@(FileManagerFeatures.NavigationBack | FileManagerFeatures.NavigationForward | FileManagerFeatures.UpALevel | FileManagerFeatures.Breadcrumbs)" />
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private IEnumerable<IFileManagerEntry> SelectedFiles { get; set; }
|
||||||
|
|
||||||
|
public override async Task OnFeedbackOkAsync(ModalClosingEventArgs args)
|
||||||
|
{
|
||||||
|
await base.OkCancelRefWithResult!.OnOk(SelectedFiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsEntryVisible(IFileManagerEntry entry)
|
||||||
|
{
|
||||||
|
if (!Options.AllowDirectories && entry is FileManagerDirectory)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
namespace LANCommander.Models
|
namespace LANCommander.Models
|
||||||
{
|
{
|
||||||
public class ArchiveBrowserOptions
|
public class ArchiveFilePickerOptions
|
||||||
{
|
{
|
||||||
public Guid ArchiveId { get; set; }
|
public Guid ArchiveId { get; set; }
|
||||||
public bool Select { get; set; }
|
public bool Select { get; set; }
|
|
@ -1,4 +1,5 @@
|
||||||
@using LANCommander.Data.Models
|
@using LANCommander.Components.FileManagerComponents;
|
||||||
|
@using LANCommander.Data.Models
|
||||||
@using LANCommander.Extensions
|
@using LANCommander.Extensions
|
||||||
@using LANCommander.Models;
|
@using LANCommander.Models;
|
||||||
@using System.IO.Compression;
|
@using System.IO.Compression;
|
||||||
|
@ -11,7 +12,7 @@
|
||||||
<Input Type="text" @bind-Value="context.Name" />
|
<Input Type="text" @bind-Value="context.Name" />
|
||||||
</PropertyColumn>
|
</PropertyColumn>
|
||||||
<PropertyColumn Property="a => a.Path">
|
<PropertyColumn Property="a => a.Path">
|
||||||
<InputArchiveFile @bind-Value="context.Path" ArchiveId="@ArchiveId" AllowDirectories="true" />
|
<ArchiveFilePicker @bind-Value="context.Path" ArchiveId="@ArchiveId" AllowDirectories="true" />
|
||||||
</PropertyColumn>
|
</PropertyColumn>
|
||||||
<PropertyColumn Property="a => a.Arguments">
|
<PropertyColumn Property="a => a.Arguments">
|
||||||
<Input Type="text" @bind-Value="context.Arguments" />
|
<Input Type="text" @bind-Value="context.Arguments" />
|
||||||
|
@ -100,18 +101,18 @@
|
||||||
OkText = "Select File"
|
OkText = "Select File"
|
||||||
};
|
};
|
||||||
|
|
||||||
var browserOptions = new ArchiveBrowserOptions()
|
var browserOptions = new ArchiveFilePickerOptions()
|
||||||
{
|
{
|
||||||
ArchiveId = ArchiveId,
|
ArchiveId = ArchiveId,
|
||||||
Select = true,
|
Select = true,
|
||||||
Multiple = false
|
Multiple = false
|
||||||
};
|
};
|
||||||
|
|
||||||
var modalRef = await ModalService.CreateModalAsync<ArchiveBrowserDialog, ArchiveBrowserOptions, IEnumerable<ZipArchiveEntry>>(modalOptions, browserOptions);
|
var modalRef = await ModalService.CreateModalAsync<ArchiveFilePickerDialog, ArchiveFilePickerOptions, IEnumerable<IFileManagerEntry>>(modalOptions, browserOptions);
|
||||||
|
|
||||||
modalRef.OnOk = (results) =>
|
modalRef.OnOk = (results) =>
|
||||||
{
|
{
|
||||||
action.Path = results.FirstOrDefault().FullName;
|
action.Path = results.FirstOrDefault().Path;
|
||||||
|
|
||||||
var parts = action.Path.Split('/');
|
var parts = action.Path.Split('/');
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<InputArchiveFile @bind-Value="context.Path" ArchiveId="@ArchiveId" AllowDirectories="true" />
|
<ArchiveFilePicker @bind-Value="context.Path" ArchiveId="@ArchiveId" AllowDirectories="true" />
|
||||||
}
|
}
|
||||||
</PropertyColumn>
|
</PropertyColumn>
|
||||||
<ActionColumn>
|
<ActionColumn>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
@using LANCommander.Data.Enums;
|
@using LANCommander.Components.FileManagerComponents;
|
||||||
|
@using LANCommander.Data.Enums;
|
||||||
@using LANCommander.Extensions;
|
@using LANCommander.Extensions;
|
||||||
@using LANCommander.Models
|
@using LANCommander.Models
|
||||||
@using LANCommander.Services
|
@using LANCommander.Services
|
||||||
|
@ -213,18 +214,18 @@
|
||||||
OkText = "Insert File Path"
|
OkText = "Insert File Path"
|
||||||
};
|
};
|
||||||
|
|
||||||
var browserOptions = new ArchiveBrowserOptions()
|
var browserOptions = new ArchiveFilePickerOptions()
|
||||||
{
|
{
|
||||||
ArchiveId = ArchiveId,
|
ArchiveId = ArchiveId,
|
||||||
Select = true,
|
Select = true,
|
||||||
Multiple = false
|
Multiple = false
|
||||||
};
|
};
|
||||||
|
|
||||||
var modalRef = await ModalService.CreateModalAsync<ArchiveBrowserDialog, ArchiveBrowserOptions, IEnumerable<ZipArchiveEntry>>(modalOptions, browserOptions);
|
var modalRef = await ModalService.CreateModalAsync<ArchiveFilePickerDialog, ArchiveFilePickerOptions, IEnumerable<IFileManagerEntry>>(modalOptions, browserOptions);
|
||||||
|
|
||||||
modalRef.OnOk = (results) =>
|
modalRef.OnOk = (results) =>
|
||||||
{
|
{
|
||||||
var path = results.FirstOrDefault().FullName;
|
var path = results.FirstOrDefault().Path;
|
||||||
|
|
||||||
Editor.Trigger("keyboard", "type", new
|
Editor.Trigger("keyboard", "type", new
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
@page "/Games/{id:guid}"
|
@page "/Games/{id:guid}"
|
||||||
@page "/Games/{id:guid}/{panel}"
|
@page "/Games/{id:guid}/{panel}"
|
||||||
@page "/Games/Add"
|
@page "/Games/Add"
|
||||||
|
@using LANCommander.Components.FileManagerComponents;
|
||||||
@using LANCommander.Models;
|
@using LANCommander.Models;
|
||||||
@using LANCommander.Pages.Games.Components
|
@using LANCommander.Pages.Games.Components
|
||||||
@using System.IO.Compression;
|
@using System.IO.Compression;
|
||||||
|
@ -70,7 +71,7 @@
|
||||||
<Input @bind-Value="@context.SortTitle" />
|
<Input @bind-Value="@context.SortTitle" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem Label="Icon">
|
<FormItem Label="Icon">
|
||||||
<InputArchiveFile @bind-Value="context.Icon" ArchiveId="@LatestArchiveId" AllowDirectories="true" />
|
<ArchiveFilePicker @bind-Value="context.Icon" ArchiveId="@LatestArchiveId" AllowDirectories="true" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem Label="Notes">
|
<FormItem Label="Notes">
|
||||||
<TextArea @bind-Value="@context.Notes" MaxLength=2000 ShowCount />
|
<TextArea @bind-Value="@context.Notes" MaxLength=2000 ShowCount />
|
||||||
|
@ -160,7 +161,7 @@ else
|
||||||
IEnumerable<Genre> Genres;
|
IEnumerable<Genre> Genres;
|
||||||
IEnumerable<Data.Models.Tag> Tags;
|
IEnumerable<Data.Models.Tag> Tags;
|
||||||
|
|
||||||
ArchiveBrowserDialog ArchiveBrowserDialog;
|
ArchiveFilePickerDialog ArchiveFilePickerDialog;
|
||||||
|
|
||||||
Modal FileSelectorModal;
|
Modal FileSelectorModal;
|
||||||
|
|
||||||
|
@ -250,18 +251,18 @@ else
|
||||||
OkText = "Select File"
|
OkText = "Select File"
|
||||||
};
|
};
|
||||||
|
|
||||||
var browserOptions = new ArchiveBrowserOptions()
|
var browserOptions = new ArchiveFilePickerOptions()
|
||||||
{
|
{
|
||||||
ArchiveId = Game.Archives.FirstOrDefault().Id,
|
ArchiveId = Game.Archives.FirstOrDefault().Id,
|
||||||
Select = true,
|
Select = true,
|
||||||
Multiple = false
|
Multiple = false
|
||||||
};
|
};
|
||||||
|
|
||||||
var modalRef = await ModalService.CreateModalAsync<ArchiveBrowserDialog, ArchiveBrowserOptions, IEnumerable<ZipArchiveEntry>>(modalOptions, browserOptions);
|
var modalRef = await ModalService.CreateModalAsync<ArchiveFilePickerDialog, ArchiveFilePickerOptions, IEnumerable<IFileManagerEntry>>(modalOptions, browserOptions);
|
||||||
|
|
||||||
modalRef.OnOk = (results) =>
|
modalRef.OnOk = (results) =>
|
||||||
{
|
{
|
||||||
Game.Icon = results.FirstOrDefault().FullName;
|
Game.Icon = results.FirstOrDefault().Path;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
};
|
};
|
||||||
|
|
|
@ -142,6 +142,14 @@
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.archive-file-picker-dialog .ant-modal-body {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.archive-file-picker-dialog .file-manager {
|
||||||
|
height: calc(100vh - 55px - 53px);
|
||||||
|
}
|
||||||
|
|
||||||
@media screen and (min-width: 768px) {
|
@media screen and (min-width: 768px) {
|
||||||
.mobile-menu {
|
.mobile-menu {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
Loading…
Reference in New Issue