TUI: добавить endpoint в dashboard и выход по Q
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
@inject InMemoryLogSink LogSink
|
||||
@inject GlobalKeyboardService KeyboardService
|
||||
@inject LocalizationService Localization
|
||||
@inject IHostApplicationLifetime AppLifetime
|
||||
|
||||
@implements IDisposable
|
||||
|
||||
@@ -38,6 +39,7 @@
|
||||
SelectedIndex="@_overviewSelection"
|
||||
SelectedIndexChanged="@OnOverviewSelectionChanged"
|
||||
ViewportRows="@GetOverviewViewportRows()"
|
||||
Endpoint="@_mcpEndpoint"
|
||||
Loc="@Localization.Current" />
|
||||
}
|
||||
else if (_activeTab == Tab.Logs)
|
||||
@@ -81,6 +83,9 @@
|
||||
private int _settingsSelection;
|
||||
private bool _logsStickToBottom = true;
|
||||
|
||||
private static readonly string _mcpEndpoint =
|
||||
Environment.GetEnvironmentVariable("ASPNETCORE_URLS") ?? "http://localhost:5000";
|
||||
|
||||
private static int GetPanelHeight() => Math.Max(Console.WindowHeight - 2, 10);
|
||||
private static int GetOverviewViewportRows() => Math.Max(Console.WindowHeight - 11, 3);
|
||||
private static int GetLogsViewportRows() => Math.Max(Console.WindowHeight - 16, 5);
|
||||
@@ -152,6 +157,12 @@
|
||||
return; // StateHasChanged вызовет OnLocaleChanged
|
||||
}
|
||||
|
||||
if (args.Key is "q" or "Q")
|
||||
{
|
||||
AppLifetime.StopApplication();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (_activeTab)
|
||||
{
|
||||
case Tab.Overview:
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
<Markup Content="@Loc.OverviewTitle" Foreground="@UiPalette.Text" Decoration="@Spectre.Console.Decoration.Bold" />
|
||||
<Markup Content="@Loc.OverviewHint" Foreground="@UiPalette.TextMuted" />
|
||||
<Markup Content=" " />
|
||||
<Markup Content="@($"{Loc.DashboardEndpointLabel}: {Endpoint}")" Foreground="@UiPalette.Accent" />
|
||||
<Markup Content=" " />
|
||||
|
||||
@if (Rows.Count == 0)
|
||||
{
|
||||
@@ -30,6 +32,7 @@
|
||||
[Parameter] public int SelectedIndex { get; set; }
|
||||
[Parameter] public EventCallback<int> SelectedIndexChanged { get; set; }
|
||||
[Parameter] public int ViewportRows { get; set; } = 3;
|
||||
[Parameter] public string Endpoint { get; set; } = "";
|
||||
[Parameter] public TuiResources Loc { get; set; } = TuiResources.En;
|
||||
|
||||
private int[] GetOptions() => Enumerable.Range(0, Rows.Count).ToArray();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@using Microsoft.AspNetCore.Components
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using Microsoft.Extensions.Hosting
|
||||
@using RazorConsole.Components
|
||||
@using RazorConsole.Core
|
||||
@using RazorConsole.Core.Rendering
|
||||
|
||||
@@ -12,10 +12,11 @@ public sealed record TuiResources
|
||||
public string TabLogs { get; init; } = "";
|
||||
public string TabSettings { get; init; } = "";
|
||||
|
||||
// ── Overview ─────────────────────────────────────────────────────────────
|
||||
// ── Dashboard ────────────────────────────────────────────────────────────
|
||||
public string OverviewTitle { get; init; } = "";
|
||||
public string OverviewHint { get; init; } = "";
|
||||
public string OverviewEmpty { get; init; } = "";
|
||||
public string DashboardEndpointLabel { get; init; } = "";
|
||||
public string StateOn { get; init; } = "";
|
||||
public string StateOff { get; init; } = "";
|
||||
public string FooterModule { get; init; } = "";
|
||||
@@ -43,14 +44,15 @@ public sealed record TuiResources
|
||||
|
||||
public static readonly TuiResources En = new()
|
||||
{
|
||||
HintBar = "Tab: tabs | Arrows: navigate | Space: toggle | Enter: open | L: language",
|
||||
TabOverview = "Overview",
|
||||
HintBar = "Tab: tabs | Arrows: navigate | Space: toggle | Enter: open | L: language | Q: quit",
|
||||
TabOverview = "Dashboard",
|
||||
TabLogs = "Logs",
|
||||
TabSettings = "Settings",
|
||||
|
||||
OverviewTitle = "Module Overview",
|
||||
OverviewTitle = "Dashboard",
|
||||
OverviewHint = "Up/Down: select module. Enter: open settings.",
|
||||
OverviewEmpty = "No modules registered.",
|
||||
DashboardEndpointLabel = "MCP Endpoint",
|
||||
StateOn = "ON",
|
||||
StateOff = "OFF",
|
||||
FooterModule = "Module",
|
||||
@@ -75,14 +77,15 @@ public sealed record TuiResources
|
||||
|
||||
public static readonly TuiResources Ru = new()
|
||||
{
|
||||
HintBar = "Tab: вкладки | Стрелки: навигация | Space: вкл/выкл | Enter: открыть | L: язык",
|
||||
TabOverview = "Обзор",
|
||||
HintBar = "Tab: вкладки | Стрелки: навигация | Space: вкл/выкл | Enter: открыть | L: язык | Q: выход",
|
||||
TabOverview = "Dashboard",
|
||||
TabLogs = "Логи",
|
||||
TabSettings = "Настройки",
|
||||
|
||||
OverviewTitle = "Модули",
|
||||
OverviewTitle = "Dashboard",
|
||||
OverviewHint = "Вверх/вниз: выбор модуля. Enter: открыть настройки.",
|
||||
OverviewEmpty = "Нет зарегистрированных модулей.",
|
||||
DashboardEndpointLabel = "MCP Endpoint",
|
||||
StateOn = "ВКЛ",
|
||||
StateOff = "ВЫКЛ",
|
||||
FooterModule = "Модуль",
|
||||
|
||||
Reference in New Issue
Block a user