Merge branch 'dev' into idf4

This commit is contained in:
MichaelDvP
2022-05-18 17:09:38 +02:00
17 changed files with 162 additions and 118 deletions

View File

@@ -12,10 +12,10 @@
"@emotion/styled": "^11.8.1",
"@msgpack/msgpack": "^2.7.2",
"@mui/icons-material": "^5.6.2",
"@mui/material": "^5.6.4",
"@table-library/react-table-library": "^3.1.0",
"@mui/material": "^5.7.0",
"@table-library/react-table-library": "^3.1.2",
"@types/lodash": "^4.14.182",
"@types/node": "^17.0.31",
"@types/node": "^17.0.33",
"@types/react": "^17.0.43",
"@types/react-dom": "^17.0.14",
"@types/react-router-dom": "^5.3.3",
@@ -24,7 +24,7 @@
"http-proxy-middleware": "^2.0.6",
"jwt-decode": "^3.1.2",
"lodash": "^4.17.21",
"notistack": "^2.0.4",
"notistack": "^2.0.5",
"parse-ms": "^3.0.0",
"react": "^17.0.2",
"react-app-rewired": "^2.2.1",
@@ -3629,14 +3629,13 @@
}
},
"node_modules/@table-library/react-table-library": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@table-library/react-table-library/-/react-table-library-3.1.0.tgz",
"integrity": "sha512-YCWmLPdElk/4+VPSxDcgQXlJx+jxYH2xJwr8NXm9e1AEy17K8mtrjzD5SQXDOiVT8vSOzD21eEldfIaI/kooHA==",
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/@table-library/react-table-library/-/react-table-library-3.1.2.tgz",
"integrity": "sha512-zfjIvcEP114KFh5WyZzbPQHtaxiSr0LHHgm+A8El6YG/SQ7D+i88RUdwiBu3uuKXTY7OV+5v/GESEiioZo150w==",
"dependencies": {
"clsx": "1.1.1",
"react-virtualized-auto-sizer": "1.0.6",
"react-window": "1.8.6",
"use-double-click": "1.0.5"
"react-window": "1.8.6"
},
"peerDependencies": {
"@emotion/react": ">= 11",
@@ -3843,9 +3842,9 @@
"integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw=="
},
"node_modules/@types/node": {
"version": "17.0.31",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.31.tgz",
"integrity": "sha512-AR0x5HbXGqkEx9CadRH3EBYx/VkiUgZIhP4wvPn/+5KIsgpNoyFaRlVe0Zlx9gRtg8fA06a9tskE2MSN7TcG4Q=="
"version": "17.0.33",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.33.tgz",
"integrity": "sha512-miWq2m2FiQZmaHfdZNcbpp9PuXg34W5JZ5CrJ/BaS70VuhoJENBEQybeiYSaPBRNq6KQGnjfEnc/F3PN++D+XQ=="
},
"node_modules/@types/parse-json": {
"version": "4.0.0",
@@ -12469,9 +12468,9 @@
}
},
"node_modules/notistack": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/notistack/-/notistack-2.0.4.tgz",
"integrity": "sha512-kOJmKvTG91ElMzi4aHu82BDe1liQ0zMrBp+TnWJptgowDsTbeTKbZmsRqJNIj145BmlOtZsEE9xjcrN46zVo3w==",
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/notistack/-/notistack-2.0.5.tgz",
"integrity": "sha512-Ig2T1Muqkc1PaSQcEDrK7diKv6cBxw02Iq6uv074ySfgq524TV5lK41diAb6OSsaiWfp3aRt+T3+0MF8m2EcJQ==",
"dependencies": {
"clsx": "^1.1.0",
"hoist-non-react-statics": "^3.3.0"
@@ -16960,19 +16959,6 @@
"node": ">=4"
}
},
"node_modules/use-double-click": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/use-double-click/-/use-double-click-1.0.5.tgz",
"integrity": "sha512-71LUca6NtzpzHYlcfM/dOdmwvmvpMbzeIVQpN87w+DctpLiMCXtZpsN8FNWPgHpPBtNhvucPUHIDh5al8D8C7w==",
"engines": {
"node": ">=8",
"npm": ">=5"
},
"peerDependencies": {
"react": ">=16.8",
"react-dom": ">=16.8"
}
},
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
@@ -20346,14 +20332,13 @@
}
},
"@table-library/react-table-library": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@table-library/react-table-library/-/react-table-library-3.1.0.tgz",
"integrity": "sha512-YCWmLPdElk/4+VPSxDcgQXlJx+jxYH2xJwr8NXm9e1AEy17K8mtrjzD5SQXDOiVT8vSOzD21eEldfIaI/kooHA==",
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/@table-library/react-table-library/-/react-table-library-3.1.2.tgz",
"integrity": "sha512-zfjIvcEP114KFh5WyZzbPQHtaxiSr0LHHgm+A8El6YG/SQ7D+i88RUdwiBu3uuKXTY7OV+5v/GESEiioZo150w==",
"requires": {
"clsx": "1.1.1",
"react-virtualized-auto-sizer": "1.0.6",
"react-window": "1.8.6",
"use-double-click": "1.0.5"
"react-window": "1.8.6"
}
},
"@tootallnate/once": {
@@ -20549,9 +20534,9 @@
"integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw=="
},
"@types/node": {
"version": "17.0.31",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.31.tgz",
"integrity": "sha512-AR0x5HbXGqkEx9CadRH3EBYx/VkiUgZIhP4wvPn/+5KIsgpNoyFaRlVe0Zlx9gRtg8fA06a9tskE2MSN7TcG4Q=="
"version": "17.0.33",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.33.tgz",
"integrity": "sha512-miWq2m2FiQZmaHfdZNcbpp9PuXg34W5JZ5CrJ/BaS70VuhoJENBEQybeiYSaPBRNq6KQGnjfEnc/F3PN++D+XQ=="
},
"@types/parse-json": {
"version": "4.0.0",
@@ -26878,9 +26863,9 @@
"integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A=="
},
"notistack": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/notistack/-/notistack-2.0.4.tgz",
"integrity": "sha512-kOJmKvTG91ElMzi4aHu82BDe1liQ0zMrBp+TnWJptgowDsTbeTKbZmsRqJNIj145BmlOtZsEE9xjcrN46zVo3w==",
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/notistack/-/notistack-2.0.5.tgz",
"integrity": "sha512-Ig2T1Muqkc1PaSQcEDrK7diKv6cBxw02Iq6uv074ySfgq524TV5lK41diAb6OSsaiWfp3aRt+T3+0MF8m2EcJQ==",
"requires": {
"clsx": "^1.1.0",
"hoist-non-react-statics": "^3.3.0"
@@ -30021,12 +30006,6 @@
"prepend-http": "^2.0.0"
}
},
"use-double-click": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/use-double-click/-/use-double-click-1.0.5.tgz",
"integrity": "sha512-71LUca6NtzpzHYlcfM/dOdmwvmvpMbzeIVQpN87w+DctpLiMCXtZpsN8FNWPgHpPBtNhvucPUHIDh5al8D8C7w==",
"requires": {}
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",

View File

@@ -8,10 +8,10 @@
"@emotion/styled": "^11.8.1",
"@msgpack/msgpack": "^2.7.2",
"@mui/icons-material": "^5.6.2",
"@mui/material": "^5.6.4",
"@table-library/react-table-library": "^3.1.0",
"@mui/material": "^5.7.0",
"@table-library/react-table-library": "^3.1.2",
"@types/lodash": "^4.14.182",
"@types/node": "^17.0.31",
"@types/node": "^17.0.33",
"@types/react": "^17.0.43",
"@types/react-dom": "^17.0.14",
"@types/react-router-dom": "^5.3.3",
@@ -20,7 +20,7 @@
"http-proxy-middleware": "^2.0.6",
"jwt-decode": "^3.1.2",
"lodash": "^4.17.21",
"notistack": "^2.0.4",
"notistack": "^2.0.5",
"parse-ms": "^3.0.0",
"react": "^17.0.2",
"react-app-rewired": "^2.2.1",

View File

@@ -38,3 +38,4 @@ export function updateLogSettings(logSettings: LogSettings): AxiosPromise<LogSet
export function readLogEntries(): AxiosPromise<LogEntries> {
return AXIOS_BIN.get('/fetchLog');
}

View File

@@ -24,7 +24,22 @@ const HelpInformation: FC = () => {
const { me } = useContext(AuthenticatedContext);
const onDownload = async (endpoint: string) => {
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',
@@ -34,19 +49,33 @@ const HelpInformation: FC = () => {
if (response.status !== 200) {
enqueueSnackbar('API call failed', { variant: 'error' });
} else {
const json = response.data;
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' });
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' });
@@ -103,7 +132,7 @@ const HelpInformation: FC = () => {
</ListItemAvatar>
<ListItemText>
To report an issue or request a feature, please&nbsp;
<Link component="button" variant="body1" onClick={() => onDownload('info')}>
<Link component="button" variant="body1" onClick={() => callAPI('info')}>
download
</Link>
&nbsp;the debug information and include in a new&nbsp;
@@ -131,7 +160,7 @@ const HelpInformation: FC = () => {
startIcon={<DownloadIcon />}
variant="outlined"
color="primary"
onClick={() => onDownload('settings')}
onClick={() => downloadSettings()}
>
settings
</Button>
@@ -139,7 +168,7 @@ const HelpInformation: FC = () => {
startIcon={<DownloadIcon />}
variant="outlined"
color="primary"
onClick={() => onDownload('customizations')}
onClick={() => downloadCustomizations()}
>
customizations
</Button>

View File

@@ -86,3 +86,11 @@ export function resetCustomizations(): AxiosPromise<void> {
export function API(apiCall: APIcall): AxiosPromise<void> {
return AXIOS_API.post('/', apiCall);
}
export function getSettings(): AxiosPromise<void> {
return AXIOS.get('/getSettings');
}
export function getCustomizations(): AxiosPromise<void> {
return AXIOS.get('/getCustomizations');
}