[table viz] allow showing time granularity in table (#2284) (#2291)

The time granularity currently does not show up in table viz. Now
defining a granularity will add an extra ISO-formatted time column in
the table. The column will be added for both grouped by and not grouped
by.
This commit is contained in:
vera-liu
2017-02-27 20:33:21 -08:00
committed by GitHub
parent 47be3ef3ea
commit 09f1083c50
2 changed files with 26 additions and 7 deletions

View File

@@ -4,6 +4,9 @@ import Select from 'react-select';
import { Button, Row, Col } from 'react-bootstrap';
import SelectControl from './SelectControl';
const arrayFilterOps = ['in', 'not in'];
const strFilterOps = ['==', '!=', '>', '<', '>=', '<=', 'regex'];
const propTypes = {
choices: PropTypes.array,
changeFilter: PropTypes.func,
@@ -55,6 +58,15 @@ export default class Filter extends React.Component {
if (event && event.value) {
value = event.value;
}
if (control === 'op') {
if (arrayFilterOps.indexOf(this.props.filter.op) !== -1
&& strFilterOps.indexOf(value) !== -1) {
this.props.changeFilter('val', this.props.filter.val[0]);
} else if (strFilterOps.indexOf(this.props.filter.op) !== -1
&& arrayFilterOps.indexOf(value) !== -1) {
this.props.changeFilter('val', [this.props.filter.val]);
}
}
this.props.changeFilter(control, value);
if (control === 'col' && value !== null && this.props.datasource.filter_select) {
this.fetchFilterValues(value);
@@ -70,13 +82,13 @@ export default class Filter extends React.Component {
this.fetchFilterValues(filter.col);
}
}
if (this.props.having) {
// druid having filter
if (this.props.having || StrFilterOps.indexOf(filter.op) !== -1) {
// druid having filter or regex/==/!= filters
return (
<input
type="text"
onChange={this.changeFilter.bind(this, 'val')}
value={filter.value}
value={filter.val}
className="form-control input-sm"
placeholder="Filter value"
/>