From ca230f0a496d7e26199491a18aa3f8b76a472b41 Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Thu, 14 Sep 2017 14:06:43 -0700 Subject: [PATCH] Add a TICKscript table to alert rules page --- ui/src/kapacitor/components/KapacitorRules.js | 45 +++++++-- .../components/KapacitorRulesTable.js | 6 +- ui/src/kapacitor/components/TasksTable.js | 96 +++++++++++++++++++ .../kapacitor/components/TickscriptHeader.js | 2 +- ui/src/kapacitor/components/TickscriptID.js | 4 +- ui/src/kapacitor/constants/tableSizing.js | 9 +- 6 files changed, 145 insertions(+), 17 deletions(-) create mode 100644 ui/src/kapacitor/components/TasksTable.js diff --git a/ui/src/kapacitor/components/KapacitorRules.js b/ui/src/kapacitor/components/KapacitorRules.js index 913c1c45d0..6980dda058 100644 --- a/ui/src/kapacitor/components/KapacitorRules.js +++ b/ui/src/kapacitor/components/KapacitorRules.js @@ -4,6 +4,7 @@ import {Link} from 'react-router' import NoKapacitorError from 'shared/components/NoKapacitorError' import SourceIndicator from 'shared/components/SourceIndicator' import KapacitorRulesTable from 'src/kapacitor/components/KapacitorRulesTable' +import TasksTable from 'src/kapacitor/components/TasksTable' import FancyScrollbar from 'shared/components/FancyScrollbar' const KapacitorRules = ({ @@ -40,13 +41,17 @@ const KapacitorRules = ({ ) } - const tableHeader = - rules.length === 1 ? '1 Alert Rule' : `${rules.length} Alert Rules` + const rulez = rules.filter(r => r.query) + const tasks = rules.filter(r => !r.query) + + const rHeader = `${rulez.length} Alert Rule${rulez.length === 1 ? '' : 's'}` + const tHeader = `${tasks.length} TICKscript${tasks.length === 1 ? '' : 's'}` + return (

- {tableHeader} + {rHeader}

Build Rule - - Write TICKscript -
+ +
+
+
+
+

+ {tHeader} +

+
+ + Write TICKscript + +
+
+ +
+
+
) } diff --git a/ui/src/kapacitor/components/KapacitorRulesTable.js b/ui/src/kapacitor/components/KapacitorRulesTable.js index 8c2b65aa82..00f6ab2689 100644 --- a/ui/src/kapacitor/components/KapacitorRulesTable.js +++ b/ui/src/kapacitor/components/KapacitorRulesTable.js @@ -5,7 +5,7 @@ import _ from 'lodash' import {KAPACITOR_RULES_TABLE} from 'src/kapacitor/constants/tableSizing' const { colName, - colType, + colTrigger, colMessage, colAlerts, colEnabled, @@ -18,7 +18,7 @@ const KapacitorRulesTable = ({rules, source, onDelete, onChangeRuleStatus}) => Name - Rule Type + Rule Trigger Message Alerts @@ -50,7 +50,7 @@ const RuleRow = ({rule, source, onDelete, onChangeRuleStatus}) => - + {rule.trigger} diff --git a/ui/src/kapacitor/components/TasksTable.js b/ui/src/kapacitor/components/TasksTable.js new file mode 100644 index 0000000000..75784e508d --- /dev/null +++ b/ui/src/kapacitor/components/TasksTable.js @@ -0,0 +1,96 @@ +import React, {PropTypes} from 'react' +import {Link} from 'react-router' +import _ from 'lodash' + +import {TASKS_TABLE} from 'src/kapacitor/constants/tableSizing' + +const {colID, colType, colEnabled, colActions} = TASKS_TABLE + +const TasksTable = ({tasks, source, onDelete, onChangeRuleStatus}) => +
+ + + + + + + + + + {_.sortBy(tasks, t => t.name.toLowerCase()).map(task => { + return ( + + ) + })} + +
IDType + Enabled + +
+
+ +const handleDelete = (task, onDelete) => onDelete(task) + +const TaskRow = ({task, source, onDelete, onChangeRuleStatus}) => + + + + {task.id} + + + + {task.type} + + +
+ +
+ + + + Edit TICKscript + + + + + +const {arrayOf, func, shape, string} = PropTypes + +TasksTable.propTypes = { + tasks: arrayOf(shape()), + onChangeRuleStatus: func, + onDelete: func, + source: shape({ + id: string.isRequired, + }).isRequired, +} + +TaskRow.propTypes = { + task: shape(), + source: shape(), + onChangeRuleStatus: func, + onDelete: func, +} + +export default TasksTable diff --git a/ui/src/kapacitor/components/TickscriptHeader.js b/ui/src/kapacitor/components/TickscriptHeader.js index 8cc1531aa6..c6dcaee71d 100644 --- a/ui/src/kapacitor/components/TickscriptHeader.js +++ b/ui/src/kapacitor/components/TickscriptHeader.js @@ -34,7 +34,7 @@ const TickscriptHeader = ({ />