From 64bebee21ace6209b425dbaccff407a4c4400833 Mon Sep 17 00:00:00 2001 From: Stalwart Git Sync <279488187+stalwart-labs@users.noreply.github.com> Date: Sun, 29 Nov 2026 16:56:26 +0100 Subject: [PATCH] Dashboard: zero-fill empty counter buckets and teal-first series colours --- CHANGELOG.md | 3 +++ package-lock.json | 4 ++-- package.json | 2 +- .../dashboard/components/DashboardChart.tsx | 24 ++++--------------- src/features/dashboard/helpers.ts | 23 ++++++++++++++++++ src/index.css | 8 +++---- 6 files changed, 38 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 377e766..172992f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ All notable changes to this project will be documented in this file. This projec ### Fixed - Sign-in no longer sends `prompt=login`, so an existing single sign-on session at an external OpenID Connect provider is reused instead of asking for the login again. - Calendars, address books and mailboxes that still hold events, contacts or messages can be deleted. The delete confirmation says that their contents are deleted with them. +- Dashboard: + - Counter charts drop to zero in empty intervals instead of repeating the last value, so a short burst (for example the morning DMARC and TLS reports) no longer shows as hours of steady activity. + - Pass, ham and other good series are drawn in teal and fail or spam in red, instead of the reverse. ## [2.1.1] - 2026-11-23 diff --git a/package-lock.json b/package-lock.json index 7dbd873..87a5030 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "stalwart-webui", - "version": "2.1.1", + "version": "2.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "stalwart-webui", - "version": "2.1.1", + "version": "2.1.2", "dependencies": { "@daypicker/react": "^10.0.2", "@dnd-kit/core": "^6.3.1", diff --git a/package.json b/package.json index acfd0a4..5ba86f8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "stalwart-webui", "private": true, - "version": "2.1.1", + "version": "2.1.2", "stalwart": { "minServerVersion": "1.0.0" }, diff --git a/src/features/dashboard/components/DashboardChart.tsx b/src/features/dashboard/components/DashboardChart.tsx index 6961fc4..2916679 100644 --- a/src/features/dashboard/components/DashboardChart.tsx +++ b/src/features/dashboard/components/DashboardChart.tsx @@ -13,7 +13,7 @@ import { HelpTooltip } from '@/components/common/HelpTooltip'; import { ChartTooltipContent, getChartColor } from '@/components/ui/chart'; import type { Chart as ChartSchema, Placement } from '../types/schema'; import type { Metric, Period } from '../types/metrics'; -import { bucketTimestamps, bucketValues, getBucketCount, formatTimeTick, formatValue } from '../helpers'; +import { bucketTimestamps, chartBucketValues, getBucketCount, formatTimeTick, formatValue } from '../helpers'; import { ChartSizedContainer } from './ChartSizedContainer'; import { toneClasses } from './tone'; import { cn } from '@/lib/utils'; @@ -33,10 +33,12 @@ export function DashboardChart({ chart, historySamples, historyWindow, period, c const valueFormat = chart.valueFormat ?? 'number'; const data = useMemo(() => { - const seriesValues = chart.series.map((series) => bucketValues(series, historySamples, from, to, bucketCount)); + const seriesValues = chart.series.map((series) => + chartBucketValues(series, historySamples, from, to, bucketCount, chart.stacked ?? false), + ); const timestamps = bucketTimestamps(from, to, bucketCount); - const points = timestamps.map((ts, i) => { + return timestamps.map((ts, i) => { const point: Record = { time: ts.getTime(), timeLabel: formatTimeTick(ts, period), @@ -46,22 +48,6 @@ export function DashboardChart({ chart, historySamples, historyWindow, period, c }); return point; }); - - if (chart.stacked) { - const lastSeen: Record = {}; - for (const point of points) { - for (const series of chart.series) { - const v = point[series.label]; - if (typeof v === 'number') { - lastSeen[series.label] = v; - } else { - point[series.label] = lastSeen[series.label] ?? 0; - } - } - } - } - - return points; }, [historySamples, from, to, bucketCount, chart.series, chart.stacked, period]); const tickFormatter = (value: number) => formatValue(value, valueFormat); diff --git a/src/features/dashboard/helpers.ts b/src/features/dashboard/helpers.ts index d9a7b75..8546d97 100644 --- a/src/features/dashboard/helpers.ts +++ b/src/features/dashboard/helpers.ts @@ -249,6 +249,29 @@ export function bucketValues( }); } +export function chartBucketValues( + target: MetricTarget, + samples: Metric[], + from: Date, + to: Date, + bucketCount: number, + stacked: boolean, +): (number | null)[] { + const values = bucketValues(target, samples, from, to, bucketCount); + const index = indexSamples(samples); + const kind = target.metrics.map((id) => index.get(id)?.[0]).find((m) => m !== undefined)?.['@type']; + if (kind === 'Gauge') { + if (!stacked) return values; + let lastSeen = 0; + return values.map((v) => { + if (v !== null) lastSeen = v; + return lastSeen; + }); + } + if (kind === 'Histogram' && !stacked) return values; + return values.map((v) => v ?? 0); +} + export function cardValue(card: Card, samples: Metric[]): number { return reduceSamples(card, selectSamples(card, samples)) ?? 0; } diff --git a/src/index.css b/src/index.css index 9f3f8c3..325420b 100644 --- a/src/index.css +++ b/src/index.css @@ -80,8 +80,8 @@ --shadow-c2: rgb(62 44 26 / 0.05); --hi: rgb(255 255 255 / 0); - --chart-1: #db2d54; - --chart-2: #2a9d8f; + --chart-1: #2a9d8f; + --chart-2: #db2d54; --chart-3: #d9822b; --chart-4: #4a3f8f; --chart-5: #8b7e6e; @@ -153,8 +153,8 @@ --shadow-c2: rgb(0 0 0 / 0.3); --hi: rgb(255 255 255 / 0.045); - --chart-1: #ff5c7f; - --chart-2: #4cc3b3; + --chart-1: #4cc3b3; + --chart-2: #ff5c7f; --chart-3: #f0a35a; --chart-4: #a99bf0; --chart-5: #9e9ea4;