From 2e26ee3e758f48ffa51e44534dbc1dbe3af2aed5 Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Mon, 31 Oct 2016 11:03:45 -0700 Subject: [PATCH] Add HipChat config --- ui/src/kapacitor/components/AlertOutputs.js | 14 ++- ui/src/kapacitor/components/HipchatConfig.js | 95 ++++++++++++++++++++ 2 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 ui/src/kapacitor/components/HipchatConfig.js diff --git a/ui/src/kapacitor/components/AlertOutputs.js b/ui/src/kapacitor/components/AlertOutputs.js index 869c2ffd80..f63c054bd1 100644 --- a/ui/src/kapacitor/components/AlertOutputs.js +++ b/ui/src/kapacitor/components/AlertOutputs.js @@ -2,6 +2,7 @@ import React, {PropTypes} from 'react'; import _ from 'lodash'; import {getKapacitorConfig, updateKapacitorConfigSection, testAlertOutput} from 'shared/apis'; import AlertaConfig from './AlertaConfig'; +import HipchatConfig from './HipchatConfig'; import PagerdutyConfig from './PagerdutyConfig'; import SlackConfig from './SlackConfig'; import SMTPConfig from './SMTPConfig'; @@ -27,7 +28,8 @@ const AlertOutputs = React.createClass({ alertaConfig: null, smtpConfig: null, slackConfig: null, - telegram: null, + telegramConfig: null, + hipchatConfig: null, }; }, @@ -39,6 +41,7 @@ const AlertOutputs = React.createClass({ getKapacitorConfig(this.props.kapacitor).then(({data: {sections}}) => { this.setState({ alertaConfig: this.getSection(sections, 'alerta'), + hipchatConfig: this.getSection(sections, 'hipchat'), pagerdutyConfig: this.getSection(sections, 'pagerduty'), slackConfig: this.getSection(sections, 'slack'), smtpConfig: this.getSection(sections, 'smtp'), @@ -94,11 +97,12 @@ const AlertOutputs = React.createClass({ @@ -138,6 +142,10 @@ const AlertOutputs = React.createClass({ return ; } + if (endpoint === 'hipchat' && this.state.pagerdutyConfig) { + return ; + } + return
This endpoint is not supported yet!
; }, }); diff --git a/ui/src/kapacitor/components/HipchatConfig.js b/ui/src/kapacitor/components/HipchatConfig.js new file mode 100644 index 0000000000..4fce7e23ce --- /dev/null +++ b/ui/src/kapacitor/components/HipchatConfig.js @@ -0,0 +1,95 @@ +import React, {PropTypes} from 'react'; + +const HipchatConfig = React.createClass({ + propTypes: { + config: PropTypes.shape({ + options: PropTypes.shape({ + global: PropTypes.bool.isRequired, + room: PropTypes.string.isRequired, + 'state-changes-only': PropTypes.bool.isRequired, + token: PropTypes.bool.isRequired, + url: PropTypes.string.isRequired, + }).isRequired, + }).isRequired, + onSave: PropTypes.func.isRequired, + }, + + handleSaveAlert(e) { + e.preventDefault(); + + const properties = { + room: this.room.value, + url: this.url.value, + token: this.token.value, + 'state-changes-only': this.stateChangesOnly.checked, + global: this.global.checked, + }; + + this.props.onSave(properties); + }, + + render() { + const {options} = this.props.config; + const stateChangesOnly = options['state-changes-only']; + const {url, global, room, token} = options; + + return ( +
+

VictorOps Alert

+
+
+
+
+

+ Have alerts sent to HipChat +

+ +
+ + this.url = r} defaultValue={url || ''}> +
+ +
+ + this.room = r} defaultValue={room || ''}> +
+ +
+ + this.token = r} defaultValue={token || ''}> + Note: a value of true indicates the HipChat token has been set +
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+ ); + }, +}); + +export default HipchatConfig;