Skip to content

Commit

Permalink
Filter aggregation fields for rollup indices, reorganize rollup direc…
Browse files Browse the repository at this point in the history
…tory
  • Loading branch information
jen-huang committed Jul 24, 2018
1 parent 6d2a6d6 commit bdfcd20
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/rollup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function rollup(kibana) {
'plugins/rollup/index_pattern_list',
],
visualize: [
'plugins/rollup/vis_type_agg_filter',
'plugins/rollup/visualize',
],
},
init: function (server) {
Expand Down
28 changes: 28 additions & 0 deletions x-pack/plugins/rollup/public/visualize/agg_type_field_filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { aggTypeFieldFilters } from 'ui/agg_types/param_types/filter';

/**
* If rollup index pattern, check its capabilities
* and limit available fields for a given aggType based on that.
*/
aggTypeFieldFilters.addFilter(
(field, fieldParamType, indexPattern, aggConfig) => {
if(indexPattern.type !== 'rollup') {
return true;
}

const fieldName = field.name;
const aggName = aggConfig.type.name;
const jobs = indexPattern.typeMeta.jobs;

return !!jobs.find(job => {
const fields = indexPattern.typeMeta.capabilities[job].fields;
return fields[fieldName] && fields[fieldName].find(agg => agg.agg === aggName);
});
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
* you may not use this file except in compliance with the Elastic License.
*/

import './register';
import './agg_type_filter';
import './agg_type_field_filter';

0 comments on commit bdfcd20

Please sign in to comment.