mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 16:59:50 +03:00
download buttons for settings
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { Component } from 'react';
|
import { Component } from 'react';
|
||||||
import {
|
import {
|
||||||
Typography,
|
Typography,
|
||||||
Box,
|
Box,
|
||||||
@@ -14,14 +14,40 @@ import CommentIcon from '@material-ui/icons/CommentTwoTone';
|
|||||||
import MenuBookIcon from '@material-ui/icons/MenuBookTwoTone';
|
import MenuBookIcon from '@material-ui/icons/MenuBookTwoTone';
|
||||||
import GitHubIcon from '@material-ui/icons/GitHub';
|
import GitHubIcon from '@material-ui/icons/GitHub';
|
||||||
import StarIcon from '@material-ui/icons/Star';
|
import StarIcon from '@material-ui/icons/Star';
|
||||||
import ImportExportIcon from '@material-ui/icons/ImportExport';
|
import DownloadIcon from '@material-ui/icons/GetApp';
|
||||||
import BugReportIcon from '@material-ui/icons/BugReportTwoTone';
|
|
||||||
|
|
||||||
export const WebAPISystemSettings =
|
import { FormButton } from '../components';
|
||||||
window.location.origin + '/api/system/settings';
|
|
||||||
export const WebAPISystemInfo = window.location.origin + '/api/system/info';
|
import { API_ENDPOINT_ROOT } from '../api';
|
||||||
|
|
||||||
|
import { redirectingAuthorizedFetch } from '../authentication';
|
||||||
|
|
||||||
class EMSESPHelp extends Component {
|
class EMSESPHelp extends Component {
|
||||||
|
onDownload = (endpoint: string) => {
|
||||||
|
redirectingAuthorizedFetch(API_ENDPOINT_ROOT + 'system/' + endpoint)
|
||||||
|
.then((response) => {
|
||||||
|
if (response.status === 200) {
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
throw Error(
|
||||||
|
'Device returned unexpected response code: ' + response.status
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.then((json) => {
|
||||||
|
const a = document.createElement('a');
|
||||||
|
const filename = 'emsesp_system_' + endpoint + '.txt';
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<SectionContent title="EMS-ESP Help" titleGutter>
|
<SectionContent title="EMS-ESP Help" titleGutter>
|
||||||
@@ -31,9 +57,9 @@ class EMSESPHelp extends Component {
|
|||||||
<MenuBookIcon />
|
<MenuBookIcon />
|
||||||
</ListItemAvatar>
|
</ListItemAvatar>
|
||||||
<ListItemText>
|
<ListItemText>
|
||||||
For the latest news and updates go to the{' '}
|
For help and information on the latest updates visit the{' '}
|
||||||
<Link href="https://emsesp.github.io/docs" color="primary">
|
<Link href="https://emsesp.github.io/docs" color="primary">
|
||||||
{'official documentation'} website
|
{'online documentation'}
|
||||||
</Link>
|
</Link>
|
||||||
</ListItemText>
|
</ListItemText>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
@@ -55,41 +81,36 @@ class EMSESPHelp extends Component {
|
|||||||
<GitHubIcon />
|
<GitHubIcon />
|
||||||
</ListItemAvatar>
|
</ListItemAvatar>
|
||||||
<ListItemText>
|
<ListItemText>
|
||||||
To report an issue or feature request go to{' '}
|
To report an issue or request a feature go to{' '}
|
||||||
<Link
|
<Link
|
||||||
href="https://github.com/emsesp/EMS-ESP32/issues/new/choose"
|
href="https://github.com/emsesp/EMS-ESP32/issues/new/choose"
|
||||||
color="primary"
|
color="primary"
|
||||||
>
|
>
|
||||||
{'click here'}
|
{'GitHub'}
|
||||||
</Link>
|
|
||||||
</ListItemText>
|
|
||||||
</ListItem>
|
|
||||||
|
|
||||||
<ListItem>
|
|
||||||
<ListItemAvatar>
|
|
||||||
<ImportExportIcon />
|
|
||||||
</ListItemAvatar>
|
|
||||||
<ListItemText>
|
|
||||||
To export your system settings{' '}
|
|
||||||
<Link target="_blank" href={WebAPISystemSettings} color="primary">
|
|
||||||
{'click here'}
|
|
||||||
</Link>
|
|
||||||
</ListItemText>
|
|
||||||
</ListItem>
|
|
||||||
|
|
||||||
<ListItem>
|
|
||||||
<ListItemAvatar>
|
|
||||||
<BugReportIcon />
|
|
||||||
</ListItemAvatar>
|
|
||||||
<ListItemText>
|
|
||||||
To export the current status of EMS-ESP{' '}
|
|
||||||
<Link target="_blank" href={WebAPISystemInfo} color="primary">
|
|
||||||
{'click here'}
|
|
||||||
</Link>
|
</Link>
|
||||||
</ListItemText>
|
</ListItemText>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</List>
|
</List>
|
||||||
|
|
||||||
|
<Box flexWrap="none" padding={1} whiteSpace="nowrap">
|
||||||
|
<FormButton
|
||||||
|
startIcon={<DownloadIcon />}
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
onClick={() => this.onDownload('info')}
|
||||||
|
>
|
||||||
|
download system info
|
||||||
|
</FormButton>
|
||||||
|
<FormButton
|
||||||
|
startIcon={<DownloadIcon />}
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
onClick={() => this.onDownload('settings')}
|
||||||
|
>
|
||||||
|
download all settings
|
||||||
|
</FormButton>
|
||||||
|
</Box>
|
||||||
|
|
||||||
<Box bgcolor="info.main" border={1} p={3} mt={1} mb={0}>
|
<Box bgcolor="info.main" border={1} p={3} mt={1} mb={0}>
|
||||||
<Typography variant="h6">
|
<Typography variant="h6">
|
||||||
EMS-ESP is free and open-source.
|
EMS-ESP is free and open-source.
|
||||||
|
|||||||
Reference in New Issue
Block a user