Skip to content

Commit

Permalink
Feature/soft 4568 update messages (#661)
Browse files Browse the repository at this point in the history
  • Loading branch information
KraPete authored Dec 9, 2024
1 parent ede0bee commit 1d208d9
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 23 deletions.
9 changes: 7 additions & 2 deletions app/scripts/i18n/react/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
"copy-device": "Copy device",
"updating-firmware": "Updating firmware {{current}} to {{available}}",
"updating-bootloader": "Updating bootloader {{current}} to {{available}}",
"current-firmware": "Current firmware version: {{firmware}}",
"actual-firmware": "Current firmware version: {{firmware}} (actual)",
"new-firmware": "There is a new firmware: {{available_firmware}}, current: {{current_firmware}}.",
"new-firmware-link": "There is a new firmware: {{available_firmware}}, current: {{current_firmware}}. <0 href=\"https://wirenboard.com/wiki/Changelog?signature={{device_model}}\">Change log</0>",
Expand Down Expand Up @@ -296,8 +297,12 @@
"duplicate-mqtt-topic": "MQTT id is the same as for {{device}}",
"is-disconnected": "The device is not responding. Check the physical connection of the RS-485 bus and the communication settings of the port and device, which should be the same",
"setup": "{{device}} setup failed: {{error}}",
"update-error-firmware": "Updating firmware {{from_version}} to {{to_version}} failed: {{error}}. If the device is not responding, <0 href=\"https://wirenboard.com/wiki/Wb-mcu-fw-updater#%D0%92%D0%BE%D1%81%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5_(recover)\">try to recover</0>",
"update-error-bootloader": "Updating bootloader {{from_version}} to {{to_version}} failed: {{error}}"
"update-error-firmware": "Updating firmware {{from_version}} to {{to_version}} failed.",
"update-error-bootloader": "Updating bootloader {{from_version}} to {{to_version}} failed.",
"update-error-generic": "Error: {{error}}. If the device is not responding, it may be in bootloader mode, to restore use the \"Find device\" button and search for devices in bootloader mode. If restore failed, contact technical support.",
"update-error-recoverable": "If the device is not responding, it may be in bootloader mode, to restore use the \"Find device\" button and search for devices in bootloader mode.",
"update-error-rpc-timeout": "Check wb-mqtt-serial is up and running.",
"update-error-download": "File download error. Check the network connection."
}
},
"exp-check": {
Expand Down
9 changes: 7 additions & 2 deletions app/scripts/i18n/react/locales/ru/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
"copy-device": "Скопировать устройство",
"updating-firmware": "Обновление прошивки {{current}} на {{available}}",
"updating-bootloader": "Обновление загрузчика {{current}} на {{available}}",
"current-firmware": "Текущая версия прошивки: {{firmware}}",
"actual-firmware": "Текущая версия прошивки: {{firmware}} (актуальная)",
"new-firmware": "Доступна новая версия прошивки: {{available_firmware}}, текущая: {{current_firmware}}.",
"new-firmware-link": "Доступна новая версия прошивки: {{available_firmware}}, текущая: {{current_firmware}}. <0 href=\"https://wirenboard.com/wiki/Changelog?signature={{device_model}}\">Список изменений</0>",
Expand Down Expand Up @@ -294,8 +295,12 @@
"duplicate-mqtt-topic": "Идентификатор устройства в MQTT совпадает с {{device}}",
"is-disconnected": "Нет связи с устройством. Проверьте физическое подключение шины RS-485 и настройки связи порта и устройства, которые должны быть одинаковы",
"setup": "Не удалось настроить {{device}}: {{error}}",
"update-error-firmware": "Не удалось обновить прошивку {{from_version}} до версии {{to_version}}: {{error}}. Если устройство не отвечает, воспользуйтесь <0 href=\"https://wirenboard.com/wiki/Wb-mcu-fw-updater#%D0%92%D0%BE%D1%81%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5_(recover)\">инструкцией по восстановлению</0>",
"update-error-bootloader": "Не удалось обновить загрузчик {{from_version}} до версии {{to_version}}: {{error}}"
"update-error-firmware": "Не удалось обновить прошивку {{from_version}} до версии {{to_version}}.",
"update-error-bootloader": "Не удалось обновить загрузчик {{from_version}} до версии {{to_version}}.",
"update-error-generic": "Ошибка: {{error}}. Если устройство не отвечает, возможно, оно находится в режиме загрузчика, для восстановления воспользуйтесь кнопкой \"Найти устройство\" и поиском устройств в режиме загрузчика. Если восстановить работу не получается, обратитесь в техническую поддержку.",
"update-error-recoverable": "Если устройство не отвечает, возможно, оно находится в режиме загрузчика, для восстановления воспользуйтесь кнопкой \"Найти устройство\" и поиском устройств в режиме загрузчика.",
"update-error-rpc-timeout": "Убедитесь, что сервис wb-mqtt-serial запущен и работает корректно.",
"update-error-download": "Не удалось загрузить файл с обновлением. Проверьте интернет-соединение."
}
},
"exp-check": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,19 @@ const EmbeddedSoftwareUpdatePanel = observer(({ component }) => {
);
});

