Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add reboot board #36

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/components/Firmware/Firmware.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,30 @@ const Description: FC<{ text: string; value: any }> = ({ text, value }) => (
</div>
);

const RebootToBoard: FC = () => {
const intl = useIntl();
const device = useSelector((state: RootState) => state.runtime.device);
const [loading, setLoading] = useState(false);

const onRebootToBoard = useCallback(async () => {
setLoading(true);
await serviceHardware.rebootToBoard();
setLoading(false);
}, []);

if (['touch', 'pro'].includes(getDeviceType(device?.features))) {
return (
<div className="flex items-center justify-between text-sm text-gray-800 py-1">
<Button loading={loading} className="w-full" onClick={onRebootToBoard}>
{intl.formatMessage({ id: 'TR_CLICK_TO_BOARD' })}
</Button>
</div>
);
}

return null;
};

const ConfirmUpdate: FC = () => {
const intl = useIntl();
const device = useSelector((state: RootState) => state.runtime.device);
Expand Down Expand Up @@ -311,6 +335,7 @@ export default function Firmware() {
})}
value={device?.uuid ?? '-'}
/>
<RebootToBoard />
</div>
</div>
{['touch', 'pro'].includes(getDeviceType(device?.features)) && (
Expand Down
6 changes: 6 additions & 0 deletions src/hardware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,12 @@ class ServiceHardware {
return response.payload;
});
}

async rebootToBoard() {
const hardwareSDK = await this.getSDKInstance();
const response = await hardwareSDK.deviceRebootToBoardloader('');
return !!response.success;
}
}

export default ServiceHardware;
Expand Down
1 change: 1 addition & 0 deletions src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"TR_CLOSE": "close",
"TR_RES_REPAIR": "For {0} device, if there are problems such as picture display, you can click the fix button to restore the resources",
"TR_CLICK_TO_REPAIR": "click to fix",
"TR_CLICK_TO_BOARD": "Click to enter the board mode",
"TR_FIRMWARE_UPDATE_1": "Please first upgrade your OneKey Touch firmware to {version} or above",
"TR_FIRMWARE_UPDATE_2": "current version",
"TR_LIST_TIP_1": "Please unlock the device and keep it on the home page of the device, click the start button to operate, do not operate the device during the process",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"TR_CLOSE": "关闭",
"TR_RES_REPAIR": "{0} 设备,如果出现图片、图标显示不完全等问题,可以点击后方按钮进行资源修复后恢复",
"TR_CLICK_TO_REPAIR": "点击修复",
"TR_CLICK_TO_BOARD": "点击进入 Board 模式",
"TR_FIRMWARE_UPDATE_1": "请首先将您的 OneKey Touch 固件升级到 {version} 或以上",
"TR_FIRMWARE_UPDATE_2": "当前版本",
"TR_LIST_TIP_1": "请解锁设备并保持在设备首页后,点击开始按钮进行操作,过程中切勿操作设备",
Expand Down
Loading