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