mirror of
https://github.com/frosch95/K8sFileBrowser.git
synced 2026-04-11 12:58:22 +02:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d405677420 | |||
| 0e979fad5f | |||
| 6754210e9b | |||
| 0d11fdd000 | |||
| b33552531a |
@@ -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' ">
|
||||||
|
|||||||
@@ -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!;
|
||||||
@@ -59,12 +59,15 @@ 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
|
||||||
|
|
||||||
#region Commands
|
#region Commands
|
||||||
|
|
||||||
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();
|
||||||
@@ -246,6 +251,24 @@ public class MainWindowViewModel : ViewModelBase
|
|||||||
.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)
|
||||||
{
|
{
|
||||||
var isFile = this
|
var isFile = this
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user