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 @@ +