5 Commits

Author SHA1 Message Date
d405677420 Merge pull request #10 from frosch95/pr-9
Refresh button for the file list
2023-10-09 20:30:31 +02:00
0e979fad5f Closes #9 : Refresh button for the file list 2023-10-09 20:29:40 +02:00
6754210e9b Merge pull request #7 from frosch95/pr-6
Sort properties in alphabatically order
2023-10-05 14:37:30 +02:00
0d11fdd000 Closes #6 Sort properties in alphabatically order 2023-10-05 14:22:18 +02:00
b33552531a remember last chosen local directory 2023-08-28 20:26:41 +02:00
3 changed files with 39 additions and 7 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
@@ -65,6 +67,7 @@ public class MainWindowViewModel : ViewModelBase
public ReactiveCommand<Unit, Unit> DownloadCommand { get; private set; } = null!; public ReactiveCommand<Unit, Unit> DownloadCommand { get; private set; } = null!;
public ReactiveCommand<Unit, Unit> DownloadLogCommand { get; private set; } = null!; public ReactiveCommand<Unit, Unit> DownloadLogCommand { get; private set; } = null!;
public ReactiveCommand<Unit, Unit> RefreshCommand { get; private set; } = null!;
public ReactiveCommand<Unit, Unit> ParentCommand { get; private set; } = null!; public ReactiveCommand<Unit, Unit> ParentCommand { get; private set; } = null!;
public ReactiveCommand<Unit, Unit> OpenCommand { get; private set; } = null!; public ReactiveCommand<Unit, Unit> OpenCommand { get; private set; } = null!;
private ReactiveCommand<Namespace, IEnumerable<Pod>> GetPodsForNamespace { get; set; } = null!; private ReactiveCommand<Namespace, IEnumerable<Pod>> GetPodsForNamespace { get; set; } = null!;
@@ -80,6 +83,7 @@ public class MainWindowViewModel : ViewModelBase
// commands // commands
ConfigureOpenDirectoryCommand(); ConfigureOpenDirectoryCommand();
ConfigureDownloadFileCommand(kubernetesService); ConfigureDownloadFileCommand(kubernetesService);
ConfigureRefreshCommand(kubernetesService);
ConfigureDownloadLogCommand(kubernetesService); ConfigureDownloadLogCommand(kubernetesService);
ConfigureParentDirectoryCommand(); ConfigureParentDirectoryCommand();
ConfigureGetPodsForNamespaceCommand(kubernetesService); ConfigureGetPodsForNamespaceCommand(kubernetesService);
@@ -108,7 +112,7 @@ public class MainWindowViewModel : ViewModelBase
.Subscribe(x => .Subscribe(x =>
{ {
ResetNamespaces(); ResetNamespaces();
ClusterContexts = x; ClusterContexts = x.OrderBy(c => c.Name);
// select the current cluster context // select the current cluster context
SelectedClusterContext = ClusterContexts SelectedClusterContext = ClusterContexts
@@ -127,7 +131,7 @@ public class MainWindowViewModel : ViewModelBase
.Subscribe(ns => .Subscribe(ns =>
{ {
ResetPods(); ResetPods();
Namespaces = ns; Namespaces = ns.OrderBy(n => n.Name);
}); });
} }
@@ -143,7 +147,7 @@ public class MainWindowViewModel : ViewModelBase
.Subscribe(x => .Subscribe(x =>
{ {
ResetContainers(); ResetContainers();
Pods = x; Pods = x.OrderBy(p => p.Name);
}); });
} }
@@ -232,9 +236,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();
@@ -245,6 +250,24 @@ public class MainWindowViewModel : ViewModelBase
DownloadLogCommand.ThrownExceptions.ObserveOn(RxApp.MainThreadScheduler) DownloadLogCommand.ThrownExceptions.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(ShowErrorMessage); .Subscribe(ShowErrorMessage);
} }
private void ConfigureRefreshCommand(IKubernetesService kubernetesService)
{
var isSelectedContainer = this
.WhenAnyValue(x => x.SelectedContainer)
.Select(x => x != null);
RefreshCommand = ReactiveCommand.CreateFromTask(async () =>
{
await Observable.Start(() =>
{
FileInformation = GetFileInformation(kubernetesService, SelectedPath!, SelectedPod!, SelectedNamespace!, SelectedContainer!);
}, RxApp.TaskpoolScheduler);
}, isSelectedContainer, RxApp.MainThreadScheduler);
RefreshCommand.ThrownExceptions.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(ShowErrorMessage);
}
private void ConfigureDownloadFileCommand(IKubernetesService kubernetesService) private void ConfigureDownloadFileCommand(IKubernetesService kubernetesService)
{ {
@@ -258,9 +281,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 +296,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

View File

@@ -94,6 +94,9 @@
<Button Command="{Binding DownloadLogCommand}" VerticalAlignment="Center" ToolTip.Tip="Download Container Log" Margin="0 0 48 0 "> <Button Command="{Binding DownloadLogCommand}" VerticalAlignment="Center" ToolTip.Tip="Download Container Log" Margin="0 0 48 0 ">
<PathIcon Data="{StaticResource document_one_page_regular}"></PathIcon> <PathIcon Data="{StaticResource document_one_page_regular}"></PathIcon>
</Button> </Button>
<Button Command="{Binding RefreshCommand}" VerticalAlignment="Center" ToolTip.Tip="Refresh Directory">
<PathIcon Data="{StaticResource arrow_sync_circle_regular}"></PathIcon>
</Button>
<Button Command="{Binding ParentCommand}" VerticalAlignment="Center" ToolTip.Tip="Go To Parent Directory"> <Button Command="{Binding ParentCommand}" VerticalAlignment="Center" ToolTip.Tip="Go To Parent Directory">
<PathIcon Data="{StaticResource arrow_curve_up_left_regular}"></PathIcon> <PathIcon Data="{StaticResource arrow_curve_up_left_regular}"></PathIcon>
</Button> </Button>