This commit is contained in:
Proddy
2022-07-20 20:33:43 +02:00
parent c3757f95e5
commit ca30b8233b
2 changed files with 5 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
import { FC, useContext } from 'react'; import { FC } from 'react';
import { AxiosPromise } from 'axios'; import { AxiosPromise } from 'axios';
import { Typography, Button, Box } from '@mui/material'; import { Typography, Button, Box } from '@mui/material';
@@ -6,8 +6,6 @@ import { Typography, Button, Box } from '@mui/material';
import { FileUploadConfig } from '../../api/endpoints'; import { FileUploadConfig } from '../../api/endpoints';
import { SingleUpload, useFileUpload } from '../../components'; import { SingleUpload, useFileUpload } from '../../components';
import { AuthenticatedContext } from '../../contexts/authentication';
import DownloadIcon from '@mui/icons-material/GetApp'; import DownloadIcon from '@mui/icons-material/GetApp';
import { useSnackbar } from 'notistack'; import { useSnackbar } from 'notistack';
@@ -23,12 +21,11 @@ interface UploadFileProps {
const GeneralFileUpload: FC<UploadFileProps> = ({ uploadGeneralFile }) => { const GeneralFileUpload: FC<UploadFileProps> = ({ uploadGeneralFile }) => {
const [uploadFile, cancelUpload, uploading, uploadProgress] = useFileUpload({ upload: uploadGeneralFile }); const [uploadFile, cancelUpload, uploading, uploadProgress] = useFileUpload({ upload: uploadGeneralFile });
const { me } = useContext(AuthenticatedContext);
const { enqueueSnackbar } = useSnackbar(); const { enqueueSnackbar } = useSnackbar();
const saveFile = (json: any, endpoint: string) => { const saveFile = (json: any, endpoint: string) => {
const a = document.createElement('a'); const a = document.createElement('a');
const filename = 'emsesp_' + endpoint + '_json.txt'; const filename = 'emsesp_' + endpoint + '.json';
a.href = URL.createObjectURL( a.href = URL.createObjectURL(
new Blob([JSON.stringify(json, null, 2)], { new Blob([JSON.stringify(json, null, 2)], {
type: 'text/plain' type: 'text/plain'
@@ -84,7 +81,7 @@ const GeneralFileUpload: FC<UploadFileProps> = ({ uploadGeneralFile }) => {
<Typography sx={{ pt: 2, pb: 2 }} variant="h6" color="primary"> <Typography sx={{ pt: 2, pb: 2 }} variant="h6" color="primary">
Download Download
</Typography> </Typography>
{me.admin && ( {!uploading && (
<> <>
<Box color="warning.main"> <Box color="warning.main">
<Typography mb={1} variant="body2"> <Typography mb={1} variant="body2">

View File

@@ -21,7 +21,7 @@ const HelpInformation: FC = () => {
const saveFile = (json: any, endpoint: string) => { const saveFile = (json: any, endpoint: string) => {
const a = document.createElement('a'); const a = document.createElement('a');
const filename = 'emsesp_' + endpoint + '_json.txt'; const filename = 'emsesp_' + endpoint + '.txt';
a.href = URL.createObjectURL( a.href = URL.createObjectURL(
new Blob([JSON.stringify(json, null, 2)], { new Blob([JSON.stringify(json, null, 2)], {
type: 'text/plain' type: 'text/plain'
@@ -31,7 +31,7 @@ const HelpInformation: FC = () => {
document.body.appendChild(a); document.body.appendChild(a);
a.click(); a.click();
document.body.removeChild(a); document.body.removeChild(a);
enqueueSnackbar('File downloaded', { variant: 'info' }); enqueueSnackbar('System information downloaded', { variant: 'info' });
}; };
const callAPI = async (endpoint: string) => { const callAPI = async (endpoint: string) => {