make checkKapacitorConnection async

pull/1412/head
Jade McGough 2017-05-08 12:17:49 -07:00
parent 3cc94185d1
commit 71259b35b1
1 changed files with 12 additions and 12 deletions

View File

@ -39,22 +39,22 @@ class KapacitorPage extends Component {
}
getKapacitor(source, id).then(kapacitor => {
this.setState({kapacitor}, () => this.checkKapacitorConnection(kapacitor))
this.setState({kapacitor})
this.checkKapacitorConnection(kapacitor)
})
}
checkKapacitorConnection(kapacitor) {
pingKapacitor(kapacitor)
.then(() => {
this.setState({exists: true})
})
.catch(() => {
this.setState({exists: false})
this.props.addFlashMessage({
type: 'error',
text: 'Could not connect to Kapacitor. Check settings.',
})
async checkKapacitorConnection(kapacitor) {
try {
await pingKapacitor(kapacitor)
this.setState({exists: true})
} catch (error) {
this.setState({exists: false})
this.props.addFlashMessage({
type: 'error',
text: 'Could not connect to Kapacitor. Check settings.',
})
}
}
handleInputChange(e) {