Enable date picker for alerts page
parent
172c8369ad
commit
55c52c9baf
ui/src
alerts
components
containers
shared/components
|
@ -27,18 +27,19 @@ const AlertsTable = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillReceiveProps(newProps) {
|
componentWillReceiveProps(newProps) {
|
||||||
this.filterAlerts(newProps.alerts, this.state.searchTerm)
|
this.filterAlerts(this.state.searchTerm, newProps.alerts)
|
||||||
},
|
},
|
||||||
|
|
||||||
filterAlerts(searchTerm) {
|
filterAlerts(searchTerm, newAlerts) {
|
||||||
const filteredAlerts = this.props.alerts.filter((h) => {
|
const alerts = newAlerts || this.props.alerts
|
||||||
|
const filteredAlerts = alerts.filter((h) => {
|
||||||
if (h.host === null || h.name === null || h.level === null) {
|
if (h.host === null || h.name === null || h.level === null) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return h.name.toLowerCase().search((searchTerm).toLowerCase()) !== -1 ||
|
return h.name.toLowerCase().search((searchTerm).toLowerCase()) !== -1 ||
|
||||||
h.host.toLowerCase().search((searchTerm).toLowerCase()) !== -1 ||
|
h.host.toLowerCase().search((searchTerm).toLowerCase()) !== -1 ||
|
||||||
h.level.toLowerCase().search((searchTerm).toLowerCase()) !== -1
|
h.level.toLowerCase().search((searchTerm).toLowerCase()) !== -1
|
||||||
})
|
})
|
||||||
this.setState({searchTerm, filteredAlerts})
|
this.setState({searchTerm, filteredAlerts})
|
||||||
},
|
},
|
||||||
|
|
|
@ -52,6 +52,12 @@ const AlertsApp = React.createClass({
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps, prevState) {
|
||||||
|
if (!_.isEqual(prevState.timeRange, this.state.timeRange)) {
|
||||||
|
this.fetchAlerts()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
fetchAlerts() {
|
fetchAlerts() {
|
||||||
getAlerts(this.props.source.links.proxy, this.state.timeRange).then((resp) => {
|
getAlerts(this.props.source.links.proxy, this.state.timeRange).then((resp) => {
|
||||||
const results = [];
|
const results = [];
|
||||||
|
@ -105,8 +111,13 @@ const AlertsApp = React.createClass({
|
||||||
this.setState({isTimeOpen: false})
|
this.setState({isTimeOpen: false})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleApplyTime(timeRange) {
|
||||||
|
this.setState({timeRange})
|
||||||
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {source} = this.props
|
const {source} = this.props
|
||||||
|
const {timeRange} = this.state
|
||||||
return (
|
return (
|
||||||
<div className="page">
|
<div className="page">
|
||||||
<div className="page-header">
|
<div className="page-header">
|
||||||
|
@ -122,8 +133,8 @@ const AlertsApp = React.createClass({
|
||||||
isVisible={this.state.isTimeOpen}
|
isVisible={this.state.isTimeOpen}
|
||||||
onToggle={this.handleToggleTime}
|
onToggle={this.handleToggleTime}
|
||||||
onClose={this.handleCloseTime}
|
onClose={this.handleCloseTime}
|
||||||
onApplyTimeRange={(timeRange) => console.log(timeRange)}
|
onApplyTimeRange={this.handleApplyTime}
|
||||||
timeRange={{upper: null, lower: null}}
|
timeRange={timeRange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -132,7 +143,7 @@ const AlertsApp = React.createClass({
|
||||||
<div className="container-fluid">
|
<div className="container-fluid">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-md-12">
|
<div className="col-md-12">
|
||||||
{ this.renderSubComponents() }
|
{this.renderSubComponents()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -140,7 +151,6 @@ const AlertsApp = React.createClass({
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export default AlertsApp
|
export default AlertsApp
|
||||||
|
|
|
@ -62,10 +62,7 @@ class CustomTimeRange extends Component {
|
||||||
const lower = this.lowerCal.getDate().toISOString()
|
const lower = this.lowerCal.getDate().toISOString()
|
||||||
const upper = this.upperCal.getDate().toISOString()
|
const upper = this.upperCal.getDate().toISOString()
|
||||||
|
|
||||||
this.props.onApplyTimeRange({
|
this.props.onApplyTimeRange({lower, upper})
|
||||||
lower: `'${lower}'`,
|
|
||||||
upper: `'${upper}'`,
|
|
||||||
})
|
|
||||||
this.props.onClose()
|
this.props.onClose()
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue