@devicechain/widgets 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -1
- package/dist/access-strings.d.ts +1 -1
- package/dist/aggregate-strings.d.ts +3 -1
- package/dist/alarm-strings.d.ts +4 -1
- package/dist/chunks/{aggregate-feed-HCF5FYIJ.js → aggregate-feed-QJRO7Y4V.js} +7 -4
- package/dist/chunks/aggregate-feed-QJRO7Y4V.js.map +7 -0
- package/dist/chunks/{aggregate-widgets-IFZUFYXV.js → aggregate-widgets-SHPHUHNL.js} +39 -62
- package/dist/chunks/aggregate-widgets-SHPHUHNL.js.map +7 -0
- package/dist/chunks/{alarm-widgets-TTQYBKMZ.js → alarm-widgets-DQEITFVN.js} +2 -2
- package/dist/chunks/alarm-widgets-DQEITFVN.js.map +7 -0
- package/dist/chunks/{chunk-FM7OI5TQ.js → chunk-2GMBZTQD.js} +44 -5
- package/dist/chunks/chunk-2GMBZTQD.js.map +7 -0
- package/dist/chunks/{chunk-AF4M5OXQ.js → chunk-4BEFYYM3.js} +3 -3
- package/dist/chunks/chunk-5UDZ5R5F.js +60 -0
- package/dist/chunks/chunk-5UDZ5R5F.js.map +7 -0
- package/dist/chunks/{chunk-VTGKDO44.js → chunk-7TEFJ64H.js} +19 -5
- package/dist/chunks/chunk-7TEFJ64H.js.map +7 -0
- package/dist/chunks/{chunk-GUCEPNGM.js → chunk-EFTUK5YX.js} +1 -1
- package/dist/chunks/chunk-EFTUK5YX.js.map +7 -0
- package/dist/chunks/{chunk-EQOWBDS7.js → chunk-G5UBMPMX.js} +2 -2
- package/dist/chunks/{chunk-EQOWBDS7.js.map → chunk-G5UBMPMX.js.map} +2 -2
- package/dist/chunks/{chunk-RG2AYYKO.js → chunk-GWH5AHG3.js} +6 -4
- package/dist/chunks/chunk-GWH5AHG3.js.map +7 -0
- package/dist/chunks/{chunk-XJ7UF2CP.js → chunk-O763YMOG.js} +1 -1
- package/dist/chunks/chunk-O763YMOG.js.map +7 -0
- package/dist/chunks/{chunk-ZX4K3GT5.js → chunk-R2XEYQEJ.js} +45 -24
- package/dist/chunks/chunk-R2XEYQEJ.js.map +7 -0
- package/dist/chunks/{chunk-JVC6JYUR.js → chunk-RLVZXNPJ.js} +1 -1
- package/dist/chunks/{chunk-JVC6JYUR.js.map → chunk-RLVZXNPJ.js.map} +1 -1
- package/dist/chunks/{chunk-QHTO5ZEM.js → chunk-UDQVBVXJ.js} +1 -1
- package/dist/chunks/chunk-UDQVBVXJ.js.map +7 -0
- package/dist/chunks/chunk-UVLEBGAC.js +17 -0
- package/dist/chunks/chunk-UVLEBGAC.js.map +7 -0
- package/dist/chunks/chunk-VR6643C7.js +119 -0
- package/dist/chunks/chunk-VR6643C7.js.map +7 -0
- package/dist/chunks/{chunk-ZR74ORIT.js → chunk-XDHKONWK.js} +1 -1
- package/dist/chunks/chunk-XDHKONWK.js.map +7 -0
- package/dist/chunks/{chunk-3FSXS67N.js → chunk-ZKR5WDF5.js} +68 -18
- package/dist/chunks/chunk-ZKR5WDF5.js.map +7 -0
- package/dist/chunks/{compare-feed-MLHG7YFN.js → compare-feed-K46QVE5D.js} +28 -16
- package/dist/chunks/compare-feed-K46QVE5D.js.map +7 -0
- package/dist/chunks/{control-widgets-KTH6BWMH.js → control-widgets-VMWBTRC6.js} +70 -34
- package/dist/chunks/control-widgets-VMWBTRC6.js.map +7 -0
- package/dist/chunks/entity-selector-IRUFUDQ6.js +7 -0
- package/dist/chunks/{event-markers-feed-BQO4T367.js → event-markers-feed-TOAQ53YC.js} +29 -11
- package/dist/chunks/event-markers-feed-TOAQ53YC.js.map +7 -0
- package/dist/chunks/{export-rows-OEWIBIUY.js → export-rows-XKIVLOM3.js} +3 -3
- package/dist/chunks/{fleet-feed-AKJ7QIMP.js → fleet-feed-AYNL3CC2.js} +6 -6
- package/dist/chunks/{history-widgets-7GNKTE5X.js → history-widgets-WJ4KRTG7.js} +55 -20
- package/dist/chunks/history-widgets-WJ4KRTG7.js.map +7 -0
- package/dist/chunks/{level-widgets-DKCQT2XF.js → level-widgets-3SRESJYW.js} +46 -14
- package/dist/chunks/level-widgets-3SRESJYW.js.map +7 -0
- package/dist/chunks/{natural-earth-data-VMKQ6LY3.js → natural-earth-data-R7NPQARR.js} +1 -1
- package/dist/chunks/natural-earth-data-R7NPQARR.js.map +7 -0
- package/dist/chunks/{no-reading-B4MPXAS2.js → no-reading-CTQCMNYA.js} +4 -4
- package/dist/chunks/{presence-widgets-7OGANOLB.js → presence-widgets-P2H3A2SD.js} +34 -16
- package/dist/chunks/presence-widgets-P2H3A2SD.js.map +7 -0
- package/dist/chunks/table-HAKFOUMS.js +8 -0
- package/dist/command-control-strings.d.ts +1 -1
- package/dist/compare-strings.d.ts +1 -1
- package/dist/event-markers-strings.d.ts +1 -1
- package/dist/fleet-strings.d.ts +1 -1
- package/dist/history-strings.d.ts +1 -1
- package/dist/host-context.js +1 -1
- package/dist/index.d.ts +112 -4
- package/dist/index.js +338 -131
- package/dist/index.js.map +4 -4
- package/dist/level-strings.d.ts +1 -1
- package/dist/presence-strings.d.ts +1 -1
- package/dist/registry.d.ts +2 -0
- package/dist/scada-strings.d.ts +1 -1
- package/dist/selection-strings.d.ts +10 -0
- package/dist/shared-strings.d.ts +38 -0
- package/dist/state-timeline-strings.d.ts +1 -1
- package/dist/status-grid-strings.d.ts +1 -1
- package/dist/table-strings.d.ts +1 -1
- package/dist/time-range-bar.d.ts +1 -2
- package/dist/time-range-strings.d.ts +8 -0
- package/dist/vite.js.map +1 -1
- package/dist/widgets/command-status.d.ts +1 -0
- package/dist/widgets/map-geometry.d.ts +2 -0
- package/package.json +8 -8
- package/dist/chunks/aggregate-feed-HCF5FYIJ.js.map +0 -7
- package/dist/chunks/aggregate-widgets-IFZUFYXV.js.map +0 -7
- package/dist/chunks/alarm-widgets-TTQYBKMZ.js.map +0 -7
- package/dist/chunks/chunk-3FSXS67N.js.map +0 -7
- package/dist/chunks/chunk-BRH66T5F.js +0 -15
- package/dist/chunks/chunk-BRH66T5F.js.map +0 -7
- package/dist/chunks/chunk-FM7OI5TQ.js.map +0 -7
- package/dist/chunks/chunk-GUCEPNGM.js.map +0 -7
- package/dist/chunks/chunk-QHTO5ZEM.js.map +0 -7
- package/dist/chunks/chunk-QMGKB6J3.js +0 -84
- package/dist/chunks/chunk-QMGKB6J3.js.map +0 -7
- package/dist/chunks/chunk-RG2AYYKO.js.map +0 -7
- package/dist/chunks/chunk-VTGKDO44.js.map +0 -7
- package/dist/chunks/chunk-XJ7UF2CP.js.map +0 -7
- package/dist/chunks/chunk-ZR74ORIT.js.map +0 -7
- package/dist/chunks/chunk-ZX4K3GT5.js.map +0 -7
- package/dist/chunks/compare-feed-MLHG7YFN.js.map +0 -7
- package/dist/chunks/control-widgets-KTH6BWMH.js.map +0 -7
- package/dist/chunks/entity-selector-3JJFI4DT.js +0 -7
- package/dist/chunks/event-markers-feed-BQO4T367.js.map +0 -7
- package/dist/chunks/history-widgets-7GNKTE5X.js.map +0 -7
- package/dist/chunks/level-widgets-DKCQT2XF.js.map +0 -7
- package/dist/chunks/natural-earth-data-VMKQ6LY3.js.map +0 -7
- package/dist/chunks/presence-widgets-7OGANOLB.js.map +0 -7
- package/dist/chunks/table-2UGM2Q4H.js +0 -8
- /package/dist/chunks/{chunk-AF4M5OXQ.js.map → chunk-4BEFYYM3.js.map} +0 -0
- /package/dist/chunks/{entity-selector-3JJFI4DT.js.map → entity-selector-IRUFUDQ6.js.map} +0 -0
- /package/dist/chunks/{export-rows-OEWIBIUY.js.map → export-rows-XKIVLOM3.js.map} +0 -0
- /package/dist/chunks/{fleet-feed-AKJ7QIMP.js.map → fleet-feed-AYNL3CC2.js.map} +0 -0
- /package/dist/chunks/{no-reading-B4MPXAS2.js.map → no-reading-CTQCMNYA.js.map} +0 -0
- /package/dist/chunks/{table-2UGM2Q4H.js.map → table-HAKFOUMS.js.map} +0 -0
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ npm install @devicechain/widgets @devicechain/dashboards @devicechain/client gra
|
|
|
23
23
|
import { DashboardRenderer } from '@devicechain/widgets';
|
|
24
24
|
import { DashboardHub, parseDashboardDefinition } from '@devicechain/dashboards';
|
|
25
25
|
|
|
26
|
-
const hub = new DashboardHub({ resolver, authorities: user.
|
|
26
|
+
const hub = new DashboardHub({ resolver, authorities: user.authorities });
|
|
27
27
|
const definition = parseDashboardDefinition(json);
|
|
28
28
|
|
|
29
29
|
<DashboardRenderer definition={definition} hub={hub} actions={hub} />;
|
|
@@ -61,6 +61,19 @@ or the one you pass as `registry`; see `createBuiltinWidgetRegistry` and
|
|
|
61
61
|
bound to a slot needs its datasource resolved first (`resolveWidgets` or
|
|
62
62
|
`resolveWidgetDatasource`).
|
|
63
63
|
|
|
64
|
+
The `@devicechain/widgets/host-context` subpath exports `MapRuntimeProvider`,
|
|
65
|
+
`useMapRuntime`, `MapRuntime`, `TenantBasemapProvider` and `useTenantBasemap`
|
|
66
|
+
without importing the widget catalog. Use it for providers above lazy dashboard
|
|
67
|
+
routes. `@devicechain/widgets/vite` exports only `viteMapRuntime`; the root stays
|
|
68
|
+
bundler-independent. Chart helpers can also be imported directly from
|
|
69
|
+
`@devicechain/widget-sdk/echarts`.
|
|
70
|
+
|
|
71
|
+
For offline preview, use `new SyntheticDataSource()` from `@devicechain/dashboards`
|
|
72
|
+
and set `seedHistory={false}` on the renderer; dispose the source with `disposeAll()`.
|
|
73
|
+
Use `validateDefinitionOptions(definition, { catalog })` to report invalid options
|
|
74
|
+
across a board and `stripUnknownOptions(definition, { catalog })` to remove
|
|
75
|
+
undeclared option keys. Supply your registry's catalog for extension widgets.
|
|
76
|
+
|
|
64
77
|
## The widgets
|
|
65
78
|
|
|
66
79
|
| channel | widgets |
|
package/dist/access-strings.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare const AGGREGATE_STATS: readonly ['avg', 'min', 'max', 'sum', 'count', 'last'];
|
|
2
2
|
export type AggregateStat = (typeof AGGREGATE_STATS)[number];
|
|
3
3
|
export interface AggregateStrings {
|
|
4
|
+
missingCount: (bucket: string, name: string) => string;
|
|
5
|
+
missingFields: (bucket: string, name: string, count: number, fields: string) => string;
|
|
4
6
|
stats: Record<AggregateStat, string>;
|
|
5
7
|
loading: string;
|
|
6
8
|
unsupported: string;
|
|
@@ -13,5 +15,5 @@ export interface AggregateStrings {
|
|
|
13
15
|
pieNegative: string;
|
|
14
16
|
pieNoShare: string;
|
|
15
17
|
}
|
|
16
|
-
export declare const AGGREGATE_STRINGS: Record<'en' | 'es', AggregateStrings>;
|
|
18
|
+
export declare const AGGREGATE_STRINGS: Record<'en' | 'es' | 'zh-CN', AggregateStrings>;
|
|
17
19
|
export declare function aggregateStrings(locale?: string | undefined): AggregateStrings;
|
package/dist/alarm-strings.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export interface AlarmStrings {
|
|
2
|
+
countUnit: (count: number) => string;
|
|
3
|
+
worst: (severity: string) => string;
|
|
4
|
+
countLabel: (count: number, severity: string | undefined) => string;
|
|
2
5
|
tabsLabel: string;
|
|
3
6
|
all: string;
|
|
4
7
|
deviceType: string;
|
|
@@ -36,5 +39,5 @@ export interface AlarmStrings {
|
|
|
36
39
|
failed: string;
|
|
37
40
|
};
|
|
38
41
|
}
|
|
39
|
-
export declare const ALARM_STRINGS: Record<'en' | 'es', AlarmStrings>;
|
|
42
|
+
export declare const ALARM_STRINGS: Record<'en' | 'es' | 'zh-CN', AlarmStrings>;
|
|
40
43
|
export declare function alarmStrings(locale?: string | undefined): AlarmStrings;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
measurementSpan
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EFTUK5YX.js";
|
|
4
|
+
import {
|
|
5
|
+
aggregateStrings
|
|
6
|
+
} from "./chunk-5UDZ5R5F.js";
|
|
4
7
|
|
|
5
8
|
// src/aggregate-feed.tsx
|
|
6
9
|
import {
|
|
@@ -24,14 +27,14 @@ function aggregateBuckets(buckets) {
|
|
|
24
27
|
const out = {};
|
|
25
28
|
for (const b of buckets) {
|
|
26
29
|
if (typeof b.count !== "number") {
|
|
27
|
-
throw new AggregateFieldsError(
|
|
30
|
+
throw new AggregateFieldsError(aggregateStrings().missingCount(b.bucketStart, b.name));
|
|
28
31
|
}
|
|
29
32
|
if (b.count === 0) continue;
|
|
30
33
|
const { min, max, sum } = b;
|
|
31
34
|
if (min == null || max == null || sum == null) {
|
|
32
35
|
const missing = [min == null && "min", max == null && "max", sum == null && "sum"].filter(Boolean);
|
|
33
36
|
throw new AggregateFieldsError(
|
|
34
|
-
|
|
37
|
+
aggregateStrings().missingFields(b.bucketStart, b.name, b.count, missing.join(", "))
|
|
35
38
|
);
|
|
36
39
|
}
|
|
37
40
|
const a = out[b.name];
|
|
@@ -168,4 +171,4 @@ function AggregateFeed({ hub, widget, descriptor, Component, actions, ErrorFrame
|
|
|
168
171
|
export {
|
|
169
172
|
AggregateFeed as default
|
|
170
173
|
};
|
|
171
|
-
//# sourceMappingURL=aggregate-feed-
|
|
174
|
+
//# sourceMappingURL=aggregate-feed-QJRO7Y4V.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/aggregate-feed.tsx", "../../src/aggregate-fold.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright The DeviceChain Authors\n// SPDX-License-Identifier: Apache-2.0\n\n// The data feed of an aggregate widget: the exact aggregates of its measurements over its span,\n// plus the newest live reading of each. Loaded on first use (connected-widget.tsx imports it\n// dynamically), so a board with no aggregate widget never downloads it.\n//\n// The aggregates are folded from the source's own buckets (WidgetDataSource.bucketMeasurements: each\n// carries the exact count, min, max and sum), never from the chart seed: a seed is a series of bucket\n// AVERAGES, and a minimum or maximum cannot be recovered from those. A source that produces no\n// buckets is an explained state, not a guess.\n//\n// - the span is the widget's pinned one, else the board's (DEFAULT_TIME_RANGE_SECONDS off a board);\n// - the window is whole minutes (aggregateWindow), so it holds no reading from before the span;\n// - live, the read ends at the last minute and repeats on the boundaries of aggregateRefreshMs\n// (one chart bucket of the span: a minute for an hour, 42 minutes for a week), so every card on\n// the board reads at the same moment and the hub serves identical reads once; paused, it ends\n// at the freeze instant and is read once, so the number on screen does not move;\n// - a card with `sparkline` set reads the SAME window in the span's chart buckets\n// (bucketSecondsFor) instead of one, and keeps each bucket as a trend point; the figure is\n// folded from those buckets and is the same number either way;\n// - a hidden tab does not read; it reads once when it is shown again;\n// - a live feed that resumes after an interruption reads again at once, so the figures take in\n// the readings sent during the outage (and a read that failed during it stops saying so) without\n// waiting for the next refresh, which on a week's span is 42 minutes away;\n// - a read for a different selector, span or freeze instant is not shown under the new one: a\n// result is tagged with the key it was read for, and a mismatch reads as loading;\n// - a card showing the latest reading ('last') is also handed the newest stored bucket by the board\n// (initialSamples), a minute's mean standing in until a live reading arrives and never over one.\n\nimport {\n bucketSecondsFor,\n DEFAULT_TIME_RANGE_SECONDS,\n type AggregateResult,\n type AggregateStreamState,\n type MeasurementSample,\n type WidgetActions,\n type WidgetDataSource,\n type WidgetDescriptor,\n type WidgetInstance,\n} from '@devicechain/dashboards';\nimport { optBoolean, useMeasurementStream, useWidgetTimeRange } from '@devicechain/widget-sdk';\nimport { useEffect, useMemo, useReducer, useState, type ComponentType } from 'react';\n\nimport { aggregateBuckets, aggregateRefreshMs, aggregateSeries, aggregateWindow } from './aggregate-fold';\nimport { measurementSpan } from './binding-policy';\n\nconst LOADING: AggregateResult = { status: 'loading' };\n\nexport interface AggregateFeedProps {\n hub: WidgetDataSource;\n widget: WidgetInstance;\n descriptor: WidgetDescriptor;\n // The widget's component, and the host's pane for a stream that failed (before any figure).\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Component: ComponentType<any>;\n actions: WidgetActions | undefined;\n // The stored latest reading of a card that shows it (see seedKey in dashboard-renderer.tsx).\n initialSamples?: MeasurementSample[];\n initialSamplesAsOf?: number;\n onReconnect?: () => void;\n ErrorFrame: ComponentType<{ widget: WidgetInstance; error: unknown }>;\n}\n\nexport default function AggregateFeed({ hub, widget, descriptor, Component, actions, ErrorFrame, initialSamples, initialSamplesAsOf, onReconnect }: AggregateFeedProps) {\n const range = useWidgetTimeRange();\n const now = useMemo(() => (hub.now ? () => hub.now!() : Date.now), [hub]);\n const spanSeconds = measurementSpan(descriptor, widget, range?.spanSeconds) ?? DEFAULT_TIME_RANGE_SECONDS;\n const pausedAt = range?.paused ? range.pausedAt : undefined;\n const ds = widget.datasource;\n\n // The newest live reading per measurement. It holds one sample: only `latest` is read, and the\n // pause keeps it from moving.\n const [resumes, resumed] = useReducer((n: number) => n + 1, 0);\n const stream = useMeasurementStream(hub, ds, {\n window: 1,\n pausedAt,\n now,\n initialSamples,\n initialSamplesAsOf,\n onReconnect: () => {\n resumed();\n onReconnect?.();\n },\n });\n\n const trend = optBoolean(widget.options, 'sparkline');\n const key = JSON.stringify([ds ?? null, spanSeconds, pausedAt ?? null, trend]);\n const supported = hub.bucketMeasurements !== undefined;\n const [tagged, setTagged] = useState<{ key: string; result: AggregateResult }>({ key, result: LOADING });\n\n useEffect(() => {\n if (!supported || !ds) return;\n let current = true;\n // Reads overlap (a boundary, a tab shown, a reconnect); only the NEWEST one's outcome is applied.\n let latest = 0;\n const run = (): void => {\n const mine = ++latest;\n const { window, spanSeconds: covered } = aggregateWindow(spanSeconds, pausedAt ?? now(), trend ? bucketSecondsFor(spanSeconds) : undefined);\n // Folded inside the chain, so a bucket that cannot be trusted fails the read like a network error.\n hub.bucketMeasurements!(ds, window).then((buckets) => ({ byName: aggregateBuckets(buckets), buckets })).then(\n ({ byName, buckets }) => {\n if (!current || mine !== latest) return;\n const { startTime, endTime } = window;\n const series = trend ? { series: aggregateSeries(buckets) } : {};\n setTagged({ key, result: { status: 'ready', byName, ...series, startTime, endTime, spanSeconds: covered } });\n },\n (err: unknown) => {\n if (!current || mine !== latest) return;\n const message = err instanceof Error ? err.message : String(err);\n setTagged({ key, result: { status: 'unavailable', reason: 'failed', message } });\n },\n );\n };\n run();\n // Paused, the window is fixed at the freeze instant: nothing new can land in it.\n if (pausedAt !== undefined) return () => void (current = false);\n const hidden = () => document.hidden;\n const every = aggregateRefreshMs(spanSeconds);\n let timer: ReturnType<typeof setTimeout>;\n const schedule = (): void => {\n timer = setTimeout(\n () => {\n if (!hidden()) run();\n schedule();\n },\n every - (now() % every),\n );\n };\n schedule();\n const shown = (): void => {\n if (!hidden()) run();\n };\n document.addEventListener('visibilitychange', shown);\n return () => {\n current = false;\n clearTimeout(timer);\n document.removeEventListener('visibilitychange', shown);\n };\n // `ds` is read through `key` (value identity), not by reference.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [hub, supported, key, resumes]);\n\n let aggregates: AggregateResult;\n if (!supported) aggregates = { status: 'unavailable', reason: 'unsupported' };\n else if (!ds) aggregates = { status: 'ready', byName: {}, startTime: '', endTime: '', spanSeconds };\n else aggregates = tagged.key === key ? tagged.result : LOADING;\n\n const data: AggregateStreamState = { aggregates, latest: stream.latest, error: stream.error };\n return data.error ? <ErrorFrame widget={widget} error={data.error} /> : <Component widget={widget} data={data} actions={actions} />;\n}\n", "// Copyright The DeviceChain Authors\n// SPDX-License-Identifier: Apache-2.0\n\n// Aggregates over a span, folded from the backend's time buckets. Each bucket carries the exact\n// count, minimum, maximum and sum of the readings in it, so the span's aggregates are exact too:\n// the min of the mins, the max of the maxes, the sum of the sums, the count of the counts, and a\n// mean that is the total sum over the total count (which is the count-weighted mean of the\n// buckets' averages, without ever reading an average).\n//\n// 🔴 A MINIMUM OR MAXIMUM IS NEVER DERIVED FROM AVERAGES. A bucket's average hides its extremes, so\n// the \"max of the avgs\" is a plausible number that is not the maximum. A bucket that holds\n// readings but lacks a field the aggregate needs is therefore a loud failure here, never a\n// quiet substitution.\n\nimport {\n bucketSecondsFor,\n type AggregateTrendPoint,\n type HistoryWindow,\n type MeasurementAggregate,\n type MeasurementBucket,\n} from '@devicechain/dashboards';\nimport { aggregateStrings } from './aggregate-strings';\n\nexport class AggregateFieldsError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'AggregateFieldsError';\n }\n}\n\n// aggregateBuckets folds the buckets (any number of devices) into one aggregate per measurement\n// name. A name with no readings in any bucket is absent from the result, not zero.\nexport function aggregateBuckets(buckets: readonly MeasurementBucket[]): Record<string, MeasurementAggregate> {\n const out: Record<string, MeasurementAggregate> = {};\n for (const b of buckets) {\n if (typeof b.count !== 'number') {\n throw new AggregateFieldsError(aggregateStrings().missingCount(b.bucketStart, b.name));\n }\n if (b.count === 0) continue;\n const { min, max, sum } = b;\n if (min == null || max == null || sum == null) {\n const missing = [min == null && 'min', max == null && 'max', sum == null && 'sum'].filter(Boolean);\n throw new AggregateFieldsError(\n aggregateStrings().missingFields(b.bucketStart, b.name, b.count, missing.join(', ')),\n );\n }\n const a = out[b.name];\n if (!a) out[b.name] = { count: b.count, min, max, sum, avg: sum / b.count };\n else {\n a.count += b.count;\n a.sum += sum;\n a.min = Math.min(a.min, min);\n a.max = Math.max(a.max, max);\n a.avg = a.sum / a.count;\n }\n }\n return out;\n}\n\n// aggregateSeries lays the same buckets out as a trend: per measurement name, one point per bucket\n// that holds readings, oldest first. Buckets of several devices at one instant merge exactly as\n// aggregateBuckets merges them. Call it only on buckets aggregateBuckets accepted (it does not\n// re-validate), so a bucket that cannot be trusted has already failed the read.\nexport function aggregateSeries(buckets: readonly MeasurementBucket[]): Record<string, AggregateTrendPoint[]> {\n const byName = new Map<string, Map<string, AggregateTrendPoint>>();\n for (const b of buckets) {\n if (!b.count || b.min == null || b.max == null || b.sum == null) continue;\n let points = byName.get(b.name);\n if (!points) byName.set(b.name, (points = new Map()));\n const at = points.get(b.bucketStart);\n if (!at) {\n points.set(b.bucketStart, { bucketStart: b.bucketStart, count: b.count, min: b.min, max: b.max, sum: b.sum, avg: b.sum / b.count });\n } else {\n at.count += b.count;\n at.sum += b.sum;\n at.min = Math.min(at.min, b.min);\n at.max = Math.max(at.max, b.max);\n at.avg = at.sum / at.count;\n }\n }\n const out: Record<string, AggregateTrendPoint[]> = {};\n for (const [name, points] of byName) {\n out[name] = [...points.values()].sort((a, b) => Date.parse(a.bucketStart) - Date.parse(b.bucketStart));\n }\n return out;\n}\n\n// ---- The window a stat reads ------------------------------------------------------------------\n\nconst MINUTE_MS = 60_000;\n\n// aggregateRefreshMs is how often a live stat reads again: one bucket of the span's chart\n// (bucketSecondsFor), so never more often than once a minute. Finer is wasted -- the window it\n// reads moves in whole minutes (aggregateWindow) -- and a 7-day figure re-read every few seconds\n// costs the event store a scan of a week of summaries to move by a few seconds' readings.\nexport function aggregateRefreshMs(spanSeconds: number): number {\n return bucketSecondsFor(spanSeconds) * 1000;\n}\n\nexport interface AggregateWindow {\n window: HistoryWindow;\n // The length the window actually covers, in seconds: the span, or less when the span is not a\n // whole number of minutes. This, not the span asked for, is what the card says it covers.\n spanSeconds: number;\n}\n\n// aggregateWindow is the window a stat over `spanSeconds` reads at `at` (epoch ms): whole minutes,\n// ending at the last minute boundary at or before `at`.\n//\n// 🔴 Whole minutes because the event store answers from one-minute summaries, and a summary is\n// read whole: a window starting mid-minute would also count the readings from that minute's\n// start, BEFORE the span, so \"Maximum · 1h\" could be the maximum of an hour and a minute. Both\n// edges fall on minute boundaries instead, and the end is asked for as the instant just before\n// its boundary (the store's end is inclusive), so the summaries read are exactly the window's.\n// The start rounds UP, so a span that is not a whole number of minutes covers less, never more,\n// and says so (`spanSeconds`).\n//\n// Live cards read again on the boundaries of aggregateRefreshMs (a whole number of minutes), so\n// every card of one span ends its window on the same boundary: cards that read the same\n// measurement ask the same question at the same moment, and the hub answers them with one read.\n// One bucket wide: the card needs only the totals, so the store returns one or two rows per\n// measurement rather than a chart's worth.\n//\n// `bucketSeconds` asks for the window in finer buckets (a trend needs a point per bucket); the\n// totals fold identically from any number of buckets, so the figure is the same either way. Unset\n// the window is one bucket wide, as above.\nexport function aggregateWindow(spanSeconds: number, at: number, bucketSeconds?: number): AggregateWindow {\n const end = Math.floor(at / MINUTE_MS) * MINUTE_MS;\n const start = Math.ceil((end - spanSeconds * 1000) / MINUTE_MS) * MINUTE_MS;\n const covered = (end - start) / 1000;\n return {\n window: {\n startTime: new Date(start).toISOString(),\n endTime: new Date(end - 1).toISOString(),\n intervalSeconds: Math.max(60, bucketSeconds === undefined ? covered : Math.min(covered, bucketSeconds)),\n },\n spanSeconds: covered,\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AA8BA;AAAA,EACE,oBAAAA;AAAA,EACA;AAAA,OAQK;AACP,SAAS,YAAY,sBAAsB,0BAA0B;AACrE,SAAS,WAAW,SAAS,YAAY,gBAAoC;;;AC5B7E;AAAA,EACE;AAAA,OAKK;AAGA,IAAM,uBAAN,cAAmC,MAAM;AAAA,EAC9C,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAIO,SAAS,iBAAiB,SAA6E;AAC5G,QAAM,MAA4C,CAAC;AACnD,aAAW,KAAK,SAAS;AACvB,QAAI,OAAO,EAAE,UAAU,UAAU;AAC/B,YAAM,IAAI,qBAAqB,iBAAiB,EAAE,aAAa,EAAE,aAAa,EAAE,IAAI,CAAC;AAAA,IACvF;AACA,QAAI,EAAE,UAAU,EAAG;AACnB,UAAM,EAAE,KAAK,KAAK,IAAI,IAAI;AAC1B,QAAI,OAAO,QAAQ,OAAO,QAAQ,OAAO,MAAM;AAC7C,YAAM,UAAU,CAAC,OAAO,QAAQ,OAAO,OAAO,QAAQ,OAAO,OAAO,QAAQ,KAAK,EAAE,OAAO,OAAO;AACjG,YAAM,IAAI;AAAA,QACR,iBAAiB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,QAAQ,KAAK,IAAI,CAAC;AAAA,MACrF;AAAA,IACF;AACA,UAAM,IAAI,IAAI,EAAE,IAAI;AACpB,QAAI,CAAC,EAAG,KAAI,EAAE,IAAI,IAAI,EAAE,OA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UAAM,QAAQ,mBAAmB,WAAW;AAC5C,QAAI;AACJ,UAAM,WAAW,MAAY;AAC3B,cAAQ;AAAA,QACN,MAAM;AACJ,cAAI,CAAC,OAAO,EAAG,KAAI;AACnB,mBAAS;AAAA,QACX;AAAA,QACA,QAAS,IAAI,IAAI;AAAA,MACnB;AAAA,IACF;AACA,aAAS;AACT,UAAM,QAAQ,MAAY;AACxB,UAAI,CAAC,OAAO,EAAG,KAAI;AAAA,IACrB;AACA,aAAS,iBAAiB,oBAAoB,KAAK;AACnD,WAAO,MAAM;AACX,gBAAU;AACV,mBAAa,KAAK;AAClB,eAAS,oBAAoB,oBAAoB,KAAK;AAAA,IACxD;AAAA,EAGF,GAAG,CAAC,KAAK,WAAW,KAAK,OAAO,CAAC;AAEjC,MAAI;AACJ,MAAI,CAAC,UAAW,cAAa,EAAE,QAAQ,eAAe,QAAQ,cAAc;AAAA,WACnE,CAAC,GAAI,cAAa,EAAE,QAAQ,SAAS,QAAQ,CAAC,GAAG,WAAW,IAAI,SAAS,IAAI,YAAY;AAAA,MAC7F,cAAa,OAAO,QAAQ,MAAM,OAAO,SAAS;AAEvD,QAAM,OAA6B,EAAE,YAAY,QAAQ,OAAO,QAAQ,OAAO,OAAO,MAAM;AAC5F,SAAO,KAAK,QAAQ,oBAAC,cAAW,QAAgB,OAAO,KAAK,OAAO,IAAK,oBAAC,aAAU,QAAgB,MAAY,SAAkB;AACnI;",
|
|
6
|
+
"names": ["bucketSecondsFor", "bucketSecondsFor"]
|
|
7
|
+
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AGGREGATE_STATS,
|
|
3
|
+
aggregateStrings
|
|
4
|
+
} from "./chunk-5UDZ5R5F.js";
|
|
1
5
|
import {
|
|
2
6
|
niceDomain,
|
|
3
7
|
pieSlices,
|
|
@@ -5,22 +9,22 @@ import {
|
|
|
5
9
|
} from "./chunk-YYJV54BV.js";
|
|
6
10
|
import {
|
|
7
11
|
fleetStrings
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-VR6643C7.js";
|
|
13
|
+
import "./chunk-UVLEBGAC.js";
|
|
10
14
|
import {
|
|
11
15
|
Explained
|
|
12
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-4BEFYYM3.js";
|
|
13
17
|
import {
|
|
14
18
|
NoReading
|
|
15
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-RLVZXNPJ.js";
|
|
16
20
|
import {
|
|
17
21
|
LevelEmpty,
|
|
18
22
|
LevelReadout
|
|
19
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-G5UBMPMX.js";
|
|
20
24
|
import {
|
|
21
25
|
fleetExport
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
26
|
+
} from "./chunk-7TEFJ64H.js";
|
|
27
|
+
import "./chunk-O763YMOG.js";
|
|
24
28
|
import {
|
|
25
29
|
DEFAULT_PAGE_SIZE,
|
|
26
30
|
cellFor,
|
|
@@ -42,41 +46,6 @@ import {
|
|
|
42
46
|
WidgetFrame
|
|
43
47
|
} from "@devicechain/widget-sdk";
|
|
44
48
|
|
|
45
|
-
// src/aggregate-strings.ts
|
|
46
|
-
import { viewerLocale } from "@devicechain/widget-sdk";
|
|
47
|
-
var AGGREGATE_STATS = ["avg", "min", "max", "sum", "count", "last"];
|
|
48
|
-
var AGGREGATE_STRINGS = {
|
|
49
|
-
en: {
|
|
50
|
-
stats: { avg: "Average", min: "Minimum", max: "Maximum", sum: "Sum", count: "Readings", last: "Latest" },
|
|
51
|
-
loading: "Loading",
|
|
52
|
-
unsupported: "This data source cannot compute aggregates",
|
|
53
|
-
failed: (m) => m ? `Aggregates unavailable: ${m}` : "Aggregates unavailable",
|
|
54
|
-
noReadings: (span) => `No readings in the last ${span}`,
|
|
55
|
-
noData: "No data",
|
|
56
|
-
unbound: "Choose a device for this widget",
|
|
57
|
-
trend: (stat, span) => `${stat} trend over the last ${span}`,
|
|
58
|
-
noCategories: "Select the measurements to show",
|
|
59
|
-
pieNegative: "A pie needs values of zero or more",
|
|
60
|
-
pieNoShare: "Every value is zero, so there is no share to show"
|
|
61
|
-
},
|
|
62
|
-
es: {
|
|
63
|
-
stats: { avg: "Promedio", min: "M\xEDnimo", max: "M\xE1ximo", sum: "Suma", count: "Lecturas", last: "\xDAltimo" },
|
|
64
|
-
loading: "Cargando",
|
|
65
|
-
unsupported: "Esta fuente de datos no puede calcular agregados",
|
|
66
|
-
failed: (m) => m ? `Agregados no disponibles: ${m}` : "Agregados no disponibles",
|
|
67
|
-
noReadings: (span) => `Sin lecturas en los \xFAltimos ${span}`,
|
|
68
|
-
noData: "Sin datos",
|
|
69
|
-
unbound: "Elija un dispositivo para este widget",
|
|
70
|
-
trend: (stat, span) => `Tendencia de ${stat.toLowerCase()} en los \xFAltimos ${span}`,
|
|
71
|
-
noCategories: "Seleccione las mediciones que mostrar",
|
|
72
|
-
pieNegative: "Un gr\xE1fico circular necesita valores de cero o m\xE1s",
|
|
73
|
-
pieNoShare: "Todos los valores son cero, no hay proporci\xF3n que mostrar"
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
function aggregateStrings(locale = viewerLocale()) {
|
|
77
|
-
return locale?.toLowerCase().split("-")[0] === "es" ? AGGREGATE_STRINGS.es : AGGREGATE_STRINGS.en;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
49
|
// src/category-items.ts
|
|
81
50
|
var CATEGORY_SORTS = ["none", "ascending", "descending"];
|
|
82
51
|
function parseSort(v) {
|
|
@@ -164,7 +133,7 @@ function DeviceBars({
|
|
|
164
133
|
}
|
|
165
134
|
function fitLabel(label, chars) {
|
|
166
135
|
if (chars < 2) return "";
|
|
167
|
-
return label.length <= chars ? label : `${label.slice(0, Math.max(1, chars - 1))}
|
|
136
|
+
return label.length <= chars ? label : `${label.slice(0, Math.max(1, chars - 1))}…`;
|
|
168
137
|
}
|
|
169
138
|
function Bars({
|
|
170
139
|
items,
|
|
@@ -218,7 +187,7 @@ function Bars({
|
|
|
218
187
|
height: H,
|
|
219
188
|
viewBox: `0 0 ${W} ${H}`,
|
|
220
189
|
role: "img",
|
|
221
|
-
"aria-label": items.map((i) => `${i.label}: ${i.value === null ? "
|
|
190
|
+
"aria-label": items.map((i) => `${i.label}: ${i.value === null ? "—" : withUnit(i.value)}`).join(", "),
|
|
222
191
|
style: { display: "block" },
|
|
223
192
|
children: [
|
|
224
193
|
note ? /* @__PURE__ */ jsx("text", { "data-bar-note": "", x: pad, y: fullH - font * 0.4, style: { ...text, ...muted }, children: note }) : null,
|
|
@@ -250,7 +219,7 @@ function Bars({
|
|
|
250
219
|
const lo = Math.min(zero, end);
|
|
251
220
|
const hi = Math.max(zero, end);
|
|
252
221
|
return /* @__PURE__ */ jsxs("g", { "data-bar": item.label, "data-value": v ?? void 0, children: [
|
|
253
|
-
/* @__PURE__ */ jsx("title", { children: `${item.label}: ${v === null ? "
|
|
222
|
+
/* @__PURE__ */ jsx("title", { children: `${item.label}: ${v === null ? "—" : withUnit(v)}` }),
|
|
254
223
|
v === null ? null : horizontal ? /* @__PURE__ */ jsx("rect", { x: x0 + lo, y: centre - thick / 2, width: Math.max(1, hi - lo), height: thick, style: { fill: css("chart-1") } }) : /* @__PURE__ */ jsx("rect", { x: centre - thick / 2, y: y1 - hi, width: thick, height: Math.max(1, hi - lo), style: { fill: css("chart-1") } }),
|
|
255
224
|
labelled && v !== null ? horizontal ? /* @__PURE__ */ jsx("text", { x: x0 + hi + pad, y: centre + font * 0.35, style: { ...text, fill: css("foreground") }, children: withUnit(v) }) : /* @__PURE__ */ jsx("text", { x: centre, y: y1 - hi - pad, textAnchor: "middle", style: { ...text, fill: css("foreground") }, children: fmt(v) }) : null,
|
|
256
225
|
/* @__PURE__ */ jsx(
|
|
@@ -533,7 +502,7 @@ function Table({
|
|
|
533
502
|
setPage(0);
|
|
534
503
|
};
|
|
535
504
|
const ariaSort = (by) => sort.by === by ? sort.descending ? "descending" : "ascending" : "none";
|
|
536
|
-
const arrow = (by) => sort.by === by ? sort.descending ? "
|
|
505
|
+
const arrow = (by) => sort.by === by ? sort.descending ? " ▼" : " ▲" : "";
|
|
537
506
|
const wide = /* @__PURE__ */ jsxs3("table", { style: { width: "100%", borderCollapse: "collapse", fontSize: fontVar2("md"), color: css3("foreground") }, children: [
|
|
538
507
|
/* @__PURE__ */ jsx3("thead", { children: /* @__PURE__ */ jsxs3("tr", { children: [
|
|
539
508
|
/* @__PURE__ */ jsx3("th", { scope: "col", "aria-sort": ariaSort(null), style: { ...headBox, ...stickyFirst, zIndex: 2 }, children: /* @__PURE__ */ jsxs3("button", { type: "button", style: plainButton, onClick: () => sortOn(null), title: strings.sortBy(strings.device), children: [
|
|
@@ -681,9 +650,9 @@ function Table({
|
|
|
681
650
|
children: [
|
|
682
651
|
/* @__PURE__ */ jsx3("span", { "data-fleet-truncated": fleet.truncated ? "" : void 0, children: fleet.truncated ? strings.truncated(fleet.members.length, fleet.total) : "" }),
|
|
683
652
|
pages > 1 && /* @__PURE__ */ jsxs3("span", { style: { display: "inline-flex", alignItems: "center", gap: spaceVar2(2) }, children: [
|
|
684
|
-
/* @__PURE__ */ jsx3("button", { type: "button", style: pagerButton, disabled: shownPage === 0, onClick: () => setPage(shownPage - 1), "aria-label": strings.previous, children: "
|
|
653
|
+
/* @__PURE__ */ jsx3("button", { type: "button", style: pagerButton, disabled: shownPage === 0, onClick: () => setPage(shownPage - 1), "aria-label": strings.previous, children: "‹" }),
|
|
685
654
|
/* @__PURE__ */ jsx3("span", { children: strings.range(shownPage * pageSize + 1, shownPage * pageSize + rows.length, sorted.length) }),
|
|
686
|
-
/* @__PURE__ */ jsx3("button", { type: "button", style: pagerButton, disabled: shownPage >= pages - 1, onClick: () => setPage(shownPage + 1), "aria-label": strings.next, children: "
|
|
655
|
+
/* @__PURE__ */ jsx3("button", { type: "button", style: pagerButton, disabled: shownPage >= pages - 1, onClick: () => setPage(shownPage + 1), "aria-label": strings.next, children: "›" })
|
|
687
656
|
] })
|
|
688
657
|
]
|
|
689
658
|
}
|
|
@@ -731,7 +700,7 @@ function CellView({
|
|
|
731
700
|
const muted = { color: css3("muted-foreground"), fontSize: fontVar2("sm"), ...wrap ? { overflowWrap: "anywhere" } : {} };
|
|
732
701
|
switch (cell.kind) {
|
|
733
702
|
case "loading":
|
|
734
|
-
return /* @__PURE__ */ jsx3("span", { style: muted, title: strings.loading, "aria-label": strings.loading, children: "
|
|
703
|
+
return /* @__PURE__ */ jsx3("span", { style: muted, title: strings.loading, "aria-label": strings.loading, children: "…" });
|
|
735
704
|
case "failed":
|
|
736
705
|
return /* @__PURE__ */ jsx3("span", { style: muted, children: strings.failed });
|
|
737
706
|
case "not-reported":
|
|
@@ -754,7 +723,7 @@ function CellView({
|
|
|
754
723
|
] }),
|
|
755
724
|
age !== void 0 && showAge && /* @__PURE__ */ jsxs3("span", { style: muted, "data-cell-age": "", children: [
|
|
756
725
|
formatAge(age),
|
|
757
|
-
stale ? `
|
|
726
|
+
stale ? ` · ${strings.stale}` : ""
|
|
758
727
|
] })
|
|
759
728
|
] });
|
|
760
729
|
}
|
|
@@ -791,7 +760,7 @@ function Pie({
|
|
|
791
760
|
viewBox: "0 0 100 100",
|
|
792
761
|
preserveAspectRatio: "xMidYMid meet",
|
|
793
762
|
role: "img",
|
|
794
|
-
"aria-label": items.map((i, n) => `${i.label}: ${i.value === null ? "
|
|
763
|
+
"aria-label": items.map((i, n) => `${i.label}: ${i.value === null ? "—" : fmt(i.value)} (${percent(slices[n].fraction)})`).join(", "),
|
|
795
764
|
style: { flex: "1 1 0", minHeight: 0, width: "100%", display: "block" },
|
|
796
765
|
children: slices.map((s) => {
|
|
797
766
|
const d = wedgePath(50, 50, 48, s.from, s.to);
|
|
@@ -803,7 +772,7 @@ function Pie({
|
|
|
803
772
|
"data-fraction": s.fraction,
|
|
804
773
|
d,
|
|
805
774
|
style: { fill: css4(RAMP[s.index % RAMP.length]), stroke: css4("card"), strokeWidth: 1 },
|
|
806
|
-
children: /* @__PURE__ */ jsx4("title", { children: `${item.label}: ${item.value === null ? "
|
|
775
|
+
children: /* @__PURE__ */ jsx4("title", { children: `${item.label}: ${item.value === null ? "—" : fmt(item.value)} (${percent(s.fraction)})` })
|
|
807
776
|
},
|
|
808
777
|
item.label
|
|
809
778
|
) : null;
|
|
@@ -828,7 +797,7 @@ function Pie({
|
|
|
828
797
|
fontSize: fontVar3("xs"),
|
|
829
798
|
color: css4("muted-foreground")
|
|
830
799
|
},
|
|
831
|
-
children: items.map((item, i) => /* @__PURE__ */ jsxs4("li", { title: `${item.label}: ${item.value === null ? "
|
|
800
|
+
children: items.map((item, i) => /* @__PURE__ */ jsxs4("li", { title: `${item.label}: ${item.value === null ? "—" : fmt(item.value)}`, style: { whiteSpace: "nowrap" }, children: [
|
|
832
801
|
/* @__PURE__ */ jsx4(
|
|
833
802
|
"span",
|
|
834
803
|
{
|
|
@@ -845,7 +814,7 @@ function Pie({
|
|
|
845
814
|
),
|
|
846
815
|
item.label,
|
|
847
816
|
" ",
|
|
848
|
-
item.value === null ? "
|
|
817
|
+
item.value === null ? "—" : `${fmt(item.value)} · ${percent(slices[i].fraction)}`
|
|
849
818
|
] }, item.label))
|
|
850
819
|
}
|
|
851
820
|
)
|
|
@@ -1104,7 +1073,7 @@ function StatCard({ widget, data }) {
|
|
|
1104
1073
|
}
|
|
1105
1074
|
function caption(r, stats) {
|
|
1106
1075
|
const name = stats[r.stat];
|
|
1107
|
-
return r.spanSeconds === void 0 ? name : `${name}
|
|
1076
|
+
return r.spanSeconds === void 0 ? name : `${name} · ${spanLabel(r.spanSeconds)}`;
|
|
1108
1077
|
}
|
|
1109
1078
|
function emptyMessage(r, strings) {
|
|
1110
1079
|
switch (r.reason) {
|
|
@@ -1176,7 +1145,7 @@ function tileSide(count, width, height, min, max, gap) {
|
|
|
1176
1145
|
}
|
|
1177
1146
|
|
|
1178
1147
|
// src/status-grid-strings.ts
|
|
1179
|
-
import { viewerLocale
|
|
1148
|
+
import { viewerLocale } from "@devicechain/widget-sdk";
|
|
1180
1149
|
var STATUS_GRID_STRINGS = {
|
|
1181
1150
|
en: {
|
|
1182
1151
|
ok: "OK",
|
|
@@ -1188,13 +1157,21 @@ var STATUS_GRID_STRINGS = {
|
|
|
1188
1157
|
es: {
|
|
1189
1158
|
ok: "Correcto",
|
|
1190
1159
|
none: "Sin lectura",
|
|
1191
|
-
chooseMeasurement: "Elija la
|
|
1192
|
-
levels: { critical: "
|
|
1160
|
+
chooseMeasurement: "Elija la medición que muestran los mosaicos",
|
|
1161
|
+
levels: { critical: "Crítico", major: "Mayor", minor: "Menor", warning: "Aviso", info: "Información", normal: "Correcto" },
|
|
1193
1162
|
tile: (device, reading, group) => `${device}: ${reading}, ${group}`
|
|
1163
|
+
},
|
|
1164
|
+
"zh-CN": {
|
|
1165
|
+
ok: "正常",
|
|
1166
|
+
none: "暂无读数",
|
|
1167
|
+
chooseMeasurement: "请选择方格显示的测量项",
|
|
1168
|
+
levels: { critical: "危急", major: "严重", minor: "次要", warning: "警告", info: "提示", normal: "正常" },
|
|
1169
|
+
tile: (device, reading, group) => `${device}:${reading},${group}`
|
|
1194
1170
|
}
|
|
1195
1171
|
};
|
|
1196
|
-
function statusGridStrings(locale =
|
|
1197
|
-
|
|
1172
|
+
function statusGridStrings(locale = viewerLocale()) {
|
|
1173
|
+
const language = locale?.toLowerCase().split("-")[0];
|
|
1174
|
+
return language === "es" ? STATUS_GRID_STRINGS.es : language === "zh" ? STATUS_GRID_STRINGS["zh-CN"] : STATUS_GRID_STRINGS.en;
|
|
1198
1175
|
}
|
|
1199
1176
|
|
|
1200
1177
|
// src/widgets/status-grid.tsx
|
|
@@ -1322,7 +1299,7 @@ ${stateName}`,
|
|
|
1322
1299
|
},
|
|
1323
1300
|
children: [
|
|
1324
1301
|
/* @__PURE__ */ jsx7("span", { style: { fontSize: fontVar5("xs"), overflowWrap: "anywhere", lineHeight: 1.15, color: css7("muted-foreground") }, children: t.label }),
|
|
1325
|
-
/* @__PURE__ */ jsx7("span", { style: { fontSize: has ? fontVar5("md") : fontVar5("xs"), fontWeight: 600, fontVariantNumeric: "tabular-nums", overflowWrap: "anywhere", lineHeight: 1.15 }, children: has ? reading : "
|
|
1302
|
+
/* @__PURE__ */ jsx7("span", { style: { fontSize: has ? fontVar5("md") : fontVar5("xs"), fontWeight: 600, fontVariantNumeric: "tabular-nums", overflowWrap: "anywhere", lineHeight: 1.15 }, children: has ? reading : "—" }),
|
|
1326
1303
|
sayState && /* @__PURE__ */ jsx7("span", { "data-tile-state": "", style: { fontSize: fontVar5("xs"), lineHeight: 1.1, overflowWrap: "anywhere", color: css7("muted-foreground") }, children: stateName })
|
|
1327
1304
|
]
|
|
1328
1305
|
},
|
|
@@ -1356,4 +1333,4 @@ export {
|
|
|
1356
1333
|
StatCard,
|
|
1357
1334
|
StatusGrid
|
|
1358
1335
|
};
|
|
1359
|
-
//# sourceMappingURL=aggregate-widgets-
|
|
1336
|
+
//# sourceMappingURL=aggregate-widgets-SHPHUHNL.js.map
|