Web console: Expand filter UI (#8579)

* add controls to the filter UI

* fix double base
This commit is contained in:
Vadim Ogievetsky 2019-09-24 12:27:46 -07:00 committed by Clint Wylie
parent b6a16b5eb6
commit 7c14fa08f8
3 changed files with 52 additions and 4 deletions

View File

@ -110,7 +110,7 @@ export class StatusDialog extends React.PureComponent<StatusDialogProps, StatusD
text="View raw" text="View raw"
disabled={!response} disabled={!response}
minimal minimal
onClick={() => window.open(UrlBaser.base(UrlBaser.base(`/status`)), '_blank')} onClick={() => window.open(UrlBaser.base(`/status`), '_blank')}
/> />
</div> </div>
<div className="closeButton"> <div className="closeButton">

View File

@ -286,11 +286,13 @@ const PARSE_SPEC_FORM_FIELDS: Field<ParseSpec>[] = [
{ {
name: 'pattern', name: 'pattern',
type: 'string', type: 'string',
required: true,
defined: (p: ParseSpec) => p.format === 'regex', defined: (p: ParseSpec) => p.format === 'regex',
}, },
{ {
name: 'function', name: 'function',
type: 'string', type: 'string',
required: true,
defined: (p: ParseSpec) => p.format === 'javascript', defined: (p: ParseSpec) => p.format === 'javascript',
}, },
{ {
@ -513,11 +515,13 @@ const FLATTEN_FIELD_FORM_FIELDS: Field<FlattenField>[] = [
name: 'name', name: 'name',
type: 'string', type: 'string',
placeholder: 'column_name', placeholder: 'column_name',
required: true,
}, },
{ {
name: 'type', name: 'type',
type: 'string', type: 'string',
suggestions: ['path', 'jq', 'root'], suggestions: ['path', 'jq', 'root'],
required: true,
}, },
{ {
name: 'expr', name: 'expr',
@ -525,6 +529,7 @@ const FLATTEN_FIELD_FORM_FIELDS: Field<FlattenField>[] = [
placeholder: '$.thing', placeholder: '$.thing',
defined: (flattenField: FlattenField) => defined: (flattenField: FlattenField) =>
flattenField.type === 'path' || flattenField.type === 'jq', flattenField.type === 'path' || flattenField.type === 'jq',
required: true,
info: ( info: (
<> <>
Specify a flatten{' '} Specify a flatten{' '}
@ -557,16 +562,19 @@ const TRANSFORM_FORM_FIELDS: Field<Transform>[] = [
name: 'name', name: 'name',
type: 'string', type: 'string',
placeholder: 'output_name', placeholder: 'output_name',
required: true,
}, },
{ {
name: 'type', name: 'type',
type: 'string', type: 'string',
suggestions: ['expression'], suggestions: ['expression'],
required: true,
}, },
{ {
name: 'expression', name: 'expression',
type: 'string', type: 'string',
placeholder: '"foo" + "bar"', placeholder: '"foo" + "bar"',
required: true,
info: ( info: (
<> <>
A valid Druid{' '} A valid Druid{' '}
@ -2126,21 +2134,60 @@ const FILTER_FORM_FIELDS: Field<DruidFilter>[] = [
{ {
name: 'type', name: 'type',
type: 'string', type: 'string',
suggestions: ['selector', 'in'], suggestions: ['selector', 'in', 'regex', 'like', 'not'],
}, },
{ {
name: 'dimension', name: 'dimension',
type: 'string', type: 'string',
defined: (df: DruidFilter) => ['selector', 'in', 'regex', 'like'].includes(df.type),
}, },
{ {
name: 'value', name: 'value',
type: 'string', type: 'string',
defined: (druidFilter: DruidFilter) => druidFilter.type === 'selector', defined: (df: DruidFilter) => df.type === 'selector',
}, },
{ {
name: 'values', name: 'values',
type: 'string-array', type: 'string-array',
defined: (druidFilter: DruidFilter) => druidFilter.type === 'in', defined: (df: DruidFilter) => df.type === 'in',
},
{
name: 'pattern',
type: 'string',
defined: (df: DruidFilter) => ['regex', 'like'].includes(df.type),
},
{
name: 'field.type',
label: 'Sub-filter type',
type: 'string',
suggestions: ['selector', 'in', 'regex', 'like'],
defined: (df: DruidFilter) => df.type === 'not',
},
{
name: 'field.dimension',
label: 'Sub-filter dimension',
type: 'string',
defined: (df: DruidFilter) => df.type === 'not',
},
{
name: 'field.value',
label: 'Sub-filter value',
type: 'string',
defined: (df: DruidFilter) => df.type === 'not' && deepGet(df, 'field.type') === 'selector',
},
{
name: 'field.values',
label: 'Sub-filter values',
type: 'string-array',
defined: (df: DruidFilter) => df.type === 'not' && deepGet(df, 'field.type') === 'in',
},
{
name: 'field.pattern',
label: 'Sub-filter pattern',
type: 'string',
defined: (df: DruidFilter) =>
df.type === 'not' && ['regex', 'like'].includes(deepGet(df, 'field.type')),
}, },
]; ];

View File

@ -1989,6 +1989,7 @@ export class LoadDataView extends React.PureComponent<LoadDataViewProps, LoadDat
fields={getFilterFormFields()} fields={getFilterFormFields()}
model={selectedFilter} model={selectedFilter}
onChange={f => this.setState({ selectedFilter: f })} onChange={f => this.setState({ selectedFilter: f })}
showCustom={f => !['selector', 'in', 'regex', 'like', 'not'].includes(f.type)}
/> />
<div className="controls-buttons"> <div className="controls-buttons">
<Button <Button