mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
factory reset show system monitor
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import AccessTimeIcon from '@mui/icons-material/AccessTime';
|
import AccessTimeIcon from '@mui/icons-material/AccessTime';
|
||||||
import CancelIcon from '@mui/icons-material/Cancel';
|
import CancelIcon from '@mui/icons-material/Cancel';
|
||||||
@@ -30,11 +30,14 @@ import { SectionContent, useLayoutTitle } from 'components';
|
|||||||
import ListMenuItem from 'components/layout/ListMenuItem';
|
import ListMenuItem from 'components/layout/ListMenuItem';
|
||||||
import { useI18nContext } from 'i18n/i18n-react';
|
import { useI18nContext } from 'i18n/i18n-react';
|
||||||
|
|
||||||
|
import SystemMonitor from '../status/SystemMonitor';
|
||||||
|
|
||||||
const Settings = () => {
|
const Settings = () => {
|
||||||
const { LL } = useI18nContext();
|
const { LL } = useI18nContext();
|
||||||
useLayoutTitle(LL.SETTINGS(0));
|
useLayoutTitle(LL.SETTINGS(0));
|
||||||
|
|
||||||
const [confirmFactoryReset, setConfirmFactoryReset] = useState(false);
|
const [confirmFactoryReset, setConfirmFactoryReset] = useState(false);
|
||||||
|
const [restarting, setRestarting] = useState<boolean>();
|
||||||
|
|
||||||
const { send: sendAPI } = useRequest((data: APIcall) => API(data), {
|
const { send: sendAPI } = useRequest((data: APIcall) => API(data), {
|
||||||
immediate: false
|
immediate: false
|
||||||
@@ -42,6 +45,7 @@ const Settings = () => {
|
|||||||
|
|
||||||
const doFormat = useCallback(async () => {
|
const doFormat = useCallback(async () => {
|
||||||
await sendAPI({ device: 'system', cmd: 'format', id: 0 }).then(() => {
|
await sendAPI({ device: 'system', cmd: 'format', id: 0 }).then(() => {
|
||||||
|
setRestarting(true);
|
||||||
setConfirmFactoryReset(false);
|
setConfirmFactoryReset(false);
|
||||||
});
|
});
|
||||||
}, [sendAPI]);
|
}, [sendAPI]);
|
||||||
@@ -54,120 +58,131 @@ const Settings = () => {
|
|||||||
setConfirmFactoryReset(true);
|
setConfirmFactoryReset(true);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
const content = useMemo(() => {
|
||||||
<SectionContent>
|
return (
|
||||||
<List>
|
<>
|
||||||
<ListMenuItem
|
<List>
|
||||||
icon={TuneIcon}
|
<ListMenuItem
|
||||||
bgcolor="#134ba2"
|
icon={TuneIcon}
|
||||||
label={LL.APPLICATION()}
|
bgcolor="#134ba2"
|
||||||
text={LL.APPLICATION_SETTINGS_1()}
|
label={LL.APPLICATION()}
|
||||||
to="application"
|
text={LL.APPLICATION_SETTINGS_1()}
|
||||||
/>
|
to="application"
|
||||||
|
/>
|
||||||
|
|
||||||
<ListMenuItem
|
<ListMenuItem
|
||||||
icon={SettingsEthernetIcon}
|
icon={SettingsEthernetIcon}
|
||||||
bgcolor="#40828f"
|
bgcolor="#40828f"
|
||||||
label={LL.NETWORK(0)}
|
label={LL.NETWORK(0)}
|
||||||
text={LL.CONFIGURE(LL.SETTINGS_OF(LL.NETWORK(1)))}
|
text={LL.CONFIGURE(LL.SETTINGS_OF(LL.NETWORK(1)))}
|
||||||
to="network"
|
to="network"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ListMenuItem
|
<ListMenuItem
|
||||||
icon={SettingsInputAntennaIcon}
|
icon={SettingsInputAntennaIcon}
|
||||||
bgcolor="#5f9a5f"
|
bgcolor="#5f9a5f"
|
||||||
label={LL.ACCESS_POINT(0)}
|
label={LL.ACCESS_POINT(0)}
|
||||||
text={LL.CONFIGURE(LL.ACCESS_POINT(1))}
|
text={LL.CONFIGURE(LL.ACCESS_POINT(1))}
|
||||||
to="ap"
|
to="ap"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ListMenuItem
|
<ListMenuItem
|
||||||
icon={AccessTimeIcon}
|
icon={AccessTimeIcon}
|
||||||
bgcolor="#c5572c"
|
bgcolor="#c5572c"
|
||||||
label="NTP"
|
label="NTP"
|
||||||
text={LL.CONFIGURE(LL.LOCAL_TIME(1))}
|
text={LL.CONFIGURE(LL.LOCAL_TIME(1))}
|
||||||
to="ntp"
|
to="ntp"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ListMenuItem
|
<ListMenuItem
|
||||||
icon={DeviceHubIcon}
|
icon={DeviceHubIcon}
|
||||||
bgcolor="#68374d"
|
bgcolor="#68374d"
|
||||||
label="MQTT"
|
label="MQTT"
|
||||||
text={LL.CONFIGURE('MQTT')}
|
text={LL.CONFIGURE('MQTT')}
|
||||||
to="mqtt"
|
to="mqtt"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ListMenuItem
|
<ListMenuItem
|
||||||
icon={LockIcon}
|
icon={LockIcon}
|
||||||
label={LL.SECURITY(0)}
|
label={LL.SECURITY(0)}
|
||||||
text={LL.SECURITY_1()}
|
text={LL.SECURITY_1()}
|
||||||
to="security"
|
to="security"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ListMenuItem
|
<ListMenuItem
|
||||||
icon={ViewModuleIcon}
|
icon={ViewModuleIcon}
|
||||||
bgcolor="#efc34b"
|
bgcolor="#efc34b"
|
||||||
label={LL.MODULES()}
|
label={LL.MODULES()}
|
||||||
text={LL.MODULES_1()}
|
text={LL.MODULES_1()}
|
||||||
to="modules"
|
to="modules"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ListMenuItem
|
<ListMenuItem
|
||||||
icon={ImportExportIcon}
|
icon={ImportExportIcon}
|
||||||
bgcolor="#5d89f7"
|
bgcolor="#5d89f7"
|
||||||
label={LL.DOWNLOAD_UPLOAD()}
|
label={LL.DOWNLOAD_UPLOAD()}
|
||||||
text={LL.DOWNLOAD_UPLOAD_1()}
|
text={LL.DOWNLOAD_UPLOAD_1()}
|
||||||
to="downloadUpload"
|
to="downloadUpload"
|
||||||
/>
|
/>
|
||||||
</List>
|
</List>
|
||||||
|
|
||||||
<Dialog
|
<Dialog
|
||||||
sx={dialogStyle}
|
sx={dialogStyle}
|
||||||
open={confirmFactoryReset}
|
open={confirmFactoryReset}
|
||||||
onClose={handleFactoryResetClose}
|
onClose={handleFactoryResetClose}
|
||||||
>
|
>
|
||||||
<DialogTitle>{LL.FACTORY_RESET()}</DialogTitle>
|
<DialogTitle>{LL.FACTORY_RESET()}</DialogTitle>
|
||||||
<DialogContent dividers>{LL.SYSTEM_FACTORY_TEXT_DIALOG()}</DialogContent>
|
<DialogContent dividers>{LL.SYSTEM_FACTORY_TEXT_DIALOG()}</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button
|
<Button
|
||||||
startIcon={<CancelIcon />}
|
startIcon={<CancelIcon />}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onClick={handleFactoryResetClose}
|
onClick={handleFactoryResetClose}
|
||||||
color="secondary"
|
color="secondary"
|
||||||
>
|
>
|
||||||
{LL.CANCEL()}
|
{LL.CANCEL()}
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
startIcon={<SettingsBackupRestoreIcon />}
|
||||||
|
variant="outlined"
|
||||||
|
onClick={doFormat}
|
||||||
|
color="error"
|
||||||
|
>
|
||||||
|
{LL.FACTORY_RESET()}
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
<Box
|
||||||
|
mt={2}
|
||||||
|
display="flex"
|
||||||
|
justifyContent="flex-end"
|
||||||
|
flexWrap="nowrap"
|
||||||
|
whiteSpace="nowrap"
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
startIcon={<SettingsBackupRestoreIcon />}
|
startIcon={<SettingsBackupRestoreIcon />}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onClick={doFormat}
|
onClick={handleFactoryResetClick}
|
||||||
color="error"
|
color="error"
|
||||||
>
|
>
|
||||||
{LL.FACTORY_RESET()}
|
{LL.FACTORY_RESET()}
|
||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</Box>
|
||||||
</Dialog>
|
</>
|
||||||
|
);
|
||||||
|
}, [
|
||||||
|
LL,
|
||||||
|
handleFactoryResetClick,
|
||||||
|
handleFactoryResetClose,
|
||||||
|
doFormat,
|
||||||
|
confirmFactoryReset,
|
||||||
|
restarting
|
||||||
|
]);
|
||||||
|
|
||||||
<Divider />
|
return <SectionContent>{restarting ? <SystemMonitor /> : content}</SectionContent>;
|
||||||
|
|
||||||
<Box
|
|
||||||
mt={2}
|
|
||||||
display="flex"
|
|
||||||
justifyContent="flex-end"
|
|
||||||
flexWrap="nowrap"
|
|
||||||
whiteSpace="nowrap"
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
startIcon={<SettingsBackupRestoreIcon />}
|
|
||||||
variant="outlined"
|
|
||||||
onClick={handleFactoryResetClick}
|
|
||||||
color="error"
|
|
||||||
>
|
|
||||||
{LL.FACTORY_RESET()}
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
</SectionContent>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Settings;
|
export default Settings;
|
||||||
|
|||||||
Reference in New Issue
Block a user