Merge pull request #363 from influxdata/feature/rules-index-#307
Make index page for Kapacitor Rulespull/10616/head
commit
033fe066b2
|
@ -7,7 +7,7 @@ import App from 'src/App';
|
||||||
import AlertsApp from 'src/alerts';
|
import AlertsApp from 'src/alerts';
|
||||||
import CheckDataNodes from 'src/CheckDataNodes';
|
import CheckDataNodes from 'src/CheckDataNodes';
|
||||||
import {HostsPage, HostPage} from 'src/hosts';
|
import {HostsPage, HostPage} from 'src/hosts';
|
||||||
import {KapacitorPage, KapacitorRulePage, KapacitorTasksPage} from 'src/kapacitor';
|
import {KapacitorPage, KapacitorRulePage, KapacitorRulesPage, KapacitorTasksPage} from 'src/kapacitor';
|
||||||
import QueriesPage from 'src/queries';
|
import QueriesPage from 'src/queries';
|
||||||
import TasksPage from 'src/tasks';
|
import TasksPage from 'src/tasks';
|
||||||
import RetentionPoliciesPage from 'src/retention_policies';
|
import RetentionPoliciesPage from 'src/retention_policies';
|
||||||
|
@ -117,7 +117,8 @@ const Root = React.createClass({
|
||||||
<Route path="kapacitor-config" component={KapacitorPage} />
|
<Route path="kapacitor-config" component={KapacitorPage} />
|
||||||
<Route path="kapacitor-tasks" component={KapacitorTasksPage} />
|
<Route path="kapacitor-tasks" component={KapacitorTasksPage} />
|
||||||
<Route path="alerts" component={AlertsApp} />
|
<Route path="alerts" component={AlertsApp} />
|
||||||
<Route path="alert-rules" component={KapacitorRulePage} />
|
<Route path="alert-rules" component={KapacitorRulesPage} />
|
||||||
|
<Route path="alert-rules/:ruleID" component={KapacitorRulePage} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="tasks" component={TasksPage} />
|
<Route path="tasks" component={TasksPage} />
|
||||||
<Route path="*" component={NotFound} />
|
<Route path="*" component={NotFound} />
|
||||||
|
|
|
@ -7,3 +7,10 @@ export function createRule(kapacitor, rule) {
|
||||||
data: rule,
|
data: rule,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getRules(kapacitor) {
|
||||||
|
return AJAX({
|
||||||
|
method: 'GET',
|
||||||
|
url: kapacitor.links.rules,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ export const KapacitorRulePage = React.createClass({
|
||||||
links: PropTypes.shape({
|
links: PropTypes.shape({
|
||||||
proxy: PropTypes.string.isRequired,
|
proxy: PropTypes.string.isRequired,
|
||||||
self: PropTypes.string.isRequired,
|
self: PropTypes.string.isRequired,
|
||||||
}).isRequired,
|
}),
|
||||||
}),
|
}),
|
||||||
addFlashMessage: PropTypes.func,
|
addFlashMessage: PropTypes.func,
|
||||||
rules: PropTypes.shape({}).isRequired,
|
rules: PropTypes.shape({}).isRequired,
|
||||||
|
@ -50,7 +50,7 @@ export const KapacitorRulePage = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const {ruleID} = this.props.params;
|
const {ruleID} = false; // this.props.params;
|
||||||
if (ruleID) {
|
if (ruleID) {
|
||||||
this.props.kapacitorActions.fetchRule(ruleID);
|
this.props.kapacitorActions.fetchRule(ruleID);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
import React, {PropTypes} from 'react';
|
||||||
|
import {Link} from 'react-router';
|
||||||
|
import {getRules} from 'src/kapacitor/apis';
|
||||||
|
import {getKapacitor} from 'src/shared/apis';
|
||||||
|
|
||||||
|
export const KapacitorRulesPage = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
source: PropTypes.shape({
|
||||||
|
id: PropTypes.string.isRequired,
|
||||||
|
name: PropTypes.string.isRequired,
|
||||||
|
type: PropTypes.string.isRequired, // 'influx-enterprise'
|
||||||
|
username: PropTypes.string.isRequired,
|
||||||
|
links: PropTypes.shape({
|
||||||
|
kapacitors: PropTypes.string.isRequired,
|
||||||
|
}).isRequired,
|
||||||
|
}).isRequired,
|
||||||
|
addFlashMessage: PropTypes.func,
|
||||||
|
},
|
||||||
|
|
||||||
|
getInitialState() {
|
||||||
|
return {
|
||||||
|
rules: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
getKapacitor(this.props.source).then((kapacitor) => {
|
||||||
|
getRules(kapacitor).then(({data: {rules}}) => {
|
||||||
|
this.setState({rules});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {rules} = this.state;
|
||||||
|
const {source} = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="kapacitor-rules-page">
|
||||||
|
<div className="enterprise-header">
|
||||||
|
<div className="enterprise-header__container">
|
||||||
|
<div className="enterprise-header__left">
|
||||||
|
<h1>Kapacitor Rules</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="container-fluid">
|
||||||
|
<div className="panel panel-minimal">
|
||||||
|
<div className="panel-heading u-flex u-ai-center u-jc-space-between">
|
||||||
|
<h2 className="panel-title">Alert Rules</h2>
|
||||||
|
</div>
|
||||||
|
<div className="panel-body">
|
||||||
|
<table className="table v-center">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Trigger</th>
|
||||||
|
<th>Message</th>
|
||||||
|
<th>Alerts</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{
|
||||||
|
rules.map((rule) => {
|
||||||
|
return (
|
||||||
|
<tr key={rule.id}>
|
||||||
|
<td className="monotype"><Link to={`/sources/${source.id}/alert-rules/${rule.id}`}>{rule.name}</Link></td>
|
||||||
|
<td className="monotype">{rule.trigger}</td>
|
||||||
|
<td className="monotype">{rule.message}</td>
|
||||||
|
<td className="monotype">{rule.alerts.join(', ')}</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default KapacitorRulesPage;
|
|
@ -1,4 +1,5 @@
|
||||||
import KapacitorPage from './containers/KapacitorPage';
|
import KapacitorPage from './containers/KapacitorPage';
|
||||||
import KapacitorRulePage from './containers/KapacitorRulePage';
|
import KapacitorRulePage from './containers/KapacitorRulePage';
|
||||||
|
import KapacitorRulesPage from './containers/KapacitorRulesPage';
|
||||||
import KapacitorTasksPage from './containers/KapacitorTasksPage';
|
import KapacitorTasksPage from './containers/KapacitorTasksPage';
|
||||||
export {KapacitorPage, KapacitorRulePage, KapacitorTasksPage};
|
export {KapacitorPage, KapacitorRulePage, KapacitorRulesPage, KapacitorTasksPage};
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
Hosts Dashboard
|
Hosts Dashboard
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
.kapacitor-rules-page,
|
||||||
.hosts-page {
|
.hosts-page {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
@ -44,7 +45,7 @@
|
||||||
.enterprise-header {
|
.enterprise-header {
|
||||||
background-color: $g0-obsidian;
|
background-color: $g0-obsidian;
|
||||||
}
|
}
|
||||||
|
|
||||||
.panel-minimal {
|
.panel-minimal {
|
||||||
border: 0;
|
border: 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue