Skip to content

Commit

Permalink
remove dialog from upload as C++ code does restart immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Oct 19, 2023
1 parent eb274a9 commit 9698e78
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 57 deletions.
4 changes: 2 additions & 2 deletions interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@table-library/react-table-library": "4.1.7",
"@types/lodash-es": "^4.17.10",
"@types/node": "^20.8.7",
"@types/react": "^18.2.29",
"@types/react": "^18.2.30",
"@types/react-dom": "^18.2.14",
"@types/react-router-dom": "^5.3.3",
"alova": "^2.13.1",
Expand All @@ -52,7 +52,7 @@
"@preact/preset-vite": "^2.6.0",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"concurrently": "^8.2.1",
"concurrently": "^8.2.2",
"eslint": "^8.51.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.1.0",
Expand Down
52 changes: 7 additions & 45 deletions interface/src/framework/system/UploadFileForm.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import CancelIcon from '@mui/icons-material/Cancel';
import DownloadIcon from '@mui/icons-material/GetApp';
import PowerSettingsNewIcon from '@mui/icons-material/PowerSettingsNew';
import { Typography, Button, Box, Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material';
import { Typography, Button, Box } from '@mui/material';
import { useRequest } from 'alova';
import { useState, type FC } from 'react';
import { toast } from 'react-toastify';
import RestartMonitor from './RestartMonitor';

import { dialogStyle } from 'CustomTheme';
import * as SystemApi from 'api/system';
import { SectionContent, SingleUpload } from 'components';

Expand All @@ -17,7 +14,6 @@ import * as EMSESP from 'project/api';
const UploadFileForm: FC = () => {
const { LL } = useI18nContext();
const [restarting, setRestarting] = useState<boolean>();
const [confirmRestart, setConfirmRestart] = useState<boolean>(false);
const [md5, setMd5] = useState<string>();

const { send: getSettings, onSuccess: onSuccessGetSettings } = useRequest(EMSESP.getSettings(), {
Expand All @@ -36,10 +32,6 @@ const UploadFileForm: FC = () => {
immediate: false
});

const { send: restartCommand } = useRequest(SystemApi.restart(), {
immediate: false
});

const {
loading: isUploading,
uploading: progress,
Expand All @@ -56,7 +48,7 @@ const UploadFileForm: FC = () => {
setMd5(data.md5);
toast.success(LL.UPLOAD() + ' MD5 ' + LL.SUCCESSFUL());
} else {
setConfirmRestart(true);
setRestarting(true);
}
});

Expand All @@ -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 anchor = document.createElement('a');
anchor.href = URL.createObjectURL(
Expand Down Expand Up @@ -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 = () => (
<>
<Typography sx={{ pt: 2, pb: 2 }} variant="h6" color="primary">
{LL.UPLOAD()}
</Typography>
<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>
{md5 && (
<Box mb={2}>
Expand Down Expand Up @@ -226,7 +189,6 @@ const UploadFileForm: FC = () => {
</Button>
</>
)}
{renderRestartDialog()}
</>
);
return (
Expand Down
20 changes: 10 additions & 10 deletions interface/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1370,14 +1370,14 @@ __metadata:
languageName: node
linkType: hard

"@types/react@npm:^18.2.29":
version: 18.2.29
resolution: "@types/react@npm:18.2.29"
"@types/react@npm:^18.2.30":
version: 18.2.30
resolution: "@types/react@npm:18.2.30"
dependencies:
"@types/prop-types": "npm:*"
"@types/scheduler": "npm:*"
csstype: "npm:^3.0.2"
checksum: c261e4e2ec18a7244c959cb40ac2f43b0fa7f0b40fcce615243402fc61699cbebf6f2eae2632b8a0f0a2775a1ca735279b15543349cafa276c064b591712b85b
checksum: dcad8aed0d0bf5731f4c6a7e8d28d8f571bd031c6c94edbcc1b7ab2c86e7cf61ae49d66c3229e1849fb4b82c5aa7be7c40e71ac5c2d7fef4eafb7a3b4abd25d6
languageName: node
linkType: hard

Expand Down Expand Up @@ -1550,14 +1550,14 @@ __metadata:
"@table-library/react-table-library": "npm:4.1.7"
"@types/lodash-es": "npm:^4.17.10"
"@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-router-dom": "npm:^5.3.3"
"@typescript-eslint/eslint-plugin": "npm:^6.8.0"
"@typescript-eslint/parser": "npm:^6.8.0"
alova: "npm:^2.13.1"
async-validator: "npm:^4.2.5"
concurrently: "npm:^8.2.1"
concurrently: "npm:^8.2.2"
eslint: "npm:^8.51.0"
eslint-config-airbnb: "npm:^19.0.4"
eslint-config-airbnb-typescript: "npm:^17.1.0"
Expand Down Expand Up @@ -2384,9 +2384,9 @@ __metadata:
languageName: node
linkType: hard

"concurrently@npm:^8.2.1":
version: 8.2.1
resolution: "concurrently@npm:8.2.1"
"concurrently@npm:^8.2.2":
version: 8.2.2
resolution: "concurrently@npm:8.2.2"
dependencies:
chalk: "npm:^4.1.2"
date-fns: "npm:^2.30.0"
Expand All @@ -2400,7 +2400,7 @@ __metadata:
bin:
conc: dist/bin/concurrently.js
concurrently: dist/bin/concurrently.js
checksum: 8a7cb8caeb9430f939ae6ba3ccdce6080e7f3084dcbffb6383059002937bbe771d71f8f4f854258e6138f52918637a3d66a6b21fd19d0ea69c426011f878e701
checksum: dcb1aa69d9c611a7bda9d4fc0fe1e388f971d1744acec7e0d52dffa2ef55743f1266ec9292f414c5789b9f61734b3fce772bd005d4de9564a949fb121b97bae1
languageName: node
linkType: hard

Expand Down

0 comments on commit 9698e78

Please sign in to comment.