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:
parent
fbebbd7a14
commit
63747a6468
1 changed files with 29 additions and 8 deletions
|
@ -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" ? (
|
||||
<>
|
||||
|
|
Loading…
Add table
Reference in a new issue