1 Commits

Author SHA1 Message Date
b33552531a remember last chosen local directory 2023-08-28 20:26:41 +02:00
2 changed files with 13 additions and 4 deletions

View File

@@ -9,7 +9,7 @@
<Configurations>Debug;Release</Configurations> <Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU</Platforms> <Platforms>AnyCPU</Platforms>
<ApplicationIcon>Assets/app.ico</ApplicationIcon> <ApplicationIcon>Assets/app.ico</ApplicationIcon>
<Version>0.1.1</Version> <Version>0.1.2</Version>
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers> <RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

View File

@@ -21,7 +21,7 @@ public class MainWindowViewModel : ViewModelBase
#region Properties #region Properties
[Reactive] [Reactive]
public string? Version { get; set; } = null!; public string? Version { get; set; }
[Reactive] [Reactive]
public IEnumerable<ClusterContext> ClusterContexts { get; set; } = null!; public IEnumerable<ClusterContext> ClusterContexts { get; set; } = null!;
@@ -58,6 +58,8 @@ public class MainWindowViewModel : ViewModelBase
[Reactive] [Reactive]
public Message Message { get; set; } = null!; public Message Message { get; set; } = null!;
private string _lastDirectory = ".";
#endregion Properties #endregion Properties
@@ -232,9 +234,10 @@ public class MainWindowViewModel : ViewModelBase
await Observable.StartAsync(async () => await Observable.StartAsync(async () =>
{ {
var fileName = SelectedPod?.Name + ".log"; var fileName = SelectedPod?.Name + ".log";
var saveFileName = await ApplicationHelper.SaveFile(".", fileName); var saveFileName = await ApplicationHelper.SaveFile(_lastDirectory, fileName);
if (saveFileName != null) if (saveFileName != null)
{ {
SetLastDirectory(saveFileName);
ShowWorkingMessage("Downloading Log..."); ShowWorkingMessage("Downloading Log...");
await kubernetesService.DownloadLog(SelectedNamespace, SelectedPod, SelectedContainer, saveFileName); await kubernetesService.DownloadLog(SelectedNamespace, SelectedPod, SelectedContainer, saveFileName);
HideWorkingMessage(); HideWorkingMessage();
@@ -258,9 +261,10 @@ public class MainWindowViewModel : ViewModelBase
{ {
var fileName = SelectedFile!.Name.Substring(SelectedFile!.Name.LastIndexOf('/') + 1, var fileName = SelectedFile!.Name.Substring(SelectedFile!.Name.LastIndexOf('/') + 1,
SelectedFile!.Name.Length - SelectedFile!.Name.LastIndexOf('/') - 1); SelectedFile!.Name.Length - SelectedFile!.Name.LastIndexOf('/') - 1);
var saveFileName = await ApplicationHelper.SaveFile(".", fileName); var saveFileName = await ApplicationHelper.SaveFile(_lastDirectory, fileName);
if (saveFileName != null) if (saveFileName != null)
{ {
SetLastDirectory(saveFileName);
ShowWorkingMessage("Downloading File..."); ShowWorkingMessage("Downloading File...");
await kubernetesService.DownloadFile(SelectedNamespace, SelectedPod, SelectedContainer, SelectedFile, saveFileName); await kubernetesService.DownloadFile(SelectedNamespace, SelectedPod, SelectedContainer, SelectedFile, saveFileName);
HideWorkingMessage(); HideWorkingMessage();
@@ -272,6 +276,11 @@ public class MainWindowViewModel : ViewModelBase
.Subscribe(ShowErrorMessage); .Subscribe(ShowErrorMessage);
} }
private void SetLastDirectory(string saveFileName)
{
_lastDirectory = saveFileName.Substring(0, saveFileName.LastIndexOf('\\'));
}
private void ConfigureOpenDirectoryCommand() private void ConfigureOpenDirectoryCommand()
{ {
var isDirectory = this var isDirectory = this