Skip to content

Commit

Permalink
feat(Pod): Improved Console Xterm + Color support (IvanJosipovic#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanJosipovic authored Jan 13, 2025
1 parent 11ce37c commit 0a7a94b
Show file tree
Hide file tree
Showing 55 changed files with 9,303 additions and 140 deletions.
6 changes: 6 additions & 0 deletions KubeUI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KubeUI.Tests", "tests\KubeU
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KubeUI.Core", "src\KubeUI.Core\KubeUI.Core.csproj", "{57504622-EB10-4E5C-9436-B2DAA35F4335}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XtermSharp", "src\XtermSharp\XtermSharp.csproj", "{51CC524C-8557-D5ED-7ABB-7CC8FEC3E242}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -45,6 +47,10 @@ Global
{57504622-EB10-4E5C-9436-B2DAA35F4335}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57504622-EB10-4E5C-9436-B2DAA35F4335}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57504622-EB10-4E5C-9436-B2DAA35F4335}.Release|Any CPU.Build.0 = Release|Any CPU
{51CC524C-8557-D5ED-7ABB-7CC8FEC3E242}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{51CC524C-8557-D5ED-7ABB-7CC8FEC3E242}.Debug|Any CPU.Build.0 = Debug|Any CPU
{51CC524C-8557-D5ED-7ABB-7CC8FEC3E242}.Release|Any CPU.ActiveCfg = Release|Any CPU
{51CC524C-8557-D5ED-7ABB-7CC8FEC3E242}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
5 changes: 5 additions & 0 deletions src/KubeUI.Desktop/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Avalonia;
using Avalonia.Fonts.Inter;
using Velopack;

namespace KubeUI.Desktop;
Expand All @@ -21,5 +22,9 @@ public static void Main(string[] args)
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.ConfigureFonts(fontManager =>
{
fontManager.AddFontCollection(new CascadiaMonoFontCollection());
})
.WithInterFont();
}
Binary file added src/KubeUI/Assets/Fonts/CascadiaMono-Regular.otf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions src/KubeUI/CascadiaMonoFontCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Avalonia.Media.Fonts;

public sealed class CascadiaMonoFontCollection : EmbeddedFontCollection
{
public CascadiaMonoFontCollection() : base(
new Uri("fonts:Cascadia Mono", UriKind.Absolute),
new Uri("avares://KubeUI/Assets", UriKind.Absolute))
{
}
}
1 change: 1 addition & 0 deletions src/KubeUI/KubeUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@

<ItemGroup>
<ProjectReference Include="..\KubeUI.Core\KubeUI.Core.csproj" />
<ProjectReference Include="..\XtermSharp\XtermSharp.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 2 additions & 13 deletions src/KubeUI/ViewModels/ResourceListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1721,26 +1721,15 @@ private bool CanViewLogs(V1Container? container)
}

[RelayCommand(CanExecute = nameof(CanViewConsole))]
private async Task ViewConsole(V1Container container)
private void ViewConsole(V1Container container)
{
var vm = Application.Current.GetRequiredService<PodConsoleViewModel>();
vm.Cluster = Cluster;
vm.Object = ((KeyValuePair<NamespacedName, V1Pod>)SelectedItem).Value;
vm.ContainerName = container.Name;
vm.Id = $"{nameof(ViewConsole)}-{Cluster.Name}-{((KeyValuePair<NamespacedName, V1Pod>)SelectedItem).Key}-{container.Name}";

if (Factory.AddToBottom(vm))
{
try
{
await vm.Connect();
}
catch (Exception ex)
{
_logger.LogError(ex, "Error connecting to console");
return;
}
}
Factory.AddToBottom(vm);
}

private bool CanViewConsole(V1Container? container)
Expand Down
Loading

0 comments on commit 0a7a94b

Please sign in to comment.