Skip to content

Commit

Permalink
Merge pull request #54 from istresearch/P4-1675
Browse files Browse the repository at this point in the history
P4-1675 - Fix Kibana Filtering for Discover and Dashboard.
  • Loading branch information
andrewkcarter committed Jun 18, 2020
2 parents 827c852 + 75c27a0 commit 7c6504f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "kibana_object_format",
"version": "0.1.7",
"version": "0.1.8",
"description": "Enables objects in arrays to be configured with a field formatter.",
"license": "Apache 2.0",
"homepage": "https://github.com/istresearch/kibana-object-format",
Expand Down Expand Up @@ -38,4 +38,4 @@
"eslint-plugin-prefer-object-spread": "^1.2.1",
"eslint-plugin-react": "^7.12.4"
}
}
}
4 changes: 1 addition & 3 deletions public/field_formats/object/cleanFieldTemplate.js
Expand Up @@ -62,8 +62,6 @@ const cleanTemplate = showPopover => {

export default (showPopover = false) => {
setTimeout(() => {
if ($('.application.tab-discover').length) {
cleanTemplate(showPopover);
}
cleanTemplate(showPopover);
}, 0);
};
26 changes: 11 additions & 15 deletions public/hacks/custom_filter_bootstrap/index.js
Expand Up @@ -34,34 +34,30 @@ app.run(['$rootScope', ($rootScope) => {
popover.destroy();
}

if (originalPath.indexOf('/discover/') !== -1) {
popover.init();
}
popover.init();
});
}]);

(async (indexPatterns, addFiltersCached) => {
const indexPatternList = await indexPatterns.getFields(['id', 'title']);
let selectedIndexPattern = null;
const indexPatternIDList = await indexPatterns.getFields(['id']);
let indexPatternLookup = {};

const filterManagerHelper = new FilterManagerHelper(addFiltersCached);
for (let pattern of indexPatternIDList) {
let ip = await indexPatterns.get(pattern.id);
indexPatternLookup[pattern.id] = ip.fieldFormatMap;
}

await $('body').observe('.indexPattern__triggerButton', async () => {
const ipTitle = $('.indexPattern__triggerButton > span > span').text();
const ip = indexPatternList.filter(ipItem => ipItem.title === ipTitle);
if (ip.length === 1) {
selectedIndexPattern = await indexPatterns.get(ip[0].id);
}
});
const filterManagerHelper = new FilterManagerHelper(addFiltersCached);

filterManager.addFilters = newFilters => {
if (_.isArray(newFilters) && newFilters.length !== 1) {
return;
}

const { fieldFormatMap } = selectedIndexPattern;

const newFilter = newFilters[0];

const selectedIndexPatternID = _.get(newFilter, 'meta.index', null);
const fieldFormatMap = indexPatternLookup[selectedIndexPatternID];
const matchPhrase = _.get(newFilter, 'query.match_phrase', {});
const fieldNameKeys = Object.keys(matchPhrase);

Expand Down

0 comments on commit 7c6504f

Please sign in to comment.