From 83a5fedb95ea211f3bd66ab94d87e82ee1cc51e3 Mon Sep 17 00:00:00 2001 From: therealbobo Date: Mon, 14 Sep 2020 12:11:45 +0200 Subject: added error handling --- frontend/src/views/Config.js | 21 +++++++++++++++++++-- frontend/src/views/Config.scss | 4 ++++ 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'frontend') diff --git a/frontend/src/views/Config.js b/frontend/src/views/Config.js index 1468b1b..f5766eb 100644 --- a/frontend/src/views/Config.js +++ b/frontend/src/views/Config.js @@ -20,7 +20,8 @@ class Config extends Component { showConfig: true, tmpUser:"", tmpPass:"", - tmpConf:"" + tmpConf:"", + errors:"" }; this.serverIpChanged = this.serverIpChanged.bind(this); @@ -71,6 +72,7 @@ class Config extends Component { }) }; + let msg = ""; fetch('/setup', requestOptions) .then(response => { @@ -78,7 +80,12 @@ class Config extends Component { //this.setState({showConfig:false}); this.props.onHide(); this.props.onDone(); - console.log(this.props.disabled); + } else { + response.json().then(data => { + this.setState( + {errors : data.error.toString()} + ); + }); } } ); @@ -215,6 +222,16 @@ class Config extends Component { + +
+ + {this.state.errors + .split('\n').map((item, key) => { + return {item}
}) + } +
+
+
diff --git a/frontend/src/views/Config.scss b/frontend/src/views/Config.scss index b0b899f..331d7a7 100644 --- a/frontend/src/views/Config.scss +++ b/frontend/src/views/Config.scss @@ -49,3 +49,7 @@ } } + +.error{ + color: red; +} -- cgit v1.2.3-70-g09d2