diff --git a/interface/package.json b/interface/package.json index 9ff23469e..d5c97796f 100644 --- a/interface/package.json +++ b/interface/package.json @@ -50,10 +50,12 @@ "typescript": "^5.4.5" }, "devDependencies": { + "@babel/core": "^7.24.5", "@eslint/js": "^9.2.0", "@preact/compat": "^17.1.2", "@preact/preset-vite": "^2.8.2", "@trivago/prettier-plugin-sort-imports": "^4.3.0", + "@types/babel__core": "^7", "concurrently": "^8.2.2", "eslint": "^9.2.0", "eslint-config-prettier": "^9.1.0", diff --git a/interface/src/AuthenticatedRouting.tsx b/interface/src/AuthenticatedRouting.tsx index 00ca0d836..3b5344168 100644 --- a/interface/src/AuthenticatedRouting.tsx +++ b/interface/src/AuthenticatedRouting.tsx @@ -43,10 +43,7 @@ const AuthenticatedRouting: FC = () => { } /> } /> } /> - } - /> + } /> } /> )} diff --git a/interface/src/CustomTheme.tsx b/interface/src/CustomTheme.tsx index 03c03c6a3..b42b7d0cc 100644 --- a/interface/src/CustomTheme.tsx +++ b/interface/src/CustomTheme.tsx @@ -15,8 +15,7 @@ export const dialogStyle = { borderColor: '#565656', borderStyle: 'solid', borderWidth: '1px' - }, - backdropFilter: 'blur(1px)' + } }; const theme = responsiveFontSizes( diff --git a/interface/src/framework/Settings.tsx b/interface/src/framework/Settings.tsx index 6164406ad..9ce091ce2 100644 --- a/interface/src/framework/Settings.tsx +++ b/interface/src/framework/Settings.tsx @@ -1,5 +1,4 @@ import { type FC, useState } from 'react'; -import { toast } from 'react-toastify'; import AccessTimeIcon from '@mui/icons-material/AccessTime'; import CancelIcon from '@mui/icons-material/Cancel'; @@ -7,7 +6,6 @@ import DeviceHubIcon from '@mui/icons-material/DeviceHub'; import ImportExportIcon from '@mui/icons-material/ImportExport'; import LockIcon from '@mui/icons-material/Lock'; import MemoryIcon from '@mui/icons-material/Memory'; -import PowerSettingsNewIcon from '@mui/icons-material/PowerSettingsNew'; import SettingsBackupRestoreIcon from '@mui/icons-material/SettingsBackupRestore'; import SettingsEthernetIcon from '@mui/icons-material/SettingsEthernet'; import SettingsInputAntennaIcon from '@mui/icons-material/SettingsInputAntenna'; @@ -19,6 +17,7 @@ import { DialogActions, DialogContent, DialogTitle, + Divider, List } from '@mui/material'; @@ -26,118 +25,25 @@ import * as SystemApi from 'api/system'; import { dialogStyle } from 'CustomTheme'; import { useRequest } from 'alova'; -import { ButtonRow, SectionContent, useLayoutTitle } from 'components'; +import { SectionContent, useLayoutTitle } from 'components'; import ListMenuItem from 'components/layout/ListMenuItem'; import { useI18nContext } from 'i18n/i18n-react'; -import RestartMonitor from './system/RestartMonitor'; - const Settings: FC = () => { const { LL } = useI18nContext(); useLayoutTitle(LL.SETTINGS(0)); - const [confirmRestart, setConfirmRestart] = useState(false); const [confirmFactoryReset, setConfirmFactoryReset] = useState(false); - const [processing, setProcessing] = useState(false); - const [restarting, setRestarting] = useState(); - - const { send: restartCommand } = useRequest(SystemApi.restart(), { - immediate: false - }); const { send: factoryResetCommand } = useRequest(SystemApi.factoryReset(), { immediate: false }); - const { send: partitionCommand } = useRequest(SystemApi.partition(), { - immediate: false - }); - - const restart = async () => { - setProcessing(true); - await restartCommand() - .then(() => { - setRestarting(true); - }) - .catch((error: Error) => { - toast.error(error.message); - }) - .finally(() => { - setConfirmRestart(false); - setProcessing(false); - }); - }; - const factoryReset = async () => { - setProcessing(true); - await factoryResetCommand() - .then(() => { - setRestarting(true); - }) - .catch((error: Error) => { - toast.error(error.message); - }) - .finally(() => { - setConfirmFactoryReset(false); - setProcessing(false); - }); + await factoryResetCommand(); + setConfirmFactoryReset(false); }; - const partition = async () => { - setProcessing(true); - await partitionCommand() - .then(() => { - setRestarting(true); - }) - .catch((error: Error) => { - toast.error(error.message); - }) - .finally(() => { - setConfirmRestart(false); - setProcessing(false); - }); - }; - - const renderRestartDialog = () => ( - setConfirmRestart(false)} - > - {LL.RESTART()} - {LL.RESTART_CONFIRM()} - - - - - - - ); - const renderFactoryResetDialog = () => ( { startIcon={} variant="outlined" onClick={() => setConfirmFactoryReset(false)} - disabled={processing} color="secondary" > {LL.CANCEL()} @@ -160,7 +65,6 @@ const Settings: FC = () => { startIcon={} variant="outlined" onClick={factoryReset} - disabled={processing} color="error" > {LL.FACTORY_RESET()} @@ -175,7 +79,7 @@ const Settings: FC = () => { @@ -219,13 +123,7 @@ const Settings: FC = () => { to="security" /> - + { /> - {renderRestartDialog()} {renderFactoryResetDialog()} - - - - - - - - - - - + + ); - return ( - {restarting ? : content()} - ); + return {content()}; }; export default Settings; diff --git a/interface/src/framework/system/SystemStatus.tsx b/interface/src/framework/system/SystemStatus.tsx index 1b023cde6..4b616fac4 100644 --- a/interface/src/framework/system/SystemStatus.tsx +++ b/interface/src/framework/system/SystemStatus.tsx @@ -8,6 +8,7 @@ import DeviceHubIcon from '@mui/icons-material/DeviceHub'; import DirectionsBusIcon from '@mui/icons-material/DirectionsBus'; import MemoryIcon from '@mui/icons-material/Memory'; import PermScanWifiIcon from '@mui/icons-material/PermScanWifi'; +import PowerSettingsNewIcon from '@mui/icons-material/PowerSettingsNew'; import RefreshIcon from '@mui/icons-material/Refresh'; import SettingsInputAntennaIcon from '@mui/icons-material/SettingsInputAntenna'; import TimerIcon from '@mui/icons-material/Timer'; @@ -39,6 +40,8 @@ import { useI18nContext } from 'i18n/i18n-react'; import { busConnectionStatus } from 'project/types'; import { NTPSyncStatus } from 'types'; +import RestartMonitor from './RestartMonitor'; + const SystemStatus: FC = () => { const { LL } = useI18nContext(); @@ -46,7 +49,18 @@ const SystemStatus: FC = () => { const { me } = useContext(AuthenticatedContext); + const [confirmRestart, setConfirmRestart] = useState(false); const [confirmScan, setConfirmScan] = useState(false); + const [processing, setProcessing] = useState(false); + const [restarting, setRestarting] = useState(); + + const { send: restartCommand } = useRequest(SystemApi.restart(), { + immediate: false + }); + + const { send: partitionCommand } = useRequest(SystemApi.partition(), { + immediate: false + }); const { data: data, @@ -180,6 +194,76 @@ const SystemStatus: FC = () => { ); + const restart = async () => { + setProcessing(true); + await restartCommand() + .then(() => { + setRestarting(true); + }) + .catch((error: Error) => { + toast.error(error.message); + }) + .finally(() => { + setConfirmRestart(false); + setProcessing(false); + }); + }; + + const partition = async () => { + setProcessing(true); + await partitionCommand() + .then(() => { + setRestarting(true); + }) + .catch((error: Error) => { + toast.error(error.message); + }) + .finally(() => { + setConfirmRestart(false); + setProcessing(false); + }); + }; + + const renderRestartDialog = () => ( + setConfirmRestart(false)} + > + {LL.RESTART()} + {LL.RESTART_CONFIRM()} + + + + + + + ); + const content = () => { if (!data) { return ; @@ -198,13 +282,28 @@ const SystemStatus: FC = () => { - + + + + + + + + {me.admin && ( + + )} + + @@ -252,7 +351,7 @@ const SystemStatus: FC = () => { bgcolor="#68374d" label={LL.SYSTEM_MEMORY()} text={formatNumber(data.free_heap) + ' KB'} - to="/settings/espsystemstatus" + to="/system/espsystemstatus" /> @@ -288,6 +387,7 @@ const SystemStatus: FC = () => { {renderScanDialog()} + {renderRestartDialog()}