Skip to content

Commit

Permalink
Merge pull request #10 from frosch95/pr-9
Browse files Browse the repository at this point in the history
Refresh button for the file list
  • Loading branch information
frosch95 committed Oct 9, 2023
2 parents 6754210 + 0e979fa commit d405677
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions K8sFileBrowser/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class MainWindowViewModel : ViewModelBase

public ReactiveCommand<Unit, Unit> DownloadCommand { 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> OpenCommand { get; private set; } = null!;
private ReactiveCommand<Namespace, IEnumerable<Pod>> GetPodsForNamespace { get; set; } = null!;
Expand All @@ -82,6 +83,7 @@ public MainWindowViewModel()
// commands
ConfigureOpenDirectoryCommand();
ConfigureDownloadFileCommand(kubernetesService);
ConfigureRefreshCommand(kubernetesService);
ConfigureDownloadLogCommand(kubernetesService);
ConfigureParentDirectoryCommand();
ConfigureGetPodsForNamespaceCommand(kubernetesService);
Expand Down Expand Up @@ -248,6 +250,24 @@ await Observable.StartAsync(async () =>
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)
{
Expand Down
3 changes: 3 additions & 0 deletions K8sFileBrowser/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@
<Button Command="{Binding DownloadLogCommand}" VerticalAlignment="Center" ToolTip.Tip="Download Container Log" Margin="0 0 48 0 ">
<PathIcon Data="{StaticResource document_one_page_regular}"></PathIcon>
</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">
<PathIcon Data="{StaticResource arrow_curve_up_left_regular}"></PathIcon>
</Button>
Expand Down

0 comments on commit d405677

Please sign in to comment.