import { FC, useContext } from 'react'; import { Typography, Button, Box, List, ListItem, ListItemText, Link, ListItemAvatar } from '@mui/material'; import { SectionContent, ButtonRow, MessageBox } from '../components'; import { AuthenticatedContext } from '../contexts/authentication'; import { useSnackbar } from 'notistack'; import CommentIcon from '@mui/icons-material/CommentTwoTone'; import MenuBookIcon from '@mui/icons-material/MenuBookTwoTone'; import GitHubIcon from '@mui/icons-material/GitHub'; import StarIcon from '@mui/icons-material/Star'; import DownloadIcon from '@mui/icons-material/GetApp'; import TuneIcon from '@mui/icons-material/Tune'; import { extractErrorMessage } from '../utils'; import * as EMSESP from './api'; const HelpInformation: FC = () => { const { enqueueSnackbar } = useSnackbar(); const { me } = useContext(AuthenticatedContext); const saveFile = (json: any, endpoint: string) => { const a = document.createElement('a'); const filename = 'emsesp_' + endpoint + '.json'; a.href = URL.createObjectURL( new Blob([JSON.stringify(json, null, 2)], { type: 'text/plain' }) ); a.setAttribute('download', filename); document.body.appendChild(a); a.click(); document.body.removeChild(a); enqueueSnackbar('File downloaded', { variant: 'info' }); }; const callAPI = async (endpoint: string) => { try { const response = await EMSESP.API({ device: 'system', entity: endpoint, id: 0 }); if (response.status !== 200) { enqueueSnackbar('API call failed', { variant: 'error' }); } else { saveFile(response.data, endpoint); } } catch (error: unknown) { enqueueSnackbar(extractErrorMessage(error, 'Problem with downloading'), { variant: 'error' }); } }; const downloadSettings = async () => { try { const response = await EMSESP.getSettings(); if (response.status !== 200) { enqueueSnackbar('Unable to get settings', { variant: 'error' }); } else { saveFile(response.data, 'settings'); } } catch (error: unknown) { enqueueSnackbar(extractErrorMessage(error, 'Problem with downloading'), { variant: 'error' }); } }; const downloadCustomizations = async () => { try { const response = await EMSESP.getCustomizations(); if (response.status !== 200) { enqueueSnackbar('Unable to get customizations', { variant: 'error' }); } else { saveFile(response.data, 'customizations'); } } catch (error: unknown) { enqueueSnackbar(extractErrorMessage(error, 'Problem with downloading'), { variant: 'error' }); } }; return ( For a help on each of the Application Settings see  {'Configuring EMS-ESP'} For general information about EMS-ESP visit the online  {'Documentation'} For live community chat join our  {'Discord'}  server To report an issue or request a feature, please  callAPI('info')}> download  the debug information and include in a new  GitHub issue {me.admin && ( <> Download Settings Export the application settings and any customizations to a JSON file. These files can later be uploaded via System→Upload. )} EMS-ESP is a free and open-source project.

Please consider supporting us by giving it a  on  {'GitHub'}  !
); }; export default HelpInformation;