Enable date picker for alerts page

pull/10616/head
Andrew Watkins 2017-03-29 09:29:55 -07:00
parent 3cecd6d49b
commit e3282bc505
3 changed files with 21 additions and 13 deletions

View File

@ -27,11 +27,12 @@ const AlertsTable = React.createClass({
},
componentWillReceiveProps(newProps) {
this.filterAlerts(newProps.alerts, this.state.searchTerm)
this.filterAlerts(this.state.searchTerm, newProps.alerts)
},
filterAlerts(searchTerm) {
const filteredAlerts = this.props.alerts.filter((h) => {
filterAlerts(searchTerm, newAlerts) {
const alerts = newAlerts || this.props.alerts
const filteredAlerts = alerts.filter((h) => {
if (h.host === null || h.name === null || h.level === null) {
return false
}

View File

@ -52,6 +52,12 @@ const AlertsApp = React.createClass({
})
},
componentDidUpdate(prevProps, prevState) {
if (!_.isEqual(prevState.timeRange, this.state.timeRange)) {
this.fetchAlerts()
}
},
fetchAlerts() {
getAlerts(this.props.source.links.proxy, this.state.timeRange).then((resp) => {
const results = [];
@ -105,8 +111,13 @@ const AlertsApp = React.createClass({
this.setState({isTimeOpen: false})
},
handleApplyTime(timeRange) {
this.setState({timeRange})
},
render() {
const {source} = this.props
const {timeRange} = this.state
return (
<div className="page">
<div className="page-header">
@ -122,8 +133,8 @@ const AlertsApp = React.createClass({
isVisible={this.state.isTimeOpen}
onToggle={this.handleToggleTime}
onClose={this.handleCloseTime}
onApplyTimeRange={(timeRange) => console.log(timeRange)}
timeRange={{upper: null, lower: null}}
onApplyTimeRange={this.handleApplyTime}
timeRange={timeRange}
/>
</div>
</div>
@ -140,7 +151,6 @@ const AlertsApp = React.createClass({
</div>
)
},
})
export default AlertsApp

View File

@ -62,10 +62,7 @@ class CustomTimeRange extends Component {
const lower = this.lowerCal.getDate().toISOString()
const upper = this.upperCal.getDate().toISOString()
this.props.onApplyTimeRange({
lower: `'${lower}'`,
upper: `'${upper}'`,
})
this.props.onApplyTimeRange({lower, upper})
this.props.onClose()
}
/*