diff --git a/CHANGELOG.md b/CHANGELOG.md index 41f98d1714..53d2e2fd83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Features 1. [#1863](https://github.com/influxdata/chronograf/pull/1863): Improve 'new-sources' server flag example by adding 'type' key +1. [#1898](https://github.com/influxdata/chronograf/pull/1898): Add an input and validation to custom time range calendar dropdowns ### UI Improvements 1. [#1862](https://github.com/influxdata/chronograf/pull/1862): Show "Add Graph" button on cells with no queries diff --git a/ui/src/shared/components/CustomTimeRange.js b/ui/src/shared/components/CustomTimeRange.js index 8b84f315ab..0b03629f74 100644 --- a/ui/src/shared/components/CustomTimeRange.js +++ b/ui/src/shared/components/CustomTimeRange.js @@ -3,71 +3,69 @@ import rome from 'rome' import moment from 'moment' import shortcuts from 'hson!shared/data/timeRangeShortcuts.hson' +const dateFormat = 'YYYY-MM-DD HH:mm' class CustomTimeRange extends Component { constructor(props) { super(props) - - this.handleClick = ::this.handleClick - this._formatTimeRange = ::this._formatTimeRange - this.handleTimeRangeShortcut = ::this.handleTimeRangeShortcut } componentDidMount() { const {timeRange} = this.props const lower = rome(this.lower, { - initialValue: this._formatTimeRange(timeRange.lower), + dateValidator: rome.val.beforeEq(this.upper), + appendTo: this.lowerContainer, + initialValue: this.getInitialDate(timeRange.lower), + autoClose: false, + autoHideOnBlur: false, + autoHideOnClick: false, }) + const upper = rome(this.upper, { - initialValue: this._formatTimeRange(timeRange.upper), + dateValidator: rome.val.afterEq(this.lower), + appendTo: this.upperContainer, + autoClose: false, + initialValue: this.getInitialDate(timeRange.upper), + autoHideOnBlur: false, + autoHideOnClick: false, }) this.lowerCal = lower this.upperCal = upper + + this.lowerCal.show() + this.upperCal.show() } - // If there is an upper or lower time range set, set the corresponding calendar's value. componentWillReceiveProps(nextProps) { const {lower, upper} = nextProps.timeRange if (lower) { + const formattedLower = this._formatTimeRange(lower) this.lowerCal.setValue(this._formatTimeRange(lower)) + this.lower.value = formattedLower } if (upper) { + const formattedUpper = this._formatTimeRange(upper) this.upperCal.setValue(this._formatTimeRange(upper)) + this.upper.value = formattedUpper } } - render() { - return ( -