From 63747a6468a183d2a0e1411854ea31e9d222244e Mon Sep 17 00:00:00 2001 From: Sonja Happ Date: Tue, 16 Mar 2021 14:31:04 +0100 Subject: [PATCH] catch error if IC raw status is no JSON object --- src/ic/ic-dialog.js | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/ic/ic-dialog.js b/src/ic/ic-dialog.js index cba6291..eff8ef0 100644 --- a/src/ic/ic-dialog.js +++ b/src/ic/ic-dialog.js @@ -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 {
Raw Status:
- + {this.isJSON(this.props.ic.statusupdateraw) ? + + : +
No valid JSON raw data available.
+ } + {this.props.ic.type === "villas-node" || this.props.ic.type === "villas-relay" ? ( <>