restart dialog

This commit is contained in:
MichaelDvP
2024-08-12 09:23:46 +02:00
parent f10d8757b8
commit 8a409e8e9c
6 changed files with 73 additions and 31 deletions

View File

@@ -65,6 +65,10 @@ const SystemStatus: FC = () => {
immediate: false
});
const { send: factoryPartitionCommand } = useRequest(SystemApi.factoryPartition(), {
immediate: false
});
const {
data: data,
send: loadData,
@@ -229,6 +233,21 @@ const SystemStatus: FC = () => {
});
};
const factoryPartition = async () => {
setProcessing(true);
await factoryPartitionCommand()
.then(() => {
setRestarting(true);
})
.catch((error: Error) => {
toast.error(error.message);
})
.finally(() => {
setConfirmRestart(false);
setProcessing(false);
});
};
const renderRestartDialog = () => (
<Dialog
sx={dialogStyle}
@@ -247,15 +266,28 @@ const SystemStatus: FC = () => {
>
{LL.CANCEL()}
</Button>
<Button
startIcon={<PowerSettingsNewIcon />}
variant="outlined"
onClick={partition}
disabled={processing}
color="warning"
>
EMS-ESP Loader
</Button>
{data.has_loader && (
<Button
startIcon={<PowerSettingsNewIcon />}
variant="outlined"
onClick={factoryPartition}
disabled={processing}
color="warning"
>
EMS-ESP Boot
</Button>
)}
{data.has_partition && (
<Button
startIcon={<PowerSettingsNewIcon />}
variant="outlined"
onClick={partition}
disabled={processing}
color="warning"
>
Partition
</Button>
)}
<Button
startIcon={<PowerSettingsNewIcon />}
variant="outlined"