From 7ab6515a104d3173f7a112ee604a7a779efa6219 Mon Sep 17 00:00:00 2001 From: lucas lelievre Date: Thu, 6 Mar 2025 17:45:27 +0100 Subject: [PATCH] Better status messages and ui feedback when needing user actions on the firmware tool (#1331) --- gui/public/i18n/en/translation.ftl | 4 +-- .../components/firmware-tool/DeviceCard.tsx | 27 ++++++++++++------- .../firmware-update/FirmwareUpdate.tsx | 22 ++++++++------- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/gui/public/i18n/en/translation.ftl b/gui/public/i18n/en/translation.ftl index dae47e8f8..01881bf2a 100644 --- a/gui/public/i18n/en/translation.ftl +++ b/gui/public/i18n/en/translation.ftl @@ -1261,11 +1261,11 @@ firmware_tool-build-ERROR = Unable to build the firmware ## Firmware update status firmware_update-status-DOWNLOADING = Downloading the firmware -firmware_update-status-NEED_MANUAL_REBOOT = Waiting for the user to reboot the tracker +firmware_update-status-NEED_MANUAL_REBOOT = Please restart the tracker firmware_update-status-AUTHENTICATING = Authenticating with the mcu firmware_update-status-UPLOADING = Uploading the firmware firmware_update-status-SYNCING_WITH_MCU = Syncing with the mcu -firmware_update-status-REBOOTING = Rebooting the tracker +firmware_update-status-REBOOTING = Applying the update firmware_update-status-PROVISIONING = Setting Wi-Fi credentials firmware_update-status-DONE = Update complete! firmware_update-status-ERROR_DEVICE_NOT_FOUND = Could not find the device diff --git a/gui/src/components/firmware-tool/DeviceCard.tsx b/gui/src/components/firmware-tool/DeviceCard.tsx index 1ddfb3cc4..405d934ec 100644 --- a/gui/src/components/firmware-tool/DeviceCard.tsx +++ b/gui/src/components/firmware-tool/DeviceCard.tsx @@ -10,6 +10,7 @@ import { TrackerStatus as TrackerStatusEnum, } from 'solarxr-protocol'; import { TrackerStatus } from '@/components/tracker/TrackerStatus'; +import { useMemo } from 'react'; interface DeviceCardProps { deviceNames: string[]; @@ -40,7 +41,7 @@ export function DeviceCardContent({ deviceNames, status }: DeviceCardProps) { ))} {status !== undefined ? ( - + {l10n.getString( 'firmware_update-status-' + FirmwareUpdateStatus[status] )} @@ -60,18 +61,26 @@ export function DeviceCardControl({ online = null, ...props }: DeviceCardControlProps & DeviceCardProps) { + const cardborder = useMemo(() => { + if (!props.status) return 'border-transparent'; + + if (props.status === FirmwareUpdateStatus.DONE) + return 'border-status-success'; + + if (props.status === FirmwareUpdateStatus.NEED_MANUAL_REBOOT) + return 'border-status-special'; + + if (firmwareUpdateErrorStatus.includes(props.status)) + return 'border-status-critical'; + + return 'border-transparent'; + }, [props.status]); + return (
{control && name ? ( diff --git a/gui/src/components/firmware-update/FirmwareUpdate.tsx b/gui/src/components/firmware-update/FirmwareUpdate.tsx index af56add12..d137b6427 100644 --- a/gui/src/components/firmware-update/FirmwareUpdate.tsx +++ b/gui/src/components/firmware-update/FirmwareUpdate.tsx @@ -251,16 +251,18 @@ export function FirmwareUpdate() { [status] ); - const shouldShowRebootWarning = useMemo( - () => - Object.keys(status).find((id) => - [ - FirmwareUpdateStatus.REBOOTING, - FirmwareUpdateStatus.UPLOADING, - ].includes(status[id].status) - ), - [status] - ); + const shouldShowRebootWarning = useMemo(() => { + const statuses = Object.keys(status); + return ( + statuses.length > 0 && + statuses.find( + (id) => + ![FirmwareUpdateStatus.DONE, ...firmwareUpdateErrorStatus].includes( + status[id].status + ) + ) + ); + }, [status]); const retryError = () => { const devices = trackerWithErrors.map((id) => {