Skip to content

Commit

Permalink
Time Series Visual Builder: Modify Behavior for Aggregation Selection (
Browse files Browse the repository at this point in the history
…#10890)

* Removing derivative behavior... adding better tooltips to add delete

* Re-organizing metrics; Adding headers; Adding default behavoir

* Adding help text

* Additional fixes

- Fix for deactivated still being able to be added
- Added Experimental Feature to description

* [elasticsearch/healthCheck] ensure that multi.allow_explicit_index=true (#10855)

* [elasticsearch/healthCheck] ensure that multi.allow_explicit_index=true

* [elasticsearch/healthCheck] fix tests

* [eslint/console] enable no-undef rule (#10881)

* [eslint/console] enable no-undef rule

* [eslint/console] fix no-undef violations

* Navbarextensions improvements (#9871)

* - added controller option
- added $location service to determine on which the user is at currently

* added test for the hideButton method that is dependent on the location path

* removed  argument

* use locals object to pass variables to the template's scope

* use map object

* fixing percentage mode extents (#10843)

* fixes axis title for new axis (#10866)

* fixes metrics options matching (#10865)

* Add kuiLocalTab-isDisabled state. (#10830)

* Add kuiLocalTab-isDisabled state.

* Update Management header to use kuiLocalTab-isDisabled class.

* test: send content-type with proxy POST tests (#10903)

Elasticsearch now requires that content-type be sent on all requests
with payloads, so our tests should be sending it with requests as well.

* [esArchiver] combine elasticDump and ScenarioManager (#10359)

* As a part of bringing functional testing to plugins, esArchiver gives these plugins a way to capture and reload es indexes without needing to write a bunch of custom code. It works similarly to the elasticDump and ScenarioManager tools that it replaces.

Differences:
  - Streaming implementation allows for much larger archives
  - CLI for creating and using archives
  - Configurable archive location
  - Stores the data in gzipped files (better for source control, searching, large archives)
  - Automatically identifies and upgrades Kibana config documents

Methods:
  - `#load(name)`: import an archive
  - `#loadIfNeeded(name)`: import an archive, but skip the documents what belong to any existing index
  - `#unload(name)`: delete the indexes stored in an archive

CLI operations:
  - `./bin/es_archiver save <name> [index patterns...]`: save the mapping and documents in one or more indexes that match the wild-card patterns into an the `<name>` archive
  - `./bin/es_archiver load <name>`: load the mapping and documents from the `<name>` archive

* [functional_tests/common/nagivate] check for statusPage

* [es_archiver] move bins into new scripts dir

* [functional_tests/apps/context] use esArchiver

* [esArchiver] general improvements after showing to a few folks

 - remove auto-upgrading config doc logic (until we have better access to kibana version info)
 - export unload command
 - remove preemptive checks in favor of reacting to errors
 - use type "doc" vs "hit" for doc records (consistency)
 - wrote a bunch of pending tests to think though and plan

* [esArchiver] make log a stream that writes to itself

* [esArchiver] fill in stats and archive format tests

* [esArchiver] splitup action logic

* [esArchiver/cli] fix cli --help output and comment

* [esArchiver] remove type-based param coercion

* [esArchiver/log] use strings for log levels

* [esArchvier] remove unused var

* [esArchiver/indexDocRecordsStream] add tests

* [esArchive] fill in remaining tests

* [esArchiver] fix dem tests

* [eslint] remove unused vars

* [esArchiver/loadIfNeeded] fix call to load()

* [esArchiver] remove loadDumpData helpers
  • Loading branch information
simianhacker authored Mar 28, 2017
1 parent 059864f commit 753327c
Show file tree
Hide file tree
Showing 23 changed files with 193 additions and 35 deletions.
14 changes: 10 additions & 4 deletions src/core_plugins/metrics/common/agg_lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,21 @@ export function isBasicAgg(item) {
return _.includes(Object.keys(byType.basic), item.type);
}

export function createOptions(type = '_all') {
export function createOptions(type = '_all', siblings = []) {
let aggs = byType[type];
if (!aggs) aggs = byType._all;
let enablePipelines = siblings.some(isBasicAgg);
if (siblings.length <= 1) enablePipelines = false;
return _(aggs)
.map((label, value) => {
const disabled = false;
return { label, value, disabled };
const disabled = _.includes(pipeline, value) ? !enablePipelines : false;
return {
label: disabled ? `${label} (use the "+" button to add this pipeline agg)` : label,
value,
disabled
};
})
.sortBy('label')
.value();
}

export default lookup;
15 changes: 12 additions & 3 deletions src/core_plugins/metrics/public/components/add_delete_buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function AddDeleteButtons(props) {
return null;
}
return (
<Tooltip text="Delete">
<Tooltip text={props.deleteTooltip}>
<a className="thor__button-outlined-danger sm" onClick={ props.onDelete }>
<i className="fa fa-trash-o"></i>
</a>
Expand All @@ -19,7 +19,7 @@ function AddDeleteButtons(props) {
return null;
}
return (
<Tooltip text="Add">
<Tooltip text={props.addTooltip}>
<a className="thor__button-outlined-default sm" onClick={ props.onAdd }>
<i className="fa fa-plus"></i>
</a>
Expand All @@ -31,7 +31,7 @@ function AddDeleteButtons(props) {
let clone;
if (props.onClone && !props.disableAdd) {
clone = (
<Tooltip text="Clone">
<Tooltip text={props.cloneTooltip}>
<a className="thor__button-outlined-default sm" onClick={ props.onClone }>
<i className="fa fa-files-o"></i>
</a>
Expand All @@ -47,7 +47,16 @@ function AddDeleteButtons(props) {
);
}

AddDeleteButtons.defaultProps = {
addTooltip: 'Add',
deleteTooltip: 'Delete',
cloneTooltip: 'Clone'
};

AddDeleteButtons.propTypes = {
addTooltip: PropTypes.string,
deleteTooltip: PropTypes.string,
cloneTooltip: PropTypes.string,
disableAdd: PropTypes.bool,
disableDelete: PropTypes.bool,
onClone: PropTypes.func,
Expand Down
2 changes: 2 additions & 0 deletions src/core_plugins/metrics/public/components/aggs/agg_row.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function AggRow(props) {
{props.children}
{ dragHandle }
<AddDeleteButtons
addTooltip="Add Metric"
deleteTooltip="Delete Metric"
onAdd={props.onAdd}
onDelete={props.onDelete}
disableDelete={props.disableDelete}/>
Expand Down
140 changes: 135 additions & 5 deletions src/core_plugins/metrics/public/components/aggs/agg_select.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,147 @@
import React, { PropTypes } from 'react';
import React, { PropTypes, Component } from 'react';
import Select from 'react-select';
import { createOptions } from '../../../common/agg_lookup';

const metricAggs = [
{ label: 'Average', value: 'avg' },
{ label: 'Cardinality', value: 'cardinality' },
{ label: 'Count', value: 'count' },
{ label: 'Filter Ratio', value: 'filter_ratio' },
{ label: 'Max', value: 'max' },
{ label: 'Min', value: 'min' },
{ label: 'Percentile', value: 'percentile' },
{ label: 'Percentile Rank', value: 'percentile_rank' },
{ label: 'Std. Deviation', value: 'std_deviation' },
{ label: 'Sum', value: 'sum' },
{ label: 'Sum of Squares', value: 'sum_of_squares' },
{ label: 'Value Count', value: 'value_count' },
{ label: 'Variance', value: 'variance' }
];

const pipelineAggs = [
{ label: 'Calculation', value: 'calculation' },
{ label: 'Cumulative Sum', value: 'cumulative_sum' },
{ label: 'Derivative', value: 'derivative' },
{ label: 'Moving Average', value: 'moving_average' },
{ label: 'Serial Difference', value: 'serial_diff' },
{ label: 'Series Agg', value: 'series_agg' }
];

const siblingAggs = [
{ label: 'Overall Average', value: 'avg_bucket' },
{ label: 'Overall Max', value: 'max_bucket' },
{ label: 'Overall Min', value: 'min_bucket' },
{ label: 'Overall Std. Deviation', value: 'std_deviation_bucket' },
{ label: 'Overall Sum', value: 'sum_bucket' },
{ label: 'Overall Sum of Squares', value: 'sum_of_squares_bucket' },
{ label: 'Overall Variance', value: 'variance_bucket' }
];

class AggSelectOption extends Component {

constructor(props) {
super(props);
this.handleMouseMove = this.handleMouseMove.bind(this);
this.handleMouseEnter = this.handleMouseEnter.bind(this);
this.handleMouseDown = this.handleMouseDown.bind(this);
}

handleMouseDown(event) {
event.preventDefault();
event.stopPropagation();
this.props.onSelect(this.props.option, event);
}

handleMouseEnter(event) {
this.props.onFocus(this.props.option, event);
}

handleMouseMove(event) {
if (this.props.isFocused) return;
this.props.onFocus(this.props.option, event);
}

render() {
const { label, heading, pipeline } = this.props.option;
const style = {
paddingLeft: heading ? 0 : 10
};
if (heading) {
let note;
if (pipeline) {
note = (<span className="vis_editor__agg_select-note">(requires child aggregation)</span>);
}
return (
<div className="Select-option vis_editor__agg_select-heading"
onMouseEnter={this.handleMouseEnter}
onMouseDown={this.handleMouseDown}
onMouseMove={this.handleMouseMove}
title={label}>
<span className="Select-value-label" style={style}>
<strong>{label}</strong>
{note}
</span>
</div>
);
}
return (
<div className={this.props.className}
onMouseEnter={this.handleMouseEnter}
onMouseDown={this.handleMouseDown}
onMouseMove={this.handleMouseMove}
title={label}>
<span className="Select-value-label" style={style}>
{ this.props.children }
</span>
</div>
);
}

}

AggSelectOption.props = {
children: PropTypes.node,
className: PropTypes.string,
isDisabled: PropTypes.bool,
isFocused: PropTypes.bool,
isSelected: PropTypes.bool,
onFocus: PropTypes.func,
onSelect: PropTypes.func,
option: PropTypes.object.isRequired,
};

function AggSelect(props) {
const { siblings, panelType } = props;
const options = createOptions(panelType, siblings);

let enablePipelines = siblings.some(s => !!metricAggs.find(m => m.value === s.type));
if (siblings.length <= 1) enablePipelines = false;

let options;
if (panelType === 'metrics') {
options = metricAggs;
} else {
options = [
{ label: 'Metric Aggregations', value: null, heading: true, disabled: true },
...metricAggs,
{ label: 'Parent Pipeline Aggregations', value: null, pipeline: true, heading: true, disabled: true },
...pipelineAggs.map(agg => ({ ...agg, disabled: !enablePipelines })),
{ label: 'Sibling Pipeline Aggregations', value: null, pipeline: true, heading: true, disabled: true },
...siblingAggs.map(agg => ({ ...agg, disabled: !enablePipelines }))
];
}

const handleChange = (value) => {
if (value.disabled) return;
if (value.value) props.onChange(value);
};

return (
<div className="vis_editor__row_item">
<Select
clearable={false}
options={options}
value={props.value || 'count'}
onChange={props.onChange}/>
value={props.value}
optionComponent={AggSelectOption}
onChange={handleChange}/>
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CalculationAgg extends Component {
}

render() {
const { panel, siblings } = this.props;
const { siblings } = this.props;

const defaults = { script: '' };
const model = { ...defaults, ...this.props.model };
Expand All @@ -41,7 +41,6 @@ class CalculationAgg extends Component {
<div className="vis_editor__label">Aggregation</div>
<AggSelect
siblings={this.props.siblings}
panelType={panel.type}
value={model.type}
onChange={handleSelectChange('type')}/>
<div className="vis_editor__variables">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import createChangeHandler from '../lib/create_change_handler';
import createSelectHandler from '../lib/create_select_handler';

function CumlativeSumAgg(props) {
const { model, panel, siblings } = props;
const { model, siblings } = props;
const handleChange = createChangeHandler(props.onChange, model);
const handleSelectChange = createSelectHandler(handleChange);
return (
Expand All @@ -20,7 +20,6 @@ function CumlativeSumAgg(props) {
<div className="vis_editor__label">Aggregation</div>
<AggSelect
siblings={props.siblings}
panelType={panel.type}
value={model.type}
onChange={handleSelectChange('type')}/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import createTextHandler from '../lib/create_text_handler';
class DerivativeAgg extends Component {

render() {
const { siblings, panel } = this.props;
const { siblings } = this.props;

const defaults = { unit: '' };
const model = { ...defaults, ...this.props.model };
Expand All @@ -29,7 +29,6 @@ class DerivativeAgg extends Component {
<div className="vis_editor__label">Aggregation</div>
<AggSelect
siblings={this.props.siblings}
panelType={panel.type}
value={model.type}
onChange={handleSelectChange('type')}/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class FilterRatioAgg extends Component {
<div className="vis_editor__label">Aggregation</div>
<AggSelect
siblings={this.props.siblings}
panelType={panel.type}
value={model.type}
onChange={handleSelectChange('type')}/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import createNumberHandler from '../lib/create_number_handler';

class MovingAverageAgg extends Component {
render() {
const { panel, siblings } = this.props;
const { siblings } = this.props;
const defaults = {
settings: '',
minimize: 0,
Expand Down Expand Up @@ -46,7 +46,6 @@ class MovingAverageAgg extends Component {
<div className="vis_editor__label">Aggregation</div>
<AggSelect
siblings={this.props.siblings}
panelType={panel.type}
value={model.type}
onChange={handleSelectChange('type')}/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ class PercentileAgg extends Component {
<div className="vis_editor__label">Aggregation</div>
<AggSelect
siblings={this.props.siblings}
panelType={panel.type}
value={model.type}
onChange={handleSelectChange('type')}/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class PercentileRankAgg extends Component {
<div className="vis_editor__label">Aggregation</div>
<AggSelect
siblings={this.props.siblings}
panelType={panel.type}
value={model.type}
onChange={handleSelectChange('type')}/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import createNumberHandler from '../lib/create_number_handler';
class SerialDiffAgg extends Component {

render() {
const { siblings, panel } = this.props;
const { siblings } = this.props;
const defaults = { lag: '' };
const model = { ...defaults, ...this.props.model };

Expand All @@ -28,7 +28,6 @@ class SerialDiffAgg extends Component {
<div className="vis_editor__label">Aggregation</div>
<AggSelect
siblings={this.props.siblings}
panelType={panel.type}
value={model.type}
onChange={handleSelectChange('type')}/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import createChangeHandler from '../lib/create_change_handler';
import createSelectHandler from '../lib/create_select_handler';

function SeriesAgg(props) {
const {
model,
panel
} = props;
const { model } = props;

const handleChange = createChangeHandler(props.onChange, model);
const handleSelectChange = createSelectHandler(handleChange);
Expand Down Expand Up @@ -37,7 +34,6 @@ function SeriesAgg(props) {
<div className="vis_editor__label">Aggregation</div>
<AggSelect
siblings={props.siblings}
panelType={panel.type}
value={model.type}
onChange={handleSelectChange('type')}/>
</div>
Expand Down
1 change: 0 additions & 1 deletion src/core_plugins/metrics/public/components/aggs/std_agg.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function StandardAgg(props) {
<div className="vis_editor__label">Aggregation</div>
<AggSelect
siblings={props.siblings}
panelType={panel.type}
value={model.type}
onChange={handleSelectChange('type')}/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class StandardDeviationAgg extends Component {
<div className="vis_editor__label">Aggregation</div>
<AggSelect
siblings={this.props.siblings}
panelType={panel.type}
value={model.type}
onChange={handleSelectChange('type')}/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import createTextHandler from '../lib/create_text_handler';
class StandardSiblingAgg extends Component {

render() {
const { siblings, panel } = this.props;
const { siblings } = this.props;
const defaults = { sigma: '' };
const model = { ...defaults, ...this.props.model };

Expand Down Expand Up @@ -59,7 +59,6 @@ class StandardSiblingAgg extends Component {
<div className="vis_editor__label">Aggregation</div>
<AggSelect
siblings={this.props.siblings}
panelType={panel.type}
value={model.type}
onChange={handleSelectChange('type')}/>
</div>
Expand Down
Loading

0 comments on commit 753327c

Please sign in to comment.