From 93ce5277a97e3fa8dabdf001f2e9313c1ae37b05 Mon Sep 17 00:00:00 2001 From: Kevin Cantrell Date: Mon, 8 Jun 2026 01:23:25 +0900 Subject: [PATCH] correctly showing errors if they happen on sensors on the dashboard and detail page --- messages/en.json | 1 + messages/ja.json | 1 + package.json | 2 +- pnpm-lock.yaml | 10 +++++----- src/lib/api/api.dtos.ts | 2 ++ src/lib/components/dashboard/DashboardCards.svelte | 9 +++++++++ 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/messages/en.json b/messages/en.json index 2054ca95..f4b4188b 100644 --- a/messages/en.json +++ b/messages/en.json @@ -1034,6 +1034,7 @@ "dashboard_loading_details": "Loading details…", "dashboard_no_devices": "No devices", "dashboard_no_location": "No location", + "dashboard_sensor_error": "Sensor Error", "sensor_temperature": "Temperature", "sensor_humidity": "Humidity", "sensor_moisture": "Moisture", diff --git a/messages/ja.json b/messages/ja.json index dbcc6c2b..d2b15787 100644 --- a/messages/ja.json +++ b/messages/ja.json @@ -728,6 +728,7 @@ "dashboard_loading_details": "詳細を読み込み中…", "dashboard_no_devices": "デバイスがありません", "dashboard_no_location": "ロケーションなし", + "dashboard_sensor_error": "センサーエラー", "dashboard_no_matching_locations_body": "ダッシュボードのフィルターを調整するか、解除してロケーションをさらに表示してください。", "dashboard_no_matching_locations_title": "この条件に一致するデバイスはありません", "dashboard_virtual_scroll": "仮想スクロール", diff --git a/package.json b/package.json index ca0bf6e3..c0dcb25e 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ }, "packageManager": "pnpm@10.18.2+sha512.9fb969fa749b3ade6035e0f109f0b8a60b5d08a1a87fdf72e337da90dcc93336e2280ca4e44f2358a649b83c17959e9993e777c2080879f3801e6f0d999ad3dd", "dependencies": { - "@cropwatchdevelopment/cwui": "0.1.103", + "@cropwatchdevelopment/cwui": "0.1.105", "@supabase/supabase-js": "^2.98.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e5fdb647..a43647a4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@cropwatchdevelopment/cwui': - specifier: 0.1.103 - version: 0.1.103(svelte@5.53.0) + specifier: 0.1.105 + version: 0.1.105(svelte@5.53.0) '@supabase/supabase-js': specifier: ^2.98.0 version: 2.98.0 @@ -117,8 +117,8 @@ importers: packages: - '@cropwatchdevelopment/cwui@0.1.103': - resolution: {integrity: sha512-EZXs2nqNqhvtLqyA6+pSLsYzPlFEigXlphX62mhVG5kc+DRSKHLMywnIU3SkgU1b7D+6y0WOilOWb2rm9NX5SA==, tarball: https://npm.pkg.github.com/download/@cropwatchdevelopment/cwui/0.1.103/1e56a28d9c7af92fb2e2b4c03e8887a466e5d8e7} + '@cropwatchdevelopment/cwui@0.1.105': + resolution: {integrity: sha512-hmN1d7aNy4D+NUYc6G5nSILI4UBFxwngocojzf3wtrPfecoFAgbHbMEuiQe/p/norhdkG5wGR9frckqkAB0wwA==, tarball: https://npm.pkg.github.com/download/@cropwatchdevelopment/cwui/0.1.105/fb228c70c83b370df92b60cf8de16ce687f161f9} peerDependencies: svelte: ^5.0.0 @@ -2147,7 +2147,7 @@ packages: snapshots: - '@cropwatchdevelopment/cwui@0.1.103(svelte@5.53.0)': + '@cropwatchdevelopment/cwui@0.1.105(svelte@5.53.0)': dependencies: svelte: 5.53.0 diff --git a/src/lib/api/api.dtos.ts b/src/lib/api/api.dtos.ts index a1866571..1d05d9cc 100644 --- a/src/lib/api/api.dtos.ts +++ b/src/lib/api/api.dtos.ts @@ -139,6 +139,8 @@ export interface DashboardRow { group: string | null; upload_interval: number | null; last_data_updated_at: string | null; + /** Device-reported fault string; non-empty means the sensor needs attention. */ + error_status: string | null; device_type: DashboardDeviceType; location: DashboardLocation | null; latest: DashboardLatest | null; diff --git a/src/lib/components/dashboard/DashboardCards.svelte b/src/lib/components/dashboard/DashboardCards.svelte index 6d034e76..b08e56c3 100644 --- a/src/lib/components/dashboard/DashboardCards.svelte +++ b/src/lib/components/dashboard/DashboardCards.svelte @@ -123,6 +123,7 @@ existing.latest = next.latest; existing.last_data_updated_at = next.last_data_updated_at; existing.upload_interval = next.upload_interval; + existing.error_status = next.error_status; } } } @@ -176,6 +177,13 @@ return { ...readingProps(def.format, def.unit, row.latest?.secondary), icon: def.icon }; } + // A non-empty `error_status` on the device row means the sensor has reported a + // fault. Mirrors the device-detail page's convention. The raw status value is a + // device-side code (e.g. "-55"), so the card shows a localized message instead. + function hasDeviceError(row: DashboardRow): boolean { + return typeof row.error_status === 'string' && row.error_status.trim().length > 0; + } + function detailEntries(details: Record) { return Object.entries(details) .filter(([col, value]) => isDisplayableColumn(col) && value !== null && value !== undefined) @@ -276,6 +284,7 @@