parent
cd543265be
commit
cfeb37b78f
|
@ -1,12 +1,11 @@
|
|||
import { VisFactoryProvider } from 'ui/vis/vis_factory';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import { CATEGORY } from 'ui/vis/vis_category';
|
||||
import pointSeriesTemplate from 'plugins/kbn_vislib_vis_types/editors/point_series.html';
|
||||
import image from './images/icon-area.svg';
|
||||
|
||||
export default function PointSeriesVisType(Private) {
|
||||
const VisFactory = Private(VisFactoryProvider);
|
||||
const Schemas = Private(VisSchemasProvider);
|
||||
|
||||
return VisFactory.createVislibVisualization({
|
||||
name: 'area',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { VisFactoryProvider } from 'ui/vis/vis_factory';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import { CATEGORY } from 'ui/vis/vis_category';
|
||||
import gaugeTemplate from 'plugins/kbn_vislib_vis_types/editors/gauge.html';
|
||||
import { vislibColorMaps } from 'ui/vislib/components/color/colormaps';
|
||||
|
@ -7,7 +7,6 @@ import image from './images/icon-gauge.svg';
|
|||
|
||||
export default function GaugeVisType(Private) {
|
||||
const VisFactory = Private(VisFactoryProvider);
|
||||
const Schemas = Private(VisSchemasProvider);
|
||||
|
||||
return VisFactory.createVislibVisualization({
|
||||
name: 'gauge',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { VisFactoryProvider } from 'ui/vis/vis_factory';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import { CATEGORY } from 'ui/vis/vis_category';
|
||||
import gaugeTemplate from 'plugins/kbn_vislib_vis_types/editors/gauge.html';
|
||||
import { vislibColorMaps } from 'ui/vislib/components/color/colormaps';
|
||||
|
@ -7,7 +7,6 @@ import image from './images/icon-goal.svg';
|
|||
|
||||
export default function GoalVisType(Private) {
|
||||
const VisFactory = Private(VisFactoryProvider);
|
||||
const Schemas = Private(VisSchemasProvider);
|
||||
|
||||
return VisFactory.createVislibVisualization({
|
||||
name: 'goal',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { VisFactoryProvider } from 'ui/vis/vis_factory';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import { CATEGORY } from 'ui/vis/vis_category';
|
||||
import heatmapTemplate from 'plugins/kbn_vislib_vis_types/editors/heatmap.html';
|
||||
import { vislibColorMaps } from 'ui/vislib/components/color/colormaps';
|
||||
|
@ -7,7 +7,6 @@ import image from './images/icon-heatmap.svg';
|
|||
|
||||
export default function HeatmapVisType(Private) {
|
||||
const VisFactory = Private(VisFactoryProvider);
|
||||
const Schemas = Private(VisSchemasProvider);
|
||||
|
||||
return VisFactory.createVislibVisualization({
|
||||
name: 'heatmap',
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import { VisFactoryProvider } from 'ui/vis/vis_factory';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import { CATEGORY } from 'ui/vis/vis_category';
|
||||
import pointSeriesTemplate from 'plugins/kbn_vislib_vis_types/editors/point_series.html';
|
||||
import image from './images/icon-vertical.svg';
|
||||
|
||||
export default function PointSeriesVisType(Private) {
|
||||
const VisFactory = Private(VisFactoryProvider);
|
||||
const Schemas = Private(VisSchemasProvider);
|
||||
|
||||
return VisFactory.createVislibVisualization({
|
||||
name: 'histogram',
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import { VisFactoryProvider } from 'ui/vis/vis_factory';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import { CATEGORY } from 'ui/vis/vis_category';
|
||||
import pointSeriesTemplate from 'plugins/kbn_vislib_vis_types/editors/point_series.html';
|
||||
import image from './images/icon-horizontal.svg';
|
||||
|
||||
export default function PointSeriesVisType(Private) {
|
||||
const VisFactory = Private(VisFactoryProvider);
|
||||
const Schemas = Private(VisSchemasProvider);
|
||||
|
||||
return VisFactory.createVislibVisualization({
|
||||
name: 'horizontal_bar',
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import { VisFactoryProvider } from 'ui/vis/vis_factory';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import { CATEGORY } from 'ui/vis/vis_category';
|
||||
import pointSeriesTemplate from 'plugins/kbn_vislib_vis_types/editors/point_series.html';
|
||||
import image from './images/icon-line.svg';
|
||||
|
||||
export default function PointSeriesVisType(Private) {
|
||||
const VisFactory = Private(VisFactoryProvider);
|
||||
const Schemas = Private(VisSchemasProvider);
|
||||
|
||||
return VisFactory.createVislibVisualization({
|
||||
name: 'line',
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import { VisFactoryProvider } from 'ui/vis/vis_factory';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import { CATEGORY } from 'ui/vis/vis_category';
|
||||
import pieTemplate from 'plugins/kbn_vislib_vis_types/editors/pie.html';
|
||||
import image from './images/icon-pie.svg';
|
||||
|
||||
export default function HistogramVisType(Private) {
|
||||
const VisFactory = Private(VisFactoryProvider);
|
||||
const Schemas = Private(VisSchemasProvider);
|
||||
|
||||
return VisFactory.createVislibVisualization({
|
||||
name: 'pie',
|
||||
|
|
|
@ -2,7 +2,7 @@ import 'plugins/metric_vis/metric_vis.less';
|
|||
import 'plugins/metric_vis/metric_vis_params';
|
||||
import { VisFactoryProvider } from 'ui/vis/vis_factory';
|
||||
import { CATEGORY } from 'ui/vis/vis_category';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';
|
||||
import { vislibColorMaps } from 'ui/vislib/components/color/colormaps';
|
||||
import { MetricVisComponent } from './metric_vis_controller';
|
||||
|
@ -15,7 +15,6 @@ import image from './images/icon_number.svg';
|
|||
VisTypesRegistryProvider.register(MetricVisProvider);
|
||||
|
||||
function MetricVisProvider(Private) {
|
||||
const Schemas = Private(VisSchemasProvider);
|
||||
const VisFactory = Private(VisFactoryProvider);
|
||||
|
||||
// return the visType object, which kibana will use to display and configure new
|
||||
|
|
|
@ -3,7 +3,7 @@ import './region_map_vis_params';
|
|||
import image from './images/icon-vector-map.svg';
|
||||
import { VisFactoryProvider } from 'ui/vis/vis_factory';
|
||||
import { CATEGORY } from 'ui/vis/vis_category';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';
|
||||
import { truncatedColorMaps } from 'ui/vislib/components/color/truncated_colormaps';
|
||||
import { mapToLayerWithId } from './util';
|
||||
|
@ -12,7 +12,6 @@ import { Status } from 'ui/vis/update_status';
|
|||
|
||||
VisTypesRegistryProvider.register(function RegionMapProvider(Private, regionmapsConfig, config) {
|
||||
const VisFactory = Private(VisFactoryProvider);
|
||||
const Schemas = Private(VisSchemasProvider);
|
||||
const RegionMapsVisualization = Private(RegionMapsVisualizationProvider);
|
||||
|
||||
const vectorLayers = regionmapsConfig.layers.map(mapToLayerWithId.bind(null, 'self_hosted'));
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'ui/agg_table';
|
|||
import 'ui/agg_table/agg_table_group';
|
||||
import { VisFactoryProvider } from 'ui/vis/vis_factory';
|
||||
import { CATEGORY } from 'ui/vis/vis_category';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import tableVisTemplate from 'plugins/table_vis/table_vis.html';
|
||||
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';
|
||||
import image from './images/icon-table.svg';
|
||||
|
@ -23,7 +23,6 @@ VisTypesRegistryProvider.register(TableVisTypeProvider);
|
|||
// define the TableVisType
|
||||
function TableVisTypeProvider(Private) {
|
||||
const VisFactory = Private(VisFactoryProvider);
|
||||
const Schemas = Private(VisSchemasProvider);
|
||||
|
||||
// define the TableVisController which is used in the template
|
||||
// by angular's ng-controller directive
|
||||
|
|
|
@ -2,7 +2,7 @@ import 'plugins/tagcloud/tag_cloud.less';
|
|||
import 'plugins/tagcloud/tag_cloud_vis_params';
|
||||
import { VisFactoryProvider } from 'ui/vis/vis_factory';
|
||||
import { CATEGORY } from 'ui/vis/vis_category';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import { TagCloudVisualization } from './tag_cloud_visualization';
|
||||
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';
|
||||
import image from './images/icon-tagcloud.svg';
|
||||
|
@ -11,7 +11,6 @@ import { Status } from 'ui/vis/update_status';
|
|||
VisTypesRegistryProvider.register(function (Private) {
|
||||
|
||||
const VisFactory = Private(VisFactoryProvider);
|
||||
const Schemas = Private(VisSchemasProvider);
|
||||
|
||||
return VisFactory.createBaseVisualization({
|
||||
name: 'tagcloud',
|
||||
|
|
|
@ -4,7 +4,7 @@ import { supports } from 'ui/utils/supports';
|
|||
import { CATEGORY } from 'ui/vis/vis_category';
|
||||
import { VisFactoryProvider } from 'ui/vis/vis_factory';
|
||||
import { CoordinateMapsVisualizationProvider } from './coordinate_maps_visualization';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import { AggResponseGeoJsonProvider } from 'ui/agg_response/geo_json/geo_json';
|
||||
import image from './images/icon-tilemap.svg';
|
||||
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';
|
||||
|
@ -13,7 +13,6 @@ import { Status } from 'ui/vis/update_status';
|
|||
|
||||
VisTypesRegistryProvider.register(function TileMapVisType(Private, getAppState, courier, config) {
|
||||
|
||||
const Schemas = Private(VisSchemasProvider);
|
||||
const geoJsonConverter = Private(AggResponseGeoJsonProvider);
|
||||
const VisFactory = Private(VisFactoryProvider);
|
||||
const CoordinateMapsVisualization = Private(CoordinateMapsVisualizationProvider);
|
||||
|
|
|
@ -1,31 +1,12 @@
|
|||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
import { AggTypesAggParamsProvider } from 'ui/agg_types/agg_params';
|
||||
import { BaseParamTypeProvider } from '../param_types/base';
|
||||
import { FieldParamTypeProvider } from '../param_types/field';
|
||||
import { OptionedParamTypeProvider } from '../param_types/optioned';
|
||||
import { RegexParamTypeProvider } from '../param_types/regex';
|
||||
import { AggParams } from 'ui/agg_types/agg_params';
|
||||
import { BaseParamType } from '../param_types/base';
|
||||
import { FieldParamType } from '../param_types/field';
|
||||
import { OptionedParamType } from '../param_types/optioned';
|
||||
import { RegexParamType } from '../param_types/regex';
|
||||
|
||||
describe('AggParams class', function () {
|
||||
|
||||
let AggParams;
|
||||
let BaseParamType;
|
||||
let FieldParamType;
|
||||
let OptionedParamType;
|
||||
let RegexParamType;
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
// stub out the param classes before we get the AggParams
|
||||
beforeEach(ngMock.inject(require('./utils/_stub_agg_params')));
|
||||
// fetch out deps
|
||||
beforeEach(ngMock.inject(function (Private) {
|
||||
AggParams = Private(AggTypesAggParamsProvider);
|
||||
BaseParamType = Private(BaseParamTypeProvider);
|
||||
FieldParamType = Private(FieldParamTypeProvider);
|
||||
OptionedParamType = Private(OptionedParamTypeProvider);
|
||||
RegexParamType = Private(RegexParamTypeProvider);
|
||||
}));
|
||||
|
||||
describe('constructor args', function () {
|
||||
it('accepts an array of param defs', function () {
|
||||
const params = [
|
||||
|
@ -94,10 +75,6 @@ describe('AggParams class', function () {
|
|||
];
|
||||
const aggParams = new AggParams(params);
|
||||
|
||||
expect(BaseParamType).to.have.property('callCount', params.length);
|
||||
expect(FieldParamType).to.have.property('callCount', 0);
|
||||
expect(OptionedParamType).to.have.property('callCount', 0);
|
||||
|
||||
expect(aggParams).to.have.length(params.length);
|
||||
aggParams.forEach(function (aggParam) {
|
||||
expect(aggParam).to.be.a(BaseParamType);
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import _ from 'lodash';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import sinon from 'sinon';
|
||||
import 'ui/private';
|
||||
import { AggTypesAggParamsProvider } from 'ui/agg_types/agg_params';
|
||||
import { AggParams } from 'ui/agg_types/agg_params';
|
||||
import { VisProvider } from 'ui/vis';
|
||||
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
|
||||
import { AggTypesAggTypeProvider } from 'ui/agg_types/agg_type';
|
||||
|
@ -11,7 +10,6 @@ import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logsta
|
|||
|
||||
describe('AggType Class', function () {
|
||||
let AggType;
|
||||
let AggParams;
|
||||
let indexPattern;
|
||||
let fieldFormat;
|
||||
let Vis;
|
||||
|
@ -19,8 +17,6 @@ describe('AggType Class', function () {
|
|||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
beforeEach(ngMock.inject(function (Private) {
|
||||
AggParams = sinon.spy(Private(AggTypesAggParamsProvider));
|
||||
Private.stub(AggTypesAggParamsProvider, AggParams);
|
||||
|
||||
Vis = Private(VisProvider);
|
||||
fieldFormat = Private(RegistryFieldFormatsProvider);
|
||||
|
@ -121,9 +117,6 @@ describe('AggType Class', function () {
|
|||
});
|
||||
|
||||
describe('params', function () {
|
||||
beforeEach(function () {
|
||||
AggParams.reset();
|
||||
});
|
||||
|
||||
it('defaults to AggParams object with JSON param', function () {
|
||||
const aggType = new AggType({
|
||||
|
@ -160,8 +153,6 @@ describe('AggType Class', function () {
|
|||
|
||||
expect(aggType.params).to.be.an(AggParams);
|
||||
expect(aggType.params.length).to.be(paramLength);
|
||||
expect(AggParams.callCount).to.be(1);
|
||||
expect(AggParams.firstCall.args[0]).to.be(params);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -2,20 +2,16 @@ import expect from 'expect.js';
|
|||
import { reject } from 'lodash';
|
||||
import ngMock from 'ng_mock';
|
||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
import { BaseParamTypeProvider } from '../../param_types/base';
|
||||
import { FieldParamTypeProvider } from '../../param_types/field';
|
||||
import { BaseParamType } from '../../param_types/base';
|
||||
import { FieldParamType } from '../../param_types/field';
|
||||
|
||||
describe('Field', function () {
|
||||
|
||||
let BaseParamType;
|
||||
let FieldParamType;
|
||||
let indexPattern;
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
// fetch out deps
|
||||
beforeEach(ngMock.inject(function (Private) {
|
||||
BaseParamType = Private(BaseParamTypeProvider);
|
||||
FieldParamType = Private(FieldParamTypeProvider);
|
||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||
}));
|
||||
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
import _ from 'lodash';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import { BaseParamTypeProvider } from '../../param_types/base';
|
||||
import { JsonParamTypeProvider } from '../../param_types/json';
|
||||
import { BaseParamType } from '../../param_types/base';
|
||||
import { JsonParamType } from '../../param_types/json';
|
||||
|
||||
// eslint-disable-next-line @elastic/kibana-custom/no-default-export
|
||||
export default describe('JSON', function () {
|
||||
const paramName = 'json_test';
|
||||
let BaseParamType;
|
||||
let JsonParamType;
|
||||
let aggParam;
|
||||
let aggConfig;
|
||||
let output;
|
||||
|
@ -23,18 +20,14 @@ export default describe('JSON', function () {
|
|||
aggParam = new JsonParamType(_.defaults(config, defaults));
|
||||
}
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
|
||||
// fetch out deps
|
||||
beforeEach(ngMock.inject(function (Private) {
|
||||
beforeEach(function () {
|
||||
aggConfig = { params: {} };
|
||||
output = { params: {} };
|
||||
|
||||
BaseParamType = Private(BaseParamTypeProvider);
|
||||
JsonParamType = Private(JsonParamTypeProvider);
|
||||
|
||||
initParamType();
|
||||
}));
|
||||
});
|
||||
|
||||
describe('constructor', function () {
|
||||
it('it is an instance of BaseParamType', function () {
|
||||
|
|
|
@ -1,20 +1,9 @@
|
|||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import { BaseParamTypeProvider } from '../../param_types/base';
|
||||
import { OptionedParamTypeProvider } from '../../param_types/optioned';
|
||||
import { BaseParamType } from '../../param_types/base';
|
||||
import { OptionedParamType } from '../../param_types/optioned';
|
||||
|
||||
describe('Optioned', function () {
|
||||
|
||||
let BaseParamType;
|
||||
let OptionedParamType;
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
// fetch out deps
|
||||
beforeEach(ngMock.inject(function (Private) {
|
||||
BaseParamType = Private(BaseParamTypeProvider);
|
||||
OptionedParamType = Private(OptionedParamTypeProvider);
|
||||
}));
|
||||
|
||||
describe('constructor', function () {
|
||||
it('it is an instance of BaseParamType', function () {
|
||||
const aggParam = new OptionedParamType({
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import { BaseParamTypeProvider } from '../../param_types/base';
|
||||
import { RegexParamTypeProvider } from '../../param_types/regex';
|
||||
import { BaseParamType } from '../../param_types/base';
|
||||
import { RegexParamType } from '../../param_types/regex';
|
||||
import { VisProvider } from 'ui/vis';
|
||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
|
||||
describe('Regex', function () {
|
||||
|
||||
let BaseParamType;
|
||||
let RegexParamType;
|
||||
let Vis;
|
||||
let indexPattern;
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
// fetch out deps
|
||||
beforeEach(ngMock.inject(function (Private) {
|
||||
BaseParamType = Private(BaseParamTypeProvider);
|
||||
RegexParamType = Private(RegexParamTypeProvider);
|
||||
Vis = Private(VisProvider);
|
||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||
}));
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
import _ from 'lodash';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import { BaseParamTypeProvider } from '../../param_types/base';
|
||||
import { StringParamTypeProvider } from '../../param_types/string';
|
||||
import { BaseParamType } from '../../param_types/base';
|
||||
import { StringParamType } from '../../param_types/string';
|
||||
|
||||
// eslint-disable-next-line @elastic/kibana-custom/no-default-export
|
||||
export default describe('String', function () {
|
||||
const paramName = 'json_test';
|
||||
let BaseParamType;
|
||||
let StringParamType;
|
||||
let aggParam;
|
||||
let aggConfig;
|
||||
let output;
|
||||
|
@ -23,16 +20,13 @@ export default describe('String', function () {
|
|||
aggParam = new StringParamType(_.defaults(config, defaults));
|
||||
}
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
|
||||
// fetch our deps
|
||||
beforeEach(ngMock.inject(function (Private) {
|
||||
BaseParamType = Private(BaseParamTypeProvider);
|
||||
StringParamType = Private(StringParamTypeProvider);
|
||||
beforeEach(function () {
|
||||
|
||||
aggConfig = { params: {} };
|
||||
output = { params: {} };
|
||||
}));
|
||||
});
|
||||
|
||||
describe('constructor', function () {
|
||||
it('it is an instance of BaseParamType', function () {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import _ from 'lodash';
|
||||
import sinon from 'sinon';
|
||||
import { BaseParamTypeProvider } from '../../param_types/base';
|
||||
import { FieldParamTypeProvider } from '../../param_types/field';
|
||||
import { OptionedParamTypeProvider } from '../../param_types/optioned';
|
||||
import { BaseParamType } from '../../param_types/base';
|
||||
import { FieldParamType } from '../../param_types/field';
|
||||
import { OptionedParamType } from '../../param_types/optioned';
|
||||
|
||||
function ParamClassStub(parent, body) {
|
||||
const stub = sinon.spy(body || function () {
|
||||
|
@ -29,19 +29,19 @@ function ParamClassStub(parent, body) {
|
|||
// eslint-disable-next-line @elastic/kibana-custom/no-default-export
|
||||
export default function stubParamClasses(Private) {
|
||||
const BaseAggParam = Private.stub(
|
||||
BaseParamTypeProvider,
|
||||
BaseParamType,
|
||||
new ParamClassStub(null, function (config) {
|
||||
_.assign(this, config);
|
||||
})
|
||||
);
|
||||
|
||||
Private.stub(
|
||||
FieldParamTypeProvider,
|
||||
FieldParamType,
|
||||
new ParamClassStub(BaseAggParam)
|
||||
);
|
||||
|
||||
Private.stub(
|
||||
OptionedParamTypeProvider,
|
||||
OptionedParamType,
|
||||
new ParamClassStub(BaseAggParam)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,76 +1,74 @@
|
|||
import 'ui/filters/label';
|
||||
import _ from 'lodash';
|
||||
import { IndexedArray } from 'ui/indexed_array';
|
||||
import { FieldParamTypeProvider } from './param_types/field';
|
||||
import { OptionedParamTypeProvider } from './param_types/optioned';
|
||||
import { RegexParamTypeProvider } from './param_types/regex';
|
||||
import { StringParamTypeProvider } from './param_types/string';
|
||||
import { JsonParamTypeProvider } from './param_types/json';
|
||||
import { BaseParamTypeProvider } from './param_types/base';
|
||||
import { FieldParamType } from './param_types/field';
|
||||
import { OptionedParamType } from './param_types/optioned';
|
||||
import { RegexParamType } from './param_types/regex';
|
||||
import { StringParamType } from './param_types/string';
|
||||
import { JsonParamType } from './param_types/json';
|
||||
import { BaseParamType } from './param_types/base';
|
||||
|
||||
export function AggTypesAggParamsProvider(Private) {
|
||||
const paramTypeMap = {
|
||||
field: Private(FieldParamTypeProvider),
|
||||
optioned: Private(OptionedParamTypeProvider),
|
||||
regex: Private(RegexParamTypeProvider),
|
||||
string: Private(StringParamTypeProvider),
|
||||
json: Private(JsonParamTypeProvider),
|
||||
_default: Private(BaseParamTypeProvider)
|
||||
};
|
||||
const paramTypeMap = {
|
||||
field: FieldParamType,
|
||||
optioned: (OptionedParamType),
|
||||
regex: (RegexParamType),
|
||||
string: (StringParamType),
|
||||
json: (JsonParamType),
|
||||
_default: (BaseParamType)
|
||||
};
|
||||
|
||||
/**
|
||||
* Wraps a list of {{#crossLink "AggParam"}}{{/crossLink}} objects; owned by an {{#crossLink "AggType"}}{{/crossLink}}
|
||||
*
|
||||
* used to create:
|
||||
* - `FieldAggParam` – When the config has `name: "field"`
|
||||
* - `*AggParam` – When the type matches something in the map above
|
||||
* - `BaseAggParam` – All other params
|
||||
*
|
||||
* @class AggParams
|
||||
* @constructor
|
||||
* @extends IndexedArray
|
||||
* @param {object[]} params - array of params that get new-ed up as AggParam objects as descibed above
|
||||
*/
|
||||
_.class(AggParams).inherits(IndexedArray);
|
||||
function AggParams(params) {
|
||||
AggParams.Super.call(this, {
|
||||
index: ['name'],
|
||||
initialSet: params.map(function (config) {
|
||||
const type = config.name === 'field' ? config.name : config.type;
|
||||
const Class = paramTypeMap[type] || paramTypeMap._default;
|
||||
return new Class(config);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an aggConfigs
|
||||
*
|
||||
* @method write
|
||||
* @param {AggConfig} aggConfig
|
||||
* the AggConfig object who's type owns these aggParams and contains the param values for our param defs
|
||||
* @param {object} [locals]
|
||||
* an array of locals that will be available to the write function (can be used to enhance
|
||||
* the quality of things like date_histogram's "auto" interval)
|
||||
* @return {object} output
|
||||
* output of the write calls, reduced into a single object. A `params: {}` property is exposed on the
|
||||
* output object which is used to create the agg dsl for the search request. All other properties
|
||||
* are dependent on the AggParam#write methods which should be studied for each AggType.
|
||||
*/
|
||||
AggParams.prototype.write = function (aggConfig, locals) {
|
||||
const output = { params: {} };
|
||||
locals = locals || {};
|
||||
|
||||
this.forEach(function (param) {
|
||||
if (param.write) {
|
||||
param.write(aggConfig, output, locals);
|
||||
} else {
|
||||
output.params[param.name] = aggConfig.params[param.name];
|
||||
}
|
||||
});
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
return AggParams;
|
||||
/**
|
||||
* Wraps a list of {{#crossLink "AggParam"}}{{/crossLink}} objects; owned by an {{#crossLink "AggType"}}{{/crossLink}}
|
||||
*
|
||||
* used to create:
|
||||
* - `FieldAggParam` – When the config has `name: "field"`
|
||||
* - `*AggParam` – When the type matches something in the map above
|
||||
* - `BaseAggParam` – All other params
|
||||
*
|
||||
* @class AggParams
|
||||
* @constructor
|
||||
* @extends IndexedArray
|
||||
* @param {object[]} params - array of params that get new-ed up as AggParam objects as descibed above
|
||||
*/
|
||||
_.class(AggParams).inherits(IndexedArray);
|
||||
function AggParams(params) {
|
||||
AggParams.Super.call(this, {
|
||||
index: ['name'],
|
||||
initialSet: params.map(function (config) {
|
||||
const type = config.name === 'field' ? config.name : config.type;
|
||||
const Class = paramTypeMap[type] || paramTypeMap._default;
|
||||
return new Class(config);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an aggConfigs
|
||||
*
|
||||
* @method write
|
||||
* @param {AggConfig} aggConfig
|
||||
* the AggConfig object who's type owns these aggParams and contains the param values for our param defs
|
||||
* @param {object} [locals]
|
||||
* an array of locals that will be available to the write function (can be used to enhance
|
||||
* the quality of things like date_histogram's "auto" interval)
|
||||
* @return {object} output
|
||||
* output of the write calls, reduced into a single object. A `params: {}` property is exposed on the
|
||||
* output object which is used to create the agg dsl for the search request. All other properties
|
||||
* are dependent on the AggParam#write methods which should be studied for each AggType.
|
||||
*/
|
||||
AggParams.prototype.write = function (aggConfig, locals) {
|
||||
const output = { params: {} };
|
||||
locals = locals || {};
|
||||
|
||||
this.forEach(function (param) {
|
||||
if (param.write) {
|
||||
param.write(aggConfig, output, locals);
|
||||
} else {
|
||||
output.params[param.name] = aggConfig.params[param.name];
|
||||
}
|
||||
});
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
export { AggParams };
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import _ from 'lodash';
|
||||
import { AggTypesAggParamsProvider } from 'ui/agg_types/agg_params';
|
||||
import { AggParams } from 'ui/agg_types/agg_params';
|
||||
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
|
||||
|
||||
export function AggTypesAggTypeProvider(Private) {
|
||||
const AggParams = Private(AggTypesAggParamsProvider);
|
||||
const fieldFormats = Private(RegistryFieldFormatsProvider);
|
||||
|
||||
|
||||
/**
|
||||
* Generic AggType Constructor
|
||||
*
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import _ from 'lodash';
|
||||
import { AggTypesBucketsBucketAggTypeProvider } from 'ui/agg_types/buckets/_bucket_agg_type';
|
||||
import { VisAggConfigProvider } from 'ui/vis/agg_config';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import { AggTypesBucketsCreateFilterTermsProvider } from 'ui/agg_types/buckets/create_filter/terms';
|
||||
import orderAggTemplate from 'ui/agg_types/controls/order_agg.html';
|
||||
import orderAndSizeTemplate from 'ui/agg_types/controls/order_and_size.html';
|
||||
|
@ -11,7 +11,6 @@ import { OtherBucketHelperProvider } from './_terms_other_bucket_helper';
|
|||
export function AggTypesBucketsTermsProvider(Private) {
|
||||
const BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider);
|
||||
const AggConfig = Private(VisAggConfigProvider);
|
||||
const Schemas = Private(VisSchemasProvider);
|
||||
const createFilter = Private(AggTypesBucketsCreateFilterTermsProvider);
|
||||
const routeBasedNotifier = Private(RouteBasedNotifierProvider);
|
||||
const { buildOtherBucketAgg, mergeOtherBucketAggResponse, updateMissingBucket } = Private(OtherBucketHelperProvider);
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
import metricAggTemplate from 'ui/agg_types/controls/sub_agg.html';
|
||||
import _ from 'lodash';
|
||||
import { VisAggConfigProvider } from 'ui/vis/agg_config';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import { parentPipelineAggController } from './parent_pipeline_agg_controller';
|
||||
import { parentPipelineAggWritter } from './parent_pipeline_agg_writter';
|
||||
|
||||
export const ParentPipelineAggHelperProvider = function (Private) {
|
||||
|
||||
const AggConfig = Private(VisAggConfigProvider);
|
||||
const Schemas = Private(VisSchemasProvider);
|
||||
|
||||
const metricAggFilter = ['!top_hits', '!percentiles', '!percentile_ranks', '!median', '!std_dev'];
|
||||
const metricAggSchema = (new Schemas([
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import _ from 'lodash';
|
||||
import { VisAggConfigProvider } from 'ui/vis/agg_config';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
|
||||
import { siblingPipelineAggController } from './sibling_pipeline_agg_controller';
|
||||
import { siblingPipelineAggWritter } from './sibling_pipeline_agg_writter';
|
||||
|
@ -9,7 +9,6 @@ import metricAggTemplate from 'ui/agg_types/controls/sub_metric.html';
|
|||
export const SiblingPipelineAggHelperProvider = function (Private) {
|
||||
|
||||
const AggConfig = Private(VisAggConfigProvider);
|
||||
const Schemas = Private(VisSchemasProvider);
|
||||
|
||||
const metricAggFilter = [
|
||||
'!top_hits', '!percentiles', '!percentile_ranks', '!median', '!std_dev',
|
||||
|
|
|
@ -1,24 +1,21 @@
|
|||
import _ from 'lodash';
|
||||
|
||||
export function BaseParamTypeProvider() {
|
||||
|
||||
function BaseParamType(config) {
|
||||
_.assign(this, config);
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that will be called before an aggConfig is serialized and sent to ES.
|
||||
* Allows aggConfig to retrieve values needed for serialization by creating a {SearchRequest}
|
||||
* Example usage: an aggregation needs to know the min/max of a field to determine an appropriate interval
|
||||
*
|
||||
* @param {AggConfig} aggconfig
|
||||
* @param {Courier.SearchSource} searchSource
|
||||
* @param {Courier.SearchRequest} searchRequest
|
||||
* @returns {Promise<undefined>|undefined}
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
BaseParamType.prototype.modifyAggConfigOnSearchRequestStart = function (aggconfig, searchSource, searchRequest) {
|
||||
};
|
||||
|
||||
return BaseParamType;
|
||||
function BaseParamType(config) {
|
||||
_.assign(this, config);
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that will be called before an aggConfig is serialized and sent to ES.
|
||||
* Allows aggConfig to retrieve values needed for serialization by creating a {SearchRequest}
|
||||
* Example usage: an aggregation needs to know the min/max of a field to determine an appropriate interval
|
||||
*
|
||||
* @param {AggConfig} aggconfig
|
||||
* @param {Courier.SearchSource} searchSource
|
||||
* @param {Courier.SearchRequest} searchRequest
|
||||
* @returns {Promise<undefined>|undefined}
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
BaseParamType.prototype.modifyAggConfigOnSearchRequestStart = function (aggconfig, searchSource, searchRequest) {
|
||||
};
|
||||
|
||||
export { BaseParamType };
|
||||
|
|
|
@ -1,116 +1,115 @@
|
|||
import { SavedObjectNotFound } from 'ui/errors';
|
||||
import _ from 'lodash';
|
||||
import editorHtml from '../controls/field.html';
|
||||
import { BaseParamTypeProvider } from './base';
|
||||
import { BaseParamType } from './base';
|
||||
import 'ui/filters/field_type';
|
||||
import { IndexedArray } from 'ui/indexed_array';
|
||||
import { Notifier } from 'ui/notify';
|
||||
import { propFilter } from 'ui/filters/_prop_filter';
|
||||
|
||||
export function FieldParamTypeProvider(Private, $filter) {
|
||||
const BaseParamType = Private(BaseParamTypeProvider);
|
||||
const notifier = new Notifier();
|
||||
|
||||
_.class(FieldParamType).inherits(BaseParamType);
|
||||
function FieldParamType(config) {
|
||||
FieldParamType.Super.call(this, config);
|
||||
const notifier = new Notifier();
|
||||
|
||||
_.class(FieldParamType).inherits(BaseParamType);
|
||||
function FieldParamType(config) {
|
||||
FieldParamType.Super.call(this, config);
|
||||
}
|
||||
|
||||
FieldParamType.prototype.editor = editorHtml;
|
||||
FieldParamType.prototype.scriptable = true;
|
||||
FieldParamType.prototype.filterFieldTypes = '*';
|
||||
// retain only the fields with the aggregatable property if the onlyAggregatable option is true
|
||||
FieldParamType.prototype.onlyAggregatable = true;
|
||||
|
||||
/**
|
||||
* Called to serialize values for saving an aggConfig object
|
||||
*
|
||||
* @param {field} field - the field that was selected
|
||||
* @return {string}
|
||||
*/
|
||||
FieldParamType.prototype.serialize = function (field) {
|
||||
return field.name;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the options for this field from the indexPattern
|
||||
*/
|
||||
FieldParamType.prototype.getFieldOptions = function (aggConfig) {
|
||||
const indexPattern = aggConfig.getIndexPattern();
|
||||
let fields = indexPattern.fields.raw;
|
||||
|
||||
if (this.onlyAggregatable) {
|
||||
fields = fields.filter(f => f.aggregatable);
|
||||
}
|
||||
|
||||
FieldParamType.prototype.editor = editorHtml;
|
||||
FieldParamType.prototype.scriptable = true;
|
||||
FieldParamType.prototype.filterFieldTypes = '*';
|
||||
// retain only the fields with the aggregatable property if the onlyAggregatable option is true
|
||||
FieldParamType.prototype.onlyAggregatable = true;
|
||||
if (!this.scriptable) {
|
||||
fields = fields.filter(field => !field.scripted);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to serialize values for saving an aggConfig object
|
||||
*
|
||||
* @param {field} field - the field that was selected
|
||||
* @return {string}
|
||||
*/
|
||||
FieldParamType.prototype.serialize = function (field) {
|
||||
return field.name;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the options for this field from the indexPattern
|
||||
*/
|
||||
FieldParamType.prototype.getFieldOptions = function (aggConfig) {
|
||||
const indexPattern = aggConfig.getIndexPattern();
|
||||
let fields = indexPattern.fields.raw;
|
||||
|
||||
if (this.onlyAggregatable) {
|
||||
fields = fields.filter(f => f.aggregatable);
|
||||
}
|
||||
|
||||
if (!this.scriptable) {
|
||||
fields = fields.filter(field => !field.scripted);
|
||||
}
|
||||
|
||||
if (this.filterFieldTypes) {
|
||||
let filters = this.filterFieldTypes;
|
||||
if (_.isFunction(this.filterFieldTypes)) {
|
||||
filters = this.filterFieldTypes.bind(this, aggConfig.vis);
|
||||
}
|
||||
fields = $filter('fieldType')(fields, filters);
|
||||
fields = $filter('orderBy')(fields, ['type', 'name']);
|
||||
if (this.filterFieldTypes) {
|
||||
let filters = this.filterFieldTypes;
|
||||
if (_.isFunction(this.filterFieldTypes)) {
|
||||
filters = this.filterFieldTypes.bind(this, aggConfig.vis);
|
||||
}
|
||||
fields = propFilter('type')(fields, filters);
|
||||
fields = _.sortBy(fields, ['type', 'name']);
|
||||
}
|
||||
|
||||
|
||||
return new IndexedArray({
|
||||
index: ['name'],
|
||||
group: ['type'],
|
||||
initialSet: fields
|
||||
});
|
||||
};
|
||||
return new IndexedArray({
|
||||
index: ['name'],
|
||||
group: ['type'],
|
||||
initialSet: fields
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Called to read values from a database record into the
|
||||
* aggConfig object
|
||||
*
|
||||
* @param {string} fieldName
|
||||
* @return {field}
|
||||
*/
|
||||
FieldParamType.prototype.deserialize = function (fieldName, aggConfig) {
|
||||
const field = aggConfig.getIndexPattern().fields.byName[fieldName];
|
||||
/**
|
||||
* Called to read values from a database record into the
|
||||
* aggConfig object
|
||||
*
|
||||
* @param {string} fieldName
|
||||
* @return {field}
|
||||
*/
|
||||
FieldParamType.prototype.deserialize = function (fieldName, aggConfig) {
|
||||
const field = aggConfig.getIndexPattern().fields.byName[fieldName];
|
||||
|
||||
if (!field) {
|
||||
throw new SavedObjectNotFound('index-pattern-field', fieldName);
|
||||
}
|
||||
if (!field) {
|
||||
throw new SavedObjectNotFound('index-pattern-field', fieldName);
|
||||
}
|
||||
|
||||
const validField = this.getFieldOptions(aggConfig).byName[fieldName];
|
||||
if (!validField) {
|
||||
notifier.error(`Saved "field" parameter is now invalid. Please select a new field.`);
|
||||
}
|
||||
const validField = this.getFieldOptions(aggConfig).byName[fieldName];
|
||||
if (!validField) {
|
||||
notifier.error(`Saved "field" parameter is now invalid. Please select a new field.`);
|
||||
}
|
||||
|
||||
return validField;
|
||||
};
|
||||
return validField;
|
||||
};
|
||||
|
||||
/**
|
||||
* Write the aggregation parameter.
|
||||
*
|
||||
* @param {AggConfig} aggConfig - the entire configuration for this agg
|
||||
* @param {object} output - the result of calling write on all of the aggregations
|
||||
* parameters.
|
||||
* @param {object} output.params - the final object that will be included as the params
|
||||
* for the agg
|
||||
* @return {undefined}
|
||||
*/
|
||||
FieldParamType.prototype.write = function (aggConfig, output) {
|
||||
const field = aggConfig.getField();
|
||||
/**
|
||||
* Write the aggregation parameter.
|
||||
*
|
||||
* @param {AggConfig} aggConfig - the entire configuration for this agg
|
||||
* @param {object} output - the result of calling write on all of the aggregations
|
||||
* parameters.
|
||||
* @param {object} output.params - the final object that will be included as the params
|
||||
* for the agg
|
||||
* @return {undefined}
|
||||
*/
|
||||
FieldParamType.prototype.write = function (aggConfig, output) {
|
||||
const field = aggConfig.getField();
|
||||
|
||||
if (!field) {
|
||||
throw new TypeError('"field" is a required parameter');
|
||||
}
|
||||
if (!field) {
|
||||
throw new TypeError('"field" is a required parameter');
|
||||
}
|
||||
|
||||
if (field.scripted) {
|
||||
output.params.script = {
|
||||
inline: field.script,
|
||||
lang: field.lang,
|
||||
};
|
||||
} else {
|
||||
output.params.field = field.name;
|
||||
}
|
||||
};
|
||||
if (field.scripted) {
|
||||
output.params.script = {
|
||||
inline: field.script,
|
||||
lang: field.lang,
|
||||
};
|
||||
} else {
|
||||
output.params.field = field.name;
|
||||
}
|
||||
};
|
||||
|
||||
return FieldParamType;
|
||||
}
|
||||
export { FieldParamType };
|
||||
|
|
|
@ -1,78 +1,74 @@
|
|||
import _ from 'lodash';
|
||||
import editorHtml from '../controls/raw_json.html';
|
||||
import { BaseParamTypeProvider } from './base';
|
||||
import { BaseParamType } from './base';
|
||||
|
||||
export function JsonParamTypeProvider(Private) {
|
||||
|
||||
const BaseParamType = Private(BaseParamTypeProvider);
|
||||
_.class(JsonParamType).inherits(BaseParamType);
|
||||
function JsonParamType(config) {
|
||||
// force name override
|
||||
config = _.defaults(config, { name: 'json' });
|
||||
JsonParamType.Super.call(this, config);
|
||||
}
|
||||
|
||||
_.class(JsonParamType).inherits(BaseParamType);
|
||||
function JsonParamType(config) {
|
||||
// force name override
|
||||
config = _.defaults(config, { name: 'json' });
|
||||
JsonParamType.Super.call(this, config);
|
||||
JsonParamType.prototype.editor = editorHtml;
|
||||
|
||||
/**
|
||||
* Write the aggregation parameter.
|
||||
*
|
||||
* @param {AggConfig} aggConfig - the entire configuration for this agg
|
||||
* @param {object} output - the result of calling write on all of the aggregations
|
||||
* parameters.
|
||||
* @param {object} output.params - the final object that will be included as the params
|
||||
* for the agg
|
||||
* @return {undefined}
|
||||
*/
|
||||
JsonParamType.prototype.write = function (aggConfig, output) {
|
||||
let paramJson;
|
||||
const param = aggConfig.params[this.name];
|
||||
|
||||
if (!param) {
|
||||
return;
|
||||
}
|
||||
|
||||
JsonParamType.prototype.editor = editorHtml;
|
||||
|
||||
/**
|
||||
* Write the aggregation parameter.
|
||||
*
|
||||
* @param {AggConfig} aggConfig - the entire configuration for this agg
|
||||
* @param {object} output - the result of calling write on all of the aggregations
|
||||
* parameters.
|
||||
* @param {object} output.params - the final object that will be included as the params
|
||||
* for the agg
|
||||
* @return {undefined}
|
||||
*/
|
||||
JsonParamType.prototype.write = function (aggConfig, output) {
|
||||
let paramJson;
|
||||
const param = aggConfig.params[this.name];
|
||||
|
||||
if (!param) {
|
||||
return;
|
||||
}
|
||||
|
||||
// handle invalid Json input
|
||||
try {
|
||||
paramJson = JSON.parse(param);
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
|
||||
function filteredCombine(srcA, srcB) {
|
||||
function mergeObjs(a, b) {
|
||||
return _(a)
|
||||
.keys()
|
||||
.union(_.keys(b))
|
||||
.transform(function (dest, key) {
|
||||
const val = compare(a[key], b[key]);
|
||||
if (val !== undefined) dest[key] = val;
|
||||
}, {})
|
||||
.value();
|
||||
}
|
||||
|
||||
function mergeArrays(a, b) {
|
||||
// attempt to merge each value
|
||||
return _.times(Math.max(a.length, b.length), function (i) {
|
||||
return compare(a[i], b[i]);
|
||||
});
|
||||
}
|
||||
|
||||
function compare(a, b) {
|
||||
if (_.isPlainObject(a) && _.isPlainObject(b)) return mergeObjs(a, b);
|
||||
if (Array.isArray(a) && Array.isArray(b)) return mergeArrays(a, b);
|
||||
if (b === null) return undefined;
|
||||
if (b !== undefined) return b;
|
||||
return a;
|
||||
}
|
||||
|
||||
return compare(srcA, srcB);
|
||||
}
|
||||
|
||||
output.params = filteredCombine(output.params, paramJson);
|
||||
// handle invalid Json input
|
||||
try {
|
||||
paramJson = JSON.parse(param);
|
||||
} catch (err) {
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
return JsonParamType;
|
||||
}
|
||||
function filteredCombine(srcA, srcB) {
|
||||
function mergeObjs(a, b) {
|
||||
return _(a)
|
||||
.keys()
|
||||
.union(_.keys(b))
|
||||
.transform(function (dest, key) {
|
||||
const val = compare(a[key], b[key]);
|
||||
if (val !== undefined) dest[key] = val;
|
||||
}, {})
|
||||
.value();
|
||||
}
|
||||
|
||||
function mergeArrays(a, b) {
|
||||
// attempt to merge each value
|
||||
return _.times(Math.max(a.length, b.length), function (i) {
|
||||
return compare(a[i], b[i]);
|
||||
});
|
||||
}
|
||||
|
||||
function compare(a, b) {
|
||||
if (_.isPlainObject(a) && _.isPlainObject(b)) return mergeObjs(a, b);
|
||||
if (Array.isArray(a) && Array.isArray(b)) return mergeArrays(a, b);
|
||||
if (b === null) return undefined;
|
||||
if (b !== undefined) return b;
|
||||
return a;
|
||||
}
|
||||
|
||||
return compare(srcA, srcB);
|
||||
}
|
||||
|
||||
output.params = filteredCombine(output.params, paramJson);
|
||||
return;
|
||||
};
|
||||
|
||||
export { JsonParamType };
|
||||
|
|
|
@ -1,55 +1,50 @@
|
|||
import _ from 'lodash';
|
||||
import { IndexedArray } from 'ui/indexed_array';
|
||||
import { BaseParamTypeProvider } from './base';
|
||||
import { BaseParamType } from './base';
|
||||
|
||||
export function OptionedParamTypeProvider(Private) {
|
||||
_.class(OptionedParamType).inherits(BaseParamType);
|
||||
function OptionedParamType(config) {
|
||||
OptionedParamType.Super.call(this, config);
|
||||
|
||||
const BaseParamType = Private(BaseParamTypeProvider);
|
||||
|
||||
_.class(OptionedParamType).inherits(BaseParamType);
|
||||
function OptionedParamType(config) {
|
||||
OptionedParamType.Super.call(this, config);
|
||||
|
||||
this.options = new IndexedArray({
|
||||
index: ['val'],
|
||||
immutable: true,
|
||||
initialSet: this.options
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize a selection to be stored in the database
|
||||
* @param {object} selected - the option that was selected
|
||||
* @return {any}
|
||||
*/
|
||||
OptionedParamType.prototype.serialize = function (selected) {
|
||||
return selected.val;
|
||||
};
|
||||
|
||||
/**
|
||||
* Take a value that was serialized to the database and
|
||||
* return the option that is represents
|
||||
*
|
||||
* @param {any} val - the value that was saved
|
||||
* @return {object}
|
||||
*/
|
||||
OptionedParamType.prototype.deserialize = function (val) {
|
||||
return this.options.byVal[val];
|
||||
};
|
||||
|
||||
/**
|
||||
* Write the aggregation parameter.
|
||||
*
|
||||
* @param {AggConfig} aggConfig - the entire configuration for this agg
|
||||
* @param {object} output - the result of calling write on all of the aggregations
|
||||
* parameters.
|
||||
* @param {object} output.params - the final object that will be included as the params
|
||||
* for the agg
|
||||
* @return {undefined}
|
||||
*/
|
||||
OptionedParamType.prototype.write = function (aggConfig, output) {
|
||||
output.params[this.name] = aggConfig.params[this.name].val;
|
||||
};
|
||||
|
||||
return OptionedParamType;
|
||||
this.options = new IndexedArray({
|
||||
index: ['val'],
|
||||
immutable: true,
|
||||
initialSet: this.options
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize a selection to be stored in the database
|
||||
* @param {object} selected - the option that was selected
|
||||
* @return {any}
|
||||
*/
|
||||
OptionedParamType.prototype.serialize = function (selected) {
|
||||
return selected.val;
|
||||
};
|
||||
|
||||
/**
|
||||
* Take a value that was serialized to the database and
|
||||
* return the option that is represents
|
||||
*
|
||||
* @param {any} val - the value that was saved
|
||||
* @return {object}
|
||||
*/
|
||||
OptionedParamType.prototype.deserialize = function (val) {
|
||||
return this.options.byVal[val];
|
||||
};
|
||||
|
||||
/**
|
||||
* Write the aggregation parameter.
|
||||
*
|
||||
* @param {AggConfig} aggConfig - the entire configuration for this agg
|
||||
* @param {object} output - the result of calling write on all of the aggregations
|
||||
* parameters.
|
||||
* @param {object} output.params - the final object that will be included as the params
|
||||
* for the agg
|
||||
* @return {undefined}
|
||||
*/
|
||||
OptionedParamType.prototype.write = function (aggConfig, output) {
|
||||
output.params[this.name] = aggConfig.params[this.name].val;
|
||||
};
|
||||
|
||||
export { OptionedParamType };
|
||||
|
|
|
@ -1,53 +1,48 @@
|
|||
import _ from 'lodash';
|
||||
import editorHtml from '../controls/regular_expression.html';
|
||||
import { BaseParamTypeProvider } from './base';
|
||||
import { BaseParamType } from './base';
|
||||
|
||||
export function RegexParamTypeProvider(Private) {
|
||||
_.class(RegexParamType).inherits(BaseParamType);
|
||||
function RegexParamType(config) {
|
||||
_.defaults(config, { pattern: '' });
|
||||
RegexParamType.Super.call(this, config);
|
||||
}
|
||||
|
||||
const BaseParamType = Private(BaseParamTypeProvider);
|
||||
RegexParamType.prototype.editor = editorHtml;
|
||||
|
||||
_.class(RegexParamType).inherits(BaseParamType);
|
||||
function RegexParamType(config) {
|
||||
_.defaults(config, { pattern: '' });
|
||||
RegexParamType.Super.call(this, config);
|
||||
/**
|
||||
* Disabled state of the agg param
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
RegexParamType.prototype.disabled = function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Write the aggregation parameter.
|
||||
*
|
||||
* @param {AggConfig} aggConfig - the entire configuration for this agg
|
||||
* @param {object} output - the result of calling write on all of the aggregations
|
||||
* parameters.
|
||||
* @param {object} output.params - the final object that will be included as the params
|
||||
* for the agg
|
||||
* @return {undefined}
|
||||
*/
|
||||
RegexParamType.prototype.write = function (aggConfig, output) {
|
||||
const param = aggConfig.params[this.name];
|
||||
const paramType = aggConfig.type.params.byName[this.name];
|
||||
|
||||
// clear aggParam if pattern is not set or is disabled
|
||||
if (!param || !param.pattern || !param.pattern.length || paramType.disabled(aggConfig)) {
|
||||
return;
|
||||
}
|
||||
|
||||
RegexParamType.prototype.editor = editorHtml;
|
||||
|
||||
/**
|
||||
* Disabled state of the agg param
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
RegexParamType.prototype.disabled = function () {
|
||||
return false;
|
||||
const obj = {
|
||||
pattern: param.pattern
|
||||
};
|
||||
|
||||
/**
|
||||
* Write the aggregation parameter.
|
||||
*
|
||||
* @param {AggConfig} aggConfig - the entire configuration for this agg
|
||||
* @param {object} output - the result of calling write on all of the aggregations
|
||||
* parameters.
|
||||
* @param {object} output.params - the final object that will be included as the params
|
||||
* for the agg
|
||||
* @return {undefined}
|
||||
*/
|
||||
RegexParamType.prototype.write = function (aggConfig, output) {
|
||||
const param = aggConfig.params[this.name];
|
||||
const paramType = aggConfig.type.params.byName[this.name];
|
||||
output.params[this.name] = obj;
|
||||
};
|
||||
|
||||
// clear aggParam if pattern is not set or is disabled
|
||||
if (!param || !param.pattern || !param.pattern.length || paramType.disabled(aggConfig)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const obj = {
|
||||
pattern: param.pattern
|
||||
};
|
||||
|
||||
output.params[this.name] = obj;
|
||||
};
|
||||
|
||||
return RegexParamType;
|
||||
}
|
||||
export { RegexParamType };
|
||||
|
|
|
@ -1,33 +1,28 @@
|
|||
import _ from 'lodash';
|
||||
import editorHtml from '../controls/string.html';
|
||||
import { BaseParamTypeProvider } from './base';
|
||||
import { BaseParamType } from './base';
|
||||
|
||||
export function StringParamTypeProvider(Private) {
|
||||
|
||||
const BaseParamType = Private(BaseParamTypeProvider);
|
||||
|
||||
_.class(StringParamType).inherits(BaseParamType);
|
||||
function StringParamType(config) {
|
||||
StringParamType.Super.call(this, config);
|
||||
}
|
||||
|
||||
StringParamType.prototype.editor = editorHtml;
|
||||
|
||||
/**
|
||||
* Write the aggregation parameter.
|
||||
*
|
||||
* @param {AggConfig} aggConfig - the entire configuration for this agg
|
||||
* @param {object} output - the result of calling write on all of the aggregations
|
||||
* parameters.
|
||||
* @param {object} output.params - the final object that will be included as the params
|
||||
* for the agg
|
||||
* @return {undefined}
|
||||
*/
|
||||
StringParamType.prototype.write = function (aggConfig, output) {
|
||||
if (aggConfig.params[this.name] && aggConfig.params[this.name].length) {
|
||||
output.params[this.name] = aggConfig.params[this.name];
|
||||
}
|
||||
};
|
||||
|
||||
return StringParamType;
|
||||
_.class(StringParamType).inherits(BaseParamType);
|
||||
function StringParamType(config) {
|
||||
StringParamType.Super.call(this, config);
|
||||
}
|
||||
|
||||
StringParamType.prototype.editor = editorHtml;
|
||||
|
||||
/**
|
||||
* Write the aggregation parameter.
|
||||
*
|
||||
* @param {AggConfig} aggConfig - the entire configuration for this agg
|
||||
* @param {object} output - the result of calling write on all of the aggregations
|
||||
* parameters.
|
||||
* @param {object} output.params - the final object that will be included as the params
|
||||
* for the agg
|
||||
* @return {undefined}
|
||||
*/
|
||||
StringParamType.prototype.write = function (aggConfig, output) {
|
||||
if (aggConfig.params[this.name] && aggConfig.params[this.name].length) {
|
||||
output.params[this.name] = aggConfig.params[this.name];
|
||||
}
|
||||
};
|
||||
|
||||
export { StringParamType };
|
||||
|
|
|
@ -6,7 +6,7 @@ import { VisAggConfigProvider } from 'ui/vis/agg_config';
|
|||
import { VisProvider } from 'ui/vis';
|
||||
import { VisAggConfigsProvider } from 'ui/vis/agg_configs';
|
||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import { IndexedArray } from 'ui/indexed_array';
|
||||
|
||||
describe('AggConfigs', function () {
|
||||
|
@ -16,7 +16,6 @@ describe('AggConfigs', function () {
|
|||
let AggConfigs;
|
||||
let SpiedAggConfig;
|
||||
let indexPattern;
|
||||
let Schemas;
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
beforeEach(ngMock.inject(function (Private) {
|
||||
|
@ -35,7 +34,6 @@ describe('AggConfigs', function () {
|
|||
SpiedAggConfig = Private(VisAggConfigProvider);
|
||||
AggConfigs = Private(VisAggConfigsProvider);
|
||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||
Schemas = Private(VisSchemasProvider);
|
||||
}));
|
||||
|
||||
it('extends IndexedArray', function () {
|
||||
|
|
|
@ -6,7 +6,7 @@ import ngMock from 'ng_mock';
|
|||
import '../agg_params';
|
||||
import { VisProvider } from 'ui/vis';
|
||||
import { VisAggConfigProvider } from 'ui/vis/agg_config';
|
||||
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
|
||||
import { Schemas } from 'ui/vis/editors/default/schemas';
|
||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
|
||||
|
||||
|
@ -15,7 +15,6 @@ describe('Vis-Editor-Agg-Params plugin directive', function () {
|
|||
let Vis;
|
||||
let vis;
|
||||
let AggConfig;
|
||||
let Schemas;
|
||||
let $elem;
|
||||
let compile;
|
||||
let rootScope;
|
||||
|
@ -35,7 +34,6 @@ describe('Vis-Editor-Agg-Params plugin directive', function () {
|
|||
|
||||
Vis = Private(VisProvider);
|
||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||
Schemas = Private(VisSchemasProvider);
|
||||
AggConfig = Private(VisAggConfigProvider);
|
||||
}));
|
||||
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
import _ from 'lodash';
|
||||
import { IndexedArray } from 'ui/indexed_array';
|
||||
import { AggTypesAggParamsProvider } from 'ui/agg_types/agg_params';
|
||||
import { AggParams } from 'ui/agg_types/agg_params';
|
||||
|
||||
export function VisSchemasProvider(Private) {
|
||||
const AggParams = Private(AggTypesAggParamsProvider);
|
||||
|
||||
function Schemas(schemas) {
|
||||
const self = this;
|
||||
class Schemas {
|
||||
constructor(schemas) {
|
||||
|
||||
_(schemas || [])
|
||||
.map(function (schema) {
|
||||
.map((schema) => {
|
||||
if (!schema.name) throw new Error('all schema must have a unique name');
|
||||
|
||||
if (schema.name === 'split') {
|
||||
|
@ -40,8 +37,8 @@ export function VisSchemasProvider(Private) {
|
|||
|
||||
return schema;
|
||||
})
|
||||
.tap(function (schemas) {
|
||||
self.all = new IndexedArray({
|
||||
.tap((schemas) => {
|
||||
this.all = new IndexedArray({
|
||||
index: ['name'],
|
||||
group: ['group'],
|
||||
immutable: true,
|
||||
|
@ -49,8 +46,8 @@ export function VisSchemasProvider(Private) {
|
|||
});
|
||||
})
|
||||
.groupBy('group')
|
||||
.forOwn(function (group, groupName) {
|
||||
self[groupName] = new IndexedArray({
|
||||
.forOwn((group, groupName) => {
|
||||
this[groupName] = new IndexedArray({
|
||||
index: ['name'],
|
||||
immutable: true,
|
||||
initialSet: group
|
||||
|
@ -58,7 +55,7 @@ export function VisSchemasProvider(Private) {
|
|||
})
|
||||
.commit();
|
||||
}
|
||||
|
||||
return Schemas;
|
||||
}
|
||||
|
||||
export { Schemas };
|
||||
|
||||
|
|
Loading…
Reference in a new issue