From 90d047c29a3480a03425f4954b96f776676a273d Mon Sep 17 00:00:00 2001 From: DualFroz Date: Thu, 27 Aug 2026 09:55:47 +0200 Subject: [PATCH] feat(app): wire main window, DI services, and demo dataset --- src/Vantage.App/DemoData.cs | 38 +++++++++++ src/Vantage.App/VantageAppServices.cs | 31 +++++++++ src/Vantage.App/Views/MainWindow.axaml | 78 +++++++++++++++++++++++ src/Vantage.App/Views/MainWindow.axaml.cs | 9 +++ 4 files changed, 156 insertions(+) create mode 100644 src/Vantage.App/DemoData.cs create mode 100644 src/Vantage.App/VantageAppServices.cs create mode 100644 src/Vantage.App/Views/MainWindow.axaml create mode 100644 src/Vantage.App/Views/MainWindow.axaml.cs diff --git a/src/Vantage.App/DemoData.cs b/src/Vantage.App/DemoData.cs new file mode 100644 index 0000000..54240a9 --- /dev/null +++ b/src/Vantage.App/DemoData.cs @@ -0,0 +1,38 @@ +using Vantage.Core.Alerts; +using Vantage.Core.Logs; +using Vantage.Core.Models; + +namespace Vantage.App; + +public static class DemoData +{ + public static VantageConfig Build() => new() + { + RefreshIntervalSeconds = 3, + HistoryLength = 120, + AlertRules = + { + new AlertRule { Name = "CPU saturated", Metric = "cpu", Comparison = AlertComparison.GreaterOrEqual, Threshold = 80, For = TimeSpan.FromSeconds(30), Severity = AlertSeverity.Warning }, + new AlertRule { Name = "Memory pressure", Metric = "memory", Comparison = AlertComparison.GreaterOrEqual, Threshold = 90, For = TimeSpan.FromMinutes(2), Severity = AlertSeverity.Critical }, + new AlertRule { Name = "Disk almost full", Metric = "disk", Comparison = AlertComparison.GreaterOrEqual, Threshold = 90, For = TimeSpan.Zero, Severity = AlertSeverity.Critical } + }, + LogSources = + { + LogSource.Journal("docker", "Docker"), + LogSource.Journal("ssh", "SSH"), + LogSource.File("/var/log/syslog", "syslog") + }, + Hosts = + { + new HostConfig { Name = "edge-01", Address = "10.10.0.11", Username = "root", AuthMethod = SshAuthMethod.PrivateKey, PrivateKeyPath = "~/.ssh/id_ed25519" }, + new HostConfig { Name = "storage-01", Address = "10.10.0.21", Username = "ops", AuthMethod = SshAuthMethod.PrivateKey, PrivateKeyPath = "~/.ssh/id_ed25519" }, + new HostConfig { Name = "vps-main", Address = "vps.example.net", Username = "deploy", AuthMethod = SshAuthMethod.PrivateKey, PrivateKeyPath = "~/.ssh/id_ed25519" } + }, + HealthChecks = + { + new HealthCheckConfig { Name = "Gateway HTTP", Kind = HealthKind.Http, Target = "https://example.com" }, + new HealthCheckConfig { Name = "Local SSH", Kind = HealthKind.Tcp, Target = "127.0.0.1:22" }, + new HealthCheckConfig { Name = "DNS TCP", Kind = HealthKind.Tcp, Target = "1.1.1.1:53" } + } + }; +} diff --git a/src/Vantage.App/VantageAppServices.cs b/src/Vantage.App/VantageAppServices.cs new file mode 100644 index 0000000..24e266c --- /dev/null +++ b/src/Vantage.App/VantageAppServices.cs @@ -0,0 +1,31 @@ +using Microsoft.Extensions.DependencyInjection; +using Vantage.App.ViewModels; +using Vantage.Core; + +namespace Vantage.App; + +public static class VantageAppServices +{ + public static IServiceCollection AddVantageApp(this IServiceCollection services, bool useMockProviders) => + services.AddVantageApp(useMockProviders ? VantageProviderMode.Mock : VantageProviderMode.Ssh); + + public static IServiceCollection AddVantageApp(this IServiceCollection services, VantageProviderMode mode) + { + services.AddVantageCore(mode); + services.AddTransient(); + return services; + } + + public static bool ResolveMockMode() => ResolveProviderMode() == VantageProviderMode.Mock; + + public static VantageProviderMode ResolveProviderMode() + { + var mode = Environment.GetEnvironmentVariable("VANTAGE_PROVIDERS"); + return mode?.ToLowerInvariant() switch + { + "ssh" => VantageProviderMode.Ssh, + "prometheus" => VantageProviderMode.Prometheus, + _ => VantageProviderMode.Mock + }; + } +} diff --git a/src/Vantage.App/Views/MainWindow.axaml b/src/Vantage.App/Views/MainWindow.axaml new file mode 100644 index 0000000..938a76d --- /dev/null +++ b/src/Vantage.App/Views/MainWindow.axaml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +