From c94ac310858bb453ecd780aa2ee3bdfda8678119 Mon Sep 17 00:00:00 2001 From: spektr Date: Wed, 4 Nov 2026 10:22:08 +0100 Subject: [PATCH] GNMON-001 M3-Final: Ressourcen-Seite mit integrierten Braille-Charts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Betreiberlayout final: Overlay-Kacheln (CPU/RAM/Disk mit Chart hinter den Controls, Fade-Maske links, dichter Text-Halo) plus GPU-Kacheln mit kompakter Werteliste (max-content-Grid), Trennlinie und bündigem GPU-Util-Chart (AutoRows via Hoehenmessung, Y-Achse 0/25/50/75/100%, rechtsbuendig vor der Diagrammflaeche). ResizeObserver haelt Breite und Zeilenzahl beim Fenster-Resize aktuell (JS-Interop, dispose-safe). Erklaerungs-/Dev-Texte entfernt, Experimentseite RessourcenNeu geloescht, Layout-Metadaten aus der Statuszeile gestrichen. Komponente: ShowYLabels, YUnit, AutoRows, GridStyle(dots25), ResizeObserver-Support. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- .../Components/AsciiBrailleChart.razor | 135 ++++++-- .../Components/Layout/MainLayout.razor | 2 +- .../Components/Pages/Home.razor | 317 ++++++++++++------ .../Services/VictoriaMetricsClient.cs | 58 ++++ .../src/Ghostnet.Dashboard/wwwroot/app.css | 128 +++++++ .../wwwroot/js/gnmon-utils.js | 25 ++ 6 files changed, 540 insertions(+), 125 deletions(-) diff --git a/llm-server/monitoring/src/Ghostnet.Dashboard/Components/AsciiBrailleChart.razor b/llm-server/monitoring/src/Ghostnet.Dashboard/Components/AsciiBrailleChart.razor index 545bfeb..ba30ff5 100644 --- a/llm-server/monitoring/src/Ghostnet.Dashboard/Components/AsciiBrailleChart.razor +++ b/llm-server/monitoring/src/Ghostnet.Dashboard/Components/AsciiBrailleChart.razor @@ -1,11 +1,23 @@ @* btop-style braille chart: 2x4 dot cells per character, vertical color gradient (green -> yellow -> red), one span per text row (cheap DOM). - The dot grid is interpolated to the measured container width so the - chart always spans the full panel. *@ + The dot grid is interpolated to the measured container width; a + ResizeObserver keeps width and (optionally) row count in sync with the + live layout. Optional Y-axis labels reserve space on the left. *@ @inject IJSRuntime JS +@implements IAsyncDisposable -
+
+ @if (ShowYLabels) + { + + } @for (var r = 0; r < _rowStrings.Count; r++) { @_rowStrings[r] @@ -14,6 +26,10 @@ @code { + private const int YLabelWidthPx = 36; + + private static readonly double[] YLabelFractions = [0, 0.25, 0.5, 0.75, 1.0]; + /// Sample values in display order (oldest first). [Parameter] public IReadOnlyList? Values { get; set; } @@ -22,7 +38,7 @@ [Parameter] public int Rows { get; set; } = 22; - /// Total pixel height of the chart. + /// Total pixel height (fallback before measurement). [Parameter] public int HeightPx { get; set; } = 220; @@ -33,13 +49,27 @@ [Parameter] public double? Max { get; set; } - /// Background grid style: lines (default), dots or none. + /// Background grid style: lines (default), dots, dots25 or none. [Parameter] public string GridStyle { get; set; } = "lines"; - /// Fallback dot columns when the container width is unknown - /// (prerendering); replaced by the measured width after the first - /// interactive render. + /// Very small Y-axis labels at 25/50/75/100 % of the scale. + [Parameter] + public bool ShowYLabels { get; set; } + + /// Unit suffix for the Y-axis labels (e.g. "%"). + [Parameter] + public string YUnit { get; set; } = "%"; + + /// + /// When true, the row count adapts to the measured container height + /// (chart fills the available space exactly, e.g. between panel + /// separators). + /// + [Parameter] + public bool AutoRows { get; set; } + + /// Fallback dot columns before the first measurement. [Parameter] public int WidthDots { get; set; } = 160; @@ -48,18 +78,28 @@ private List _rowStrings = []; private List _rowColors = []; private int _charCols = 40; - private bool _widthMeasured; + private int _rowsEff; + private double _axisMax = 1; + private double _advance; + private bool _measured; + private DotNetObjectReference? _resizeRef; + + private string GridClass => $"braille-grid-{GridStyle}"; + + private string YLabelClass => ShowYLabels ? "with-y-labels" : ""; private int RowPx => Math.Max(6, HeightPx / Rows); + private string AxisLabel(double fraction) => $"{_axisMax * fraction:F0}{YUnit}"; + protected override void OnParametersSet() { - // Only fall back before the first measurement; later data refreshes - // must keep the measured width (the reset shrank the chart back to - // half width every 10-second update). - if (!_widthMeasured) + // Fallback geometry only until the first measurement; later data + // refreshes must keep measured values (resets shrank the chart). + if (!_measured) { _charCols = Math.Max(10, WidthDots / 2); + _rowsEff = Rows; } BuildRows(); } @@ -72,37 +112,61 @@ } try { - // Measure the real container width AND the real per-glyph + // Measure the real container width and the real per-glyph // advance (font fallbacks can render braille wider than the // 0.6em monospace default; fixed ratios under-filled panels). var width = await JS.InvokeAsync("gnmon.clientWidth", _container); - var advance = await JS.InvokeAsync("gnmon.charAdvance", _rowSpans); - if (width > 0 && advance > 0) + _advance = await JS.InvokeAsync("gnmon.charAdvance", _rowSpans); + if (width > 0 && _advance > 0) { - _charCols = Math.Max(10, (int)(width / advance)); - _widthMeasured = true; - BuildRows(); - StateHasChanged(); + ApplyGeometry(width, await JS.InvokeAsync("gnmon.clientHeight", _container)); + _measured = true; + + // Keep the chart in sync when the window (and thus the + // panel) is resized. + _resizeRef = DotNetObjectReference.Create(this); + await JS.InvokeVoidAsync("gnmon.observeSize", _container, _resizeRef); } } catch (JSDisconnectedException) { - // Circuit already gone; next render retries. } catch (InvalidOperationException) { } } + [JSInvokable] + public async Task OnResized(int width, int height) + { + if (!_measured || _advance <= 0) + { + return; + } + ApplyGeometry(width, height); + await InvokeAsync(StateHasChanged); + } + + private void ApplyGeometry(int width, int height) + { + var usable = width - (ShowYLabels ? YLabelWidthPx : 0); + _charCols = Math.Max(10, (int)(usable / _advance)); + if (AutoRows && height > 0) + { + _rowsEff = Math.Max(4, height / RowPx); + } + BuildRows(); + } + private void BuildRows() { _rowStrings = []; _rowColors = []; - var dotsHigh = Rows * 4; + var dotsHigh = _rowsEff * 4; var dotCols = _charCols * 2; - // Interpolate samples onto the dot grid (btop-style full-width). + // Interpolate samples onto the dot grid (full-width, btop-style). var grid = new double[dotCols]; if (Values is not { Count: > 1 }) { @@ -130,12 +194,13 @@ { max = Math.Max(grid.DefaultIfEmpty(1).Max(), 1e-9); } + _axisMax = max.Value; - for (var visualRow = 0; visualRow < Rows; visualRow++) + for (var visualRow = 0; visualRow < _rowsEff; visualRow++) { _rowColors.Add(GradientColor(visualRow)); var row = new char[_charCols]; - var charRowFromBottom = Rows - 1 - visualRow; + var charRowFromBottom = _rowsEff - 1 - visualRow; for (var cx = 0; cx < _charCols; cx++) { @@ -175,7 +240,7 @@ /// Green (bottom) -> yellow -> red (top), Catppuccin tones. private string GradientColor(int visualRow) { - var t = Rows <= 1 ? 1 : (Rows - visualRow) / (double)(Rows - 1); + var t = _rowsEff <= 1 ? 1 : (_rowsEff - visualRow) / (double)(_rowsEff - 1); return t <= 0.5 ? Lerp(0xa6, 0xe3, 0xa1, 0xf9, 0xe2, 0xaf, t / 0.5) : Lerp(0xf9, 0xe2, 0xaf, 0xf3, 0x8b, 0xa8, (t - 0.5) / 0.5); @@ -188,4 +253,22 @@ var b = (int)Math.Round(b1 + (b2 - b1) * t); return $"rgb({r},{g},{b})"; } + + public async ValueTask DisposeAsync() + { + _resizeRef?.Dispose(); + try + { + if (_container.Id is not null) + { + await JS.InvokeVoidAsync("gnmon.unobserveSize", _container); + } + } + catch (JSDisconnectedException) + { + } + catch (InvalidOperationException) + { + } + } } diff --git a/llm-server/monitoring/src/Ghostnet.Dashboard/Components/Layout/MainLayout.razor b/llm-server/monitoring/src/Ghostnet.Dashboard/Components/Layout/MainLayout.razor index 514d970..3a1a28a 100644 --- a/llm-server/monitoring/src/Ghostnet.Dashboard/Components/Layout/MainLayout.razor +++ b/llm-server/monitoring/src/Ghostnet.Dashboard/Components/Layout/MainLayout.razor @@ -16,7 +16,7 @@
LIVE - Quelle: VictoriaMetrics · Loki · Alertmanager — M3.3 GPU-Detail + Quelle: VictoriaMetrics · Loki · Alertmanager ▮
diff --git a/llm-server/monitoring/src/Ghostnet.Dashboard/Components/Pages/Home.razor b/llm-server/monitoring/src/Ghostnet.Dashboard/Components/Pages/Home.razor index 1ec4365..cd43373 100644 --- a/llm-server/monitoring/src/Ghostnet.Dashboard/Components/Pages/Home.razor +++ b/llm-server/monitoring/src/Ghostnet.Dashboard/Components/Pages/Home.razor @@ -7,28 +7,6 @@ Ressourcen - Ghostnet.AI Monitoring

Ressourcen

-

Host-Übersicht — Live-Werte aus VictoriaMetrics (2-s-Takt).

- -
-
- CPU - @Pct(_cpu) - - Auslastung gesamt (10-s-Rate, gleitend) -
-
- Arbeitsspeicher - @Pct(_ramPct) - - @GB(_ramUsedBytes) von @GB(_ramTotalBytes) belegt -
-
- Dateisystem (Root) - @Pct(_diskPct) - - @GB(_diskUsedBytes) von @GB(_diskTotalBytes) belegt -
-
@if (_error is not null) { @@ -36,42 +14,122 @@ } else if (!_loaded) { -
Lade VictoriaMetrics-Daten …
-} -else -{ -
Datenquelle aktiv: node_exporter → VictoriaMetrics (Scrape 10 s).
+
Lade Daten …
} -

Verläufe · CPU 1 h

- -@if (_cpuHistory.Count > 0) -{ -
-
-
CPU-Auslastung (auto-skaliert auf Fenstermaximum)
- - - - +
+
+
+ CPU + @Pct(_cpu) + + Auslastung gesamt +
+
+ @if (_cpuHistory.Count > 0) + { + + }
-} -else +
+
+ Arbeitsspeicher + @Pct(_ramPct) + + @GB(_ramUsedBytes) von @GB(_ramTotalBytes) belegt +
+
+ @if (_ramHistory.Count > 0) + { + + } +
+
+
+
+ Dateisystem (Root) + @Pct(_diskPct) + + @GB(_diskUsedBytes) von @GB(_diskTotalBytes) belegt +
+
+ @if (_diskHistory.Count > 0) + { + + } +
+
+
+ +

GPUs

+ +@if (_cards.Count == 0 && _loaded) { -
Sammle Verlaufsdaten …
+
Keine AMD-GPUs sichtbar.
} +
+ @foreach (var card in _cards) + { +
+
GPU @card.Id · @card.Model
+
+
+ Auslastung@Val(card.Util, "%") + VRAM@Val(card.VramUsed, "GB") / @Val(card.VramTotal, "GB") + Edge / Junction@Temp(card.Edge) / @Temp(card.Junction) + Leistung@Val(card.Power, " W") +
+ Util + +
+
+ VRAM + +
+
+
+ @if (card.UtilHistory.Count > 0) + { + + } +
+
+ +
+ } +
+ @code { - // Short window for a near-instant counter rate; display smoothing - // happens client-side with an EMA (no window lag). + private sealed class GpuCard + { + public required string Id { get; init; } + public required string Model { get; init; } + public double? Util; + public double? VramUsed; + public double? VramTotal; + public double? VramPct; + public double? Edge; + public double? Junction; + public double? Power; + public double? FanRpm; + public double? FanPwm; + public List UtilHistory = []; + } + private const string CpuQuery = "(1 - avg(rate(node_cpu_seconds_total{mode=\"idle\"}[10s]))) * 100"; - private const double CpuEmaAlpha = 0.65; + private const string RamPctQuery = + "100 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100"; private const string RamUsedQuery = "node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes"; private const string RamTotalQuery = "node_memory_MemTotal_bytes"; @@ -80,12 +138,12 @@ else private const string DiskTotalQuery = "node_filesystem_size_bytes{mountpoint=\"/\"}"; private const string DiskPctQuery = "100 - (node_filesystem_avail_bytes{mountpoint=\"/\"} / node_filesystem_size_bytes{mountpoint=\"/\"}) * 100"; - private const string RamPctQuery = - "100 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100"; + private const double CpuEmaAlpha = 0.65; private CancellationTokenSource? _cts; private bool _loaded; private string? _error; + private int _tick; private double? _cpu; private double? _ramPct; @@ -95,13 +153,11 @@ else private double? _diskUsedBytes; private double? _diskTotalBytes; - private List _cpuHistory = []; - private double _cpuHistoryMin; - private double _cpuHistoryAvg; - private double _cpuHistoryMax; - private int _tick; + private List _cpuHistory = []; + private List _ramHistory = []; + private List _diskHistory = []; - private IReadOnlyList _cpuHistoryValues = []; + private List _cards = []; protected override void OnInitialized() { @@ -129,7 +185,7 @@ else { // Never let a data error kill the circuit: surface it. _error = $"{ex.GetType().Name}: {ex.Message}"; - Console.Error.WriteLine($"[Home] {ex}"); + Console.Error.WriteLine($"[Ressourcen] {ex}"); } await InvokeAsync(StateHasChanged); if (!await timer.WaitForNextTickAsync(ct)) @@ -140,68 +196,133 @@ else } catch (OperationCanceledException) { - // Circuit disposed; nothing to do. } catch (InvalidOperationException) { - // Renderer already gone (e.g. tab closed mid-update). } } + private async Task LoadAsync(CancellationToken ct) + { + var values = await Vm.QueryAllAsync( + [ + CpuQuery, + RamUsedQuery, + RamTotalQuery, + RamPctQuery, + DiskUsedQuery, + DiskTotalQuery, + DiskPctQuery, + ], ct); + + _cpu = values[0] is { } rawCpu + ? _loaded ? CpuEmaAlpha * rawCpu + (1 - CpuEmaAlpha) * (_cpu ?? rawCpu) : rawCpu + : null; + _ramUsedBytes = values[1]; + _ramTotalBytes = values[2]; + _ramPct = values[3]; + _diskUsedBytes = values[4]; + _diskTotalBytes = values[5]; + _diskPct = values[6]; + + var up = await Vm.QuerySeriesAsync("gn_gpu_up", ct); + if (up.Count == 0) + { + _cards = []; + _error = null; + _loaded = true; + return; + } + + var utilTask = Vm.QuerySeriesAsync("gn_gpu_utilization_percent", ct); + var vramUsedTask = Vm.QuerySeriesAsync("gn_gpu_vram_used_bytes", ct); + var vramTotalTask = Vm.QuerySeriesAsync("gn_gpu_vram_total_bytes", ct); + var edgeTask = Vm.QuerySeriesAsync("gn_gpu_edge_temp_celsius", ct); + var junctionTask = Vm.QuerySeriesAsync("gn_gpu_junction_temp_celsius", ct); + var powerTask = Vm.QuerySeriesAsync("gn_gpu_power_watts", ct); + var fanTask = Vm.QuerySeriesAsync("gn_gpu_fan_rpm", ct); + var pwmTask = Vm.QuerySeriesAsync("gn_gpu_fan_pwm_percent", ct); + await Task.WhenAll(utilTask, vramUsedTask, vramTotalTask, edgeTask, + junctionTask, powerTask, fanTask, pwmTask); + + var oldCards = _cards.ToDictionary(c => c.Id); + _cards = up + .OrderBy(s => s.Labels.TryGetValue("card", out var id) ? id : "") + .Select(s => + { + var id = s.Labels.GetValueOrDefault("card", "?"); + return new GpuCard + { + Id = id, + Model = s.Labels.GetValueOrDefault("gpu", "unknown"), + UtilHistory = oldCards.TryGetValue(id, out var old) ? old.UtilHistory : [], + }; + }) + .ToList(); + + foreach (var card in _cards) + { + card.Util = Lookup(utilTask.Result, card.Id); + card.VramUsed = Lookup(vramUsedTask.Result, card.Id); + card.VramTotal = Lookup(vramTotalTask.Result, card.Id); + card.VramPct = card.VramUsed is not null && card.VramTotal > 0 + ? card.VramUsed / card.VramTotal * 100.0 + : null; + card.Edge = Lookup(edgeTask.Result, card.Id); + card.Junction = Lookup(junctionTask.Result, card.Id); + card.Power = Lookup(powerTask.Result, card.Id); + card.FanRpm = Lookup(fanTask.Result, card.Id); + card.FanPwm = Lookup(pwmTask.Result, card.Id); + } + + _error = null; + _loaded = true; + } + private async Task LoadHistoryAsync(CancellationToken ct) { var end = DateTimeOffset.Now; var start = end.AddMinutes(-60); - _cpuHistory = [.. await Vm.QueryRangeAsync(CpuQuery, start, end, TimeSpan.FromSeconds(30), ct)]; - _cpuHistoryValues = [.. _cpuHistory.Select(p => p.Value)]; - if (_cpuHistory.Count > 0) + var step = TimeSpan.FromSeconds(30); + + _cpuHistory = [.. (await Vm.QueryRangeAsync(CpuQuery, start, end, step, ct)).Select(p => p.Value)]; + _ramHistory = [.. (await Vm.QueryRangeAsync(RamPctQuery, start, end, step, ct)).Select(p => p.Value)]; + _diskHistory = [.. (await Vm.QueryRangeAsync(DiskPctQuery, start, end, step, ct)).Select(p => p.Value)]; + + var gpuHistory = await Vm.QueryRangeSeriesAsync( + "gn_gpu_utilization_percent", start, end, step, ct); + foreach (var card in _cards) { - _cpuHistoryMin = _cpuHistoryValues.Min(); - _cpuHistoryMax = _cpuHistoryValues.Max(); - _cpuHistoryAvg = _cpuHistoryValues.Average(); + card.UtilHistory = [.. gpuHistory + .Where(s => s.Labels.GetValueOrDefault("card") == card.Id) + .SelectMany(s => s.Points) + .OrderBy(p => p.Timestamp) + .Select(p => p.Value)]; } } - private async Task LoadAsync(CancellationToken ct) - { - try - { - var values = await Vm.QueryAllAsync( - [ - CpuQuery, - RamUsedQuery, - RamTotalQuery, - RamPctQuery, - DiskUsedQuery, - DiskTotalQuery, - DiskPctQuery, - ], ct); - - _cpu = values[0] is { } rawCpu - ? _loaded ? CpuEmaAlpha * rawCpu + (1 - CpuEmaAlpha) * (_cpu ?? rawCpu) : rawCpu - : null; - _ramUsedBytes = values[1]; - _ramTotalBytes = values[2]; - _ramPct = values[3]; - _diskUsedBytes = values[4]; - _diskTotalBytes = values[5]; - _diskPct = values[6]; - _error = null; - _loaded = true; - } - catch (Exception ex) when (ex is HttpRequestException or TaskCanceledException) - { - _error = ex.Message; - } - } + private static double? Lookup(IReadOnlyList series, string card) + => series.FirstOrDefault(s => s.Labels.GetValueOrDefault("card") == card)?.Value; private static string Pct(double? value) => value is null ? "-- %" : $"{value:F0} %"; - private static string F0(double value) => $"{value:F0}"; - private static string GB(double? bytes) => bytes is null ? "--" : $"{bytes / 1024 / 1024 / 1024:F1} GB"; + private static string Val(double? value, string unit) + => value is null ? "--" : unit switch + { + "%" => $"{value:F0} %", + "GB" => $"{value / 1024 / 1024 / 1024:F1} GB", + " W" => $"{value:F1} W", + " RPM" => $"{value:F0} RPM", + " %" => $"{value:F0} %", + _ => value.ToString() ?? "--", + }; + + private static string Temp(double? celsius) + => celsius is null ? "--" : $"{celsius:F0} °C"; + public void Dispose() => _cts?.Cancel(); } diff --git a/llm-server/monitoring/src/Ghostnet.Dashboard/Services/VictoriaMetricsClient.cs b/llm-server/monitoring/src/Ghostnet.Dashboard/Services/VictoriaMetricsClient.cs index 8f281e0..ab552b8 100644 --- a/llm-server/monitoring/src/Ghostnet.Dashboard/Services/VictoriaMetricsClient.cs +++ b/llm-server/monitoring/src/Ghostnet.Dashboard/Services/VictoriaMetricsClient.cs @@ -57,6 +57,64 @@ public sealed class VictoriaMetricsClient /// public sealed record SeriesResult(IReadOnlyDictionary Labels, double Value); + /// + /// One range series with its labels (e.g. per-GPU histories). + /// + public sealed record SeriesRange( + IReadOnlyDictionary Labels, + IReadOnlyList Points); + + /// + /// Runs a range query over every result series (label-aware). + /// + public async Task> QueryRangeSeriesAsync( + string promql, DateTimeOffset start, DateTimeOffset end, TimeSpan step, + CancellationToken ct) + { + var url = string.Create(CultureInfo.InvariantCulture, + $"/api/v1/query_range?query={Uri.EscapeDataString(promql)}" + + $"&start={start.ToUnixTimeSeconds()}&end={end.ToUnixTimeSeconds()}" + + $"&step={(int)step.TotalSeconds}"); + using var response = await _http.GetAsync(url, ct); + response.EnsureSuccessStatusCode(); + + using var doc = await response.Content.ReadFromJsonAsync(ct); + var series = new List(); + if (doc is null) + { + return series; + } + var result = doc.RootElement + .GetProperty("data") + .GetProperty("result"); + if (result.ValueKind != JsonValueKind.Array) + { + return series; + } + foreach (var item in result.EnumerateArray()) + { + var labels = new Dictionary(); + foreach (var label in item.GetProperty("metric").EnumerateObject()) + { + labels[label.Name] = label.Value.GetString() ?? ""; + } + var points = new List(); + foreach (var point in item.GetProperty("values").EnumerateArray()) + { + var raw = point[1].GetString(); + if (!double.TryParse(raw, NumberStyles.Float, + CultureInfo.InvariantCulture, out var value)) + { + continue; + } + points.Add(new RangePoint( + DateTimeOffset.FromUnixTimeSeconds(point[0].GetInt64()), value)); + } + series.Add(new SeriesRange(labels, points)); + } + return series; + } + /// /// One point of a query_range result. /// diff --git a/llm-server/monitoring/src/Ghostnet.Dashboard/wwwroot/app.css b/llm-server/monitoring/src/Ghostnet.Dashboard/wwwroot/app.css index 59afb25..a753806 100644 --- a/llm-server/monitoring/src/Ghostnet.Dashboard/wwwroot/app.css +++ b/llm-server/monitoring/src/Ghostnet.Dashboard/wwwroot/app.css @@ -178,16 +178,45 @@ a { /* ---- braille chart (btop style) ---- */ .braille-chart { + position: relative; font-family: "DejaVu Sans Mono", monospace; letter-spacing: 0.02em; overflow: hidden; white-space: nowrap; + /* Grid/Graph starten erst hinter der Y-Achsenbeschriftung. */ + background-origin: content-box; } + .braille-chart.with-y-labels { + padding-left: 36px; + } + .braille-chart span { display: block; } +/* Very small Y-axis labels at 25/50/75/100 % of the scale. */ +.braille-y-labels { + position: absolute; + top: 0; + bottom: 0; + left: 0; + width: 30px; + text-align: right; + z-index: 1; + pointer-events: none; + font-size: 8px; + line-height: 8px; +} + + .braille-y-labels span { + position: absolute; + left: 0; + transform: translateY(100%); + color: var(--overlay0); + text-shadow: 0 0 3px var(--base); + } + /* Grid variants behind the graph (coarser than the data resolution). */ .braille-grid-dots { background-image: radial-gradient(circle, var(--surface0) 1px, transparent 1.5px); @@ -206,6 +235,16 @@ a { background-image: none; } +/* Dots at 25% intervals: percentage background-size scales with any + chart dimension; the dot sits on every quarter intersection. */ +.braille-grid-dots25 { + background-image: radial-gradient(circle at left bottom, + var(--surface0) 1.2px, transparent 1.9px); + background-size: 25% 25%; + background-repeat: repeat; + background-position: left bottom; +} + .section-title { font-size: 0.95rem; font-weight: 700; @@ -220,6 +259,95 @@ a { color: var(--surface2); } +/* ---- overlay tiles (chart behind the controls, fade to the left) ---- */ +.tile-overlay { + position: relative; + overflow: hidden; +} + +.tile-copy { + position: relative; + z-index: 1; + display: flex; + flex-direction: column; + gap: 0.15rem; + /* Diffuser Schleier hinter den Controls: zur Chart-Seite auslaufend. */ + background: radial-gradient(ellipse at left center, + rgba(30, 30, 46, 0.88) 0%, + rgba(30, 30, 46, 0.55) 55%, + transparent 78%); +} + + /* Glyphen-Halo, damit der Text über dem Graph lesbar bleibt. + Die Legende (tile-sub) bekommt den dichtesten Halo: sie liegt + am tiefsten im Chart und hat die kleinste Schrift. */ + .tile-copy .tile-label { + text-shadow: 0 0 4px var(--base), 0 0 8px var(--base), 0 0 12px var(--base); + } + + .tile-copy .tile-sub { + text-shadow: 0 0 3px var(--base), 0 0 6px var(--base), + 0 0 9px var(--base), 0 0 14px var(--base), + 0 0 20px var(--mantle), 0 0 26px var(--mantle); + } + + .tile-copy .tile-value { + /* Glow der Werte nicht vom Halo erstickten lassen. */ + text-shadow: 0 0 4px var(--base), 0 0 8px var(--base), + 0 0 14px rgba(166, 227, 161, 0.4); + } + +.tile-chart { + position: absolute; + top: 0.55rem; + right: 0.55rem; + bottom: 0.55rem; + width: 58%; + z-index: 0; + /* Graph fades out toward the controls on the left. */ + -webkit-mask-image: linear-gradient(to right, transparent 0, #000 30%); + mask-image: linear-gradient(to right, transparent 0, #000 30%); +} + +/* ---- gpu split (compact values left, braille chart right) ---- */ +.gpu-split { + display: flex; + gap: 0; + align-items: stretch; +} + +/* Wertepaare kleben am Label (max-content), Rest geht an den Chart. */ +.gpu-values { + display: grid; + grid-template-columns: max-content max-content; + column-gap: 0.9rem; + row-gap: 0.25rem; + align-content: start; + border-right: 1px dashed var(--surface1); + padding-right: 0.9rem; + padding-left: 0.7rem; +} + +.gpu-values .val { + text-align: right; + white-space: nowrap; +} + +.gpu-values-wide { + grid-column: 1 / -1; +} + +/* Chart bündig mit den dashed Trennern (Panel-Padding 0.9rem). */ +.gpu-chart { + flex: 1 1 auto; + min-width: 0; + overflow: hidden; + display: flex; + padding-left: 0.9rem; + margin-top: -0.9rem; + margin-bottom: -0.9rem; +} + /* ---- ascii spinners ---- */ .ascii-spin { display: inline-block; diff --git a/llm-server/monitoring/src/Ghostnet.Dashboard/wwwroot/js/gnmon-utils.js b/llm-server/monitoring/src/Ghostnet.Dashboard/wwwroot/js/gnmon-utils.js index e88e066..ad1fb1e 100644 --- a/llm-server/monitoring/src/Ghostnet.Dashboard/wwwroot/js/gnmon-utils.js +++ b/llm-server/monitoring/src/Ghostnet.Dashboard/wwwroot/js/gnmon-utils.js @@ -2,6 +2,8 @@ window.gnmon = { clientWidth: (element) => element ? element.clientWidth : 0, + clientHeight: (element) => element ? element.clientHeight : 0, + // Exact per-glyph advance of a rendered monospace text row // (includes letter-spacing and any font fallback metrics). charAdvance: (span) => { @@ -14,4 +16,27 @@ window.gnmon = { const chars = span.textContent ? span.textContent.length : 0; return chars > 0 && rect.width > 0 ? rect.width / chars : 0; }, + + _sizeObservers: new Map(), + + observeSize: (element, dotnetRef) => { + if (!element || !dotnetRef) { + return; + } + const observer = new ResizeObserver((entries) => { + const rect = entries[0].contentRect; + dotnetRef.invokeMethodAsync('OnResized', + Math.round(rect.width), Math.round(rect.height)); + }); + observer.observe(element); + window.gnmon._sizeObservers.set(element, observer); + }, + + unobserveSize: (element) => { + const observer = window.gnmon._sizeObservers.get(element); + if (observer) { + observer.disconnect(); + window.gnmon._sizeObservers.delete(element); + } + }, };