const ActualFirmwarePanel = observer(({ firmwareVersion }) => {
const FirmwareVersionPanel = observer(({ firmwareVersion, isActual }) => {
const { t } = useTranslation();
return (
<div className="actual-firmware-panel">
<div className="firmware-version-panel">
<b>
{t('device-manager.labels.actual-firmware', {
firmware: firmwareVersion,
})}
{t(
isActual
? 'device-manager.labels.actual-firmware'
: 'device-manager.labels.current-firmware',
{
firmware: firmwareVersion,
}
)}
</b>
</div>
);
Expand Down Expand Up @@ -219,23 +224,32 @@ const NewEmbeddedSoftwareWarning = observer(
}
);

function getErrorDescriptionKey(errorId) {
const idToKey = new Map([
['com.wb.device_manager.download_error', 'download'],
['com.wb.device_manager.rpc_call_timeout_error', 'rpc-timeout'],
['com.wb.device_manager.device.response_timeout_error', 'recoverable'],
]);
const key = idToKey.get(errorId) || 'generic';
return 'device-manager.errors.update-error-' + key;
}

const EmbeddedSoftwareComponentUpdateError = observer(({ component }) => {
const { t } = useTranslation();
if (!component.hasError) {
return null;
}
const errorPrefix = t(`device-manager.errors.update-error-${component.type}`, {
from_version: component.errorData.from_version,
to_version: component.errorData.to_version,
});
const errorDescription = t(getErrorDescriptionKey(component.errorData.error.id), {
error: component.errorData.error.metadata?.exception || component.errorData.error.message,
});

return (
<ErrorPanel className={'firmware-update-error-panel'}>
<ErrorHeader>
<Trans
i18nKey={'device-manager.errors.update-error-' + component.type}
components={[<a></a>]}
values={{
error: component.errorData.error.message,
from_version: component.errorData.from_version,
to_version: component.errorData.to_version,
}}
/>
</ErrorHeader>
<ErrorHeader>{`${errorPrefix} ${errorDescription}`}</ErrorHeader>
<button type="button" className="close" onClick={() => component.clearError()}>
<span aria-hidden="true">&times;</span>
</button>
Expand All @@ -247,7 +261,7 @@ const CurrentFirmwarePanel = observer(({ firmware }) => {
if (firmware.hasUpdate || !firmware.current) {
return null;
}
return <ActualFirmwarePanel firmwareVersion={firmware.current} />;
return <FirmwareVersionPanel firmwareVersion={firmware.current} isActual={firmware.isActual} />;
});

const EmbeddedSoftwarePanel = observer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class EmbeddedSoftwareComponent {
updateProgress: observable,
errorData: observable.ref,
hasUpdate: computed,
isActual: computed,
clearVersion: action,
setUpdateProgress: action,
startUpdate: action,
Expand All @@ -64,6 +65,10 @@ export class EmbeddedSoftwareComponent {
return firmwareIsNewer(this.current, this.available);
}

get isActual() {
return this.available !== '' && this.current === this.available;
}

setUpdateProgress(data) {
this.updateProgress = data.progress;
this.current = data.from_version;
Expand Down Expand Up @@ -111,7 +116,6 @@ export class EmbeddedSoftwareComponent {
} catch (err) {}
runInAction(() => {
this.errorData = {};
this.clearVersion();
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/styles/css/device-manager.css
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
color: #bd882b;
}

.device-manager-page .actual-firmware-panel {
.device-manager-page .firmware-version-panel {
margin-bottom: 10px;
}

Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
wb-mqtt-homeui (2.106.2) stable; urgency=medium

* Make Wiren Board Modbus device update errors more verbose

-- Petr Krasnoshchekov <[email protected]> Mon, 09 Dec 2024 11:05:39 +0500

wb-mqtt-homeui (2.106.1) stable; urgency=medium

* Fix URL encoding of parameters on history page
Expand Down

0 comments on commit 1d208d9

Please sign in to comment.