diff --git a/ui/src/kapacitor/components/KapacitorRules.js b/ui/src/kapacitor/components/KapacitorRules.js index 5e22ee3f9e..475cea4c3f 100644 --- a/ui/src/kapacitor/components/KapacitorRules.js +++ b/ui/src/kapacitor/components/KapacitorRules.js @@ -5,6 +5,7 @@ import NoKapacitorError from 'shared/components/NoKapacitorError' import SourceIndicator from 'shared/components/SourceIndicator' import KapacitorRulesTable from 'src/kapacitor/components/KapacitorRulesTable' import FancyScrollbar from 'shared/components/FancyScrollbar' +import TICKscriptOverlay from 'src/kapacitor/components/TICKscriptOverlay' const KapacitorRules = ({ source, @@ -12,7 +13,10 @@ const KapacitorRules = ({ hasKapacitor, loading, onDelete, + tickscript, onChangeRuleStatus, + onReadTickscript, + onCloseTickscript, }) => { if (!hasKapacitor) { return ( @@ -33,7 +37,12 @@ const KapacitorRules = ({ ? '1 Alert Rule' : `${rules.length} Alert Rules` return ( - +

{tableHeader}

) } -const PageContents = ({children, source}) => -
+const PageContents = ({children, source, tickscript, onCloseTickscript}) => ( +
@@ -76,9 +86,16 @@ const PageContents = ({children, source}) =>
+ {tickscript + ? + : null}
+) -const {arrayOf, bool, func, shape, node} = PropTypes +const {arrayOf, bool, func, node, shape, string} = PropTypes KapacitorRules.propTypes = { source: shape(), @@ -87,11 +104,16 @@ KapacitorRules.propTypes = { loading: bool, onChangeRuleStatus: func, onDelete: func, + tickscript: string, + onReadTickscript: func, + onCloseTickscript: func, } PageContents.propTypes = { children: node, source: shape(), + tickscript: string, + onCloseTickscript: func, } export default KapacitorRules diff --git a/ui/src/kapacitor/components/KapacitorRulesTable.js b/ui/src/kapacitor/components/KapacitorRulesTable.js index b405a32ce1..24adbe4d28 100644 --- a/ui/src/kapacitor/components/KapacitorRulesTable.js +++ b/ui/src/kapacitor/components/KapacitorRulesTable.js @@ -1,7 +1,13 @@ import React, {PropTypes} from 'react' import {Link} from 'react-router' -const KapacitorRulesTable = ({rules, source, onDelete, onChangeRuleStatus}) => +const KapacitorRulesTable = ({ + rules, + source, + onDelete, + onReadTickscript, + onChangeRuleStatus, +}) => (
@@ -23,14 +29,16 @@ const KapacitorRulesTable = ({rules, source, onDelete, onChangeRuleStatus}) => source={source} onDelete={onDelete} onChangeRuleStatus={onChangeRuleStatus} + onRead={onReadTickscript} /> ) })}
+) -const RuleRow = ({rule, source, onDelete, onChangeRuleStatus}) => +const RuleRow = ({rule, source, onRead, onDelete, onChangeRuleStatus}) => ( @@ -50,12 +58,16 @@ const RuleRow = ({rule, source, onDelete, onChangeRuleStatus}) =>
- + + +) const RuleTitle = ({rule: {id, name, query}, source}) => { // no queryConfig means the rule was manually created outside of Chronograf @@ -75,6 +87,7 @@ KapacitorRulesTable.propTypes = { source: shape({ id: string.isRequired, }).isRequired, + onReadTickscript: func, } RuleRow.propTypes = { @@ -82,6 +95,7 @@ RuleRow.propTypes = { source: shape(), onChangeRuleStatus: func, onDelete: func, + onRead: func, } RuleTitle.propTypes = { @@ -90,7 +104,7 @@ RuleTitle.propTypes = { query: shape(), links: shape({ self: string.isRequired, - }).isRequired, + }), }), source: shape({ id: string.isRequired, diff --git a/ui/src/kapacitor/components/TICKscriptOverlay.js b/ui/src/kapacitor/components/TICKscriptOverlay.js new file mode 100644 index 0000000000..0abb7111aa --- /dev/null +++ b/ui/src/kapacitor/components/TICKscriptOverlay.js @@ -0,0 +1,52 @@ +import React, {PropTypes} from 'react' +import OverlayTechnologies from 'shared/components/OverlayTechnologies' + +const style = { + padding: '8px', + borderRadius: '4px', + backgroundColor: '#202028', + margin: '0 15%', + top: '16px', + position: 'relative', + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + height: 'calc(100% - 76px)', +} + +const TICKscriptOverlay = ({tickscript, onClose}) => ( + +
+
+

Generated TICKscript

+ +
+
+        {tickscript}
+      
+
+
+) + +const {string, func} = PropTypes + +TICKscriptOverlay.propTypes = { + tickscript: string, + onClose: func.isRequired, +} + +export default TICKscriptOverlay diff --git a/ui/src/kapacitor/containers/KapacitorRulesPage.js b/ui/src/kapacitor/containers/KapacitorRulesPage.js index 90b11e25ba..57d31448fe 100644 --- a/ui/src/kapacitor/containers/KapacitorRulesPage.js +++ b/ui/src/kapacitor/containers/KapacitorRulesPage.js @@ -11,10 +11,13 @@ class KapacitorRulesPage extends Component { this.state = { hasKapacitor: false, loading: true, + tickscript: null, } this.handleDeleteRule = ::this.handleDeleteRule this.handleRuleStatus = ::this.handleRuleStatus + this.handleReadTickscript = ::this.handleReadTickscript + this.handleCloseTickscript = ::this.handleCloseTickscript } componentDidMount() { @@ -39,19 +42,32 @@ class KapacitorRulesPage extends Component { actions.updateRuleStatusSuccess(rule.id, status) } + handleReadTickscript({tickscript}) { + this.setState({tickscript}) + } + + handleCloseTickscript() { + this.setState({tickscript: null}) + } + render() { const {source, rules} = this.props - const {hasKapacitor, loading} = this.state + const {hasKapacitor, loading, tickscript} = this.state return ( - +
+ +
) } }