|
@@ -23,6 +23,7 @@ export class AlertRuleList extends React.Component<IContainerProps, any> {
|
|
|
|
|
|
|
|
this.props.nav.load('alerting', 'alert-list');
|
|
this.props.nav.load('alerting', 'alert-list');
|
|
|
this.fetchRules();
|
|
this.fetchRules();
|
|
|
|
|
+ this.state = { search: '' };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onStateFilterChanged = evt => {
|
|
onStateFilterChanged = evt => {
|
|
@@ -44,9 +45,19 @@ export class AlertRuleList extends React.Component<IContainerProps, any> {
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ onSearchFilter(event) {
|
|
|
|
|
+ this.setState({ search: event.target.value });
|
|
|
|
|
+ console.log('yo');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
render() {
|
|
render() {
|
|
|
const { nav, alertList } = this.props;
|
|
const { nav, alertList } = this.props;
|
|
|
|
|
|
|
|
|
|
+ let regex = new RegExp(this.state.search, 'ig');
|
|
|
|
|
+ const filteredAlerts = alertList.rules.filter(alert => {
|
|
|
|
|
+ return regex.test(alert.name) || regex.test(alert.stateText);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<div>
|
|
<div>
|
|
|
<PageHeader model={nav as any} />
|
|
<PageHeader model={nav as any} />
|
|
@@ -58,8 +69,8 @@ export class AlertRuleList extends React.Component<IContainerProps, any> {
|
|
|
type="text"
|
|
type="text"
|
|
|
className="gf-form-input width-13"
|
|
className="gf-form-input width-13"
|
|
|
placeholder="Search alert"
|
|
placeholder="Search alert"
|
|
|
- value={this.searchQuery}
|
|
|
|
|
- onChange={this.onQueryUpdated}
|
|
|
|
|
|
|
+ value={this.state.search}
|
|
|
|
|
+ onChange={this.onSearchFilter.bind(this)}
|
|
|
/>
|
|
/>
|
|
|
<i className="gf-form-input-icon fa fa-search" />
|
|
<i className="gf-form-input-icon fa fa-search" />
|
|
|
</label>
|
|
</label>
|
|
@@ -83,7 +94,7 @@ export class AlertRuleList extends React.Component<IContainerProps, any> {
|
|
|
|
|
|
|
|
<section>
|
|
<section>
|
|
|
<ol className="alert-rule-list">
|
|
<ol className="alert-rule-list">
|
|
|
- {alertList.rules.map(rule => <AlertRuleItem rule={rule} key={rule.id} />)}
|
|
|
|
|
|
|
+ {filteredAlerts.map(rule => <AlertRuleItem rule={rule} key={rule.id} />)}
|
|
|
</ol>
|
|
</ol>
|
|
|
</section>
|
|
</section>
|
|
|
</div>
|
|
</div>
|