1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

catch error if IC raw status is no JSON object

This commit is contained in:
Sonja Happ 2021-03-16 14:31:04 +01:00
parent fbebbd7a14
commit 63747a6468

View file

@ -46,6 +46,22 @@ class ICDialog extends React.Component {
FileSaver.saveAs(blob, this.props.ic.name + ".svg");
}
isJSON(data){
if (data === undefined || data === null){
return false;
}
let str = JSON.stringify(data);
try
{
JSON.parse(str)
}
catch(ex){
return false
}
return true
}
render() {
@ -90,14 +106,19 @@ class ICDialog extends React.Component {
<Col>
<h5>Raw Status:</h5>
<ReactJson
src={this.props.ic.statusupdateraw}
name={false}
displayDataTypes={false}
displayObjectSize={false}
enableClipboard={false}
collapsed={1}
/>
{this.isJSON(this.props.ic.statusupdateraw) ?
<ReactJson
src={this.props.ic.statusupdateraw}
name={false}
displayDataTypes={false}
displayObjectSize={false}
enableClipboard={false}
collapsed={2}
/>
:
<div>No valid JSON raw data available.</div>
}
{this.props.ic.type === "villas-node" || this.props.ic.type === "villas-relay" ? (
<>