From a8b6cd4061b5ccda88e1b78bce5a9b7202ec7e18 Mon Sep 17 00:00:00 2001 From: jhartworks Date: Wed, 25 Nov 2026 15:45:49 +0100 Subject: [PATCH] feat: add modal dialog, paged results, scan status, and trend value table components - Introduced ModalDialog component for displaying modal dialogs with accessibility features. - Added PagedResults component to handle pagination of items with customizable rendering. - Created ScanStatus component to display the status of a scan with elapsed time. - Implemented TrendValueTable component for displaying trend data in a paginated table format. - Added measurement utility functions for formatting and validating measurement values. - Included tests for measurement functions and trend series fetching logic to ensure correctness. --- api/src/index.js | 3 +- api/src/lib/isp.js | 37 +- bacnet-collector/src/index.js | 8 +- collector/src/index.js | 18 +- installer/README.md | 2 + installer/SetupEngine.cs | 23 +- installer/SetupSmokeTests.cs | 19 + installer/SetupWizard.cs | 86 +- installer/setup.config.json | 3 +- shared/trend-preferences.mjs | 8 + symcon-collector/src/index.js | 1 + web/src/App.jsx | 640 ++++--- web/src/components/Gauge.jsx | 20 +- web/src/components/ModalDialog.jsx | 23 + web/src/components/PagedResults.jsx | 21 + web/src/components/ScanStatus.jsx | 20 + web/src/components/Sidebar.jsx | 9 +- web/src/components/TrendChart.jsx | 95 +- web/src/components/TrendValueTable.jsx | 40 + web/src/components/measurement.mjs | 10 + web/src/components/trend-colors.mjs | 30 +- web/src/styles.css | 2446 +++++++----------------- web/test/audit.test.mjs | 74 + 23 files changed, 1479 insertions(+), 2157 deletions(-) create mode 100644 web/src/components/ModalDialog.jsx create mode 100644 web/src/components/PagedResults.jsx create mode 100644 web/src/components/ScanStatus.jsx create mode 100644 web/src/components/TrendValueTable.jsx create mode 100644 web/src/components/measurement.mjs create mode 100644 web/test/audit.test.mjs diff --git a/api/src/index.js b/api/src/index.js index 6c360db..98ac541 100644 --- a/api/src/index.js +++ b/api/src/index.js @@ -835,7 +835,8 @@ async function getTrendDisplayOptions(user) { } async function fetchDisplayTrend(points, range, { maxSeries, defaultPresetDays }) { - const trend = await fetchTrendSeries(pool, redis, points.slice(0, maxSeries), normalizeRange(range, defaultPresetDays)); + const displayedPoints = points.slice(0, maxSeries); + const trend = await fetchTrendSeries(pool, redis, displayedPoints, normalizeRange(range, defaultPresetDays, displayedPoints.length)); return { ...trend, requestedSeriesCount: points.length, maxSeries }; } diff --git a/api/src/lib/isp.js b/api/src/lib/isp.js index e55c9c4..7d428eb 100644 --- a/api/src/lib/isp.js +++ b/api/src/lib/isp.js @@ -1,5 +1,6 @@ import { AUTO_UNIT, DEFAULT_ANALOG_UNIT, resolveEngineeringUnit } from "../../../shared/engineering-units.mjs"; import { LEGACY_DATUM_UTC, LEGACY_TREND_TIME_ZONE } from "../../../shared/trend-time.mjs"; +import { DEFAULT_TREND_ROWS, MIN_TREND_ROWS, maxTrendRowsForSeries } from "../../../shared/trend-preferences.mjs"; const META_PREFIX = "meta:isp:"; export const LEGACY_POINT_LIMIT = 200; @@ -554,6 +555,7 @@ export async function fetchTrendSeries(pool, redis, points, range) { }, new Map()); const mergedRows = new Map(); + let rowLimitReached = false; for (const [isp, pointDescriptors] of grouped.entries()) { const tableInfo = await describeTrendTable(pool, null, isp); @@ -562,8 +564,9 @@ export async function fetchTrendSeries(pool, redis, points, range) { } if (tableInfo.storage === "narrow") { - const placeholders = pointDescriptors.map(() => "?").join(", "); - const limit = Math.max(pointDescriptors.length, (range.maxRows || 4000) * Math.max(1, pointDescriptors.length)); + const byIndex = new Map(pointDescriptors.map((point) => [point.pointIndex, point])); + const placeholders = Array.from(byIndex, () => "?").join(", "); + const limit = range.maxRows * byIndex.size; const [rows] = await pool.query( ` SELECT datum, point_index, value @@ -573,16 +576,20 @@ export async function fetchTrendSeries(pool, redis, points, range) { ORDER BY datum DESC, id DESC LIMIT ? `, - [...pointDescriptors.map((descriptor) => descriptor.pointIndex), range.from, range.to, limit] + [...byIndex.keys(), range.from, range.to, limit + 1] ); + if (rows.length > limit) { + rows.pop(); + rowLimitReached = true; + } rows.reverse().forEach((row) => { const timestamp = new Date(row.datum).toISOString(); if (!mergedRows.has(timestamp)) { mergedRows.set(timestamp, { timestamp }); } const target = mergedRows.get(timestamp); - const descriptor = pointDescriptors.find((item) => item.pointIndex === Number(row.point_index)); + const descriptor = byIndex.get(Number(row.point_index)); if (!descriptor) { return; } @@ -596,16 +603,20 @@ export async function fetchTrendSeries(pool, redis, points, range) { const columns = pointDescriptors .map((descriptor) => `\`Wert${descriptor.pointIndex}\``) .join(", "); - const limit = range.maxRows || 4000; + const limit = range.maxRows; const [rows] = await pool.query( `SELECT ${LEGACY_DATUM_UTC} AS datum, ${columns} FROM \`${isp}\` WHERE datum BETWEEN DATE_SUB(?, INTERVAL 1 DAY) AND DATE_ADD(?, INTERVAL 1 DAY) AND ${LEGACY_DATUM_UTC} BETWEEN ? AND ? ORDER BY \`${isp}\`.datum DESC LIMIT ?`, - [LEGACY_TREND_TIME_ZONE, range.from, range.to, LEGACY_TREND_TIME_ZONE, range.from, range.to, limit] + [LEGACY_TREND_TIME_ZONE, range.from, range.to, LEGACY_TREND_TIME_ZONE, range.from, range.to, limit + 1] ); + if (rows.length > limit) { + rows.pop(); + rowLimitReached = true; + } rows.reverse().forEach((row) => { const timestamp = new Date(row.datum).toISOString(); @@ -624,9 +635,13 @@ export async function fetchTrendSeries(pool, redis, points, range) { }); } + const sortedRows = [...mergedRows.values()].sort((left, right) => left.timestamp.localeCompare(right.timestamp)); return { series: descriptors, - rows: [...mergedRows.values()].sort((left, right) => left.timestamp.localeCompare(right.timestamp)), + rows: sortedRows.slice(-range.maxRows), + effectiveMaxRows: range.maxRows, + requestedMaxRows: range.requestedMaxRows, + rowLimitReached: rowLimitReached || sortedRows.length > range.maxRows, }; } @@ -714,9 +729,10 @@ export async function fetchLatestValues(pool, redis, points) { return values; } -export function normalizeRange(input = {}, defaultPresetDays = 1) { +export function normalizeRange(input = {}, defaultPresetDays = 1, seriesCount = 1) { const presetDays = Number(input.presetDays || defaultPresetDays); - const maxRows = Number(input.maxRows || 4000); + const maxRows = Number(input.maxRows || DEFAULT_TREND_ROWS); + const requestedMaxRows = Number.isFinite(maxRows) ? Math.trunc(maxRows) : DEFAULT_TREND_ROWS; const now = new Date(); const to = input.to ? new Date(input.to) : now; const from = input.from ? new Date(input.from) : new Date(now.getTime() - presetDays * 24 * 60 * 60 * 1000); @@ -724,7 +740,8 @@ export function normalizeRange(input = {}, defaultPresetDays = 1) { return { from, to, - maxRows: Number.isFinite(maxRows) ? Math.max(100, Math.min(maxRows, 10000)) : 4000, + requestedMaxRows, + maxRows: Math.max(MIN_TREND_ROWS, Math.min(requestedMaxRows, maxTrendRowsForSeries(seriesCount))), }; } diff --git a/bacnet-collector/src/index.js b/bacnet-collector/src/index.js index 46092a5..590a24f 100644 --- a/bacnet-collector/src/index.js +++ b/bacnet-collector/src/index.js @@ -472,7 +472,7 @@ async function scanObjects(client, device, portNumber) { }); } - return points; + return { points, pointLimitReached: values.length > pointLimit }; } function encodeBacnetContextUnsigned(tagNumber, value) { @@ -764,7 +764,9 @@ async function scanNetwork(body) { if (resolvedName) { device.name = resolvedName; } - device.points = await scanObjects(client, device, routing.port); + const scan = await scanObjects(client, device, routing.port); + device.points = scan.points; + device.pointLimitReached = scan.pointLimitReached; device.pointCount = device.points.length; } } @@ -778,6 +780,7 @@ async function scanNetwork(body) { rawTrace: body.debug === true ? rawTrace : undefined, rawDebug: body.debug === true ? rawDebug : undefined, points: visibleDevices.flatMap((device) => device.points || []), + pointLimitReached: visibleDevices.some((device) => device.pointLimitReached), scannedAt: new Date().toISOString(), }; } finally { @@ -831,6 +834,7 @@ async function readCurrentValue(source, datapoint) { }); }); const raw = extractValue(propertyValue); + if (raw == null || (typeof raw === "string" && !raw.trim())) return null; if (typeof raw === "boolean") { return raw ? 1 : 0; } diff --git a/collector/src/index.js b/collector/src/index.js index 8d6b9bb..875f683 100644 --- a/collector/src/index.js +++ b/collector/src/index.js @@ -776,6 +776,8 @@ async function scanOpcuaEndpoint(body) { endpoints: [{ url: endpointUrl, securityMode: "auto", securityPolicy: "auto" }], tree, nodes: state.nodes, + maxNodes: state.maxNodes, + nodeLimitReached: state.nodes.length >= state.maxNodes, sampleNodes: state.nodes, scannedAt: new Date().toISOString(), }; @@ -804,6 +806,7 @@ async function readOpcuaValue(source, datapoint) { const dataValue = await session.readVariableValue(nodeId); await session.close(); const value = dataValue?.value?.value; + if (value == null || (typeof value === "string" && !value.trim())) return null; if (typeof value === "boolean") { return value ? 1 : 0; } @@ -994,6 +997,7 @@ async function readIpsymconValue(source, datapoint) { } const response = await requestIpsymconApi(source, { function: "getvalue", id: variableId }); const raw = response.value ?? response.variable?.value; + if (raw == null || (typeof raw === "string" && !raw.trim())) return null; if (typeof raw === "boolean") { return raw ? 1 : 0; } @@ -1339,7 +1343,7 @@ async function scanBacnetObjects(client, device, portNumber) { hasValue: raw !== null, }); } - return points; + return { points, pointLimitReached: values.length > LOCAL_POINT_LIMIT }; } async function requestExternalBacnetScan(body) { @@ -1368,6 +1372,7 @@ async function scanBacnetNetwork(body) { const bacnet = await loadOptionalPackage("node-bacnet"); const portNumber = Number(body.port || 47808); const timeout = Number(body.timeout || 6000); + const includeObjects = body.includeObjects === true || String(body.includeObjects).toLowerCase() === "true"; const { client, routing } = createBacnetClientInstance(bacnet, body, timeout); const devices = []; @@ -1381,13 +1386,18 @@ async function scanBacnetNetwork(body) { if (resolvedName) { device.name = resolvedName; } - device.points = await scanBacnetObjects(client, device, portNumber); + if (includeObjects) { + const scan = await scanBacnetObjects(client, device, portNumber); + device.points = scan.points; + device.pointLimitReached = scan.pointLimitReached; + } } try { client.close(); } catch {} resolve({ routing, devices, points: devices.flatMap((device) => device.points || []), + pointLimitReached: devices.some((device) => device.pointLimitReached), scannedAt: new Date().toISOString(), }); } catch (error) { @@ -1475,6 +1485,10 @@ async function readBacnetValue(source, datapoint) { return; } const raw = value?.values?.[0]?.value; + if (raw == null || (typeof raw === "string" && !raw.trim())) { + resolve(null); + return; + } if (typeof raw === "boolean") { resolve(raw ? 1 : 0); return; diff --git a/installer/README.md b/installer/README.md index 65e6752..f111543 100644 --- a/installer/README.md +++ b/installer/README.md @@ -6,6 +6,8 @@ 4. Die Fragen zur Konfiguration beantworten. Bei Passwörtern kannst du den sicher erzeugten Vorschlag übernehmen. Für vorhandene Controller aktiviert „Bestandsanlage“ den bisherigen Datenbankzugang `wago` mit Passwort `3112` und gibt den MariaDB-Port im Netzwerk frei. 5. Docker Desktop bei Bedarf fertig einrichten. Der Assistent baut und startet die Dienste und prüft Web, API und Collector. Danach kannst du SE-LTD über den Link im Assistenten auf Port 81 öffnen. +Die Fortschrittsanzeige nennt den aktuellen Schritt und die bisherige Laufzeit. Mit „Nach Schritt anhalten“ stoppt der Assistent vor dem nächsten Schritt. Ein gerade laufender Build darf fertig werden; bereits gestartete Dienste und gespeicherte Daten werden nicht entfernt. + Die Option „Nur dieser Rechner“ beschränkt Web, API, Collector und Hilfsoberflächen auf die lokale IPv4-Adresse. „Zugriff aus dem Netzwerk“ öffnet Web, API und Collector und setzt `CORS_ORIGIN=*`. Der Assistent ändert keine Windows-Firewallregeln. Verwende den Netzzugriff nur im vertrauenswürdigen Netz. Eine bestehende `.env` bleibt unverändert. „Bestandsanlage“ bezieht sich auf den Controller-Zugang für eine neu aufgesetzte Datenbank. Vorhandene Datenbank-Volumes ändern ihr Passwort nicht durch eine neue `.env`. Es wird kein Backup oder Datenimport durchgeführt und es werden keine bestehenden Docker-Volumes gelöscht. diff --git a/installer/SetupEngine.cs b/installer/SetupEngine.cs index 5c069a0..f460571 100644 --- a/installer/SetupEngine.cs +++ b/installer/SetupEngine.cs @@ -109,31 +109,42 @@ namespace SeLtd.Setup return true; } - internal void Prepare(string folder, Action progress) + internal void Prepare(string folder, Action progress, CancellationToken cancellation = default(CancellationToken)) { Folder = Path.GetFullPath(folder); Legacy = Remote = false; - foreach (var step in Config.prepare) + for (int index = 0; index < Config.prepare.Length; index++) { - progress(step.label); + cancellation.ThrowIfCancellationRequested(); + var step = Config.prepare[index]; + progress(StepLabel(step, index, Config.prepare.Length)); if (step.action == "checkout") Checkout(); else if (step.action == "template") LoadTemplate(); else if (step.action == "command") RunStep(step); else throw new InvalidDataException("Unbekannter Vorbereitungsschritt: " + step.action); } + cancellation.ThrowIfCancellationRequested(); } - internal void Install(Action progress) + internal void Install(Action progress, CancellationToken cancellation = default(CancellationToken)) { - foreach (var step in Config.install) + for (int index = 0; index < Config.install.Length; index++) { - progress(step.label); + cancellation.ThrowIfCancellationRequested(); + var step = Config.install[index]; + progress(StepLabel(step, index, Config.install.Length)); if (step.action == "dockerReady") WaitForDocker(TimeoutFor(step, 180), progress); else if (step.action == "writeSetup") WriteSetup(); else if (step.action == "command") RunStep(step); else if (step.action == "http") CheckHttp(Expand(step.url), TimeoutFor(step, 45)); else throw new InvalidDataException("Unbekannter Installationsschritt: " + step.action); } + cancellation.ThrowIfCancellationRequested(); + } + + private static string StepLabel(Step step, int index, int count) + { + return string.Format("Schritt {0} von {1}: {2}", index + 1, count, step.label); } internal string LocalOrigin diff --git a/installer/SetupSmokeTests.cs b/installer/SetupSmokeTests.cs index 0b763a2..1787484 100644 --- a/installer/SetupSmokeTests.cs +++ b/installer/SetupSmokeTests.cs @@ -40,6 +40,25 @@ namespace SeLtd.Setup Application.SetCompatibleTextRenderingDefault(false); using (var wizard = new SetupWizard(setup)) Assert(wizard.Text == "SE-LTD Setup", "wizard initialization"); + using (var pause = new CancellationTokenSource()) + { + int announced = 0; + bool paused = false; + try + { + setup.Prepare(Path.Combine(root, "paused install"), phase => + { + Assert(phase.StartsWith("Schritt 1 von 2:"), "visible progress position"); + announced++; + pause.Cancel(); + }, pause.Token); + } + catch (OperationCanceledException) { paused = true; } + Assert(paused && announced == 1, "pause between safe setup steps"); + Assert(Directory.Exists(Path.Combine(root, "paused install", ".git")), "active checkout completed before pausing"); + Assert(!File.Exists(Path.Combine(root, "paused install", ".env")), "pause does not write settings"); + } + foreach (bool legacy in new[] { false, true }) { string target = Path.Combine(root, legacy ? "legacy install" : "new install"); diff --git a/installer/SetupWizard.cs b/installer/SetupWizard.cs index a38e394..8931ec1 100644 --- a/installer/SetupWizard.cs +++ b/installer/SetupWizard.cs @@ -2,6 +2,7 @@ using System; using System.Diagnostics; using System.Drawing; using System.IO; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; @@ -15,6 +16,13 @@ namespace SeLtd.Setup private readonly FlowLayoutPanel body = new FlowLayoutPanel(); private readonly Button back = new Button { Text = "Zurück", AutoSize = true }; private readonly Button next = new Button { Text = "Weiter", AutoSize = true }; + private readonly Button pause = new Button { Text = "Nach Schritt anhalten", AutoSize = true, Visible = false }; + private readonly System.Windows.Forms.Timer progressTimer = new System.Windows.Forms.Timer { Interval = 1000 }; + private readonly Stopwatch elapsed = new Stopwatch(); + private CancellationTokenSource cancellation; + private Label activeStep; + private Label elapsedLabel; + private ProgressBar progressBar; private TextBox input; private TextBox log; private CheckBox choice; @@ -66,7 +74,7 @@ namespace SeLtd.Setup body.Margin = new Padding(0); body.ClientSizeChanged += delegate { FitBody(); }; var buttons = new FlowLayoutPanel { Dock = DockStyle.Fill, AutoSize = true, FlowDirection = FlowDirection.RightToLeft }; - buttons.Controls.AddRange(new Control[] { next, back }); + buttons.Controls.AddRange(new Control[] { next, back, pause }); layout.Controls.Add(section, 0, 0); layout.Controls.Add(headline, 0, 1); layout.Controls.Add(body, 0, 2); @@ -75,7 +83,15 @@ namespace SeLtd.Setup AcceptButton = next; back.Click += OnBack; next.Click += OnNext; - FormClosing += delegate(object sender, FormClosingEventArgs e) { if (busy) e.Cancel = true; }; + pause.Click += delegate { RequestPause(); }; + progressTimer.Tick += delegate { UpdateElapsed(); }; + Disposed += delegate { progressTimer.Dispose(); }; + FormClosing += delegate(object sender, FormClosingEventArgs e) + { + if (!busy) return; + e.Cancel = true; + RequestPause(); + }; ShowChecks(); } @@ -88,6 +104,7 @@ namespace SeLtd.Setup next.Text = nextText; back.Visible = canGoBack; next.Enabled = true; + pause.Visible = false; validation = null; input = null; choice = null; @@ -239,22 +256,72 @@ namespace SeLtd.Setup { page = 4; Screen("SE-LTD SETUP / LÄUFT", title, "Erneut versuchen", false); + cancellation = new CancellationTokenSource(); + activeStep = Note("Wird vorbereitet …"); + elapsedLabel = Note(""); + progressBar = new ProgressBar { Style = ProgressBarStyle.Marquee, Height = 12, Width = 320, AccessibleName = "Arbeitsschritt läuft" }; + Add(progressBar); log = new TextBox { ReadOnly = true, Multiline = true, ScrollBars = ScrollBars.Vertical, Height = 200, AccessibleName = "Installationsfortschritt" }; Add(log); + elapsed.Restart(); + UpdateElapsed(); + progressTimer.Start(); + pause.Enabled = true; + pause.Visible = true; SetBusy(true); } + private void UpdateElapsed() + { + if (elapsedLabel == null || elapsedLabel.IsDisposed) return; + var state = cancellation != null && cancellation.IsCancellationRequested + ? "Aktueller Schritt wird abgeschlossen. Danach hält das Setup an." + : "Setup läuft."; + elapsedLabel.Text = state + " Laufzeit " + elapsed.Elapsed.ToString(@"hh\:mm\:ss"); + } + + private void RequestPause() + { + if (!busy || cancellation == null || cancellation.IsCancellationRequested) return; + cancellation.Cancel(); + pause.Enabled = false; + UpdateElapsed(); + } + private void SetBusy(bool value) { busy = value; back.Enabled = !value; next.Enabled = !value; UseWaitCursor = value; + if (!value) + { + progressTimer.Stop(); + elapsed.Stop(); + if (progressBar != null && !progressBar.IsDisposed) + { + progressBar.Style = ProgressBarStyle.Blocks; + progressBar.Visible = false; + } + pause.Visible = false; + if (cancellation != null) + { + cancellation.Dispose(); + cancellation = null; + } + } } private void Progress(string line) { - BeginInvoke(new Action(() => log.AppendText(line + Environment.NewLine))); + var output = log; + var label = activeStep; + BeginInvoke(new Action(() => + { + if (output.IsDisposed) return; + label.Text = line; + output.AppendText(line + Environment.NewLine); + })); } private void ShowSuccess() @@ -304,10 +371,12 @@ namespace SeLtd.Setup ShowProgress("Projekt wird vorbereitet"); try { - await Task.Run(() => setup.Prepare(folder, Progress)); + var stop = cancellation.Token; + await Task.Run(() => setup.Prepare(folder, Progress, stop)); if (setup.ExistingEnvironment) ShowExisting(); else { variableIndex = 0; ShowVariable(); } } + catch (OperationCanceledException) { ShowFolder(); } catch (Exception error) { ShowError(error); ShowFolder(); } finally { SetBusy(false); } } @@ -332,12 +401,19 @@ namespace SeLtd.Setup ShowProgress("SE-LTD wird installiert"); try { - await Task.Run(() => setup.Install(Progress)); + var stop = cancellation.Token; + await Task.Run(() => setup.Install(Progress, stop)); ShowSuccess(); } + catch (OperationCanceledException) + { + headline.Text = "Setup angehalten"; + elapsedLabel.Text = "Bereits gestartete Dienste bleiben unverändert. Du kannst das Setup erneut starten."; + } catch (Exception error) { log.AppendText(Environment.NewLine + error.Message); + elapsedLabel.Text = "Setup fehlgeschlagen. Details stehen im Fortschrittsprotokoll."; ShowError(error); } finally { SetBusy(false); } diff --git a/installer/setup.config.json b/installer/setup.config.json index f9fc05c..51ce5d2 100644 --- a/installer/setup.config.json +++ b/installer/setup.config.json @@ -33,7 +33,8 @@ { "action": "dockerReady", "label": "Docker Desktop starten und Verbindung prüfen", "timeout": 180 }, { "action": "writeSetup", "label": "Lokale Installationseinstellungen schreiben" }, { "action": "command", "label": "Docker-Konfiguration prüfen", "tool": "docker", "arguments": ["compose", "--env-file", ".env", "config", "--quiet"], "timeout": 60 }, - { "action": "command", "label": "Alle SE-LTD-Dienste bauen und starten", "tool": "docker", "arguments": ["compose", "--env-file", ".env", "up", "-d", "--build", "--wait", "--wait-timeout", "240"], "timeout": 2400 }, + { "action": "command", "label": "Docker-Images für SE-LTD bauen", "tool": "docker", "arguments": ["compose", "--env-file", ".env", "build"], "timeout": 2400 }, + { "action": "command", "label": "Dienste starten und auf Bereitschaft warten", "tool": "docker", "arguments": ["compose", "--env-file", ".env", "up", "-d", "--no-build", "--wait", "--wait-timeout", "240"], "timeout": 900 }, { "action": "http", "label": "Weboberfläche prüfen", "url": "http://127.0.0.1:{{WEB_PORT}}/", "timeout": 45 }, { "action": "http", "label": "API prüfen", "url": "http://127.0.0.1:{{API_PORT}}/api/health", "timeout": 45 }, { "action": "http", "label": "Collector prüfen", "url": "http://127.0.0.1:18110/health", "timeout": 45 } diff --git a/shared/trend-preferences.mjs b/shared/trend-preferences.mjs index aa42366..01a91c0 100644 --- a/shared/trend-preferences.mjs +++ b/shared/trend-preferences.mjs @@ -1,6 +1,14 @@ export const DEFAULT_TREND_PRESET = "1"; export const DEFAULT_MAX_TREND_SERIES = 10; export const MAX_TREND_SERIES = 100; +export const DEFAULT_TREND_ROWS = 20_000; +export const MIN_TREND_ROWS = 100; +export const MAX_TREND_ROWS = 50_000; +const MAX_TREND_SAMPLES = 250_000; + +export function maxTrendRowsForSeries(seriesCount) { + return Math.min(MAX_TREND_ROWS, Math.floor(MAX_TREND_SAMPLES / Math.max(1, seriesCount || 1))); +} export const TREND_PRESETS = [ { value: "0.0034722222", label: "5 min" }, diff --git a/symcon-collector/src/index.js b/symcon-collector/src/index.js index c9fcdb1..3f7785d 100644 --- a/symcon-collector/src/index.js +++ b/symcon-collector/src/index.js @@ -146,6 +146,7 @@ async function readValue(source, datapoint) { } const response = await requestApi(source, { function: "getvalue", id: variableId }); const raw = response.value ?? response.variable?.value; + if (raw == null || (typeof raw === "string" && !raw.trim())) return null; if (typeof raw === "boolean") return raw ? 1 : 0; const numeric = Number(raw); return Number.isFinite(numeric) ? numeric * (Number(datapoint.scale || 1) || 1) : raw === null || raw === undefined ? null : String(raw); diff --git a/web/src/App.jsx b/web/src/App.jsx index b1c134c..11d4509 100644 --- a/web/src/App.jsx +++ b/web/src/App.jsx @@ -2,6 +2,10 @@ import { useEffect, useMemo, useRef, useState } from "react"; import { api } from "./api.js"; import Gauge from "./components/Gauge.jsx"; +import { formatMeasurement, measurementNumber } from "./components/measurement.mjs"; +import ModalDialog from "./components/ModalDialog.jsx"; +import PagedResults from "./components/PagedResults.jsx"; +import ScanStatus from "./components/ScanStatus.jsx"; import TrendChart from "./components/TrendChart.jsx"; import Sidebar, { SmallFootnote } from "./components/Sidebar.jsx"; import SidebarLinkSettings from "./components/SidebarLinkSettings.jsx"; @@ -10,9 +14,12 @@ import { DEFAULT_CHART_SETTINGS, normalizeTrendChartSettings } from "../../share import { DEFAULT_MAX_TREND_SERIES, DEFAULT_TREND_PRESET, + DEFAULT_TREND_ROWS, + MIN_TREND_ROWS, MAX_TREND_SERIES, TREND_PRESETS as TREND_PRESET_OPTIONS, normalizeMaxTrendSeries, + maxTrendRowsForSeries, } from "../../shared/trend-preferences.mjs"; const views = [ @@ -24,6 +31,7 @@ const views = [ const CHART_DRAFT_KEY = "seltd:trend-chart"; const TREND_TOUCH_KEY = "seltd:trend-touch"; +const EMPTY_SCANS = { opcua: null, bacnet: null, ipsymcon: null }; function loadChartDraft() { try { @@ -68,7 +76,7 @@ const emptyTrendRange = { presetDays: "", from: "", to: "", - maxRows: 20000, + maxRows: DEFAULT_TREND_ROWS, }; const defaultSelectionDraft = { @@ -127,6 +135,30 @@ const defaultSourceDraft = { ipsymconApiKey: "", }; +function sourceEditorDraft(source) { + if (!source) return { ...defaultSourceDraft }; + const protocol = source.protocol || defaultSourceDraft.protocol; + const name = source.displayName || source.name || ""; + return { + ...defaultSourceDraft, + id: source.id, + protocol, + name, + displayName: name, + host: source.host || "", + port: String(source.port || getDefaultProtocolPort(protocol)), + deviceId: source.deviceId || "", + tableName: source.tableName || buildCollectorTableName(name, protocol), + writeMode: source.writeMode === "cov" ? "cov" : "interval", + pollIntervalSeconds: String(source.pollIntervalSeconds || 60), + bacnetMode: source.options?.bacnetMode || "broadcast", + bacnetBroadcastAddress: source.options?.bacnetBroadcastAddress || "auto", + bacnetScanSubnets: source.options?.bacnetScanSubnets || "", + bacnetForeignDeviceTtl: String(source.options?.bacnetForeignDeviceTtl || 120), + ipsymconCategoryIds: source.options?.ipsymconCategoryIds || "", + }; +} + function createWidgetId() { return `widget-${Date.now()}-${Math.round(Math.random() * 1000)}`; @@ -203,10 +235,6 @@ function getManualAddressLabel(protocol) { return "Adresse / Register"; } -function formatValue(value) { - return Number.isFinite(Number(value)) ? Number(value).toFixed(2) : "--"; -} - function repairUiText(value) { let current = String(value === undefined || value === null ? "" : value); for (let attempt = 0; attempt < 3; attempt += 1) { @@ -415,7 +443,7 @@ function getUserDisplayName(currentUser) { return name.toLowerCase() === username.toLowerCase() ? name : `${name} · @${username}`; } -function UnitField({ units, value, onChange, alias, kind }) { +function UnitField({ units, value, onChange, alias, kind, inputLabel }) { const options = units?.length ? units : DEFAULT_UNIT_OPTIONS; const normalizedOptions = options.map((unit) => ({ ...unit, @@ -429,6 +457,7 @@ function UnitField({ units, value, onChange, alias, kind }) { return (
{selectedValue === CUSTOM_UNIT_VALUE ? ( - onChange(event.target.value)} /> + onChange(event.target.value)} /> ) : null}
); } -function ScaleField({ value, onChange }) { +function ScaleField({ value, onChange, inputLabel }) { const normalizedValue = String(value ?? "1"); const selectedValue = SCALE_PRESET_OPTIONS.includes(normalizedValue) ? normalizedValue : "__custom__"; return (
{selectedValue === "__custom__" ? ( - onChange(event.target.value)} /> + onChange(event.target.value)} /> ) : null}
); @@ -493,8 +523,8 @@ function ColorField({ value, onChange }) { function TrashIcon() { return ( -
-
- SE Logo -
-
Login
-
SE Local Trenddata.
+ {!inline ? ( +
+ +
SE Local Trenddata
-
+ ) : null} - {error ?
{error}
: null} + {error ?
{error}
: null} - + {!inline ? : null}
); @@ -562,6 +591,7 @@ function ThemeSelect({ value, onChange }) { key={option.value} type="button" className={value === option.value ? "theme-option active" : "theme-option"} + aria-pressed={value === option.value} onClick={() => onChange(option.value)} > {option.label} @@ -595,7 +625,8 @@ function PointLibrary({ isp, metadata, metadataCache, selectedPoints, filterText
onFilterTextChange(event.target.value)} /> @@ -611,7 +642,13 @@ function PointLibrary({ isp, metadata, metadataCache, selectedPoints, filterText {alias} {selectedOnly ? {normalizeDisplayText(metadataCache[point.isp]?.displayName, point.isp)} : null} - {selected ? "\u2713" : point.kind} + + {selected ? ( + + ) : point.kind} + ); })} @@ -702,11 +739,16 @@ export default function App() { const [isCreatingSource, setIsCreatingSource] = useState(false); const [sourceDraft, setSourceDraft] = useState(defaultSourceDraft); const [sourceModalOpen, setSourceModalOpen] = useState(false); + const sourceDraftInitial = useRef(null); + const sourceDialogTrigger = useRef(null); const emptyManualDatapointDraft = (protocol = defaultSourceDraft.protocol, kind = "analog") => ({ alias: "", address: "", pointIndex: "", unit: AUTO_UNIT, dataType: getDefaultPointDataType(protocol), kind, scale: "1", writeMode: "", condition: "" }); const [collectorPointFilter, setCollectorPointFilter] = useState(""); const [alarmPointFilter, setAlarmPointFilter] = useState(""); const [manualDatapointDraft, setManualDatapointDraft] = useState(emptyManualDatapointDraft()); - const [scanResults, setScanResults] = useState({ opcua: null, bacnet: null, ipsymcon: null }); + const [scanSnapshot, setScanSnapshot] = useState(null); + const [deviceScan, setDeviceScan] = useState(null); + const [scanStatus, setScanStatus] = useState(null); + const scanLock = useRef(false); const [debugSnapshot, setDebugSnapshot] = useState(null); const [integrationSettings, setIntegrationSettings] = useState({ mailUrl: "https://mailapi.se-inno.de", whatsappUrl: "https://whatsappapi.se-inno.de", voipUrl: "https://voipapi.se-inno.de", mailApiKey: "", whatsappApiKey: "", voipApiKey: "" }); const [integrationStatus, setIntegrationStatus] = useState({ mailConfigured: false, whatsappConfigured: false, voipConfigured: false }); @@ -742,7 +784,7 @@ export default function App() { const activeTrendPreset = trendRange.presetDays || defaultTrendPreset; const trendPeriodLabel = trendRange.from && trendRange.to ? "Eigener Zeitraum" : TREND_PRESET_OPTIONS.find((option) => option.value === activeTrendPreset)?.label; - const showTrendLimitWarning = trendMaxRows > 20000; + const trendRowLimit = maxTrendRowsForSeries(Math.min(workingPoints.length, maxTrendSeries)); const roleOptions = roles.length ? roles : [ { name: "viewer", label: "Viewer" }, { name: "technician", label: "Techniker" }, @@ -754,6 +796,10 @@ export default function App() { label: normalizeDisplayText(unit.label || unit.symbol, normalizeDisplayUnit(unit.symbol)), })), [units]); const currentSource = useMemo(() => collectorSources.find((source) => source.id === selectedSourceId) || null, [collectorSources, selectedSourceId]); + const scanResults = scanSnapshot?.sourceId === selectedSourceId ? scanSnapshot.results : EMPTY_SCANS; + const scanRunning = scanStatus?.phase === "running"; + const pointScanStatus = scanStatus?.scope === "points" && (scanRunning || scanStatus.sourceId === selectedSourceId) ? scanStatus : null; + const deviceScanStatus = scanStatus?.scope === "devices" && scanStatus.editor === sourceDraftInitial.current ? scanStatus : null; const collectorSourcePoints = useMemo(() => ( selectedSourceId ? collectorDatapoints.filter((item) => item.sourceId === selectedSourceId) @@ -825,7 +871,7 @@ export default function App() { [collectorPointFilter, scanResults.ipsymcon, scannedLoggedPointIds, selectedSourceId] ); const filteredBacnetPoints = useMemo( - () => (scanResults.bacnet?.points || []).filter((point, index) => !scannedLoggedPointIds.has(getBacnetScanDatapointId(selectedSourceId, currentSource?.host, point, index)) && matchesSearch(collectorPointFilter, [ + () => (scanResults.bacnet?.points || []).map((point, index) => ({ point, index })).filter(({ point, index }) => !scannedLoggedPointIds.has(getBacnetScanDatapointId(selectedSourceId, currentSource?.host, point, index)) && matchesSearch(collectorPointFilter, [ point.alias, point.name, point.id, @@ -836,17 +882,6 @@ export default function App() { ])), [collectorPointFilter, currentSource?.host, scanResults.bacnet, scannedLoggedPointIds, selectedSourceId] ); - const filteredBacnetDevices = useMemo( - () => (scanResults.bacnet?.devices || []).filter((device) => matchesSearch(collectorPointFilter, [ - device.name, - device.deviceId, - device.host, - device.address, - device.vendorId, - device.pointCount, - ])), - [collectorPointFilter, currentSource?.host, scanResults.bacnet, scannedLoggedPointIds, selectedSourceId] - ); const filteredAvailableCollectorPoints = useMemo( () => availableCollectorPoints.filter((item) => matchesSearch(collectorPointFilter, [ item.alias, @@ -859,7 +894,30 @@ export default function App() { item.currentValue, ])), [availableCollectorPoints, collectorPointFilter] - ); const filteredAvailableAlarmPoints = useMemo( + ); + const scannedRows = useMemo(() => [ + ...filteredOpcuaNodes.map((point, index) => ({ + point, index, id: getOpcuaScanDatapointId(selectedSourceId, point), + title: point.displayName || point.browseName || point.nodeId, + detail: point.path || point.nodeId, + })), + ...filteredIpsymconPoints.map((point, index) => ({ + point, index, id: getIpsymconScanDatapointId(selectedSourceId, point), + title: point.alias || point.name || `Variable ${point.address}`, + detail: `${point.path || "IP-Symcon"} · ID ${point.address}${point.unit ? ` · ${normalizeDisplayUnit(point.unit)}` : ""}`, + })), + ...filteredBacnetPoints.map(({ point, index }) => ({ + point, index, id: getBacnetScanDatapointId(selectedSourceId, currentSource?.host, point, index), + title: point.alias || point.name, + detail: `${point.deviceName || point.deviceId || point.host || "BACnet"} · ${point.host || "–"} · ${point.dataType || "Objekt"} ${point.objectInstance ?? ""}${point.unit ? ` · ${normalizeDisplayUnit(point.unit)}` : ""}`, + })), + ], [filteredOpcuaNodes, filteredIpsymconPoints, filteredBacnetPoints, selectedSourceId, currentSource?.host]); + const foundRows = scannedRows.length ? scannedRows : filteredAvailableCollectorPoints.map((point, index) => ({ + point, index, id: String(point.id), registered: true, + title: point.alias || point.name, + detail: point.address || point.nodeId || point.dataType || point.protocol, + })); + const filteredAvailableAlarmPoints = useMemo( () => availableAlarmCollectorPoints.filter((item) => matchesSearch(alarmPointFilter, [ item.alias, item.name, @@ -892,6 +950,7 @@ export default function App() { useEffect(() => { resetFlash(); + setScanStatus((current) => current?.phase === "running" ? current : null); }, [activeView, adminSection]); useEffect(() => { @@ -1017,7 +1076,7 @@ export default function App() { }, [collectorSources, isCreatingSource, selectedSourceId]); useEffect(() => { - setScanResults({ opcua: null, bacnet: null, ipsymcon: null }); + setScanSnapshot((current) => current?.sourceId === selectedSourceId ? current : null); setCollectorPointFilter(""); }, [selectedSourceId]); @@ -1230,34 +1289,17 @@ export default function App() { }, [canEditAliases, canManageSources, canManageAlarms, canViewDebug, token]); useEffect(() => { - if (!currentSource) { + if (!currentSource || sourceModalOpen) { return; } - setSourceDraft({ - id: currentSource.id, - protocol: currentSource.protocol || "modbus-tcp", - name: currentSource.displayName || currentSource.name || "", - host: currentSource.host || "", - port: String(currentSource.port || getDefaultProtocolPort(currentSource.protocol || "modbus-tcp") || ""), - deviceId: currentSource.deviceId || "", - tableName: currentSource.tableName || buildCollectorTableName(currentSource.displayName || currentSource.name || "", currentSource.protocol || "modbus-tcp"), - displayName: currentSource.displayName || currentSource.name || "", - writeMode: currentSource.writeMode === "cov" ? "cov" : "interval", - pollIntervalSeconds: String(currentSource.pollIntervalSeconds || 60), - bacnetMode: currentSource.options?.bacnetMode || "broadcast", - bacnetBroadcastAddress: currentSource.options?.bacnetBroadcastAddress || "auto", - bacnetScanSubnets: currentSource.options?.bacnetScanSubnets || "", - bacnetForeignDeviceTtl: String(currentSource.options?.bacnetForeignDeviceTtl || 120), - ipsymconCategoryIds: currentSource.options?.ipsymconCategoryIds || "", - ipsymconApiKey: "", - }); + setSourceDraft(sourceEditorDraft(currentSource)); setManualDatapointDraft((current) => ({ ...current, dataType: getDefaultPointDataType(currentSource.protocol || "modbus-tcp"), unit: current.unit ?? AUTO_UNIT, })); - }, [currentSource]); + }, [currentSource, sourceModalOpen]); useEffect(() => { if (!canViewDashboard && activeView === "dashboard") { @@ -1755,25 +1797,40 @@ export default function App() { } }; - const startNewSource = () => { + const startNewSource = (event) => { + resetFlash(); setIsCreatingSource(true); setSelectedSourceId(""); setManualDatapointDraft(emptyManualDatapointDraft(defaultSourceDraft.protocol)); - setSourceDraft({ - ...defaultSourceDraft, - port: getDefaultProtocolPort(defaultSourceDraft.protocol), - }); + const draft = sourceEditorDraft(); + sourceDialogTrigger.current = event.currentTarget; + sourceDraftInitial.current = draft; + setDeviceScan(null); + setSourceDraft(draft); setSourceModalOpen(true); }; - const openSourceEditor = (sourceId) => { + const openSourceEditor = (sourceId, trigger) => { + const source = collectorSources.find((item) => item.id === sourceId); + if (!source) return; + resetFlash(); setIsCreatingSource(false); setSelectedSourceId(sourceId); + const draft = sourceEditorDraft(source); + sourceDialogTrigger.current = trigger; + sourceDraftInitial.current = draft; + setDeviceScan(null); + setSourceDraft(draft); setSourceModalOpen(true); }; const closeSourceEditor = () => { + const initial = sourceDraftInitial.current; + if (initial && Object.keys(initial).some((key) => initial[key] !== sourceDraft[key]) + && !window.confirm("Ungespeicherte Änderungen an dieser Quelle verwerfen?")) return; setSourceModalOpen(false); + sourceDraftInitial.current = null; + if (!sourceDraft.id) setIsCreatingSource(false); }; const updateSourceProtocol = (nextProtocol) => { @@ -1876,24 +1933,21 @@ export default function App() { } }; - const deleteCollectorSource = async () => { - if (!selectedSourceId) { - return; - } - - if (!window.confirm("Quelle wirklich löschen?")) { + const deleteCollectorSource = async (source) => { + if (!source?.id) return; + const name = normalizeDisplayText(source.name || source.displayName, source.id); + if (!window.confirm(`Quelle „${name}“ löschen? Die Quelle und ihre Datenpunktkonfiguration werden entfernt. Bereits gespeicherte Trendwerte bleiben erhalten.`)) { return; } resetFlash(); try { - await api.deleteCollectorSource(selectedSourceId); + await api.deleteCollectorSource(source.id); await refreshCollectorData(); await refreshCollectorDebug().catch(() => undefined); - setIsCreatingSource(false); - setSelectedSourceId(""); - setSourceDraft(defaultSourceDraft); - setSuccessMessage("Protokollquelle gelöscht."); + setSelectedSourceId((current) => current === source.id ? "" : current); + if (sourceModalOpen && sourceDraft.id === source.id) setSourceModalOpen(false); + setSuccessMessage(`Quelle „${name}“ gelöscht.`); } catch (error) { setBootError(error.message); } @@ -2004,47 +2058,63 @@ export default function App() { } }; - const runOpcuaScan = async () => { - const activeSourceId = selectedSourceId || sourceDraft.id; - const activeSource = collectorSources.find((source) => source.id === activeSourceId) || null; + const runSourceScan = async ({ protocol, sourceId, name, scope = "points", anchor, request, describe }) => { + if (scanLock.current) return; + scanLock.current = true; + const editor = scope === "devices" ? sourceDraftInitial.current : null; + const context = { scope, sourceId, editor, anchor, startedAt: Date.now() }; + const label = name ? ` für „${name}“` : ""; + resetFlash(); + setScanStatus({ ...context, phase: "running", message: `Scan${label} läuft …` }); + try { + const result = await request(); + if (scope === "devices") { + if (sourceDraftInitial.current === editor) setDeviceScan(result); + } else { + setScanStatus({ ...context, phase: "running", message: `Scan${label} abgeschlossen. Datenpunkte werden aktualisiert …` }); + await refreshCollectorData(); + setScanSnapshot({ sourceId, results: { ...EMPTY_SCANS, [protocol]: result } }); + refreshCollectorDebug().catch(() => undefined); + } + setScanStatus({ ...context, phase: "done", message: describe(result) }); + } catch (error) { + setScanStatus({ ...context, phase: "error", message: `Scan${label} fehlgeschlagen: ${error.message}` }); + } finally { + scanLock.current = false; + } + }; + + const runOpcuaScan = (source = currentSource, anchor = "tools") => { + const activeSourceId = source?.id; if (!activeSourceId) { setBootError("Bitte zuerst eine Quelle auswählen oder anlegen."); return; } - resetFlash(); - try { - const result = await api.scanOpcua({ - host: activeSource?.host || sourceDraft.host, - port: activeSource?.port || sourceDraft.port || "4840", + return runSourceScan({ + protocol: "opcua", sourceId: activeSourceId, name: source.displayName || source.name, anchor, + request: () => api.scanOpcua({ + host: source.host, + port: source.port || "4840", sourceId: activeSourceId, - }); - setScanResults((current) => ({ ...current, opcua: result })); - await refreshCollectorData(); - await refreshCollectorDebug().catch(() => undefined); - setSuccessMessage("OPC-UA-Scan abgeschlossen."); - } catch (error) { - setBootError(error.message); - } + maxNodes: 2000, + }), + describe: (result) => `OPC UA: ${result.nodes?.length || 0} Datenpunkte gefunden.${result.nodeLimitReached ? ` Suchlimit: ${result.maxNodes} Datenpunkte.` : ""}`, + }); }; - const runIpsymconScan = async () => { - const activeSourceId = selectedSourceId || sourceDraft.id; + const runIpsymconScan = (source = currentSource, anchor = "tools") => { + const activeSourceId = source?.id; if (!activeSourceId) { setBootError("Bitte zuerst eine IP-Symcon-Quelle auswählen oder anlegen."); return; } - resetFlash(); - try { - const result = await api.scanIpsymcon({ sourceId: activeSourceId }); - setScanResults((current) => ({ ...current, ipsymcon: result })); - await refreshCollectorData(); - await refreshCollectorDebug().catch(() => undefined); - setSuccessMessage(`IP-Symcon-Scan abgeschlossen: ${result.points?.length || 0} Datenpunkt(e) aus ${result.categories?.length || 0} Kategorie(n).`); - } catch (error) { - setBootError(error.message); - } + return runSourceScan({ + protocol: "ipsymcon", sourceId: activeSourceId, name: source.displayName || source.name, anchor, + request: () => api.scanIpsymcon({ sourceId: activeSourceId }), + describe: (result) => `IP-Symcon: ${result.points?.length || 0} Datenpunkte aus ${result.categories?.length || 0} Kategorien.${result.truncated ? " Das Suchlimit wurde erreicht." : ""}`, + }); }; const selectBacnetDevice = (device) => { @@ -2061,7 +2131,7 @@ export default function App() { })); }; - const runBacnetScan = async (options = {}) => { + const runBacnetScan = (options = {}) => { const sourceOverride = options.source || null; const draft = sourceOverride ? { ...defaultSourceDraft, @@ -2074,12 +2144,13 @@ export default function App() { writeMode: sourceOverride.writeMode || sourceOverride.options?.writeMode || "interval", pollIntervalSeconds: String(sourceOverride.pollIntervalSeconds || sourceOverride.options?.pollIntervalSeconds || 60), } : sourceDraft; - const activeSourceId = options.sourceId || sourceOverride?.id || selectedSourceId || draft.id || ""; + const activeSourceId = options.sourceId || sourceOverride?.id || draft.id || selectedSourceId || ""; const scanHosts = draft.host ? String(draft.host).split(/[;,\s]+/).map((entry) => entry.trim()).filter(Boolean) : []; - resetFlash(); - try { - const result = await api.scanBacnet({ + return runSourceScan({ + protocol: "bacnet", sourceId: activeSourceId, name: draft.name, anchor: options.anchor, + scope: options.includeObjects ? "points" : "devices", + request: () => api.scanBacnet({ port: draft.port || "47808", deviceId: draft.deviceId, sourceId: activeSourceId || undefined, @@ -2096,16 +2167,11 @@ export default function App() { initialWaitMs: options.initialWaitMs || 6000, finalWaitMs: options.finalWaitMs || 1800, unicastDelayMs: options.unicastDelayMs || 140, - }); - setScanResults((current) => ({ ...current, bacnet: result })); - await refreshCollectorData(); - await refreshCollectorDebug().catch(() => undefined); - const deviceCount = result.devices?.length || 0; - const pointCount = result.points?.length || 0; - setSuccessMessage(options.includeObjects === true ? `BACnet-Objektscan abgeschlossen: ${deviceCount} Gerät(e), ${pointCount} Objekt(e).` : `BACnet-Scan abgeschlossen: ${deviceCount} Gerät(e) gefunden.`); - } catch (error) { - setBootError(error.message); - } + }), + describe: (result) => options.includeObjects + ? `BACnet: ${result.points?.length || 0} Objekte auf ${result.devices?.length || 0} Geräten gefunden.${result.pointLimitReached ? " Das Objektlimit wurde erreicht." : ""}` + : `BACnet: ${result.devices?.length || 0} Geräte gefunden.`, + }); }; const updateCollectorPoint = async (datapoint, changes) => { @@ -2123,9 +2189,9 @@ export default function App() { const readCollectorPoint = async (datapoint) => { resetFlash(); try { - await api.readCollectorDatapoint(datapoint.id); + const result = await api.readCollectorDatapoint(datapoint.id); await refreshCollectorData(); - setSuccessMessage("Live-Wert gelesen."); + setSuccessMessage(result.value == null || result.value === "" ? "Die Quelle hat keinen Live-Wert geliefert." : "Live-Wert gelesen."); } catch (error) { setBootError(error.message); } @@ -2372,15 +2438,20 @@ export default function App() { ].filter(Boolean).join(" ")}>
-
Ansicht
- {currentView.label} +

{activeView === "settings" && !isAuthenticated ? "Anmelden" : currentView.label}

+

{{ + dashboard: "Messwerte und Verläufe im Überblick", + trends: "Datenpunkte auswählen und zeitliche Verläufe vergleichen", + admin: "Quellen, Datenpunkte und Zugänge verwalten", + settings: isAuthenticated ? "Darstellung, Seitenleiste und Konto verwalten" : "Zugang zu Einstellungen und Verwaltung", + }[activeView]}

{activeView === "trends" ? (
{!trendFocus ? ( <> - ISPs mit Daten: {trendIsps.length} - Aktuelle Auswahl: {workingPoints.length} + {trendIsps.length} ISP mit Daten + {workingPoints.length} ausgewählt ) : null}
@@ -2454,23 +2525,24 @@ export default function App() { ) : null}
- +
-

Auswahlen

-

Gespeicherte Punktgruppen für Trend und Dashboard.

+

Gespeicherte Auswahlen

+

Datenpunktgruppen für Trend und Dashboard

+ {selections.length === 0 ? Noch keine gespeicherten Auswahlen : null} {selections.map((selection) => (
deleteSelection(selection.id)}> @@ -2487,14 +2559,14 @@ export default function App() { const data = dashboardData[widget.id]; if (widget.type === "chart") { return ( -
+

{widget.title}

removeWidget(widget.id)}>
- +
); } @@ -2520,13 +2592,13 @@ export default function App() { timestamp={value.timestamp} /> ) : ( -
+
{normalizeDisplayText(value.displayName)} {normalizeDisplayText(value.alias)} - {formatTimestampLabel(value.timestamp)} + {value.timestamp || measurementNumber(value.value) !== null ? {formatTimestampLabel(value.timestamp)} : null}
-
{formatValue(value.value)}{normalizeDisplayUnit(value.unit)}
+
{formatMeasurement(value.value)}{measurementNumber(value.value) !== null ? {normalizeDisplayUnit(value.unit)} : null}
))}
@@ -2541,36 +2613,15 @@ export default function App() { <> {!trendFocus ? (
-
- {trendResult ? ( - setTrendFocus((current) => !current)} - csvDelimiter={csvDelimiter} - onCsvDelimiterChange={setCsvDelimiter} - allowExports - allowFocusMode - lineWidth={Number(trendLineWidth)} - touchMode={trendTouch} - {...trendChartSettingsProps} - /> - ) : ( -
-

Trendansicht

-

{trendLoading ? "Trend wird geladen ..." : "Nach dem Laden erscheinen hier Graph, Exporte und Vollbildansicht."}

-
- )} - -
-

Datenpunktauswahl

+
- {showTrendLimitWarning ?

{"Mehr als 20000 Datensätze sind möglich, können aber zu längeren Ladezeiten führen."}

: null} +

+ Grenze für diese Auswahl: {trendRowLimit.toLocaleString("de-DE")} Zeilen + {trendMaxRows > trendRowLimit ? ". Die Abfrage wird auf diese Grenze begrenzt." : trendMaxRows > DEFAULT_TREND_ROWS ? ". Größere Abfragen können länger dauern." : ""} +

{workingPoints.length > maxTrendSeries ? Im Diagramm erscheinen die ersten {maxTrendSeries} Datenpunkte. : null} -
- -
- {isAuthenticated ? ( <>
+
+ {trendResult ? ( + setTrendFocus((current) => !current)} + csvDelimiter={csvDelimiter} + onCsvDelimiterChange={setCsvDelimiter} + allowExports + allowFocusMode + lineWidth={Number(trendLineWidth)} + touchMode={trendTouch} + {...trendChartSettingsProps} + /> + ) : ( +
+

Trendansicht

+

{trendLoading ? "Trend wird geladen …" : "Wähle Datenpunkte aus und klicke auf „Trend anzeigen“"}

+
+ )} +
) : trendResult ? ( -
+
+ {adminSection === "aliases" && canEditAliases ? (
@@ -2804,18 +2878,33 @@ export default function App() { {getOrderedPointEntries(aliasEditor).map((point) => (
Wert {point.pointIndex}
- updateAliasPoint(String(point.pointIndex), { alias: event.target.value })} /> - updateAliasPoint(String(point.pointIndex), { unit, unitAuto: unit === AUTO_UNIT, kind: unit === DIGITAL_UNIT ? "digital" : point.kind })} /> - updateAliasPoint(String(point.pointIndex), { factor: nextValue })} /> - - updateAliasPoint(String(point.pointIndex), { color: nextValue })} /> +
+ Alias + updateAliasPoint(String(point.pointIndex), { alias: event.target.value })} /> +
+
+ Einheit + updateAliasPoint(String(point.pointIndex), { unit, unitAuto: unit === AUTO_UNIT, kind: unit === DIGITAL_UNIT ? "digital" : point.kind })} /> +
+
+ Faktor + updateAliasPoint(String(point.pointIndex), { factor: nextValue })} /> +
+
+ Typ + +
+
+ Farbe + updateAliasPoint(String(point.pointIndex), { color: nextValue })} /> +
))}
@@ -2880,7 +2969,7 @@ export default function App() { - {currentSource ? : null} + {currentSource ? : null}
@@ -2912,32 +3001,39 @@ export default function App() { const isActive = source.id === selectedSourceId; const pointCount = collectorDatapoints.filter((item) => item.sourceId === source.id).length; return ( -
+
- - {source.protocol === "opc-ua" ? : null} - {source.protocol === "bacnet-ip" ? : null} - {source.protocol === "ipsymcon" ? : null} - + + {["opc-ua", "bacnet-ip", "ipsymcon"].includes(source.protocol) ? ( + + ) : null} +
- + {pointScanStatus?.anchor === "row" && pointScanStatus.sourceId === source.id ? ( +
+ ) : null} + ); })} - {!collectorSources.length ?

Noch keine Protokollquelle angelegt. ?ber Neue Quelle startest du sauber mit leerem Formular.

: null} + {!collectorSources.length ?

Über Neue Quelle legst du die erste Protokollquelle an

: null} @@ -2964,15 +3060,16 @@ export default function App() { importCollectorFile(event, "knx")} /> - SQL-Import bleibt oben. Bei Modbus kommt der Function Code jetzt aus dem Dropdown Datenart am Datenpunkt. + Den Modbus-Funktionscode legst du pro Datenpunkt unter „Datenart“ fest
{sourceToolProtocol === "opc-ua" ? "OPC UA" : sourceToolProtocol === "bacnet-ip" ? "BACnet IP" : sourceToolProtocol === "modbus-tcp" ? "Modbus TCP" : sourceToolProtocol === "knx-ip" ? "KNX IP" : "Quelle"} - {sourceToolProtocol === "opc-ua" ? <>
{scanResults.opcua ? (scanResults.opcua.reachable ? `${scanResults.opcua.nodes?.length || 0} Node(s), ${scanResults.opcua.endpoints?.length || 0} Endpunkt(e)` : "Host nicht erreichbar") : "Verwendet Host und Port der aktiven Quelle."} : null} - {sourceToolProtocol === "modbus-tcp" ? Für 192.168.153.50 ist Input Register / FC4 bestätigt. Den Registertyp wählst du pro Datenpunkt über Datenart. : null} + {sourceToolProtocol === "opc-ua" ? <>
Verwendet Host und Port der aktiven Quelle : null} + {sourceToolProtocol === "modbus-tcp" ? Register lassen sich als CSV importieren oder einzeln anlegen : null} {sourceToolProtocol === "knx-ip" ? KNX-Import oder Einzelpunkt rechts anlegen. Gefundene und importierte Punkte landen unten links. : null} - {sourceToolProtocol === "ipsymcon" ? <>
Liest die in der Quelle hinterlegten Kategorie-IDs rekursiv aus und führt doppelte Variablen zusammen. : null} + {sourceToolProtocol === "ipsymcon" ? <>
Liest die hinterlegten Kategorien aus und führt doppelte Variablen zusammen : null} + {pointScanStatus?.anchor !== "row" ? : null}
@@ -3041,18 +3138,18 @@ export default function App() { {sourceModalOpen ? ( -
-
event.stopPropagation()}> +
-

{sourceDraft.id ? "Quelle bearbeiten" : "Neue Quelle"}

+

{sourceDraft.id ? "Quelle bearbeiten" : "Neue Quelle"}

Host, Port, Schreibmodus und Poll-Intervall werden hier zentral verwaltet.

{(bootError || collectorError || successMessage) ? ( -
+
{bootError || collectorError || successMessage}
) : null} @@ -3148,21 +3245,23 @@ export default function App() {
- {"Der Tabellenname wird automatisch passend erzeugt. Bei BACnet läuft der Scan standardmäßig über echtes Who-Is per Broadcast. Host/IP ist nur für BBMD oder Foreign Device nötig."} + + Tabellenname wird automatisch vorgeschlagen + {sourceDraft.protocol === "bacnet-ip" ? ". Der Gerätescan nutzt Who-Is per Broadcast; Host/IP ist nur für BBMD oder Foreign Device nötig." : ""} + {sourceDraft.protocol === "bacnet-ip" ? ( <>
- +
Gefundene BACnet-Geräte - {scanResults.bacnet ? `${filteredBacnetDevices.length} Gerät(e)` : "Noch kein Scan gestartet"}
- {filteredBacnetDevices.length ? ( -
- {filteredBacnetDevices.slice(0, 80).map((device, index) => { + + { const isSelectedDevice = String(sourceDraft.deviceId || "") === String(device.deviceId || ""); return ( ); - })} -
- ) : ( -

{scanResults.bacnet ? "Kein BACnet-Gerät gefunden. Prüfe Broadcast-Adresse, Device-ID oder BBMD/Foreign-Device-Einstellung." : "Scan starten, dann erscheinen die Geräte hier."}

- )} + }} + empty={deviceScanStatus?.phase === "done" ? Kein Gerät gefunden. Prüfe Subnetz und BACnet-Modus. : null} + />
) : null}
- - {selectedSourceId ? : null} + + {sourceDraft.id && currentSource?.id === sourceDraft.id ? : null}
-
-
+ ) : null}
@@ -3210,81 +3306,30 @@ export default function App() { onChange={(event) => setCollectorPointFilter(event.target.value)} /> -
- {filteredOpcuaNodes.slice(0, 160).map((node, index) => { - const pointId = getOpcuaScanDatapointId(selectedSourceId, node); - const linkedPoint = collectorSourcePointById.get(pointId); - const isLogged = linkedPoint?.enabled === true || loggedCollectorPointIds.has(pointId); +

{collectorPointFilter.trim() ? "Keine Treffer für die aktuelle Suche" : "Nach Scan oder Import erscheinen die gefundenen Punkte hier"}

} + render={({ point, index, id, title, detail, registered }, position) => { + const linked = registered ? point : collectorSourcePointById.get(id); + const isLogged = linked?.enabled === true || loggedCollectorPointIds.has(id); + const value = linked?.currentValue ?? point.currentValue; return ( -
+
- {normalizeDisplayText(node.displayName || node.browseName || node.nodeId)} - {normalizeDisplayText(node.path || node.nodeId)} - {node.currentValue === null || node.currentValue === undefined ? "kein Live-Wert" : formatCollectorValue(node.currentValue)} + {normalizeDisplayText(title, "Datenpunkt")} + {normalizeDisplayText(detail)} + {value == null ? "Kein Live-Wert" : formatCollectorValue(value)}
- {linkedPoint?.pointIndex || index + 1} + {linked?.pointIndex ?? index + 1}
- {linkedPoint ? : null} - + {linked ? : null} + {registered ? : null} +
); - })} - {filteredIpsymconPoints.slice(0, 2000).map((point, index) => { - const pointId = getIpsymconScanDatapointId(selectedSourceId, point); - const linkedPoint = collectorSourcePointById.get(pointId); - const isLogged = linkedPoint?.enabled === true || loggedCollectorPointIds.has(pointId); - return ( -
-
- {normalizeDisplayText(point.alias || point.name || `Variable ${point.address}`)} - {`${normalizeDisplayText(point.path || "IP-Symcon")} · ID ${point.address}${point.unit ? ` · ${normalizeDisplayUnit(point.unit)}` : ""}`} - {point.currentValue === null || point.currentValue === undefined ? "kein Live-Wert" : formatCollectorValue(point.currentValue)} -
- {linkedPoint?.pointIndex || index + 1} -
- {linkedPoint ? : null} - -
-
- ); - })} - {filteredBacnetPoints.slice(0, 160).map((point, index) => { - const pointId = getBacnetScanDatapointId(selectedSourceId, currentSource?.host, point, index); - const linkedPoint = collectorSourcePointById.get(pointId); - const isLogged = linkedPoint?.enabled === true || loggedCollectorPointIds.has(pointId); - return ( -
-
- {normalizeDisplayText(point.alias || point.name)} - {`${normalizeDisplayText(point.deviceName || point.deviceId || point.host, "Gerät ?")} · ${normalizeDisplayText(point.host)} · ${normalizeDisplayText(point.dataType || "obj")}${point.objectInstance || ""}${point.unit ? ` · ${normalizeDisplayUnit(point.unit)}` : ""}`} - {point.currentValue === null || point.currentValue === undefined ? "kein Live-Wert" : formatCollectorValue(point.currentValue)} -
- {linkedPoint?.pointIndex || index + 1} -
- {linkedPoint ? : null} - -
-
- ); - })} - {(!filteredOpcuaNodes.length && !filteredIpsymconPoints.length && !filteredBacnetPoints.length) && filteredAvailableCollectorPoints.length ? filteredAvailableCollectorPoints.slice(0, 2000).map((item) => ( -
-
- {normalizeDisplayText(item.alias || item.name)} - {normalizeDisplayText(item.address || item.nodeId || item.dataType || item.protocol)} - {item.currentValue === null || item.currentValue === undefined ? "kein Live-Wert" : formatCollectorValue(item.currentValue)} -
- {item.pointIndex} -
- - - -
-
- )) : null} - {!filteredAvailableCollectorPoints.length && !filteredOpcuaNodes.length && !filteredIpsymconPoints.length && !filteredBacnetPoints.length ?

{collectorPointFilter.trim() ? "Keine Treffer für die aktuelle Suche." : "Nach Scan oder Import erscheinen die gefundenen Punkte genau hier links."}

: null} -
+ }} + />
@@ -3300,8 +3345,8 @@ export default function App() {
{normalizeDisplayText(item.alias || item.name)} - {`Wert ${item.pointIndex} ? ${normalizeDisplayText(item.address || item.nodeId || item.dataType || item.protocol)}`} - {`${item.writeMode === "cov" ? "COV" : "Intervall"}${item.condition ? ` ? ${normalizeDisplayText(item.condition)}` : ""}`} + {`Wert ${item.pointIndex} · ${normalizeDisplayText(item.address || item.nodeId || item.dataType || item.protocol)}`} + {`${item.writeMode === "cov" ? "COV" : "Intervall"}${item.condition ? ` · ${normalizeDisplayText(item.condition)}` : ""}`}
{formatCollectorValue(item.currentValue)}{item.unit ? ` ${normalizeDisplayUnit(item.unit)}` : ""}
@@ -3324,10 +3369,11 @@ export default function App() {

Datenpunkte aus vorhandenen Quellen gezielt in die Alarmüberwachung übernehmen.

- {currentSource?.protocol === "opc-ua" ? : null} - {currentSource?.protocol === "bacnet-ip" ? : null} + {currentSource?.protocol === "opc-ua" ? : null} + {currentSource?.protocol === "bacnet-ip" ? : null}
+
@@ -3736,7 +3782,7 @@ export default function App() { {normalizeDisplayText(source.name, "Quelle")} {`${source.protocol} · ${normalizeDisplayText(source.tableName)}`}
- {`${String(source.pollIntervalSeconds || 60)}s ? ${pointCount} DP`} + {`${String(source.pollIntervalSeconds || 60)} s · ${pointCount} Datenpunkte`}
); })} @@ -3763,7 +3809,7 @@ export default function App() {

Darstellung

-

Farbschema und Bedienung werden pro Benutzer in Redis gespeichert.

+

Diese Einstellungen gelten für dein Benutzerkonto

diff --git a/web/src/components/Gauge.jsx b/web/src/components/Gauge.jsx index 9bbc992..22f73ea 100644 --- a/web/src/components/Gauge.jsx +++ b/web/src/components/Gauge.jsx @@ -1,8 +1,10 @@ -export default function Gauge({ value, min = 0, max = 100, label, unit, timestamp }) { +import { formatMeasurement, measurementNumber } from "./measurement.mjs"; + +export default function Gauge({ value, min = 0, max = 100, label, unit, timestamp }) { const safeMin = Number.isFinite(Number(min)) ? Number(min) : 0; const safeMax = Number.isFinite(Number(max)) ? Number(max) : 100; - const safeValue = Number.isFinite(Number(value)) ? Number(value) : safeMin; - const ratio = Math.max(0, Math.min(1, (safeValue - safeMin) / (safeMax - safeMin || 1))); + const numeric = measurementNumber(value); + const ratio = numeric === null ? 0 : Math.max(0, Math.min(1, (numeric - safeMin) / (safeMax - safeMin || 1))); const angle = -110 + ratio * 220; const radians = (angle * Math.PI) / 180; const cx = 110; @@ -13,25 +15,25 @@ return (
- +
Aktuell
- {Number.isFinite(safeValue) ? safeValue.toFixed(2) : "--"} - {unit} + {formatMeasurement(numeric)} + {numeric !== null ? {unit} : null}
{label}
{safeMin} {safeMax}
-
{timestampLabel}
+ {numeric !== null || timestamp ?
{timestampLabel}
: null}
); } diff --git a/web/src/components/ModalDialog.jsx b/web/src/components/ModalDialog.jsx new file mode 100644 index 0000000..d675e7d --- /dev/null +++ b/web/src/components/ModalDialog.jsx @@ -0,0 +1,23 @@ +import { useLayoutEffect, useRef } from "react"; + +export default function ModalDialog({ titleId, trigger, onDismiss, children }) { + const ref = useRef(null); + + useLayoutEffect(() => { + const dialog = ref.current; + const opener = trigger || document.activeElement; + dialog.showModal(); + return () => { + if (dialog.open) dialog.close(); + if (opener?.isConnected) opener.focus(); + else document.querySelector("main h1")?.focus(); + }; + }, [trigger]); + + return ( + { event.preventDefault(); onDismiss(); }}> + {children} + + ); +} diff --git a/web/src/components/PagedResults.jsx b/web/src/components/PagedResults.jsx new file mode 100644 index 0000000..4c714f1 --- /dev/null +++ b/web/src/components/PagedResults.jsx @@ -0,0 +1,21 @@ +import { useState } from "react"; + +export default function PagedResults({ items, render, listClassName, empty, pageSize = 48 }) { + const [page, setPage] = useState(0); + const count = Math.ceil(items.length / pageSize); + const current = Math.min(page, Math.max(0, count - 1)); + const start = current * pageSize; + const end = Math.min(start + pageSize, items.length); + if (!items.length) return empty ?? null; + + return ( + <> +
+ {count > 1 ? : null} + {start + 1}–{end} von {items.length.toLocaleString("de-DE")} + {count > 1 ? : null} +
+
{items.slice(start, end).map(render)}
+ + ); +} diff --git a/web/src/components/ScanStatus.jsx b/web/src/components/ScanStatus.jsx new file mode 100644 index 0000000..143870e --- /dev/null +++ b/web/src/components/ScanStatus.jsx @@ -0,0 +1,20 @@ +import { useEffect, useState } from "react"; + +export default function ScanStatus({ status }) { + const [now, setNow] = useState(Date.now); + const startedAt = status?.phase === "running" ? status.startedAt : null; + useEffect(() => { + if (startedAt === null) return; + const timer = window.setInterval(() => setNow(Date.now()), 1000); + return () => window.clearInterval(timer); + }, [startedAt]); + if (!status) return null; + + const elapsed = Math.floor(Math.max(0, now - status.startedAt) / 1000); + return ( +
+ {status.message} + {startedAt !== null ? : null} +
+ ); +} diff --git a/web/src/components/Sidebar.jsx b/web/src/components/Sidebar.jsx index 4a04da3..3f97fa1 100644 --- a/web/src/components/Sidebar.jsx +++ b/web/src/components/Sidebar.jsx @@ -19,7 +19,7 @@ function linkMonogram(label) { function SidebarIcon({ name }) { return ( -
- SE Logo + {collapsed {collapsed ? null : ( -
-
SE
-
SE Local Trenddata.
-
+
SE Local Trenddata
)}
: null} {allowFocusMode ? : null}
-
+
: seriesLimited ? Diagrammlimit: {result.maxSeries} von {result.requestedSeriesCount} Datenpunkten : null} -
-
- - + {rowLimitAdjusted || result?.rowLimitReached ? ( +

+ {rows.length.toLocaleString("de-DE")} Zeitpunkte geladen (Limit: {result.effectiveMaxRows.toLocaleString("de-DE")}). + {result.rowLimitReached ? " Ältere Messwerte im gewählten Zeitraum wurden nicht geladen." : ""} +

+ ) : null} + Messwerte mit Pfeiltasten erkunden, mit Pos1 oder Ende zum Rand springen +
+
+
+ {cursorRow ? ( + <> + {new Date(cursorRow.timestampMs).toLocaleString("de-DE")} +
    {series.map((entry) => ( +
  • + {entry.name}: {formatMeasurement(cursorRow[entry.key])} +
  • + ))}
+ + ) : null} +
@@ -445,9 +496,12 @@ export default function TrendChart({ key={entry.key} type="button" className={active ? "legend-item active" : dimmed ? "legend-item dimmed" : "legend-item"} + aria-pressed={active} onClick={(event) => handleLegendClick(event, entry.key)} > - + {entry.name} ); @@ -459,6 +513,7 @@ export default function TrendChart({
) : null}
+
); } diff --git a/web/src/components/TrendValueTable.jsx b/web/src/components/TrendValueTable.jsx new file mode 100644 index 0000000..9da5666 --- /dev/null +++ b/web/src/components/TrendValueTable.jsx @@ -0,0 +1,40 @@ +import { useState } from "react"; +import { formatMeasurement } from "./measurement.mjs"; + +const PAGE_SIZE = 20; + +export default function TrendValueTable({ rows, series }) { + const [page, setPage] = useState(0); + const pageCount = Math.max(1, Math.ceil(rows.length / PAGE_SIZE)); + const current = Math.min(page, pageCount - 1); + const start = current * PAGE_SIZE; + const end = Math.min(start + PAGE_SIZE, rows.length); + + return ( +
+ Messwerte als Tabelle ({rows.length.toLocaleString("de-DE")}) + {rows.length === 0 ?

Keine Messwerte im sichtbaren Zeitbereich

: ( + <> +
+ + Zeilen {start + 1}–{end} von {rows.length.toLocaleString("de-DE")} + +
+
+ + {series.map((entry) => )} + + {rows.slice(start, end).map((row, index) => ( + + + {series.map((entry) => )} + + ))} + +
Zeitstempel{entry.name}
{formatMeasurement(row[entry.key])}
+
+ + )} +
+ ); +} diff --git a/web/src/components/measurement.mjs b/web/src/components/measurement.mjs new file mode 100644 index 0000000..077d0de --- /dev/null +++ b/web/src/components/measurement.mjs @@ -0,0 +1,10 @@ +export function measurementNumber(value) { + if (typeof value === "string" && !value.trim()) return null; + if (!["number", "boolean", "string"].includes(typeof value)) return null; + const numeric = Number(value); + return Number.isFinite(numeric) ? numeric : null; +} + +export function formatMeasurement(value) { + return measurementNumber(value)?.toFixed(2) ?? "Kein Messwert"; +} diff --git a/web/src/components/trend-colors.mjs b/web/src/components/trend-colors.mjs index 58d9518..eaaf6da 100644 --- a/web/src/components/trend-colors.mjs +++ b/web/src/components/trend-colors.mjs @@ -3,6 +3,11 @@ const PALETTE = [ "#e03b53", "#167b93", "#3e7b0d", "#87543f", "#d14caa", "#4d6090", ]; +const DASH_PATTERNS = [undefined, "8 3", "2 3", "8 3 2 3", "4 4", "12 3", "2 2 2 5", "7 2 3 2", "3 5", "12 3 2 3"]; +export function trendDashPattern(index) { + return index < DASH_PATTERNS.length ? DASH_PATTERNS[index] : `${14 + Math.floor(index / 5)} 3 ${2 + index % 5} 3`; +} + function hexRgb(color) { const short = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(color); const hex = short ? short.slice(1).map((digit) => digit.repeat(2)).join("") : color.slice(1); @@ -12,6 +17,28 @@ function hexRgb(color) { return null; } +function luminance(rgb) { + return rgb.reduce((sum, value, index) => { + const channel = value / 255; + const linear = channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4; + return sum + linear * [0.2126, 0.7152, 0.0722][index]; + }, 0); +} + +function accessibleAutomaticColor(color) { + const rgb = hexRgb(color); + const [dark, light] = ["#292e2c", "#f5f6f5"].map((background) => luminance(hexRgb(background))); + const min = 3.2 * (dark + 0.05) - 0.05; + const max = (light + 0.05) / 3.2 - 0.05; + const target = luminance(rgb) < min ? 255 : 0; + for (let percent = 0; percent < 100; percent += 1) { + const candidate = rgb.map((channel) => Math.round(channel + (target - channel) * percent / 100)); + const value = luminance(candidate); + if (value >= min && value <= max) return "#" + candidate.map((channel) => channel.toString(16).padStart(2, "0")).join(""); + } + return "#797979"; +} + function distance(left, right) { const [red, green, blue] = left.map((channel, index) => channel - right[index]); const redMean = (left[0] + right[0]) / 512; @@ -49,7 +76,7 @@ export function assignTrendColors(series) { const manual = series.filter((entry) => !isAutomaticColor(entry.color?.trim())); const used = manual.map((entry) => hexRgb(entry.color.trim())).filter(Boolean); - const candidates = [...new Set(palette)].map((color) => ({ + const candidates = [...new Set(palette.map(accessibleAutomaticColor))].map((color) => ({ color, rgb: hexRgb(color), contrast: Infinity, @@ -60,6 +87,7 @@ export function assignTrendColors(series) { used.forEach(compareTo); const colors = new Map(); for (const entry of automatic) { + if (candidates.length === 0) break; const best = candidates.reduce((index, candidate, current) => candidate.contrast > candidates[index].contrast ? current : index, 0); const [chosen] = candidates.splice(best, 1); colors.set(entry.key, chosen.color); diff --git a/web/src/styles.css b/web/src/styles.css index 085bdc5..7078dd2 100644 --- a/web/src/styles.css +++ b/web/src/styles.css @@ -1,1925 +1,777 @@ +/* Design pass informed by unslop by Damir Sokolovsky (@heydamir), CC BY 4.0. */ :root { color-scheme: light; - --bg: #f4f6fb; - --bg-accent: linear-gradient(180deg, rgba(248, 251, 255, 0.24) 0%, rgba(238, 243, 251, 0.32) 100%); - --page-image: url("/bg-whitemode.png"); - --surface: rgba(255, 255, 255, 0.91); - --surface-strong: #ffffff; - --text: #18212f; - --muted: #667085; - --border: rgba(37, 99, 235, 0.1); - --border-strong: rgba(214, 40, 57, 0.24); - --brand: #2563eb; - --brand-2: #d62839; - --danger: #b91c1c; - --grid: rgba(214, 40, 57, 0.11); - --shadow: 0 12px 30px rgba(15, 23, 42, 0.06); - --radius: 14px; - --sidebar-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(249, 251, 255, 0.94) 100%); - --sidebar-border: rgba(37, 99, 235, 0.08); - --sidebar-accent: linear-gradient(180deg, var(--brand-2) 0%, #cf2d5c 55%, var(--brand) 100%); - font-family: "Segoe UI", Tahoma, sans-serif; + --bg: #eff1f0; + --surface: #fff; + --surface-strong: #fff; + --surface-raised: #f5f6f5; + --sidebar-bg: #e8ebe9; + --text: #222826; + --secondary: #444e4a; + --muted: #5b6761; + --border: #dce1de; + --control-border: #c9d0cc; + --border-strong: #aeb8b2; + --brand-2: #a82936; + --accent-soft: #faeeef; + --primary: #a82936; + --on-primary: #fff; + --primary-hover: #86212c; + --danger: #a02230; + --danger-bg: #fcf0f0; + --success: #265e45; + --success-bg: #ebf5ef; + --warning: #81501b; + --grid: #d9dfdc; + --scrim: rgb(22 28 25 / 46%); + --shadow: 0 16px 48px rgb(22 28 25 / 15%); + --radius: 12px; + --control-radius: 8px; + --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace; + --feedback-time: 140ms cubic-bezier(0.22, 1, 0.36, 1); + font-family: Bahnschrift, "DIN Alternate", "Aptos", "Segoe UI", sans-serif; + font-variant-numeric: tabular-nums; } :root[data-theme="dark"] { color-scheme: dark; - --bg: #0e1624; - --bg-accent: linear-gradient(180deg, rgba(16, 24, 39, 0.2) 0%, rgba(11, 19, 32, 0.3) 100%); - --page-image: url("/bg-darkmode.png"); - --surface: rgba(16, 24, 38, 0.92); - --surface-strong: #121b2a; - --text: #edf2f7; - --muted: #94a3b8; - --border: rgba(96, 165, 250, 0.12); - --border-strong: rgba(248, 113, 113, 0.24); - --brand: #4f8df7; - --brand-2: #ef4444; - --danger: #f87171; - --grid: rgba(239, 68, 68, 0.15); - --shadow: 0 14px 36px rgba(0, 0, 0, 0.28); - --sidebar-bg: linear-gradient(180deg, rgba(15, 23, 38, 0.98) 0%, rgba(10, 16, 28, 0.96) 100%); - --sidebar-border: rgba(148, 163, 184, 0.12); - --sidebar-accent: linear-gradient(180deg, #ef4444 0%, #dc3b68 55%, #4f8df7 100%); -} - -* { - box-sizing: border-box; -} - -html, -body, -#root { - min-height: 100%; + --bg: #181b1a; + --surface: #212524; + --surface-strong: #212524; + --surface-raised: #292e2c; + --sidebar-bg: #191d1b; + --text: #eef0ef; + --secondary: #c4ccc7; + --muted: #a1afa7; + --border: #39413d; + --control-border: #4d5852; + --border-strong: #65746b; + --brand-2: #ff9ca1; + --accent-soft: #38282b; + --primary: #f3d2d3; + --on-primary: #362023; + --primary-hover: #ffebec; + --danger: #ff9ca1; + --danger-bg: #38282b; + --success: #a7d8bc; + --success-bg: #253a30; + --warning: #e5be88; + --grid: #424b46; + --scrim: rgb(0 0 0 / 60%); + --shadow: 0 16px 48px rgb(0 0 0 / 34%); } +* { box-sizing: border-box; } +html, body, #root { min-height: 100%; } body { margin: 0; - background-color: var(--bg); - background-image: var(--bg-accent), var(--page-image); - background-position: center, center; - background-size: cover, cover; - background-attachment: fixed, fixed; + background: var(--bg); color: var(--text); - font-size: 12px; + font-size: 14px; + line-height: 1.45; } -button, -input, -select, -textarea { - font: inherit; -} - -button { - cursor: pointer; -} - -input, -select, -textarea { +h1, h2, h3, h4, p, pre { margin: 0; } +strong, legend { font-weight: 600; } +h3 { font-size: 18px; font-weight: 600; line-height: 1.2; } +h4 { font-size: 14px; font-weight: 600; } +p, label, .muted { color: var(--secondary); } +small, .tiny-note { font-size: 12px; line-height: 1.4; color: var(--muted); } +button, input, select, textarea { font: inherit; } +button, summary, select, input:is([type="checkbox"], [type="color"], [type="range"]) { cursor: pointer; } +input, select, textarea { width: 100%; - border: 1px solid var(--border); + min-width: 0; + min-height: 40px; + border: 1px solid var(--control-border); + border-radius: var(--control-radius); + padding: 8px 12px; background: var(--surface-strong); color: var(--text); - border-radius: 10px; - padding: 0.46rem 0.62rem; - min-height: 34px; } - -input:focus, -select:focus, -textarea:focus { - outline: none; - border-color: var(--brand-2); - box-shadow: 0 0 0 1px rgba(214, 40, 57, 0.18); +input::placeholder, textarea::placeholder { color: var(--muted); } +input[type="checkbox"] { + width: 16px; + height: 16px; + min-height: 0; + margin: 0; + flex: none; } - -label { - display: grid; - gap: 0.28rem; - color: var(--muted); - font-size: 11px; +input:is([type="checkbox"], [type="range"]) { accent-color: var(--brand-2); } +input[type="color"] { padding: 4px; } +label { display: grid; gap: 4px; min-width: 0; font-size: 13px; } +summary { color: var(--text); } +:where(button, a, input, select, textarea, summary, [tabindex]):focus-visible, +.file-button:has(input:focus-visible) { + outline: 2px solid var(--brand-2); + outline-offset: 2px; } +:where(button, input, select, textarea):disabled { cursor: not-allowed; } +button:disabled { opacity: 0.54; } -small, -p, -span { - line-height: 1.35; -} - -.login-screen { - min-height: 100vh; - display: grid; - place-items: center; - padding: 1rem; -} - -.login-card, -.panel, -.sidebar { - background: var(--surface); - border: 1px solid var(--border); - box-shadow: var(--shadow); -} - -.login-card { - width: min(100%, 336px); - border-radius: 18px; - padding: 0.95rem; - display: grid; - gap: 0.7rem; -} - -.logo-lockup { - display: flex; - align-items: center; - gap: 0.62rem; -} - -.logo-lockup img { - width: 34px; - height: 34px; - object-fit: contain; -} - -.logo-title { - font-size: 13px; - font-weight: 600; - line-height: 1.1; -} - -.eyebrow { - color: var(--brand-2); - font-size: 9px; - letter-spacing: 0.12em; - text-transform: uppercase; -} - -.primary-button, -.ghost-button, -.nav-button, -.theme-option, -.point-item, -.selection-card, -.chip, -.icon-button, -.legend-item { - border: 1px solid var(--border); - border-radius: 10px; - background: var(--surface-strong); - color: var(--text); - padding: 0.42rem 0.64rem; - min-height: 32px; -} - -.primary-button, -.ghost-button, -.nav-button, -.theme-option, -.icon-button, -.legend-item { +.primary-button, .ghost-button, .nav-button, .theme-option, .point-item, +.selection-card, .legend-item, .icon-button { display: inline-flex; align-items: center; justify-content: center; -} - -.primary-button { - background: linear-gradient(135deg, var(--brand-2) 0%, #b8275a 62%, var(--brand) 100%); - border-color: transparent; - color: #fff; -} - -.ghost-button, -.nav-button, -.theme-option, -.icon-button, -.legend-item { + min-height: 36px; + min-width: 0; + gap: 8px; + padding: 8px 12px; + border: 1px solid transparent; + border-radius: var(--control-radius); background: transparent; + color: var(--text); + font-weight: 500; + line-height: 1.2; + transition: background-color var(--feedback-time), border-color var(--feedback-time), color var(--feedback-time); } - -.nav-button.active, -.theme-option.active, -.legend-item.active { - border-color: rgba(214, 40, 57, 0.35); - color: var(--brand-2); - background: rgba(214, 40, 57, 0.08); +.primary-button { + background: var(--primary); + color: var(--on-primary); + font-weight: 600; } - -.icon-button { - width: 32px; - height: 32px; - padding: 0; - display: grid; - place-items: center; -} - -.icon-button svg { - width: 15px; - height: 15px; -} - -.icon-button.danger { - color: var(--danger); +.primary-button:where(:hover, :active):not(:disabled) { background: var(--primary-hover); } +.ghost-button, .theme-option, .legend-item, .icon-button, .selection-card { border-color: var(--control-border); } +:is(.ghost-button, .nav-button, .theme-option, .legend-item, .icon-button, .selection-card, .point-item):hover:not(:disabled) { + background: var(--surface-raised); + border-color: var(--border-strong); } +.compact-button { min-height: 32px; padding-block: 4px; font-size: 13px; } +.icon-button { width: 36px; height: 36px; padding: 0; flex: none; } +.icon-button svg, .sidebar svg, .point-tag svg { width: 16px; height: 16px; flex: none; } +:is(.ghost-button, .icon-button).danger { color: var(--danger); } +/* Shell and navigation */ .app-shell { - --sidebar-width: 188px; + --sidebar-width: 232px; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); - min-height: 100vh; + min-height: 100dvh; } - -.app-shell.sidebar-collapsed { - --sidebar-width: 64px; -} - +.app-shell.sidebar-collapsed { --sidebar-width: 68px; } .sidebar { position: sticky; - top: 0; - height: 100vh; - padding: 0.65rem 0.55rem 0.7rem; - display: grid; - grid-template-rows: auto 1fr; - gap: 0.75rem; + inset-block-start: 0; + height: 100dvh; min-width: 0; + display: flex; + flex-direction: column; + justify-content: space-between; + gap: 24px; + padding: 16px; overflow: auto; background: var(--sidebar-bg); - border-right: 1px solid var(--sidebar-border); + border-inline-end: 1px solid var(--border); } - -.sidebar::before { - content: ""; - position: absolute; - inset: 0 auto 0 0; - width: 5px; - background: var(--sidebar-accent); -} - -.sidebar.collapsed { - padding-inline: 0.55rem; -} - -.sidebar.collapsed .sidebar-top, -.sidebar.collapsed .nav-list, -.sidebar.collapsed .sidebar-footer { - justify-items: center; +.sidebar-top, .sidebar-footer, .user-card { display: grid; min-width: 0; } +.sidebar-top { gap: 16px; } +.sidebar-footer { gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; } +.user-card { gap: 4px; overflow-wrap: anywhere; } +.user-card span { font-size: 12px; color: var(--muted); } +.sidebar-brand-row { + min-height: 44px; + display: flex; align-items: center; + justify-content: space-between; + gap: 8px; } - -.sidebar.collapsed .sidebar-brand-row { - flex-direction: column; - padding-inline: 0; +.logo-lockup { display: flex; align-items: center; gap: 8px; min-width: 0; } +.logo-lockup img { + width: 36px; + height: 32px; + padding: 4px; + object-fit: contain; + border-radius: 4px; + background: #fff; } - -.sidebar.collapsed .logo-lockup img { - width: 28px; - height: 28px; +.logo-title { font-size: 15px; font-weight: 600; line-height: 1.15; } +.sidebar-toggle { border-color: transparent; } +.nav-list { display: grid; gap: 4px; min-width: 0; } +.nav-button { justify-content: flex-start; padding-inline: 12px; } +.nav-button.active, +.theme-option.active, +.legend-item.active, +.point-item[aria-pressed="true"], +.trend-point-library [aria-pressed="true"], +.trend-touch-toggle[aria-pressed="true"], +.source-card.active, +.bacnet-device-row.active { + background: var(--accent-soft); + border-color: color-mix(in srgb, var(--brand-2) 36%, var(--border)); + color: var(--brand-2); } - -.sidebar.collapsed .nav-list { - align-self: stretch; - gap: 0.45rem; -} - -.sidebar.collapsed .nav-button, -.sidebar.collapsed .sidebar-account, -.sidebar.collapsed .sidebar-toggle { - width: 38px; - min-width: 38px; - height: 38px; - min-height: 38px; +.nav-list .nav-button.active { box-shadow: inset 2px 0 var(--brand-2); } +.sidebar-links { border-top: 1px solid var(--border); padding-top: 12px; } +.sidebar-link { text-decoration: none; } +.sidebar-link-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.sidebar-link-monogram { font-family: var(--mono); font-size: 12px; font-weight: 600; text-transform: uppercase; } +.sidebar-account { justify-self: start; } +.sidebar.collapsed { padding-inline: 12px; } +.sidebar.collapsed :is(.sidebar-top, .sidebar-footer, .nav-list) { justify-items: center; } +.sidebar.collapsed .sidebar-brand-row { flex-direction: column; } +.sidebar.collapsed :is(.nav-button, .sidebar-toggle, .sidebar-account) { + width: 40px; + height: 40px; justify-content: center; justify-self: center; padding: 0; - border-radius: 10px; -} - -.sidebar-top { - display: grid; - gap: 0.65rem; - align-content: start; -} - -.sidebar-footer, -.user-card { - display: grid; - gap: 0.4rem; -} - -.sidebar-brand-row, -.panel-header, -.point-item, -.selection-card, -.user-row, -.stat-card, -.chart-toolbar, -.chart-actions, -.view-strip, -.alias-row { - display: flex; - align-items: center; - gap: 0.5rem; -} - -.sidebar-brand-row, -.panel-header, -.view-strip { - justify-content: space-between; -} - -.sidebar-brand-row { - padding: 0.12rem 0.08rem 0.52rem 0.15rem; - border-bottom: 1px solid var(--border); -} - -.sidebar-toggle { - flex-shrink: 0; -} - -.nav-list, -.button-row, -.widget-stack, -.selection-chips, -.latest-grid, -.theme-toggle, -.view-meta, -.wrap-tight, -.chart-actions, -.legend-grid { - display: flex; - flex-wrap: wrap; - gap: 0.38rem; -} - -.nav-list { - flex-direction: column; -} - -.sidebar-links { - border-top: 1px solid var(--border); - min-width: 0; - padding-top: 0.55rem; -} - -.sidebar-link { - text-decoration: none; - min-width: 0; -} - -.sidebar-link:hover { - border-color: var(--border-strong); - background: var(--surface-strong); -} - -.sidebar-link-label { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.sidebar-link-monogram { - font-weight: 600; - text-transform: uppercase; -} - -.sidebar-link-settings { - min-width: 0; -} - -.sidebar-link-list { - list-style: none; - padding: 0; - margin: 0; - display: grid; - gap: 0.35rem; -} - -.sidebar-link-setting { - display: flex; - flex-wrap: wrap; - align-items: center; - justify-content: space-between; - gap: 0.45rem; - padding: 0.4rem 0.55rem; - border: 1px solid var(--border); - border-radius: 10px; -} - -.sidebar-link-copy { - display: grid; - gap: 0.15rem; - min-width: 0; - overflow-wrap: anywhere; -} - -.nav-button { - min-height: 34px; - padding: 0.38rem 0.58rem; - border-radius: 12px; - justify-content: flex-start; - gap: 0.42rem; - font-size: 12px; -} - -.sidebar svg { - width: 18px; - height: 18px; - flex-shrink: 0; -} - -.user-card { - padding-top: 0.1rem; -} - -.user-card span, -.panel p, -.point-item span, -.selection-card span, -.muted, -.tiny-note { - color: var(--muted); -} - -.tiny-note { - font-size: 10px; - text-align: center; -} - -.sidebar-footer { - align-self: end; - padding-top: 0.45rem; - border-top: 1px solid var(--border); -} - -.sidebar-account { - justify-self: start; - border-radius: 999px; - padding-inline: 0.7rem; - gap: 0.42rem; } .content { - min-width: 0; - padding: 0.55rem 0.65rem 0.7rem; display: grid; - gap: 0.55rem; align-content: start; grid-auto-rows: max-content; -} - -.view-strip { - padding: 0.02rem 0.08rem 0; -} - -.small-badge, -.small-label, -.point-tag, -.alias-index { - font-size: 10px; - color: var(--brand-2); -} - -.topbar h1, -.panel h3, -.login-card h1 { - margin: 0; - font-size: 15px; - font-weight: 600; -} - -.grid.two, -.dashboard-grid { - display: grid; - gap: 0.6rem; - align-items: start; -} - -.grid.two { - grid-template-columns: repeat(2, minmax(0, 1fr)); -} - -.dashboard-grid { - grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); -} - -.panel { - border-radius: var(--radius); - padding: 0.64rem; - display: grid; - gap: 0.58rem; -} - -.panel > .primary-button, -.panel > .ghost-button { - justify-self: start; - width: auto; -} - -.login-card > .primary-button { + gap: 16px; + min-width: 0; width: 100%; - justify-self: stretch; + max-width: 1920px; + margin-inline: auto; + padding: 24px 32px 40px; } - -.compact-button { - min-height: 30px; - padding: 0.36rem 0.68rem; - border-radius: 999px; -} - -.compact-header { - align-items: flex-start; -} - -.compact-header p, -.view-strip p { - margin: 0.08rem 0 0; - font-size: 11px; -} - -.form-grid { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 0.52rem; -} - -.span-two { - grid-column: 1 / -1; -} - -.point-list, -.alias-table, -.user-list, -.selection-list { - display: grid; - gap: 0.36rem; - max-height: 420px; - overflow: auto; -} - -.selection-list.compact, -.source-list, -.datapoint-preview .selection-list { - max-height: none; - overflow: visible; -} - -.alias-table { - max-height: 560px; -} - -.stack-card { - display: grid; - grid-template-columns: 1fr auto; - gap: 0.35rem; -} - -.selection-card, -.point-item, -.user-row, -.stat-card, -.legend-item, -.chip { - text-align: left; -} - -.source-card.active { - border-color: rgba(214, 40, 57, 0.38); - background: rgba(214, 40, 57, 0.08); -} - -.preview-card { - cursor: default; -} - -.selection-card, -.point-item, -.user-row, -.stat-card { +.view-strip { + display: flex; + flex-wrap: wrap; + align-items: center; justify-content: space-between; - padding: 0.42rem 0.5rem; + gap: 12px 16px; + padding-bottom: 16px; + border-bottom: 1px solid var(--control-border); } - -.point-copy, -.user-copy { - display: grid; - gap: 0.06rem; +.view-strip h1 { font-size: clamp(24px, 2.6vw, 36px); font-weight: 500; line-height: 1.12; } +.view-strip p { margin-top: 4px; font-size: 14px; } +.view-meta, .button-row, .theme-toggle, .chart-actions, .legend-grid, .selection-chips { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 8px; min-width: 0; } - -.point-item { - align-items: flex-start; - gap: 0.42rem; -} - -.point-item .point-copy strong, -.point-item .point-copy span { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.selection-chips { - min-height: 0; - gap: 0.28rem; -} - -.chip { - display: grid; - gap: 0.1rem; - border-left: 2px solid var(--brand-2); - min-width: 0; - max-width: 100%; - padding: 0.26rem 0.36rem; - border-radius: 10px; - flex: 1 1 150px; -} - -.chip strong, -.point-copy strong, -.selection-card strong, -.user-card strong, -.user-copy strong { +.small-badge, .small-label, .point-tag, .alias-index, .selection-count, .value-stamp { + color: var(--muted); font-size: 12px; } +:is(.small-badge, .alias-index, .selection-count, .datapoint-value, .stat-value, .value-stamp) { font-family: var(--mono); } +.small-badge { white-space: nowrap; } -.chip strong, -.chip span { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; +/* Panels, forms, and lists */ +.panel, .login-card { + display: grid; + align-content: start; + gap: 16px; + min-width: 0; + padding: 20px; + background: var(--surface); + border: 1px solid var(--border); + border-radius: var(--radius); } - -.chip strong { - font-size: 10px; - line-height: 1.15; +.slim-panel { padding: 16px; gap: 12px; } +.panel > :is(.primary-button, .ghost-button) { justify-self: start; } +.panel-header { + display: flex; + flex-wrap: wrap; + gap: 8px 16px; + align-items: center; + justify-content: space-between; } - -.chip span { - font-size: 10px; - line-height: 1.15; +.panel-header > div { min-width: 0; } +.panel-header h3 { overflow-wrap: anywhere; } +.panel-header p { margin-top: 4px; font-size: 13px; } +.compact-header { align-items: flex-start; } +.grid.two, .dashboard-grid, .form-grid { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 16px; + align-items: start; } - -.chart-panel { - min-height: 390px; +.form-grid { gap: 12px; align-items: end; } +.grid.two.dashboard-setup { grid-template-columns: minmax(0, 1.6fr) minmax(248px, 1fr); } +.span-two, .dashboard-chart-widget { grid-column: 1 / -1; } +.dashboard-grid:empty { display: none; } +.dashboard-grid > :is(.dashboard-chart-widget, :only-child, :has(.widget-stack > :nth-child(3))) { grid-column: 1 / -1; } +.dashboard-chart-widget { gap: 8px; } +.dashboard-chart-widget > .chart-panel { border: 0; padding: 0; } +.checkbox-field, .chart-check { display: flex; align-items: center; gap: 8px; } +.file-button { position: relative; overflow: hidden; cursor: pointer; } +.file-button input { position: absolute; inset: 0; height: 100%; opacity: 0; } +.color-field { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 4px; } +.unit-field { display: grid; gap: 4px; min-width: 0; } +.inline-create-table, .inline-table-button { align-items: end; } +.inline-table-button { display: flex; } +.inline-fields, .inline-fields.multi-line { + display: grid; + grid-template-columns: minmax(0, 1fr) 88px auto; + gap: 8px; + align-items: center; } - -.chart-panel.focus-mode { - min-height: calc(100vh - 1.2rem); +.error-box, .success-box { + border-radius: var(--control-radius); + padding: 8px 12px; + border: 1px solid currentColor; + overflow-wrap: anywhere; } +.error-box { background: var(--danger-bg); color: var(--danger); } +.success-box { background: var(--success-bg); color: var(--success); } +.warning-note { color: var(--warning); font-size: 13px; } +.empty-state { display: grid; align-content: center; justify-items: center; gap: 8px; text-align: center; } +.empty-state p { max-width: 40ch; } +.slim-empty { min-height: 132px; padding: 16px; } +.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; } +.login-screen.inline-login { min-height: 0; padding: 0; place-items: start; } +.login-card { width: min(100%, 400px); padding: 24px; } +.login-card .primary-button { width: 100%; } +.point-list, .alias-table, .user-list, .selection-list, .scan-result-list, .datapoint-table { + display: grid; + align-content: start; + grid-auto-rows: max-content; + gap: 4px; + min-width: 0; + max-height: 420px; + overflow: auto; + overscroll-behavior: contain; + padding: 4px; +} +.selection-list.compact, .source-list, .datapoint-preview .selection-list { max-height: none; overflow: visible; } +.alias-table { max-height: 560px; } +.stack-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; } +.selection-card, .point-item, .user-row { justify-content: space-between; text-align: start; } +.saved-selection-card { justify-content: flex-start; min-height: 40px; } +.saved-selection-copy { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; } +.selection-count { white-space: nowrap; } +.point-item { gap: 8px; padding: 8px; border-color: var(--border); } +.point-copy, .user-copy { display: grid; gap: 4px; min-width: 0; } +.point-copy strong, .point-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.point-tag { display: inline-flex; align-items: center; flex: none; } +.point-item[aria-pressed="true"] .point-tag { color: inherit; } +.point-item strong { font-weight: 500; } +.user-row, .sidebar-link-setting { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 8px; + border: 1px solid var(--border); + border-radius: var(--control-radius); + padding: 8px 12px; +} +.user-copy, .sidebar-link-copy { overflow-wrap: anywhere; } +.sidebar-link-list { display: grid; gap: 4px; padding: 0; margin: 0; list-style: none; } +.sidebar-link-copy { display: grid; gap: 4px; min-width: 0; } + +/* Measurement canvas and values */ +.trend-layout { + display: grid; + grid-template-columns: minmax(0, 2fr) minmax(288px, 1fr); + grid-template-areas: "plot controls"; + align-items: start; + gap: 16px; + min-width: 0; +} +.trend-main, .trend-side { display: grid; align-content: start; gap: 12px; min-width: 0; } +.trend-main { grid-area: plot; } +.trend-side { grid-area: controls; } +.trend-point-panel { + grid-template-rows: auto auto minmax(0, 1fr); + min-height: 0; +} +.trend-point-library { + grid-template-rows: auto auto minmax(0, 1fr); + min-height: 0; + gap: 8px; + background: var(--surface-raised); + padding: 12px; +} +.trend-point-library h3, .protocol-block h3 { font-size: 16px; } +.trend-point-library .point-list { max-height: min(40dvh, 384px); min-height: 0; padding: 4px; } +.trend-point-library .point-item:not([aria-pressed="true"]):not(:hover) { background: var(--surface); } +.trend-options { + border: 1px solid var(--border); + border-radius: var(--control-radius); + padding: 8px 12px; + background: var(--surface-raised); +} +.trend-options summary small { display: inline-block; margin-inline-start: 8px; } +.trend-options[open] > summary { margin-bottom: 12px; } +.trend-options :is(.warning-note, .primary-button) { margin-top: 8px; } +.chart-panel, .trend-empty { min-height: 400px; } +.compact-chart { min-height: 0; } +.compact-chart.empty-state { min-height: 160px; } +.chart-panel.focus-mode { min-height: calc(100dvh - 144px); } +.chart-toolbar { position: relative; align-items: flex-start; } +.chart-actions select { width: auto; max-width: 100%; min-height: 36px; padding-block: 4px; } .chart-wrapper { --trend-axis: var(--muted); --trend-grid: var(--grid); - --trend-band: color-mix(in srgb, var(--text) 5%, transparent); + --trend-band: color-mix(in srgb, var(--text) 4%, transparent); width: 100%; - min-height: 320px; - user-select: none; + min-width: 0; overflow-x: auto; + user-select: none; touch-action: pan-y; + border: 1px solid var(--border); + border-radius: var(--control-radius); + background: var(--surface-raised); } - .chart-wrapper.high-contrast { --trend-axis: var(--text); --trend-grid: color-mix(in srgb, var(--text) 42%, transparent); --trend-band: color-mix(in srgb, var(--text) 10%, transparent); } - -.trend-zoom-target { - cursor: crosshair; +.chart-wrapper::before, .trend-empty::before { + content: ""; + display: block; + height: 8px; + border-bottom: 1px solid var(--grid); + background-image: repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 20px); } - -.chart-host { - width: 100%; -} - -.chart-toolbar { - align-items: flex-start; +.trend-empty { position: relative; + justify-items: start; + text-align: start; + background: var(--surface) repeating-linear-gradient(0deg, transparent 0 39px, var(--surface-raised) 39px 40px); } - -.chart-actions { - align-items: center; -} - -.trend-settings > summary { - cursor: pointer; - list-style: none; -} - -.trend-settings > summary::-webkit-details-marker { - display: none; -} - +.trend-empty::before { position: absolute; inset: 0 12px auto; } +.trend-zoom-target { cursor: crosshair; } +.chart-host { padding-top: 8px; } +.chart-plot { height: 360px; } +.compact-chart .chart-plot { height: 280px; } +.focus-mode .chart-plot { height: min(680px, 74dvh); } +.recharts-cartesian-axis-tick text { font-family: var(--mono); } +.trend-settings > summary { list-style: none; } +.trend-settings > summary::-webkit-details-marker { display: none; } .trend-settings-popover { position: absolute; z-index: 12; - top: 100%; - right: 0; - width: min(100%, 420px); - max-height: min(64vh, 540px); + inset: calc(100% + 8px) 0 auto auto; + width: min(100%, 448px); + max-height: min(64dvh, 540px); overflow: auto; overscroll-behavior: contain; - background: var(--surface-strong); + padding: 16px; + background: var(--surface); border: 1px solid var(--border-strong); - border-radius: 12px; - box-shadow: 0 12px 28px #0003; - padding: 0.8rem; + border-radius: var(--radius); + box-shadow: var(--shadow); } - -.trend-settings-fields, -.trend-series-setting { +.trend-settings-fields, .trend-series-setting { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 0.5rem; + align-items: center; + gap: 8px; + overflow-wrap: anywhere; } - -.trend-settings-save { - justify-content: flex-end; - margin-top: 0.65rem; -} - -.trend-settings-fields > small, -.trend-opacity-field { - grid-column: 1 / -1; -} - +.trend-settings-save { justify-content: flex-end; margin-top: 12px; } +.trend-settings-fields > small, .trend-opacity-field { grid-column: 1 / -1; } .trend-settings-group { - margin: 0.65rem 0 0; - padding: 0.55rem; min-width: 0; - border: 1px solid var(--border-strong); - border-radius: 8px; + margin: 12px 0 0; + padding: 12px; + border: 1px solid var(--border); + border-radius: var(--control-radius); } - -.trend-axis-settings + .trend-axis-settings, -.trend-series-setting + .trend-series-setting { - margin-top: 0.55rem; - padding-top: 0.55rem; +.trend-axis-settings + .trend-axis-settings, .trend-series-setting + .trend-series-setting { + margin-top: 8px; + padding-top: 8px; border-top: 1px solid var(--border); } - -.trend-series-setting { - align-items: center; - overflow-wrap: anywhere; -} - -.chart-check { - display: inline-flex; - align-items: center; - gap: 0.32rem; - white-space: nowrap; -} - -.chart-check input { - width: auto; - min-height: auto; -} - -.legend-row { - display: flex; - justify-content: space-between; - gap: 0.55rem; - align-items: flex-start; - flex-wrap: wrap; -} - -.legend-grid { - gap: 0.34rem; - flex: 1 1 360px; -} - +.legend-row { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 8px; } +.legend-grid { flex: 1 1 320px; } .legend-item { - padding: 0.32rem 0.48rem; - display: inline-flex; - align-items: center; - gap: 0.4rem; -} - -.legend-item.dimmed { - opacity: 0.25; -} - -.legend-side-actions { - display: flex; - align-items: center; - gap: 0.38rem; -} - -.legend-swatch { - width: 10px; - height: 10px; - border-radius: 999px; - flex: 0 0 auto; -} - -.latest-grid { - display: grid; - grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); - gap: 0.42rem; -} - -.trend-layout { - display: grid; - grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.95fr); - gap: 0.65rem; - align-items: start; -} - -.trend-main, -.trend-side { - display: grid; - gap: 0.65rem; - align-content: start; - min-width: 0; -} - -.trend-point-panel, -.trend-point-library { - grid-template-rows: auto auto minmax(0, 1fr); - min-height: 0; - min-width: 0; -} - -.trend-point-library .point-list { - align-content: start; - grid-auto-rows: max-content; - max-height: min(36dvh, 24rem); - min-height: 0; - overscroll-behavior: contain; -} - -.point-item[aria-pressed="true"], -.trend-point-library [aria-pressed="true"] { - border-color: var(--border-strong); - background: color-mix(in srgb, var(--brand-2) 8%, var(--surface-strong)); -} - -.trend-options { - border: 1px solid var(--border); - border-radius: 10px; - padding: 0.44rem 0.55rem; -} - -.trend-options summary { - cursor: pointer; -} - -.trend-options summary small { - float: right; - color: var(--muted); -} - -.trend-options[open] summary { - margin-bottom: 0.44rem; -} - -.trend-selection-save > .primary-button { - margin-top: 0.44rem; -} - -.trend-touch-toggle { - min-height: 44px; - padding-inline: 0.85rem; -} - -.trend-touch-toggle[aria-pressed="true"] { - color: var(--brand-2); - border-color: var(--border-strong); - background: color-mix(in srgb, var(--brand-2) 9%, var(--surface-strong)); -} - -.trend-touch :is(.view-meta, .button-row, .chart-actions, .legend-grid) { - align-items: center; - gap: 0.55rem; -} - -.trend-touch :is(button, input, select, summary, .checkbox-field, .chart-check) { - min-height: 44px; -} - -.trend-touch :is(button, summary, .checkbox-field, .chart-check) { - touch-action: manipulation; -} - -.trend-touch :is(input:not([type="checkbox"]), select) { - font-size: 16px; -} - -.trend-touch :is(.checkbox-field, .chart-check) input[type="checkbox"] { - width: 20px; - height: 20px; - min-height: 0; - flex-shrink: 0; -} - -.trend-touch :is(.point-item, .legend-item) { - align-items: center; - padding-inline: 0.7rem; -} - -.trend-touch .point-copy strong { - font-size: 14px; -} - -.trend-touch .point-list { - gap: 0.5rem; - max-height: min(42dvh, 28rem); -} - -.trend-touch .trend-options > summary { - line-height: 1.5; - align-content: center; -} - -.trend-touch .chart-toolbar { - flex-wrap: wrap; -} - -.trend-touch .chart-wrapper { - touch-action: auto; -} - -@media (min-width: 981px) and (min-height: 560px) { - .content.trend-content:not(.trend-touch) { - display: flex; - flex-direction: column; - height: 100dvh; - } - - .trend-content:not(.trend-touch) .trend-layout { - flex: 1; - min-height: 0; - grid-template-rows: minmax(0, 1fr); - } - - .trend-content:not(.trend-touch) .trend-side { - align-self: stretch; - align-content: stretch; - min-height: 0; - grid-template-rows: minmax(0, 1fr) auto; - } - - .trend-content:not(.trend-touch) .trend-point-library .point-list { - max-height: none; - } -} - -.unit-table { - width: 100%; - border-collapse: collapse; - text-align: left; -} - -.unit-table th, -.unit-table td { - padding: 0.38rem 0.52rem; - border-bottom: 1px solid var(--border); + max-width: 100%; + min-height: 32px; + padding: 4px 8px; + text-align: start; + font-size: 12px; overflow-wrap: anywhere; } +.legend-item.dimmed { color: var(--muted); } +.legend-swatch { width: 32px; height: 6px; flex: none; } +.legend-item.dimmed .legend-swatch { opacity: 0.45; } +.trend-cursor { font-size: 13px; } +.trend-cursor:empty { position: absolute; } +.trend-cursor ul { display: grid; gap: 4px; margin: 4px 0 0; padding-inline-start: 20px; } +.trend-value-table { min-width: 0; border-top: 1px solid var(--border); } +.trend-value-table > summary { padding-block: 8px; } +.table-pagination { margin-block: 4px 8px; } +.trend-table-scroll { max-width: 100%; overflow: auto; } +.trend-table { width: 100%; border-collapse: collapse; font-size: 13px; } +.trend-table :is(th, td) { padding: 8px; border-bottom: 1px solid var(--border); text-align: start; } +.trend-table thead { background: var(--surface-raised); } +.trend-table td { white-space: nowrap; } +.trend-touch-toggle { min-height: 40px; } +.trend-touch :is(button, input:not([type="checkbox"]), select, summary, .checkbox-field, .chart-check) { min-height: 44px; } +.trend-touch .icon-button { min-width: 44px; } +.trend-touch :is(input:not([type="checkbox"]), select) { font-size: 16px; } +.trend-touch :is(button, summary) { touch-action: manipulation; } +.trend-touch input[type="checkbox"] { width: 20px; height: 20px; } +.trend-touch .point-copy strong { white-space: normal; overflow-wrap: anywhere; } +.trend-touch .trend-options summary { align-content: center; } +.trend-touch .chart-wrapper { touch-action: auto; } -.unit-table thead th, -.unit-table small { - color: var(--muted); +.widget-stack, .latest-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(min(100%, 184px), 1fr)); + align-items: start; + gap: 8px; } - -.unit-table tbody tr:nth-child(even) { - background: color-mix(in srgb, var(--border) 36%, transparent); -} - -.unit-table :is(th, td):last-child { - text-align: right; - width: 1%; - overflow-wrap: normal; - white-space: nowrap; -} - -.runner-mail-fields { - margin: 0; - padding: 0.5rem 0; - border: 0; - border-top: 1px solid var(--border); +.stat-card, .latest-card, .gauge-card { + display: grid; min-width: 0; -} - -.runner-mail-fields:disabled { - opacity: 0.55; -} - -.runner-mail-fields:disabled input { - cursor: not-allowed; -} - -.stat-card, -.gauge-card, -.user-row { + gap: 8px; + padding: 12px; border: 1px solid var(--border); - border-radius: 12px; + border-radius: var(--control-radius); + background: var(--surface-raised); + overflow-wrap: anywhere; } - -.stat-card, -.latest-card { - border-left: 4px solid var(--brand-2); -} - -.latest-card { - display: grid; - grid-template-columns: minmax(0, 1fr) auto; - align-items: center; - gap: 0.45rem; - min-width: 0; -} - -.latest-card > div:first-child { - min-width: 0; -} - -.latest-card small, -.latest-card strong, -.latest-card .value-stamp { - display: block; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.latest-card small { - font-size: 9px; -} - -.latest-card strong { - font-size: 11px; - line-height: 1.18; -} - -.latest-card .stat-value { - justify-content: flex-end; - min-width: max-content; - font-size: 13px; - line-height: 1; - white-space: nowrap; -} - -.latest-card .stat-value span { - font-size: 10px; -} - -.stat-value { +.stat-card, .latest-card { border-inline-start: 2px solid var(--series-color, var(--border-strong)); } +.stat-card > div:first-child { display: grid; gap: 4px; min-width: 0; } +.stat-value, .gauge-value { display: flex; + flex-wrap: wrap; align-items: baseline; - gap: 0.32rem; - font-size: 18px; - font-weight: 600; -} - -.stat-value span { - font-size: 11px; - color: var(--muted); -} - -.value-stamp { - display: block; - color: var(--muted); - font-size: 10px; - margin-top: 0.08rem; -} - -.gauge-card { - padding: 0.65rem; - display: grid; - gap: 0.22rem; - place-items: center; -} - -.gauge-svg { - width: 100%; - max-width: 170px; -} - -.gauge-track { - fill: none; - stroke: rgba(214, 40, 57, 0.16); - stroke-width: 12; - stroke-linecap: round; -} - -.gauge-needle { - stroke: var(--brand-2); - stroke-width: 6; - stroke-linecap: round; -} - -.gauge-center { - fill: var(--brand); -} - -.gauge-current { - color: var(--brand-2); - font-size: 10px; - letter-spacing: 0.08em; - text-transform: uppercase; -} - -.gauge-value { - display: flex; - gap: 0.35rem; - align-items: baseline; - font-size: 17px; - font-weight: 600; -} - -.gauge-range, -.gauge-label, -.gauge-stamp { - color: var(--muted); - font-size: 10px; -} - -.alias-row { - display: grid; - grid-template-columns: 92px 1.55fr 0.8fr 0.65fr 0.65fr 0.8fr; - gap: 0.58rem; - align-items: center; -} - -.alias-head { - padding: 0 0.1rem; - font-weight: 600; - color: var(--muted); -} - -.unit-field, -.color-field { - display: grid; - gap: 0.28rem; -} - -.color-field { - grid-template-columns: 38px minmax(0, 1fr); - align-items: center; -} - -.color-field input[type="color"] { - padding: 0.12rem; - min-height: 34px; -} - -.error-box, -.success-box { - padding: 0.5rem 0.62rem; - border-radius: 10px; - font-size: 12px; -} - -.error-box { - background: rgba(220, 38, 38, 0.08); - border: 1px solid rgba(220, 38, 38, 0.2); -} - -.success-box { - background: rgba(37, 99, 235, 0.08); - border: 1px solid rgba(37, 99, 235, 0.22); -} - -.warning-note { - margin: 0; - color: #c2410c; - font-size: 11px; -} - -.checkbox-field { - display: flex; - align-items: center; - gap: 0.45rem; -} - -.checkbox-field input { - width: auto; - min-height: auto; -} - -.file-button { - position: relative; - overflow: hidden; -} - -.file-button input { - position: absolute; - inset: 0; - opacity: 0; - cursor: pointer; -} - -.admin-section { - display: grid; - gap: 0.6rem; - align-content: start; + gap: 4px 8px; + font-size: clamp(18px, 2vw, 24px); + line-height: 1.1; + font-weight: 500; } +.stat-value span { color: var(--muted); font: inherit; font-size: 12px; } +.gauge-card { justify-items: center; text-align: center; } +.gauge-svg { width: 100%; max-width: 168px; } +.gauge-track { fill: none; stroke: var(--grid); stroke-width: 12; stroke-linecap: round; } +.gauge-needle { stroke: var(--brand-2); stroke-width: 6; stroke-linecap: round; } +.gauge-center { fill: var(--brand-2); } +.gauge-current, .gauge-range, .gauge-label, .gauge-stamp { color: var(--muted); font-size: 12px; } +.gauge-range { display: flex; justify-content: space-between; width: min(100%, 144px); } +.chip { display: grid; min-width: 0; gap: 4px; padding: 8px; overflow-wrap: anywhere; } +/* Administration */ +.admin-section, .protocol-panel, .protocol-block, .source-modal { display: grid; align-content: start; gap: 12px; min-width: 0; } .admin-subnav { display: flex; flex-wrap: wrap; - gap: 0.38rem; -} - -.admin-subnav .nav-button { - justify-content: center; -} - -.protocol-panel, -.protocol-block, -.datapoint-preview { - display: grid; - gap: 0.55rem; -} - -.protocol-grid { - display: grid; - grid-template-columns: repeat(3, minmax(0, 1fr)); - gap: 0.52rem; -} - -.protocol-block { - border: 1px solid var(--border); - border-radius: 12px; - padding: 0.56rem; - background: color-mix(in srgb, var(--surface-strong) 88%, transparent); -} - -.inline-fields { - display: grid; - grid-template-columns: minmax(0, 1fr) 88px auto; - gap: 0.36rem; - align-items: center; -} - -.inline-fields.multi-line { - grid-template-columns: minmax(0, 1fr) 88px auto; -} - -.empty-state { - place-items: center; - text-align: center; -} - -.slim-empty { - min-height: 220px; -} - -@media (max-width: 980px) { - .app-shell { - grid-template-columns: minmax(0, 1fr); - } - - .sidebar, - .sidebar.collapsed { - position: static; - width: auto; - height: auto; - } - - .sidebar.collapsed { - grid-template-columns: minmax(0, 1fr) auto; - grid-template-rows: auto; - column-gap: 0.4rem; - padding-block: 0.4rem; - } - - .sidebar.collapsed .sidebar-top, - .sidebar.collapsed .sidebar-brand-row, - .sidebar.collapsed .nav-list { - display: flex; - flex-direction: row; - align-items: center; - gap: 0.3rem; - } - - .sidebar.collapsed .sidebar-top { - flex-wrap: wrap; - } - - .sidebar.collapsed .sidebar-links { - flex: 1 0 100%; - max-height: 6rem; - overflow: auto; - align-content: start; - } - - .sidebar.collapsed .sidebar-brand-row, - .sidebar.collapsed .sidebar-footer { - padding: 0; - border: 0; - } - - .sidebar.collapsed .sidebar-footer { - align-self: center; - } - - .grid.two, - .form-grid, - .alias-row, - .protocol-grid, - .inline-fields, - .inline-fields.multi-line, - .trend-layout, - .latest-card { - grid-template-columns: 1fr; - } - - .latest-card .stat-value { - justify-content: flex-start; - } -} - - - - - - -.scan-result-list, -.datapoint-table { - display: grid; - gap: 0.35rem; - max-height: 420px; - overflow: auto; -} - -.scan-result-row, -.datapoint-row { - display: grid; - grid-template-columns: minmax(0, 1fr) auto auto; - gap: 0.5rem; - align-items: center; - border: 1px solid var(--border); - border-radius: 10px; - padding: 0.45rem 0.55rem; - background: color-mix(in srgb, var(--surface) 92%, transparent); -} - -.datapoint-row.inactive { - opacity: 0.68; -} - -.datapoint-main { - display: grid; - gap: 0.12rem; - min-width: 0; -} - -.datapoint-main span, -.scan-result-row span, -.datapoint-main small { - color: var(--muted); - font-size: 0.72rem; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.datapoint-value { - font-variant-numeric: tabular-nums; - font-weight: 700; - white-space: nowrap; -} - -.source-admin-top { - display: grid; - grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr); - gap: 0.65rem; - align-items: start; -} - -.source-overview-panel, -.source-settings-panel { - min-height: 100%; -} - -.source-settings-card { - margin-top: 0.1rem; -} - -.source-split { - display: grid; - grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); - gap: 0.65rem; - align-items: start; -} - -.source-split .scan-result-list, -.source-split .datapoint-table { - min-height: 320px; -} - -.source-admin-panel { - position: relative; -} - -.inline-create-table { - align-items: end; -} - -.inline-table-button { - display: flex; - align-items: end; -} - -.source-grid { - align-items: stretch; -} - -.source-tile { - display: grid; - grid-template-columns: minmax(0, 1fr) auto; - gap: 0.55rem; - align-items: start; -} - -.source-tile-copy { - display: grid; - gap: 0.18rem; - min-width: 0; -} - -.source-tile-copy small { - color: var(--muted); - font-size: 0.7rem; -} - -.source-tile-actions { - display: grid; - gap: 0.3rem; - justify-items: end; -} - -.source-toolbar-card { - display: flex; - align-items: center; - justify-content: space-between; - gap: 0.6rem; - border: 1px solid var(--border); - border-radius: 12px; - padding: 0.55rem 0.65rem; - background: color-mix(in srgb, var(--surface-strong) 90%, transparent); -} - -.source-toolbar-card > div:first-child { - display: grid; - gap: 0.14rem; -} - -.source-toolbar-card span { - color: var(--muted); - font-size: 0.74rem; -} - -.source-tools-grid { - grid-template-columns: repeat(2, minmax(0, 1fr)); -} - -.manual-point-card { - margin-bottom: 0.35rem; -} - -.modal-backdrop { - position: fixed; - inset: 0; - z-index: 30; - display: grid; - place-items: center; - padding: 1rem; - background: rgba(15, 23, 42, 0.38); - backdrop-filter: blur(8px); -} - -.modal-card { - width: min(760px, calc(100vw - 2rem)); - max-height: calc(100vh - 2rem); - overflow: auto; - border: 1px solid var(--border); - border-radius: 16px; - padding: 0.85rem; - background: var(--surface); - box-shadow: 0 28px 80px rgba(15, 23, 42, 0.22); -} - -.bacnet-device-list { - display: grid; - gap: 0.35rem; - max-height: 220px; - overflow: auto; - border: 1px solid var(--border); - border-radius: 10px; - padding: 0.35rem; -} - -.bacnet-device-row { - display: grid; - grid-template-columns: minmax(0, 1fr) auto; - align-items: center; - gap: 0.5rem; - width: 100%; - border: 1px solid transparent; - border-radius: 8px; - padding: 0.42rem 0.5rem; - background: transparent; - color: var(--text); - text-align: left; - cursor: pointer; -} - -.bacnet-device-row:hover, -.bacnet-device-row.active { - border-color: var(--accent); - background: color-mix(in srgb, var(--accent) 10%, transparent); -} - -.bacnet-device-row span { - display: grid; - gap: 0.1rem; - min-width: 0; -} - -.bacnet-device-row small { - color: var(--muted); - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.bacnet-device-row em { - color: var(--muted); - font-style: normal; - font-size: 0.72rem; -} - -.source-modal { - display: grid; - gap: 0.65rem; -} - -.modal-status { - margin: 0; - padding: 0.55rem 0.7rem; - font-size: 0.78rem; -} - -.bacnet-device-panel { - display: grid; - gap: 0.45rem; - border: 1px solid var(--border); - border-radius: 12px; - padding: 0.55rem; - background: color-mix(in srgb, var(--surface-raised) 68%, transparent); -} - -.bacnet-device-title { - display: flex; - align-items: center; - justify-content: space-between; - gap: 0.75rem; - font-size: 0.78rem; -} - -.bacnet-device-title small { - color: var(--muted); -} - -@media (max-width: 980px) { - .source-admin-top, - .source-split, - .source-tools-grid, - .source-tile, - .source-toolbar-card { - grid-template-columns: 1fr; - } - - .source-toolbar-card { - align-items: start; - } - - .source-tile-actions { - width: 100%; - justify-items: stretch; - } - - .source-tile-actions .compact-button { - width: 100%; - } -} - -/* Compact source and datapoint cards for dense Full-HD trend/admin views. */ -.source-tile { - min-height: 0; - padding: 0.36rem 0.48rem; - align-items: center; -} - -.source-tile-copy { - gap: 0.08rem; - line-height: 1.18; -} - -.source-tile-copy strong, -.source-tile-copy span, -.source-tile-copy small, -.datapoint-main strong, -.datapoint-main span, -.datapoint-main small { - min-width: 0; - overflow-wrap: anywhere; - word-break: break-word; -} - -.source-tile-actions { - gap: 0.18rem; -} - -.source-tile-actions .compact-button { - min-height: 1.55rem; - padding: 0.24rem 0.48rem; -} - -.scan-result-list, -.datapoint-table { - display: grid; - gap: 0.22rem; -} - -.datapoint-row { - align-items: center; - gap: 0.42rem; - min-height: 0; - padding: 0.34rem 0.46rem; -} - -.datapoint-main { - min-width: 0; - line-height: 1.2; -} - -.datapoint-main strong { - font-size: 0.74rem; -} - -.datapoint-main span, -.datapoint-main small, -.datapoint-value { - font-size: 0.68rem; -} - -.datapoint-value { - white-space: nowrap; -} - -.source-overview-panel .selection-list { - gap: 0.28rem; -} - -/* Stable dense datapoint lists: compact, but never overlapping. */ -.source-split .scan-result-list, -.source-split .datapoint-table { - gap: 0.3rem; - max-height: min(58vh, 620px); - min-height: 300px; - overflow-y: auto; - padding-right: 0.18rem; -} - -.source-split .datapoint-row { - grid-template-columns: minmax(0, 1fr) 3.2rem minmax(10.5rem, max-content); - min-height: 42px; - padding: 0.4rem 0.5rem; - gap: 0.55rem; - align-items: center; - border-radius: 9px; -} - -.source-split .datapoint-main { - min-width: 0; - line-height: 1.18; - gap: 0.08rem; -} - -.source-split .datapoint-main strong, -.source-split .datapoint-main span, -.source-split .datapoint-main small { - display: block; - min-width: 0; - max-width: 100%; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.source-split .datapoint-main strong { - font-size: 0.76rem; - line-height: 1.18; -} - -.source-split .datapoint-main span, -.source-split .datapoint-main small { - font-size: 0.68rem; - line-height: 1.15; -} - -.source-split .datapoint-value { - justify-self: end; - min-width: 2.2rem; - font-size: 0.68rem; - text-align: right; -} - -.source-split .datapoint-row > .button-row { - display: flex; - flex-wrap: nowrap; - justify-content: flex-end; - gap: 0.25rem; - min-width: 0; -} - -.source-split .datapoint-row > .button-row .compact-button { - min-height: 24px; - padding: 0.24rem 0.46rem; - font-size: 0.68rem; - white-space: nowrap; -} - -.source-split .datapoint-row.inactive { - opacity: 0.86; -} - -@media (max-width: 1180px) { - .source-split .datapoint-row { - grid-template-columns: minmax(0, 1fr) 2.6rem; - } - - .source-split .datapoint-row > .button-row { - grid-column: 1 / -1; - justify-content: flex-start; - } -} - -.runner-status-grid { - display: grid; - grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); - gap: 0.65rem; - margin-top: 0.75rem; -} - -.runner-status-panel { - min-width: 0; - border: 1px solid var(--border); - border-radius: 10px; - background: color-mix(in srgb, var(--panel) 92%, var(--accent) 8%); - overflow: hidden; -} - -.runner-status-header { - display: flex; - align-items: center; - justify-content: space-between; - gap: 0.5rem; - padding: 0.46rem 0.58rem; + gap: 4px; + padding-bottom: 8px; border-bottom: 1px solid var(--border); } - -.runner-status-header h4 { - margin: 0; - font-size: 0.78rem; -} - -.runner-status-header > span { - display: inline-grid; - place-items: center; - min-width: 1.35rem; - height: 1.2rem; - border-radius: 999px; - background: var(--accent-soft); - color: var(--accent); - font-size: 0.68rem; - font-weight: 700; -} - -.runner-job-list, -.runner-queue-table { - display: grid; - gap: 0; - max-height: 230px; - overflow: auto; -} - -.runner-job-row, -.runner-queue-row, -.runner-queue-head { +.admin-subnav .nav-button { min-height: 36px; } +.alias-row { display: grid; + grid-template-columns: 64px minmax(0, 1.55fr) minmax(0, 1fr) minmax(0, 0.75fr) minmax(104px, 0.8fr) minmax(0, 0.8fr); align-items: center; - gap: 0.5rem; - padding: 0.42rem 0.58rem; + min-width: 0; + gap: 8px; + padding: 8px; + border-bottom: 1px solid var(--border); + overflow-wrap: anywhere; } - -.runner-job-row { +.alias-head { margin-inline: 4px; background: var(--surface-raised); font-weight: 600; } +.alias-cell { min-width: 0; } +.alias-cell-label { display: none; } +.unit-table { width: 100%; border-collapse: collapse; text-align: start; font-size: 13px; } +.unit-table :is(th, td) { padding: 8px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; } +.unit-table thead th { background: var(--surface-raised); color: var(--secondary); } +.unit-table th { text-align: start; font-weight: 600; } +.unit-table :is(th, td):last-child { width: 1%; text-align: end; white-space: nowrap; } +.protocol-grid, .source-admin-top, .source-split, .runner-status-grid { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 12px; + align-items: start; +} +.protocol-block, .source-toolbar-card, .bacnet-device-panel { + border: 1px solid var(--border); + border-radius: var(--control-radius); + padding: 12px; + background: var(--surface-raised); +} +.source-tile { + display: grid; grid-template-columns: minmax(0, 1fr) auto; - border-bottom: 1px solid color-mix(in srgb, var(--border) 75%, transparent); + align-items: start; + padding: 12px; + background: var(--surface); } - -.runner-job-row:last-child, -.runner-queue-row:last-child { - border-bottom: 0; -} - -.runner-job-copy { +.source-tile-copy, .datapoint-main { display: grid; - gap: 0.08rem; min-width: 0; + gap: 4px; + overflow-wrap: anywhere; } - -.runner-job-copy strong, -.runner-job-copy span, -.runner-job-copy small, -.runner-queue-row strong, -.runner-queue-row small { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; +.source-select-button { + width: 100%; + min-height: 44px; + padding: 0; + border: 0; + background: none; + color: inherit; + text-align: start; + border-radius: 4px; } - -.runner-job-copy strong, -.runner-queue-row strong { - font-size: 0.75rem; +.scan-status { display: flex; justify-content: space-between; gap: 8px; } +.scan-status [role="alert"] { color: var(--danger); } +.source-tile-status { grid-column: 1 / -1; } +.source-tile-copy span, .source-toolbar-card span, .datapoint-main span { color: var(--secondary); font-size: 12px; } +.source-tile-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 4px; } +.source-toolbar-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; } +.source-toolbar-card > div:first-child { display: grid; gap: 4px; min-width: 0; } +.datapoint-preview { container-type: inline-size; } +.source-split :is(.scan-result-list, .datapoint-table) { + min-height: 160px; + max-height: min(60dvh, 624px); } - -.runner-job-copy span, -.runner-job-copy small, -.runner-queue-row small { - color: var(--muted); - font-size: 0.67rem; -} - -.runner-job-actions { - justify-content: flex-end; -} - -.runner-queue-head, -.runner-queue-row { - grid-template-columns: 1.4rem minmax(0, 1fr) auto; -} - -.runner-queue-head { - color: var(--muted); - font-size: 0.65rem; - font-weight: 700; - text-transform: uppercase; - letter-spacing: 0.04em; -} - -.runner-queue-row { - border-bottom: 1px solid color-mix(in srgb, var(--border) 75%, transparent); -} - -.runner-queue-row > span { - color: var(--accent); - font-size: 0.7rem; - font-weight: 700; -} - -@media (max-width: 900px) { - .runner-status-grid { - grid-template-columns: 1fr; - } - - .runner-job-row { - grid-template-columns: 1fr; - } - - .runner-job-actions { - justify-content: flex-start; - } -} -.saved-selection-card { - min-height: 36px; - justify-content: flex-start; - padding: 0.38rem 0.55rem; -} - -.saved-selection-copy { - display: flex; +.scan-result-row, .datapoint-row { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(36px, max-content) auto; align-items: center; - gap: 0.42rem; - min-width: 0; + gap: 8px; + padding: 8px; + background: var(--surface); + border: 1px solid var(--border); + border-radius: var(--control-radius); } +.datapoint-value { max-width: 15ch; justify-self: end; text-align: end; font-size: 12px; overflow-wrap: anywhere; } +.datapoint-row > .button-row { justify-content: flex-end; gap: 4px; } +.datapoint-row .compact-button { min-height: 32px; padding-inline: 8px; } +.datapoint-row.active { border-inline-start: 2px solid var(--success); } +@container (max-width: 640px) { + .datapoint-row { grid-template-columns: minmax(0, 1fr) minmax(36px, max-content); } + .datapoint-row > .button-row { grid-column: 1 / -1; justify-content: flex-start; } +} +.modal-card::backdrop { background: var(--scrim); } +.modal-card:not([open]) { display: none; } +.modal-card { + width: min(calc(100% - 32px), 760px); + max-height: calc(100dvh - 32px); + color: var(--text); + padding: 24px; + overflow: auto; + overscroll-behavior: contain; + background: var(--surface); + border: 1px solid var(--border-strong); + border-radius: 16px; + box-shadow: var(--shadow); +} +.modal-card .panel-header { padding-bottom: 12px; border-bottom: 1px solid var(--border); } +.bacnet-device-panel, .bacnet-device-list { display: grid; gap: 8px; } +.bacnet-device-list { max-height: 240px; overflow: auto; padding: 4px; } +.bacnet-device-title, .bacnet-device-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; } +.bacnet-device-row { + width: 100%; + padding: 8px 12px; + border: 1px solid var(--border); + border-radius: var(--control-radius); + background: var(--surface); + color: var(--text); + text-align: start; +} +.bacnet-device-row:hover { border-color: var(--border-strong); } +.bacnet-device-row span { display: grid; min-width: 0; gap: 4px; overflow-wrap: anywhere; } +.bacnet-device-row em { color: var(--muted); font-style: normal; font-size: 12px; } +.runner-mail-fields { min-width: 0; margin: 0; padding: 12px 0 0; border: 0; border-top: 1px solid var(--border); } +.runner-mail-fields:disabled input { opacity: 0.6; } +.runner-status-panel { min-width: 0; border: 1px solid var(--border); border-radius: var(--control-radius); } +.runner-status-header { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; background: var(--surface-raised); } +.runner-status-header > span { font: 12px var(--mono); color: var(--muted); } +.runner-job-list, .runner-queue-table { display: grid; align-content: start; max-height: 280px; overflow: auto; } +.runner-job-row, .runner-queue-row, .runner-queue-head { + display: grid; + align-items: center; + gap: 8px; + padding: 8px 12px; + border-bottom: 1px solid var(--border); +} +.runner-job-row { grid-template-columns: minmax(0, 1fr) auto; } +.runner-job-actions { justify-content: flex-end; } +.runner-job-copy { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; } +.runner-job-copy span { font-size: 12px; color: var(--muted); } +.runner-queue-head, .runner-queue-row { grid-template-columns: 24px minmax(0, 1fr) minmax(64px, 1fr); overflow-wrap: anywhere; } +.runner-queue-head { font-size: 12px; color: var(--secondary); } -.saved-selection-copy strong { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; +@media (min-width: 981px) and (min-height: 720px) { + .content.trend-content:not(.trend-touch) { display: flex; flex-direction: column; height: 100dvh; } + .trend-content:not(.trend-touch) > :not(.trend-layout) { flex: none; } + .trend-content:not(.trend-touch) .trend-layout { flex: 1; min-height: 0; grid-template-rows: minmax(0, 1fr); } + .trend-content:not(.trend-touch) .trend-side { + align-self: stretch; + align-content: stretch; + grid-template-rows: minmax(240px, 1fr) auto; + min-height: 0; + } + .trend-content:not(.trend-touch) .trend-point-library .point-list { max-height: none; } } - -.saved-selection-copy .selection-count { - flex: 0 0 auto; - padding: 0.08rem 0.32rem; - border-radius: 999px; - background: color-mix(in srgb, var(--accent) 12%, transparent); - color: var(--accent); - font-size: 0.65rem; - font-weight: 700; - line-height: 1.2; +@media (max-width: 1180px) { + .content { padding-inline: 20px; } + .app-shell { --sidebar-width: 196px; } + .runner-job-row { grid-template-columns: minmax(0, 1fr); } + .runner-job-actions { justify-content: flex-start; } +} +@media (max-width: 980px) { + .app-shell { grid-template-columns: minmax(0, 1fr); } + .sidebar, .sidebar.collapsed { + position: static; + height: auto; + display: grid; + grid-template-columns: minmax(0, 1fr) auto; + align-items: start; + gap: 8px; + padding: 12px 16px; + border-inline-end: 0; + border-bottom: 1px solid var(--border); + } + .sidebar .sidebar-top { display: contents; } + .sidebar-brand-row, .sidebar.collapsed .sidebar-brand-row { + grid-area: 1 / 1; + justify-content: flex-start; + flex-direction: row; + } + .sidebar .nav-list { grid-column: 1 / -1; display: flex; flex-wrap: wrap; } + .sidebar .sidebar-footer { grid-area: 1 / 2; border: 0; padding-top: 4px; } + .sidebar .sidebar-footer :is(.tiny-note, .user-card) { display: none; } + .sidebar.collapsed .sidebar-brand-row { gap: 4px; } + .trend-layout, .source-admin-top, .source-split { grid-template-columns: minmax(0, 1fr); } + .trend-layout { grid-template-areas: "controls" "plot"; } + .trend-point-library .point-list { max-height: min(30dvh, 272px); } +} +@media (max-width: 620px), (pointer: coarse) { + :is(.nav-button, .icon-button, .primary-button, .ghost-button, .theme-option, .point-item, .legend-item, .bacnet-device-row, .checkbox-field) { + min-height: 44px; + min-width: 44px; + } + .sidebar.collapsed :is(.nav-button, .sidebar-toggle, .sidebar-account) { + min-height: 44px; + min-width: 44px; + } + :is(input:not([type="checkbox"]), select, textarea) { min-height: 44px; } + .datapoint-row .compact-button, .chart-actions select { min-height: 44px; } +} +@media (max-width: 620px) { + .content { gap: 12px; padding: 16px 12px 24px; } + .sidebar, .sidebar.collapsed { padding: 8px 12px; } + .sidebar-brand-row { gap: 4px; } + .sidebar .nav-button { padding-inline: 8px; } + .sidebar.collapsed .nav-button { padding: 0; } + .panel, .modal-card { padding: 12px; gap: 12px; } + .view-strip { padding-bottom: 12px; } + .grid.two, .grid.two.dashboard-setup, .dashboard-grid, .form-grid, .protocol-grid, .runner-status-grid, .inline-fields, .inline-fields.multi-line { + grid-template-columns: minmax(0, 1fr); + gap: 12px; + } + .alias-row { grid-template-columns: minmax(0, 1fr); } + .alias-head { display: none; } + .alias-cell { display: grid; gap: 4px; } + .alias-cell-label { display: block; color: var(--secondary); font-size: 13px; } + .unit-table { font-size: 12px; } + .unit-table :is(th, td) { padding-inline: 4px; } + .source-tile { grid-template-columns: minmax(0, 1fr); } + .source-tile-actions { justify-content: flex-start; } + .trend-settings-popover { padding: 12px; } + .chart-panel, .trend-empty { min-height: 260px; } + .compact-chart { min-height: 0; } + .chart-plot, .compact-chart .chart-plot { height: 260px; } + .focus-mode .chart-plot { height: 58dvh; } +} +@media (prefers-reduced-motion: reduce) { + *, *::before, *::after { transition-duration: 0s !important; } } diff --git a/web/test/audit.test.mjs b/web/test/audit.test.mjs new file mode 100644 index 0000000..695a7fb --- /dev/null +++ b/web/test/audit.test.mjs @@ -0,0 +1,74 @@ +import { strict as assert } from "node:assert"; +import { test } from "node:test"; +import { fetchTrendSeries, normalizeRange } from "../../api/src/lib/isp.js"; +import { maxTrendRowsForSeries } from "../../shared/trend-preferences.mjs"; +import { formatMeasurement, measurementNumber } from "../src/components/measurement.mjs"; +import { assignTrendColors, trendDashPattern } from "../src/components/trend-colors.mjs"; + +test("missing measurements do not become zero", () => { + for (const value of [null, undefined, "", " ", NaN, Infinity, {}, []]) { + assert.equal(measurementNumber(value), null); + assert.equal(formatMeasurement(value), "Kein Messwert"); + } + for (const value of [0, "0", false]) assert.equal(formatMeasurement(value), "0.00"); + assert.equal(formatMeasurement(17.25), "17.25"); +}); + +test("trend range preserves 20,000 by default and exposes the effective query cap", () => { + assert.equal(normalizeRange({}, 1, 10).maxRows, 20_000); + assert.equal(normalizeRange({ maxRows: 40_000 }, 1, 2).maxRows, 40_000); + const capped = normalizeRange({ maxRows: 40_000 }, 1, 10); + assert.equal(capped.requestedMaxRows, 40_000); + assert.equal(capped.maxRows, maxTrendRowsForSeries(10)); + assert.equal(capped.maxRows, 25_000); + assert.equal(normalizeRange({ maxRows: -1 }).maxRows, 100); + assert.equal(normalizeRange({ maxRows: 100_000 }).maxRows, 50_000); +}); + +test("trend samples are capped after merging sources and keep null distinct from zero", async () => { + const points = [ + { isp: "isp_a", pointIndex: 1 }, + { isp: "isp_b", pointIndex: 1 }, + ]; + const queriedLimits = []; + const pool = { + async query(sql, args) { + if (sql.includes("information_schema.COLUMNS")) return [[{ columnName: "Wert1" }]]; + if (sql.includes("COUNT(*)")) return [[{ rowCount: 60 }]]; + if (sql.includes("source_datapoint_registry")) return [[]]; + if (sql.includes("Wert1")) { + queriedLimits.push(args.at(-1)); + const offset = sql.includes("isp_a") ? 0 : 1; + return [Array.from({ length: 60 }, (_, i) => ({ + datum: new Date(1_700_000_000_000 + (59 - i) * 2000 + offset * 1000), + Wert1: i % 2 ? null : 0, + }))]; + } + throw new Error("Unexpected query in fixture: " + sql); + }, + }; + const result = await fetchTrendSeries(pool, { get: async () => null, set: async () => {} }, points, + normalizeRange({ maxRows: 100 }, 1, points.length)); + assert.deepEqual(queriedLimits, [101, 101]); + assert.equal(result.rows.length, 100); + assert.equal(result.effectiveMaxRows, 100); + assert.equal(result.rowLimitReached, true); + assert.equal(result.rows.at(-1)["isp_b:1"], 0); + assert.equal(result.rows.at(-3)["isp_b:1"], null); +}); + +test("automatic series have contrast in both themes and manual color is preserved", () => { + const luminance = (hex) => hex.slice(1).match(/.{2}/g).map((value) => parseInt(value, 16) / 255) + .map((channel) => channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4) + .reduce((sum, value, idx) => sum + value * [0.2126, 0.7152, 0.0722][idx], 0); + const series = assignTrendColors(Array.from({ length: 100 }, (_, index) => + ({ key: String(index), color: index ? "#000000" : "#232323" }))); + assert.equal(series[0].color, "#232323"); + for (const { color } of series.slice(1)) { + for (const theme of ["#292e2c", "#f5f6f5"]) { + const [min, max] = [luminance(color), luminance(theme)].sort((a, b) => a - b); + assert.ok((max + 0.05) / (min + 0.05) >= 3.2, color + " on " + theme); + } + } + assert.equal(new Set(series.map((_, index) => trendDashPattern(index))).size, series.length); +});