From cf91d4490206f63e8b3ea1361d6fb156470e1b7d Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 25 Jun 2023 17:31:36 +0200 Subject: [PATCH] Enhanced winscp button and new file/folder menu --- .../ConnectionDetailsModal.razor | 78 ++++++++++++ .../FileManagerPartials/FileManager.razor | 120 ++++++++++-------- 2 files changed, 146 insertions(+), 52 deletions(-) create mode 100644 Moonlight/Shared/Components/FileManagerPartials/ConnectionDetailsModal.razor diff --git a/Moonlight/Shared/Components/FileManagerPartials/ConnectionDetailsModal.razor b/Moonlight/Shared/Components/FileManagerPartials/ConnectionDetailsModal.razor new file mode 100644 index 00000000..f46dffa4 --- /dev/null +++ b/Moonlight/Shared/Components/FileManagerPartials/ConnectionDetailsModal.razor @@ -0,0 +1,78 @@ +@using Moonlight.App.Helpers.Files +@using Moonlight.App.Services.Interop + +@inject ModalService ModalService + + + +@code +{ + [Parameter] + public FileAccess Access { get; set; } + + private string Host = ""; + private string Username = ""; + private int Port; + + protected override async Task OnParametersSetAsync() + { + Uri uri = new Uri(await Access.GetLaunchUrl()); + + Host = uri.Host; + Port = uri.Port; + Username = uri.UserInfo.Split(':')[0]; + } + + public async Task Show() + { + await ModalService.Show("connectionDetails"); + } +} \ No newline at end of file diff --git a/Moonlight/Shared/Components/FileManagerPartials/FileManager.razor b/Moonlight/Shared/Components/FileManagerPartials/FileManager.razor index 88c77a89..95b8b04d 100644 --- a/Moonlight/Shared/Components/FileManagerPartials/FileManager.razor +++ b/Moonlight/Shared/Components/FileManagerPartials/FileManager.razor @@ -26,7 +26,7 @@ else
- +
@@ -34,21 +34,23 @@ else @if (View != null && View.SelectedFiles.Any()) {
- @(View.SelectedFiles.Length) selected + + @(View.SelectedFiles.Length) selected +
- + - + - + - - - - - - - Launch WinSCP - +
+ + + +
- +
+ + +
- - - + }
@@ -103,13 +114,15 @@ else DisableScrolling="true"> - + + + } @code @@ -131,16 +144,19 @@ else private FileAccess MoveAccess; private FileSelectModal FileSelectModal; private FileData? SingleMoveFile = null; - + // Config private ContextAction[] Actions = Array.Empty(); + // Connection details + private ConnectionDetailsModal ConnectionDetailsModal; + protected override void OnInitialized() { MoveAccess = (FileAccess)Access.Clone(); - + List actions = new(); - + actions.Add(new() { Id = "rename", @@ -151,18 +167,18 @@ else SmartTranslateService.Translate("Rename"), SmartTranslateService.Translate("Enter a new name"), x.Name - ); + ); if (name != x.Name) { await Access.Move(x, Access.CurrentPath + name); } - + await View!.Refresh(); } }); - - actions.Add(new () + + actions.Add(new() { Id = "download", Name = "Download", @@ -188,7 +204,7 @@ else await ToastService.Error(SmartTranslateService.Translate("You are not able to download folders using the moonlight file manager")); } }); - + actions.Add(new() { Id = "compress", @@ -199,8 +215,8 @@ else await View!.Refresh(); } }); - - actions.Add(new () + + actions.Add(new() { Id = "decompress", Name = "Decompress", @@ -221,7 +237,7 @@ else await StartMoveFiles(); } }); - + actions.Add(new() { Id = "delete", @@ -232,7 +248,7 @@ else await View!.Refresh(); } }); - + Actions = actions.ToArray(); } @@ -249,11 +265,11 @@ else await InvokeAsync(StateHasChanged); return true; } - + await InvokeAsync(StateHasChanged); return false; } - + private async void Save() { var data = await Editor.GetData(); @@ -305,7 +321,7 @@ else if (string.IsNullOrEmpty(name)) return; - await Access.Write(new FileData{IsFile = true, Name = name}, ""); + await Access.Write(new FileData { IsFile = true, Name = name }, ""); await View!.Refresh(); } @@ -332,7 +348,7 @@ else private async Task CompressMultiple() { await Access.Compress(View!.SelectedFiles); - + await View!.Refresh(); } @@ -342,7 +358,7 @@ else { await Access.Move(sFile, path + sFile.Name); } - + if (SingleMoveFile != null) { await Access.Move(SingleMoveFile, path + SingleMoveFile.Name);