BUR-61 добавлена возможность сохранять и отображать current.value = null значений

This commit is contained in:
Первов Артем
2026-07-05 21:43:32 +03:00
parent e396fbbb8a
commit 3d395aaa8d
5 changed files with 11 additions and 10 deletions

View File

@@ -16,8 +16,9 @@ function isConfiguredLimit(value: number | null): value is number {
export function getMetricStatus(item: CurrentItem, now = Date.now()): MetricStatusInfo {
const measuredAt = new Date(item.time).getTime();
const ageSeconds = Number.isFinite(measuredAt) ? Math.max(0, Math.round((now - measuredAt) / 1000)) : Number.POSITIVE_INFINITY;
const belowMin = isConfiguredLimit(item.min) && item.value < item.min;
const aboveMax = isConfiguredLimit(item.max) && item.value > item.max;
const value = item.value;
const belowMin = isConfiguredLimit(value) && isConfiguredLimit(item.min) && value < item.min;
const aboveMax = isConfiguredLimit(value) && isConfiguredLimit(item.max) && value > item.max;
if (belowMin || aboveMax) {
return { status: 'critical', label: 'за пределами уставки', ageSeconds };