mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-30 10:39:12 +03:00
remove dialog from upload as C++ code does restart immediately
This commit is contained in:
@@ -28,7 +28,7 @@
|
|||||||
"@table-library/react-table-library": "4.1.7",
|
"@table-library/react-table-library": "4.1.7",
|
||||||
"@types/lodash-es": "^4.17.10",
|
"@types/lodash-es": "^4.17.10",
|
||||||
"@types/node": "^20.8.7",
|
"@types/node": "^20.8.7",
|
||||||
"@types/react": "^18.2.29",
|
"@types/react": "^18.2.30",
|
||||||
"@types/react-dom": "^18.2.14",
|
"@types/react-dom": "^18.2.14",
|
||||||
"@types/react-router-dom": "^5.3.3",
|
"@types/react-router-dom": "^5.3.3",
|
||||||
"alova": "^2.13.1",
|
"alova": "^2.13.1",
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
"@preact/preset-vite": "^2.6.0",
|
"@preact/preset-vite": "^2.6.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
||||||
"@typescript-eslint/parser": "^6.8.0",
|
"@typescript-eslint/parser": "^6.8.0",
|
||||||
"concurrently": "^8.2.1",
|
"concurrently": "^8.2.2",
|
||||||
"eslint": "^8.51.0",
|
"eslint": "^8.51.0",
|
||||||
"eslint-config-airbnb": "^19.0.4",
|
"eslint-config-airbnb": "^19.0.4",
|
||||||
"eslint-config-airbnb-typescript": "^17.1.0",
|
"eslint-config-airbnb-typescript": "^17.1.0",
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
import CancelIcon from '@mui/icons-material/Cancel';
|
|
||||||
import DownloadIcon from '@mui/icons-material/GetApp';
|
import DownloadIcon from '@mui/icons-material/GetApp';
|
||||||
import PowerSettingsNewIcon from '@mui/icons-material/PowerSettingsNew';
|
import { Typography, Button, Box } from '@mui/material';
|
||||||
import { Typography, Button, Box, Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material';
|
|
||||||
import { useRequest } from 'alova';
|
import { useRequest } from 'alova';
|
||||||
import { useState, type FC } from 'react';
|
import { useState, type FC } from 'react';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
import RestartMonitor from './RestartMonitor';
|
import RestartMonitor from './RestartMonitor';
|
||||||
|
|
||||||
import { dialogStyle } from 'CustomTheme';
|
|
||||||
import * as SystemApi from 'api/system';
|
import * as SystemApi from 'api/system';
|
||||||
import { SectionContent, SingleUpload } from 'components';
|
import { SectionContent, SingleUpload } from 'components';
|
||||||
|
|
||||||
@@ -17,7 +14,6 @@ import * as EMSESP from 'project/api';
|
|||||||
const UploadFileForm: FC = () => {
|
const UploadFileForm: FC = () => {
|
||||||
const { LL } = useI18nContext();
|
const { LL } = useI18nContext();
|
||||||
const [restarting, setRestarting] = useState<boolean>();
|
const [restarting, setRestarting] = useState<boolean>();
|
||||||
const [confirmRestart, setConfirmRestart] = useState<boolean>(false);
|
|
||||||
const [md5, setMd5] = useState<string>();
|
const [md5, setMd5] = useState<string>();
|
||||||
|
|
||||||
const { send: getSettings, onSuccess: onSuccessGetSettings } = useRequest(EMSESP.getSettings(), {
|
const { send: getSettings, onSuccess: onSuccessGetSettings } = useRequest(EMSESP.getSettings(), {
|
||||||
@@ -36,10 +32,6 @@ const UploadFileForm: FC = () => {
|
|||||||
immediate: false
|
immediate: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const { send: restartCommand } = useRequest(SystemApi.restart(), {
|
|
||||||
immediate: false
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
loading: isUploading,
|
loading: isUploading,
|
||||||
uploading: progress,
|
uploading: progress,
|
||||||
@@ -56,7 +48,7 @@ const UploadFileForm: FC = () => {
|
|||||||
setMd5(data.md5);
|
setMd5(data.md5);
|
||||||
toast.success(LL.UPLOAD() + ' MD5 ' + LL.SUCCESSFUL());
|
toast.success(LL.UPLOAD() + ' MD5 ' + LL.SUCCESSFUL());
|
||||||
} else {
|
} else {
|
||||||
setConfirmRestart(true);
|
setRestarting(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -72,19 +64,6 @@ const UploadFileForm: FC = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const restart = async () => {
|
|
||||||
await restartCommand()
|
|
||||||
.then(() => {
|
|
||||||
setRestarting(true);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
toast.error(err.message);
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
setConfirmRestart(false);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const saveFile = (json: any, endpoint: string) => {
|
const saveFile = (json: any, endpoint: string) => {
|
||||||
const anchor = document.createElement('a');
|
const anchor = document.createElement('a');
|
||||||
anchor.href = URL.createObjectURL(
|
anchor.href = URL.createObjectURL(
|
||||||
@@ -144,33 +123,17 @@ const UploadFileForm: FC = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderRestartDialog = () => (
|
|
||||||
<Dialog sx={dialogStyle} open={confirmRestart} onClose={() => setConfirmRestart(false)}>
|
|
||||||
<DialogTitle>{LL.UPLOAD() + ' ' + LL.SUCCESSFUL()}</DialogTitle>
|
|
||||||
<DialogContent dividers>{LL.RESTART_TEXT()}</DialogContent>
|
|
||||||
<DialogActions>
|
|
||||||
<Button
|
|
||||||
startIcon={<CancelIcon />}
|
|
||||||
variant="outlined"
|
|
||||||
onClick={() => setConfirmRestart(false)}
|
|
||||||
color="secondary"
|
|
||||||
>
|
|
||||||
{LL.CANCEL()}
|
|
||||||
</Button>
|
|
||||||
<Button startIcon={<PowerSettingsNewIcon />} variant="outlined" onClick={restart} color="primary">
|
|
||||||
{LL.RESTART()}
|
|
||||||
</Button>
|
|
||||||
</DialogActions>
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
|
|
||||||
const content = () => (
|
const content = () => (
|
||||||
<>
|
<>
|
||||||
<Typography sx={{ pt: 2, pb: 2 }} variant="h6" color="primary">
|
<Typography sx={{ pt: 2, pb: 2 }} variant="h6" color="primary">
|
||||||
{LL.UPLOAD()}
|
{LL.UPLOAD()}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Box mb={2} color="warning.main">
|
<Box mb={2} color="warning.main">
|
||||||
<Typography variant="body2">{LL.UPLOAD_TEXT()} </Typography>
|
<Typography variant="body2">
|
||||||
|
{LL.UPLOAD_TEXT()}
|
||||||
|
<br />
|
||||||
|
{LL.RESTART_TEXT()}.
|
||||||
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
{md5 && (
|
{md5 && (
|
||||||
<Box mb={2}>
|
<Box mb={2}>
|
||||||
@@ -226,7 +189,6 @@ const UploadFileForm: FC = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{renderRestartDialog()}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1370,14 +1370,14 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@types/react@npm:^18.2.29":
|
"@types/react@npm:^18.2.30":
|
||||||
version: 18.2.29
|
version: 18.2.30
|
||||||
resolution: "@types/react@npm:18.2.29"
|
resolution: "@types/react@npm:18.2.30"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@types/prop-types": "npm:*"
|
"@types/prop-types": "npm:*"
|
||||||
"@types/scheduler": "npm:*"
|
"@types/scheduler": "npm:*"
|
||||||
csstype: "npm:^3.0.2"
|
csstype: "npm:^3.0.2"
|
||||||
checksum: c261e4e2ec18a7244c959cb40ac2f43b0fa7f0b40fcce615243402fc61699cbebf6f2eae2632b8a0f0a2775a1ca735279b15543349cafa276c064b591712b85b
|
checksum: dcad8aed0d0bf5731f4c6a7e8d28d8f571bd031c6c94edbcc1b7ab2c86e7cf61ae49d66c3229e1849fb4b82c5aa7be7c40e71ac5c2d7fef4eafb7a3b4abd25d6
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -1550,14 +1550,14 @@ __metadata:
|
|||||||
"@table-library/react-table-library": "npm:4.1.7"
|
"@table-library/react-table-library": "npm:4.1.7"
|
||||||
"@types/lodash-es": "npm:^4.17.10"
|
"@types/lodash-es": "npm:^4.17.10"
|
||||||
"@types/node": "npm:^20.8.7"
|
"@types/node": "npm:^20.8.7"
|
||||||
"@types/react": "npm:^18.2.29"
|
"@types/react": "npm:^18.2.30"
|
||||||
"@types/react-dom": "npm:^18.2.14"
|
"@types/react-dom": "npm:^18.2.14"
|
||||||
"@types/react-router-dom": "npm:^5.3.3"
|
"@types/react-router-dom": "npm:^5.3.3"
|
||||||
"@typescript-eslint/eslint-plugin": "npm:^6.8.0"
|
"@typescript-eslint/eslint-plugin": "npm:^6.8.0"
|
||||||
"@typescript-eslint/parser": "npm:^6.8.0"
|
"@typescript-eslint/parser": "npm:^6.8.0"
|
||||||
alova: "npm:^2.13.1"
|
alova: "npm:^2.13.1"
|
||||||
async-validator: "npm:^4.2.5"
|
async-validator: "npm:^4.2.5"
|
||||||
concurrently: "npm:^8.2.1"
|
concurrently: "npm:^8.2.2"
|
||||||
eslint: "npm:^8.51.0"
|
eslint: "npm:^8.51.0"
|
||||||
eslint-config-airbnb: "npm:^19.0.4"
|
eslint-config-airbnb: "npm:^19.0.4"
|
||||||
eslint-config-airbnb-typescript: "npm:^17.1.0"
|
eslint-config-airbnb-typescript: "npm:^17.1.0"
|
||||||
@@ -2384,9 +2384,9 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"concurrently@npm:^8.2.1":
|
"concurrently@npm:^8.2.2":
|
||||||
version: 8.2.1
|
version: 8.2.2
|
||||||
resolution: "concurrently@npm:8.2.1"
|
resolution: "concurrently@npm:8.2.2"
|
||||||
dependencies:
|
dependencies:
|
||||||
chalk: "npm:^4.1.2"
|
chalk: "npm:^4.1.2"
|
||||||
date-fns: "npm:^2.30.0"
|
date-fns: "npm:^2.30.0"
|
||||||
@@ -2400,7 +2400,7 @@ __metadata:
|
|||||||
bin:
|
bin:
|
||||||
conc: dist/bin/concurrently.js
|
conc: dist/bin/concurrently.js
|
||||||
concurrently: dist/bin/concurrently.js
|
concurrently: dist/bin/concurrently.js
|
||||||
checksum: 8a7cb8caeb9430f939ae6ba3ccdce6080e7f3084dcbffb6383059002937bbe771d71f8f4f854258e6138f52918637a3d66a6b21fd19d0ea69c426011f878e701
|
checksum: dcb1aa69d9c611a7bda9d4fc0fe1e388f971d1744acec7e0d52dffa2ef55743f1266ec9292f414c5789b9f61734b3fce772bd005d4de9564a949fb121b97bae1
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user