From 0e979fad5f85eee628e8f1587c527d6aff5164f9 Mon Sep 17 00:00:00 2001 From: Andreas Billmann Date: Mon, 9 Oct 2023 20:29:40 +0200 Subject: [PATCH] Closes #9 : Refresh button for the file list --- .../ViewModels/MainWindowViewModel.cs | 20 +++++++++++++++++++ K8sFileBrowser/Views/MainWindow.axaml | 3 +++ 2 files changed, 23 insertions(+) diff --git a/K8sFileBrowser/ViewModels/MainWindowViewModel.cs b/K8sFileBrowser/ViewModels/MainWindowViewModel.cs index fea758a..ed95aa7 100644 --- a/K8sFileBrowser/ViewModels/MainWindowViewModel.cs +++ b/K8sFileBrowser/ViewModels/MainWindowViewModel.cs @@ -67,6 +67,7 @@ public class MainWindowViewModel : ViewModelBase public ReactiveCommand DownloadCommand { get; private set; } = null!; public ReactiveCommand DownloadLogCommand { get; private set; } = null!; + public ReactiveCommand RefreshCommand { get; private set; } = null!; public ReactiveCommand ParentCommand { get; private set; } = null!; public ReactiveCommand OpenCommand { get; private set; } = null!; private ReactiveCommand> GetPodsForNamespace { get; set; } = null!; @@ -82,6 +83,7 @@ public class MainWindowViewModel : ViewModelBase // commands ConfigureOpenDirectoryCommand(); ConfigureDownloadFileCommand(kubernetesService); + ConfigureRefreshCommand(kubernetesService); ConfigureDownloadLogCommand(kubernetesService); ConfigureParentDirectoryCommand(); ConfigureGetPodsForNamespaceCommand(kubernetesService); @@ -248,6 +250,24 @@ public class MainWindowViewModel : ViewModelBase DownloadLogCommand.ThrownExceptions.ObserveOn(RxApp.MainThreadScheduler) .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) { diff --git a/K8sFileBrowser/Views/MainWindow.axaml b/K8sFileBrowser/Views/MainWindow.axaml index 6f87a60..8a6e0d8 100644 --- a/K8sFileBrowser/Views/MainWindow.axaml +++ b/K8sFileBrowser/Views/MainWindow.axaml @@ -94,6 +94,9 @@ +